From bf35099e0c1c896d24c9de61508ff116550d7b22 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 16 Nov 2015 16:03:46 +0100 Subject: [PATCH] use "destructuring declarations" term instead of "multi-declarations" --- .../jetbrains/kotlin/diagnostics/Errors.java | 4 +-- .../rendering/DefaultErrorMessages.java | 4 +-- .../kotlin/parsing/KotlinParsing.java | 6 ++-- .../ExpressionTypingVisitorForStatements.java | 2 +- .../psi/MultiVariableDeclarations.txt | 28 +++++++++---------- ...ropertiesWithFunctionReceiversRecovery.txt | 4 +-- ...ultiDeclarationExtensionAllComponents.test | 8 +++--- ...DeclarationExtensionAllComponentsMany.test | 8 +++--- ...tionExtensionAllComponentsPrefereFull.test | 8 +++--- ...sionAllComponentsPrefereNotDeprecated.test | 8 +++--- .../multiDeclarationExtensionComponent1.test | 4 +-- .../multiDeclarationExtensionComponent2.test | 4 +-- ...clarationExtensionComponentNoOperator.test | 2 +- .../stdlib/src/kotlin/collections/Maps.kt | 4 +-- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index aac3184c78d..202b665ed55 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -507,9 +507,9 @@ public interface Errors { DiagnosticFactory0 CLASS_LITERAL_LHS_NOT_A_CLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT = DiagnosticFactory0.create(ERROR); - // Multi-declarations + // Destructuring-declarations - DiagnosticFactory0 INITIALIZER_REQUIRED_FOR_MULTIDECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT); + DiagnosticFactory0 INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION = DiagnosticFactory0.create(ERROR, DEFAULT); DiagnosticFactory2 COMPONENT_FUNCTION_MISSING = DiagnosticFactory2.create(ERROR, DEFAULT); DiagnosticFactory2>> COMPONENT_FUNCTION_AMBIGUITY = DiagnosticFactory2.create(ERROR, DEFAULT); DiagnosticFactory3 COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH = DiagnosticFactory3.create(ERROR, DEFAULT); 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 d4d1dc1481b..e6cc21742a4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -189,8 +189,8 @@ public class DefaultErrorMessages { MAP.put(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER, "This property must either have a type annotation, be initialized or be delegated"); MAP.put(VARIABLE_WITH_NO_TYPE_NO_INITIALIZER, "This variable must either have a type annotation or be initialized"); - MAP.put(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION, "Initializer required for multi-declaration"); - MAP.put(COMPONENT_FUNCTION_MISSING, "Multi-declaration initializer of type {1} must have a ''{0}()'' function", TO_STRING, RENDER_TYPE); + MAP.put(INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION, "Initializer required for destructuring declaration"); + MAP.put(COMPONENT_FUNCTION_MISSING, "Destructuring declaration initializer of type {1} must have a ''{0}()'' function", TO_STRING, RENDER_TYPE); MAP.put(COMPONENT_FUNCTION_AMBIGUITY, "Function ''{0}()'' is ambiguous for this expression: {1}", TO_STRING, AMBIGUOUS_CALLS); MAP.put(COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, "''{0}()'' function returns ''{1}'', but ''{2}'' is expected", TO_STRING, RENDER_TYPE, RENDER_TYPE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index 1ba880d3026..6229b593d90 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -1226,12 +1226,12 @@ public class KotlinParsing extends AbstractKotlinParsing { boolean multiDeclaration = at(LPAR); - errorIf(receiver, multiDeclaration && receiverTypeDeclared, "Receiver type is not allowed on a multi-declaration"); + errorIf(receiver, multiDeclaration && receiverTypeDeclared, "Receiver type is not allowed on a destructuring declaration"); if (multiDeclaration) { PsiBuilder.Marker multiDecl = mark(); parseMultiDeclarationName(propertyNameFollow); - errorIf(multiDecl, !local, "Multi-declarations are only allowed for local variables/values"); + errorIf(multiDecl, !local, "Destructuring declarations are only allowed for local variables/values"); } else { parseFunctionOrPropertyName(receiverTypeDeclared, "property", propertyNameFollow, /*nameRequired = */ false); @@ -1243,7 +1243,7 @@ public class KotlinParsing extends AbstractKotlinParsing { PsiBuilder.Marker type = mark(); advance(); // COLON parseTypeRef(); - errorIf(type, multiDeclaration, "Type annotations are not allowed on multi-declarations"); + errorIf(type, multiDeclaration, "Type annotations are not allowed on destructuring declarations"); } parseTypeConstraintsGuarded(typeParametersDeclared); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java index d32a45be793..d5924894f97 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java @@ -166,7 +166,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito KtExpression initializer = multiDeclaration.getInitializer(); if (initializer == null) { - context.trace.report(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION.on(multiDeclaration)); + context.trace.report(INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION.on(multiDeclaration)); return TypeInfoFactoryKt.noTypeInfo(context); } ExpressionReceiver expressionReceiver = ExpressionTypingUtils.getExpressionReceiver( diff --git a/compiler/testData/psi/MultiVariableDeclarations.txt b/compiler/testData/psi/MultiVariableDeclarations.txt index 2036e9a90cd..013ff8fcdf9 100644 --- a/compiler/testData/psi/MultiVariableDeclarations.txt +++ b/compiler/testData/psi/MultiVariableDeclarations.txt @@ -411,7 +411,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Receiver type is not allowed on a multi-declaration + PsiErrorElement:Receiver type is not allowed on a destructuring declaration TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -434,7 +434,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') - PsiErrorElement:Type annotations are not allowed on multi-declarations + PsiErrorElement:Type annotations are not allowed on destructuring declarations PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE @@ -450,7 +450,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Receiver type is not allowed on a multi-declaration + PsiErrorElement:Receiver type is not allowed on a destructuring declaration TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -460,7 +460,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') - PsiErrorElement:Type annotations are not allowed on multi-declarations + PsiErrorElement:Type annotations are not allowed on destructuring declarations PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE @@ -478,7 +478,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -496,13 +496,13 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Receiver type is not allowed on a multi-declaration + PsiErrorElement:Receiver type is not allowed on a destructuring declaration TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Int') PsiElement(DOT)('.') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -520,7 +520,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -529,7 +529,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') - PsiErrorElement:Type annotations are not allowed on multi-declarations + PsiErrorElement:Type annotations are not allowed on destructuring declarations PsiElement(COLON)(':') TYPE_REFERENCE USER_TYPE @@ -552,7 +552,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -570,13 +570,13 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Receiver type is not allowed on a multi-declaration + PsiErrorElement:Receiver type is not allowed on a destructuring declaration TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Int') PsiElement(DOT)('.') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -594,7 +594,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('a') @@ -603,7 +603,7 @@ JetFile: MultiVariableDeclarations.kt MULTI_VARIABLE_DECLARATION_ENTRY PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') - PsiErrorElement:Type annotations are not allowed on multi-declarations + PsiErrorElement:Type annotations are not allowed on destructuring declarations PsiElement(COLON)(':') PsiWhiteSpace(' ') TYPE_REFERENCE diff --git a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt index 61cba93011e..7dce320c5fd 100644 --- a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt +++ b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceiversRecovery.txt @@ -372,7 +372,7 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt MULTI_VARIABLE_DECLARATION PsiElement(val)('val') PsiWhiteSpace(' ') - PsiErrorElement:Receiver type is not allowed on a multi-declaration + PsiErrorElement:Receiver type is not allowed on a destructuring declaration TYPE_REFERENCE ANNOTATION PsiElement(AT)('@') @@ -414,7 +414,7 @@ JetFile: PropertiesWithFunctionReceiversRecovery.kt PsiElement(DOT)('.') PsiErrorElement:Expecting '.' before a property name PsiElement(IDENTIFIER)('foo') - PsiErrorElement:Multi-declarations are only allowed for local variables/values + PsiErrorElement:Destructuring declarations are only allowed for local variables/values PsiElement(LPAR)('(') PsiErrorElement:Expecting a name diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponents.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponents.test index 54a913456db..dd32b55ec14 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponents.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponents.test @@ -1,7 +1,7 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing @@ -27,8 +27,8 @@ operator fun Some.component2() = 3 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsMany.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsMany.test index a4c5ddddfa2..a0f7889149e 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsMany.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsMany.test @@ -1,7 +1,7 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing @@ -36,8 +36,8 @@ operator fun Some.component2() = 3 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereFull.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereFull.test index e656d433510..c1ac432587b 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereFull.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereFull.test @@ -1,7 +1,7 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing @@ -35,8 +35,8 @@ operator fun Some.component1() = 1 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereNotDeprecated.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereNotDeprecated.test index f2d062ec3df..ac2f08ed5bc 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereNotDeprecated.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionAllComponentsPrefereNotDeprecated.test @@ -1,7 +1,7 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type aaa.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type aaa.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type aaa.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type aaa.Some must have a 'component2()' function package testing @@ -37,8 +37,8 @@ operator fun Some.component2() = 3 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type aaa.Some must have a 'component1()' function -// ERROR: Multi-declaration initializer of type aaa.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type aaa.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type aaa.Some must have a 'component2()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent1.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent1.test index fb7d5966eea..0c99521c252 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent1.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent1.test @@ -1,6 +1,6 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function package testing @@ -26,7 +26,7 @@ operator fun Some.component2() = 3 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent2.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent2.test index 557ffc3a875..5556fc67935 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent2.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponent2.test @@ -1,6 +1,6 @@ // FILE: first.before.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing @@ -26,7 +26,7 @@ operator fun Some.component2() = 3 // FILE: first.after.kt // "Import" "true" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component2()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component2()' function package testing diff --git a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test index 400aaf6ee17..b14bd57a487 100644 --- a/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test +++ b/idea/testData/quickfix/autoImports/multiDeclarationExtensionComponentNoOperator.test @@ -1,6 +1,6 @@ // FILE: first.before.kt // "Import" "false" -// ERROR: Multi-declaration initializer of type some.Some must have a 'component1()' function +// ERROR: Destructuring declaration initializer of type some.Some must have a 'component1()' function // ACTION: Create extension function 'component1' // ACTION: Create member function 'component1' diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 47669a7cdaa..c451333093e 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -130,7 +130,7 @@ public inline fun Map.containsValueRaw(value: Any?): Boolean = (this a /** * Returns the key component of the map entry. * - * This method allows to use multi-declarations when working with maps, for example: + * This method allows to use destructuring declarations when working with maps, for example: * ``` * for ((key, value) in map) { * // do something with the key and the value @@ -142,7 +142,7 @@ public inline operator fun Map.Entry.component1(): K = key /** * Returns the value component of the map entry. - * This method allows to use multi-declarations when working with maps, for example: + * This method allows to use destructuring declarations when working with maps, for example: * ``` * for ((key, value) in map) { * // do something with the key and the value