Refactor PSI for destructuring declarations in for: they are now children of KtParameter and not instead of it

This commit is contained in:
Mikhail Glukhikh
2016-10-03 17:19:41 +03:00
parent 48437d5965
commit e7d290f726
35 changed files with 786 additions and 753 deletions
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.js.translate.utils.BindingUtils.getIteratorFunction
import org.jetbrains.kotlin.js.translate.utils.BindingUtils.getNextFunction
import org.jetbrains.kotlin.js.translate.utils.BindingUtils.getTypeForExpression
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.*
import org.jetbrains.kotlin.js.translate.utils.PsiUtils.getLoopParameter
import org.jetbrains.kotlin.js.translate.utils.PsiUtils.getLoopRange
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
import org.jetbrains.kotlin.lexer.KtTokens
@@ -99,14 +98,13 @@ fun translateForExpression(expression: KtForExpression, context: TranslationCont
getClassDescriptorForType(rangeType).name.asString() == "IntArray"
}
val destructuringParameter: KtDestructuringDeclaration? = expression.destructuringParameter
val loopParameter = getLoopParameter(expression)
val parameterName = if (loopParameter != null) {
val loopParameter = expression.loopParameter!!
val destructuringParameter: KtDestructuringDeclaration? = loopParameter?.destructuringDeclaration
val parameterName = if (destructuringParameter == null) {
context.getNameForElement(loopParameter)
}
else {
assert(destructuringParameter != null) { "If loopParameter is null, multi parameter must be not null ${expression.text}" }
context.scope().declareTemporary()
}
@@ -111,11 +111,6 @@ public final class PsiUtils {
return (binaryExpression.getOperationToken() == KtTokens.IN_KEYWORD);
}
@Nullable
public static KtParameter getLoopParameter(@NotNull KtForExpression expression) {
return expression.getLoopParameter();
}
@NotNull
public static List<KtParameter> getPrimaryConstructorParameters(@NotNull KtClassOrObject classDeclaration) {
if (classDeclaration instanceof KtClass) {