Minor: Move getValueParameters() function to jetPsiUtil.kt

This commit is contained in:
Alexey Sedunov
2015-04-02 17:32:26 +03:00
parent b47c700a27
commit d3605a5352
3 changed files with 14 additions and 9 deletions
@@ -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
}
}
@@ -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()
@@ -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