Minor: Move getValueParameters() function to jetPsiUtil.kt
This commit is contained in:
@@ -479,3 +479,15 @@ private fun findFirstLeafWhollyInRange(file: PsiFile, range: TextRange): PsiElem
|
||||
assert(elementRange.getStartOffset() >= range.getStartOffset())
|
||||
return if (elementRange.getEndOffset() <= range.getEndOffset()) element else null
|
||||
}
|
||||
|
||||
fun JetNamedDeclaration.getValueParameters(): List<JetParameter> {
|
||||
return getValueParameterList()?.getParameters() ?: Collections.emptyList()
|
||||
}
|
||||
|
||||
fun JetNamedDeclaration.getValueParameterList(): JetParameterList? {
|
||||
return when (this) {
|
||||
is JetCallableDeclaration -> getValueParameterList()
|
||||
is JetClass -> getPrimaryConstructorParameterList()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
+1
-9
@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parents
|
||||
import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||
@@ -1072,15 +1073,6 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun JetNamedDeclaration.getValueParameters(): List<JetParameter> {
|
||||
return when (this) {
|
||||
is JetCallableDeclaration -> getValueParameterList()
|
||||
is JetClass -> getPrimaryConstructorParameterList()
|
||||
is JetObjectDeclaration -> null
|
||||
else -> throw AssertionError("Unexpected declaration kind: ${getText()}")
|
||||
}?.getParameters() ?: Collections.emptyList()
|
||||
}
|
||||
|
||||
private fun JetNamedDeclaration.getReturnTypeReference(): JetTypeReference? {
|
||||
return when (this) {
|
||||
is JetCallableDeclaration -> getTypeReference()
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.core.refactoring.CollectingValidator
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getValueParameters
|
||||
import java.util.Collections
|
||||
import java.util.HashSet
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
Reference in New Issue
Block a user