From e7d290f7261963f5fc4da18fe3f0caa7498c3ea9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 3 Oct 2016 17:19:41 +0300 Subject: [PATCH] Refactor PSI for destructuring declarations in for: they are now children of KtParameter and not instead of it --- .../kotlin/codegen/ExpressionCodegen.java | 23 +- .../kotlin/cfg/ControlFlowProcessor.kt | 26 +- .../jetbrains/kotlin/diagnostics/Errors.java | 1 - .../rendering/DefaultErrorMessages.java | 1 - .../parsing/KotlinExpressionParsing.java | 5 +- .../jetbrains/kotlin/psi/KtForExpression.java | 8 +- .../org/jetbrains/kotlin/psi/KtPsiFactory.kt | 4 +- .../org/jetbrains/kotlin/psi/KtPsiUtil.java | 2 +- .../kotlin/resolve/AnnotationChecker.kt | 5 +- .../ControlStructureTypingVisitor.java | 13 +- .../controlStructures/valVarLoopParameter.kt | 4 +- .../DataFlowInMultiDeclInFor.kt | 4 +- compiler/testData/psi/ForWithMultiDecl.txt | 1194 +++++++++-------- .../testData/psi/annotation/forParameters.txt | 168 +-- .../WithWithoutInAndMultideclaration.txt | 19 +- ...structuringDeclarationReferenceSearcher.kt | 2 +- .../ExpressionsOfTypeProcessor.kt | 2 +- .../KotlinBreadcrumbsInfoProvider.kt | 2 +- .../editor/fixers/KotlinForConditionFixer.kt | 2 +- .../intentions/AddForLoopIndicesIntention.kt | 2 +- .../idea/intentions/DestructureIntention.kt | 2 +- .../intentions/IterateExpressionIntention.kt | 4 +- .../RemoveForLoopIndicesIntention.kt | 6 +- .../loopToCallChain/UseWithIndexIntention.kt | 2 +- .../loopToCallChain/matchAndConvert.kt | 2 +- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 1 - .../CreateComponentFunctionActionFactory.kt | 2 +- .../CreateIteratorFunctionActionFactory.kt | 2 +- .../CreateNextFunctionActionFactory.kt | 2 +- .../KotlinComponentUsageInDestructuring.kt | 3 +- .../idea/refactoring/elementRenderingUtils.kt | 2 +- .../DestructuringDeclarationInLambda.kt | 5 + .../checkers/PsiCheckerTestGenerated.java | 6 + .../js/translate/expression/LoopTranslator.kt | 8 +- .../kotlin/js/translate/utils/PsiUtils.java | 5 - 35 files changed, 786 insertions(+), 753 deletions(-) create mode 100644 idea/testData/checker/regression/DestructuringDeclarationInLambda.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 6af013119db..8462aa94a03 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -735,7 +735,14 @@ public class ExpressionCodegen extends KtVisitor impleme public void beforeLoop() { KtParameter loopParameter = forExpression.getLoopParameter(); - if (loopParameter != null) { + if (loopParameter == null) return; + KtDestructuringDeclaration multiParameter = loopParameter.getDestructuringDeclaration(); + if (multiParameter != null) { + // E tmp = tmp.next() + loopParameterType = asmElementType; + loopParameterVar = createLoopTempVariable(asmElementType); + } + else { // E e = tmp.next() final VariableDescriptor parameterDescriptor = bindingContext.get(VALUE_PARAMETER, loopParameter); loopParameterType = asmType(parameterDescriptor.getType()); @@ -751,14 +758,6 @@ public class ExpressionCodegen extends KtVisitor impleme } }); } - else { - KtDestructuringDeclaration multiParameter = forExpression.getDestructuringParameter(); - assert multiParameter != null; - - // E tmp = tmp.next() - loopParameterType = asmElementType; - loopParameterVar = createLoopTempVariable(asmElementType); - } } public abstract void checkEmptyLoop(@NotNull Label loopExit); @@ -769,10 +768,8 @@ public class ExpressionCodegen extends KtVisitor impleme assignToLoopParameter(); v.mark(loopParameterStartLabel); - if (forExpression.getLoopParameter() == null) { - KtDestructuringDeclaration multiParameter = forExpression.getDestructuringParameter(); - assert multiParameter != null; - + KtDestructuringDeclaration multiParameter = forExpression.getDestructuringDeclaration(); + if (multiParameter != null) { generateMultiVariables(multiParameter.getEntries()); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt index 3abffaeb902..6c08a9e5085 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt @@ -773,18 +773,19 @@ class ControlFlowProcessor(private val trace: BindingTrace) { private fun declareLoopParameter(expression: KtForExpression) { val loopParameter = expression.loopParameter - val multiDeclaration = expression.destructuringParameter if (loopParameter != null) { - builder.declareParameter(loopParameter) - } - else if (multiDeclaration != null) { - visitDestructuringDeclaration(multiDeclaration, false) + val destructuringDeclaration = loopParameter.destructuringDeclaration + if (destructuringDeclaration != null) { + visitDestructuringDeclaration(destructuringDeclaration, false) + } + else { + builder.declareParameter(loopParameter) + } } } private fun writeLoopParameterAssignment(expression: KtForExpression) { val loopParameter = expression.loopParameter - val multiDeclaration = expression.destructuringParameter val loopRange = expression.loopRange val value = builder.magic( @@ -795,11 +796,14 @@ class ControlFlowProcessor(private val trace: BindingTrace) { ).outputValue if (loopParameter != null) { - generateInitializer(loopParameter, value) - } - else if (multiDeclaration != null) { - for (entry in multiDeclaration.entries) { - generateInitializer(entry, value) + val destructuringDeclaration = loopParameter.destructuringDeclaration + if (destructuringDeclaration != null) { + for (entry in destructuringDeclaration.entries) { + generateInitializer(entry, value) + } + } + else { + generateInitializer(loopParameter, value) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index ef4c901c869..be37328879c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -744,7 +744,6 @@ public interface Errors { DiagnosticFactory3 INVISIBLE_SETTER = DiagnosticFactory3.create(ERROR); DiagnosticFactory1 VAL_OR_VAR_ON_LOOP_PARAMETER = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 VAL_OR_VAR_ON_LOOP_MULTI_PARAMETER = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 VAL_OR_VAR_ON_FUN_PARAMETER = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 VAL_OR_VAR_ON_CATCH_PARAMETER = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER = DiagnosticFactory1.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 7d13b0d0a05..a097d49d474 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -287,7 +287,6 @@ public class DefaultErrorMessages { MAP.put(VARIABLE_EXPECTED, "Variable expected"); MAP.put(VAL_OR_VAR_ON_LOOP_PARAMETER, "''{0}'' on loop parameter is not allowed", TO_STRING); - MAP.put(VAL_OR_VAR_ON_LOOP_MULTI_PARAMETER, "''{0}'' on loop multi parameter is not allowed", TO_STRING); MAP.put(VAL_OR_VAR_ON_FUN_PARAMETER, "''{0}'' on function parameter is not allowed", TO_STRING); MAP.put(VAL_OR_VAR_ON_CATCH_PARAMETER, "''{0}'' on catch parameter is not allowed", TO_STRING); MAP.put(VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER, "''{0}'' on secondary constructor parameter is not allowed", TO_STRING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java index a90efed324e..5a907cc7992 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinExpressionParsing.java @@ -1386,8 +1386,9 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD if (at(LPAR)) { + PsiBuilder.Marker destructuringDeclaration = mark(); myKotlinParsing.parseMultiDeclarationName(TokenSet.create(IN_KEYWORD, LBRACE)); - parameter.done(DESTRUCTURING_DECLARATION); + destructuringDeclaration.done(DESTRUCTURING_DECLARATION); } else { expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON, IN_KEYWORD)); @@ -1396,8 +1397,8 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing { advance(); // COLON myKotlinParsing.parseTypeRef(TokenSet.create(IN_KEYWORD)); } - parameter.done(VALUE_PARAMETER); } + parameter.done(VALUE_PARAMETER); if (expect(IN_KEYWORD, "Expecting 'in'", TokenSet.create(LPAR, LBRACE, RPAR))) { PsiBuilder.Marker range = mark(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtForExpression.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtForExpression.java index 04648c79759..517fb511033 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtForExpression.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtForExpression.java @@ -33,14 +33,16 @@ public class KtForExpression extends KtLoopExpression { return visitor.visitForExpression(this, data); } - @Nullable + @Nullable @IfNotParsed public KtParameter getLoopParameter() { return (KtParameter) findChildByType(KtNodeTypes.VALUE_PARAMETER); } @Nullable - public KtDestructuringDeclaration getDestructuringParameter() { - return (KtDestructuringDeclaration) findChildByType(KtNodeTypes.DESTRUCTURING_DECLARATION); + public KtDestructuringDeclaration getDestructuringDeclaration() { + KtParameter loopParameter = getLoopParameter(); + if (loopParameter == null) return null; + return loopParameter.getDestructuringDeclaration(); } @Nullable @IfNotParsed diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt index 5218b36b228..f9e2d0f1c47 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiFactory.kt @@ -244,9 +244,9 @@ class KtPsiFactory(private val project: Project) { return (createFunction("fun foo() {$text}").bodyExpression as KtBlockExpression).statements.first() as KtDestructuringDeclaration } - fun createDestructuringParameter(text: String): KtDestructuringDeclaration { + fun createDestructuringParameterForLoop(text: String): KtParameter { val dummyFun = createFunction("fun foo() { for ($text in foo) {} }") - return ((dummyFun.bodyExpression as KtBlockExpression).statements.first() as KtForExpression).destructuringParameter!! + return ((dummyFun.bodyExpression as KtBlockExpression).statements.first() as KtForExpression).loopParameter!! } fun createDestructuringParameterForLambda(text: String): KtParameter { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java index e9a72817c14..9e0cf357981 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtPsiUtil.java @@ -281,7 +281,7 @@ public class KtPsiUtil { if (declaration instanceof KtProperty) return true; assert declaration instanceof KtDestructuringDeclarationEntry; KtDestructuringDeclarationEntry multiDeclarationEntry = (KtDestructuringDeclarationEntry) declaration; - return !(multiDeclarationEntry.getParent().getParent() instanceof KtForExpression); + return !(multiDeclarationEntry.getParent().getParent().getParent() instanceof KtForExpression); } @Nullable diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt index 3a6bf2dd7e4..fad5da5da2b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationChecker.kt @@ -184,7 +184,10 @@ class AnnotationChecker(private val additionalCheckers: Iterable { - if (annotated.hasValOrVar()) + val destructuringDeclaration = annotated.destructuringDeclaration + if (destructuringDeclaration != null) + TargetLists.T_DESTRUCTURING_DECLARATION + else if (annotated.hasValOrVar()) TargetLists.T_VALUE_PARAMETER_WITH_VAL else TargetLists.T_VALUE_PARAMETER_WITHOUT_VAL diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java index 51f69f6acd3..6c0333c6f64 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java @@ -401,22 +401,19 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { KtParameter loopParameter = expression.getLoopParameter(); if (loopParameter != null) { VariableDescriptor variableDescriptor = createLoopParameterDescriptor(loopParameter, expectedParameterType, context); - components.modifiersChecker.withTrace(context.trace).checkModifiersForLocalDeclaration(loopParameter, variableDescriptor); + ModifiersChecker.ModifiersCheckingProcedure modifiersCheckingProcedure = components.modifiersChecker.withTrace(context.trace); + modifiersCheckingProcedure.checkModifiersForLocalDeclaration(loopParameter, variableDescriptor); components.identifierChecker.checkDeclaration(loopParameter, context.trace); - loopScope.addVariableDescriptor(variableDescriptor); - } - else { - KtDestructuringDeclaration multiParameter = expression.getDestructuringParameter(); + KtDestructuringDeclaration multiParameter = loopParameter.getDestructuringDeclaration(); if (multiParameter != null) { KotlinType elementType = expectedParameterType == null ? ErrorUtils.createErrorType("Loop range has no type") : expectedParameterType; TransientReceiver iteratorNextAsReceiver = new TransientReceiver(elementType); - components.annotationResolver.resolveAnnotationsWithArguments(loopScope, multiParameter.getModifierList(), context.trace); + components.annotationResolver.resolveAnnotationsWithArguments(loopScope, loopParameter.getModifierList(), context.trace); components.destructuringDeclarationResolver.defineLocalVariablesFromDestructuringDeclaration( loopScope, multiParameter, iteratorNextAsReceiver, loopRange, context ); - components.modifiersChecker.withTrace(context.trace).checkModifiersForDestructuringDeclaration(multiParameter); - components.modifiersChecker.withTrace(context.trace).checkParameterHasNoValOrVar(multiParameter, VAL_OR_VAR_ON_LOOP_MULTI_PARAMETER); + modifiersCheckingProcedure.checkModifiersForDestructuringDeclaration(multiParameter); components.identifierChecker.checkDeclaration(multiParameter, context.trace); } } diff --git a/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt b/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt index e4ec5dc1775..a1956f7f86d 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/valVarLoopParameter.kt @@ -22,11 +22,11 @@ fun f() { } - for (val (i,j) in Coll()) { + for (val (i,j) in Coll()) { } - for (var (i,j) in Coll()) { + for (var (i,j) in Coll()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt index dd86f3308de..6808da9546c 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInMultiDeclInFor.kt @@ -8,8 +8,8 @@ class A { } fun foo(list: List) { - for (var (c1, c2, c3) in list) { - c1 = 1 + for (var (c1, c2, c3) in list) { + c1 = 1 c3 + 1 } } diff --git a/compiler/testData/psi/ForWithMultiDecl.txt b/compiler/testData/psi/ForWithMultiDecl.txt index 80bc628f413..21ec5f530c2 100644 --- a/compiler/testData/psi/ForWithMultiDecl.txt +++ b/compiler/testData/psi/ForWithMultiDecl.txt @@ -18,11 +18,12 @@ JetFile: ForWithMultiDecl.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') @@ -40,575 +41,121 @@ JetFile: ForWithMultiDecl.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(val)('val') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(var)('var') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(var)('var') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(var)('var') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(var)('var') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(var)('var') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiErrorElement:Expecting ')' - - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - - PsiWhiteSpace(' ') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - PsiErrorElement:Type expected - - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - PsiErrorElement:Type expected - - PsiElement(COMMA)(',') - PsiErrorElement:Expecting a name - - PsiWhiteSpace(' ') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(in)('in') - PsiWhiteSpace(' ') - LOOP_RANGE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - BODY - BLOCK - PsiElement(LBRACE)('{') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FOR - PsiElement(for)('for') - PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - PsiErrorElement:Expecting a name + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('b') - PsiElement(COLON)(':') PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Int') - PsiElement(RPAR)(')') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') @@ -626,15 +173,15 @@ JetFile: ForWithMultiDecl.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('a') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - PsiErrorElement:Type expected - + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') LOOP_RANGE @@ -651,12 +198,487 @@ JetFile: ForWithMultiDecl.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - PsiErrorElement:Expecting a name - + VALUE_PARAMETER + PsiElement(val)('val') PsiWhiteSpace(' ') - PsiElement(RPAR)(')') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(var)('var') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiErrorElement:Expecting ')' + + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiErrorElement:Expecting a name + + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(COMMA)(',') + PsiErrorElement:Expecting a name + + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a name + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('b') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('a') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + PsiErrorElement:Type expected + + PsiElement(in)('in') + PsiWhiteSpace(' ') + LOOP_RANGE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BODY + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FOR + PsiElement(for)('for') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + PsiErrorElement:Expecting a name + + PsiWhiteSpace(' ') + PsiElement(RPAR)(')') PsiErrorElement:Expecting 'in' PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/annotation/forParameters.txt b/compiler/testData/psi/annotation/forParameters.txt index f180c4a74ec..98e870dd3bf 100644 --- a/compiler/testData/psi/annotation/forParameters.txt +++ b/compiler/testData/psi/annotation/forParameters.txt @@ -93,39 +93,40 @@ JetFile: forParameters.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('x') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - MODIFIER_LIST - PsiElement(private)('private') - PsiWhiteSpace(' ') - PsiElement(data)('data') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - PsiElement(AT)('@') - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('ann') - PsiWhiteSpace(' ') - ANNOTATION - PsiElement(AT)('@') - PsiElement(LBRACKET)('[') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(data)('data') + PsiWhiteSpace(' ') ANNOTATION_ENTRY + PsiElement(AT)('@') CONSTRUCTOR_CALLEE TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('ann') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('y') - PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION + PsiElement(AT)('@') + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') @@ -143,27 +144,28 @@ JetFile: forParameters.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - MODIFIER_LIST - ANNOTATION - PsiElement(AT)('@') - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('ann') - PsiElement(RBRACKET)(']') - PsiErrorElement:Expecting a name - - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('x') - PsiElement(RPAR)(')') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION + PsiElement(AT)('@') + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ann') + PsiElement(RBRACKET)(']') + PsiErrorElement:Expecting a name + + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') @@ -253,7 +255,7 @@ JetFile: forParameters.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION + VALUE_PARAMETER MODIFIER_LIST ANNOTATION_ENTRY PsiElement(AT)('@') @@ -266,23 +268,24 @@ JetFile: forParameters.kt PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('x') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - MODIFIER_LIST - ANNOTATION_ENTRY - PsiElement(AT)('@') - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Volatile') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('y') - PsiElement(RPAR)(')') + DESTRUCTURING_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') @@ -377,7 +380,7 @@ JetFile: forParameters.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION + VALUE_PARAMETER MODIFIER_LIST PsiElement(private)('private') PsiWhiteSpace(' ') @@ -391,23 +394,24 @@ JetFile: forParameters.kt PsiWhiteSpace(' ') PsiElement(val)('val') PsiWhiteSpace(' ') - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('x') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - MODIFIER_LIST - ANNOTATION_ENTRY - PsiElement(AT)('@') - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Volatile') + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('x') + PsiElement(COMMA)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('y') - PsiElement(RPAR)(')') + DESTRUCTURING_DECLARATION_ENTRY + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Volatile') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('y') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(in)('in') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt index 59480137c7d..09077c054bc 100644 --- a/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt +++ b/compiler/testData/psi/recovery/WithWithoutInAndMultideclaration.txt @@ -18,15 +18,16 @@ JetFile: WithWithoutInAndMultideclaration.kt PsiElement(for)('for') PsiWhiteSpace(' ') PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION - PsiElement(LPAR)('(') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('i') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - DESTRUCTURING_DECLARATION_ENTRY - PsiElement(IDENTIFIER)('j') - PsiElement(RPAR)(')') + VALUE_PARAMETER + DESTRUCTURING_DECLARATION + PsiElement(LPAR)('(') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('i') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + DESTRUCTURING_DECLARATION_ENTRY + PsiElement(IDENTIFIER)('j') + PsiElement(RPAR)(')') PsiErrorElement:Expecting 'in' PsiElement(RPAR)(')') diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/DestructuringDeclarationReferenceSearcher.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/DestructuringDeclarationReferenceSearcher.kt index 8a0b25a518e..51617807a8a 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/DestructuringDeclarationReferenceSearcher.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/DestructuringDeclarationReferenceSearcher.kt @@ -62,7 +62,7 @@ class DestructuringDeclarationReferenceSearcher( is KtContainerNode -> { if (parent.node.elementType == KtNodeTypes.LOOP_RANGE) { - (parent.parent as KtForExpression).destructuringParameter + (parent.parent as KtForExpression).destructuringDeclaration } else { null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt index 46379a848d1..74bbfde109b 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt @@ -543,7 +543,7 @@ class ExpressionsOfTypeProcessor( is KtContainerNode -> { if (parent.node.elementType == KtNodeTypes.LOOP_RANGE) { // "for (x in ) ..." val forExpression = parent.parent as KtForExpression - (forExpression.destructuringParameter ?: forExpression.loopParameter as KtDeclaration?)?.let { + (forExpression.destructuringDeclaration ?: forExpression.loopParameter as KtDeclaration?)?.let { processSuspiciousDeclaration(it) } break@ParentsLoop diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinBreadcrumbsInfoProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinBreadcrumbsInfoProvider.kt index 993f7337780..43af04224b2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinBreadcrumbsInfoProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinBreadcrumbsInfoProvider.kt @@ -396,7 +396,7 @@ class KotlinBreadcrumbsInfoProvider : BreadcrumbsInfoProvider() { private fun KtContainerNode.buildText(kind: TextKind): String { with (bodyOwner() as KtForExpression) { - val parameterText = loopParameter?.nameAsName?.render() ?: destructuringParameter?.text ?: return "for" + val parameterText = loopParameter?.nameAsName?.render() ?: destructuringDeclaration?.text ?: return "for" val collectionText = loopRange?.text ?: "" val text = (parameterText + " in " + collectionText).truncateEnd(kind) return labelText() + "for($text)" diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt index ec786701ea4..15c4f6e704a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinForConditionFixer.kt @@ -23,7 +23,7 @@ class KotlinForConditionFixer: MissingConditionFixer() { override val keyword = "for" override fun getElement(element: PsiElement?) = element as? KtForExpression override fun getCondition(element: KtForExpression) = - element.loopRange ?: element.loopParameter ?: element.destructuringParameter + element.loopRange ?: element.loopParameter ?: element.destructuringDeclaration override fun getLeftParenthesis(element: KtForExpression) = element.leftParenthesis override fun getRightParenthesis(element: KtForExpression) = element.rightParenthesis override fun getBody(element: KtForExpression) = element.body diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt index fc36759998c..945d17ba8ea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddForLoopIndicesIntention.kt @@ -64,7 +64,7 @@ class AddForLoopIndicesIntention : SelfTargetingRangeIntention( loopRange.replace(createWithIndexExpression(loopRange)) - var multiParameter = (psiFactory.createExpressionByPattern("for((index, $0) in x){}", loopParameter.text) as KtForExpression).destructuringParameter!! + var multiParameter = (psiFactory.createExpressionByPattern("for((index, $0) in x){}", loopParameter.text) as KtForExpression).destructuringDeclaration!! multiParameter = loopParameter.replaced(multiParameter) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DestructureIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DestructureIntention.kt index 9e3b1934bd4..b76684e3317 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DestructureIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DestructureIntention.kt @@ -68,7 +68,7 @@ class DestructureIntention : SelfTargetingRangeIntention( names.add(name) } if (forLoop != null) { - element.replace(factory.createDestructuringParameter("(${names.joinToString()})")) + element.replace(factory.createDestructuringParameterForLoop("(${names.joinToString()})")) if (removeSelectorInLoopRange && loopRange is KtDotQualifiedExpression) { loopRange.replace(loopRange.receiverExpression) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt index b52f295668a..c1e30d2df38 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt @@ -81,14 +81,14 @@ class IterateExpressionIntention : SelfTargetingIntention(KtExpres } val paramPattern = (names.singleOrNull()?.first() - ?: psiFactory.createDestructuringParameter(names.indices.joinToString(prefix = "(", postfix = ")") { "p$it" })) + ?: psiFactory.createDestructuringParameterForLoop(names.indices.joinToString(prefix = "(", postfix = ")") { "p$it" })) var forExpression = psiFactory.createExpressionByPattern("for($0 in $1) {\nx\n}", paramPattern, element) as KtForExpression forExpression = element.replaced(forExpression) PsiDocumentManager.getInstance(forExpression.project).doPostponedOperationsAndUnblockDocument(editor.document) val bodyPlaceholder = (forExpression.body as KtBlockExpression).statements.single() - val parameters = forExpression.loopParameter?.singletonList() ?: forExpression.destructuringParameter!!.entries + val parameters = forExpression.destructuringDeclaration?.entries ?: forExpression.loopParameter!!.singletonList() val templateBuilder = TemplateBuilderImpl(forExpression) for ((parameter, parameterNames) in (parameters zip names)) { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt index 1f513df59b8..7241d3fe9bb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveForLoopIndicesIntention.kt @@ -45,7 +45,7 @@ class RemoveForLoopIndicesIntention : SelfTargetingRangeIntention( val newLoopRange = factory.createExpressionByPattern("$0.withIndex()", loopRange) loopRange.replace(newLoopRange) - val multiParameter = (factory.createExpressionByPattern("for(($0, $1) in x){}", indexVariable.nameAsSafeName, loopParameter.text) as KtForExpression).destructuringParameter!! + val multiParameter = (factory.createExpressionByPattern("for(($0, $1) in x){}", indexVariable.nameAsSafeName, loopParameter.text) as KtForExpression).loopParameter!! loopParameter.replace(multiParameter) initializationStatement.delete() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt index ee30a592a38..c95fede381b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt @@ -185,7 +185,7 @@ data class LoopData( private fun extractLoopData(loop: KtForExpression): LoopData? { val loopRange = loop.loopRange ?: return null - val destructuringParameter = loop.destructuringParameter + val destructuringParameter = loop.destructuringDeclaration if (destructuringParameter != null && destructuringParameter.entries.size == 2) { val qualifiedExpression = loopRange as? KtDotQualifiedExpression if (qualifiedExpression != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 1b12099dd14..eb5d4766147 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -184,7 +184,6 @@ class QuickFixRegistrar : QuickFixContributor { VAL_OR_VAR_ON_FUN_PARAMETER.registerFactory(RemoveValVarFromParameterFix) VAL_OR_VAR_ON_LOOP_PARAMETER.registerFactory(RemoveValVarFromParameterFix) - VAL_OR_VAR_ON_LOOP_MULTI_PARAMETER.registerFactory(RemoveValVarFromParameterFix) VAL_OR_VAR_ON_CATCH_PARAMETER.registerFactory(RemoveValVarFromParameterFix) VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER.registerFactory(RemoveValVarFromParameterFix) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateComponentFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateComponentFunctionActionFactory.kt index 58f1362dfa5..cf52f91766f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateComponentFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateComponentFunctionActionFactory.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.types.Variance object CreateComponentFunctionActionFactory : CreateCallableMemberFromUsageFactory() { override fun getElementOfInterest(diagnostic: Diagnostic): KtDestructuringDeclaration? { QuickFixUtil.getParentElementOfType(diagnostic, KtDestructuringDeclaration::class.java)?.let { return it } - return QuickFixUtil.getParentElementOfType(diagnostic, KtForExpression::class.java)?.destructuringParameter + return QuickFixUtil.getParentElementOfType(diagnostic, KtForExpression::class.java)?.destructuringDeclaration } override fun createCallableInfo(element: KtDestructuringDeclaration, diagnostic: Diagnostic): CallableInfo? { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt index 9061b6e2d8d..01f14086d00 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateIteratorFunctionActionFactory.kt @@ -40,7 +40,7 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor override fun createCallableInfo(element: KtForExpression, diagnostic: Diagnostic): CallableInfo? { val file = diagnostic.psiFile as? KtFile ?: return null val iterableExpr = element.loopRange ?: return null - val variableExpr: KtExpression = ((element.loopParameter ?: element.destructuringParameter) ?: return null) as KtExpression + val variableExpr: KtExpression = ((element.loopParameter ?: element.destructuringDeclaration) ?: return null) as KtExpression val iterableType = TypeInfo(iterableExpr, Variance.IN_VARIANCE) val (bindingContext, moduleDescriptor) = file.analyzeFullyAndGetResult() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateNextFunctionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateNextFunctionActionFactory.kt index 0acff220f9f..25f8ad6447a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateNextFunctionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateNextFunctionActionFactory.kt @@ -37,7 +37,7 @@ object CreateNextFunctionActionFactory : CreateCallableMemberFromUsageFactory Int) = f(xy) + +fun foo() = convert { (x, y) } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java index e7fc5893458..5f8c3a8b0d1 100644 --- a/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/checkers/PsiCheckerTestGenerated.java @@ -502,6 +502,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest { doTest(fileName); } + @TestMetadata("DestructuringDeclarationInLambda.kt") + public void testDestructuringDeclarationInLambda() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/DestructuringDeclarationInLambda.kt"); + doTest(fileName); + } + @TestMetadata("DollarsInName.kt") public void testDollarsInName() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/regression/DollarsInName.kt"); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LoopTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LoopTranslator.kt index 53be3e4f93b..e145f5916df 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LoopTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/LoopTranslator.kt @@ -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() } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java index 4419779628b..c35b11ffcf5 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java @@ -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 getPrimaryConstructorParameters(@NotNull KtClassOrObject classDeclaration) { if (classDeclaration instanceof KtClass) {