Removed special support for parsing annotations for multi-declaration in for
This commit is contained in:
@@ -1342,7 +1342,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
PsiBuilder.Marker parameter = mark();
|
||||
|
||||
if (!at(IN_KEYWORD)) {
|
||||
myJetParsing.parseModifierListWithLookForStopAt(TokenSet.create(IDENTIFIER, LPAR), TokenSet.create(IN_KEYWORD, RPAR, COLON));
|
||||
myJetParsing.parseModifierList(ONLY_ESCAPED_REGULAR_ANNOTATIONS, TokenSet.create(IN_KEYWORD, RPAR, COLON));
|
||||
}
|
||||
|
||||
if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD
|
||||
|
||||
@@ -2084,38 +2084,6 @@ public class JetParsing extends AbstractJetParsing {
|
||||
return atGT;
|
||||
}
|
||||
|
||||
public void parseModifierListWithLookForStopAt(TokenSet lookFor, TokenSet stopAt) {
|
||||
int lastId = matchTokenStreamPredicate(new LastBefore(new AtSet(lookFor), new AnnotationTargetStop(stopAt, ANNOTATION_TARGETS), false));
|
||||
createTruncatedBuilder(lastId).parseModifierList(ONLY_ESCAPED_REGULAR_ANNOTATIONS, null);
|
||||
}
|
||||
|
||||
private class AnnotationTargetStop extends AbstractTokenStreamPredicate {
|
||||
private final TokenSet stopAt;
|
||||
private final TokenSet annotationTargets;
|
||||
|
||||
private IElementType previousToken;
|
||||
private IElementType tokenBeforePrevious;
|
||||
|
||||
public AnnotationTargetStop(TokenSet stopAt, TokenSet annotationTargets) {
|
||||
this.stopAt = stopAt;
|
||||
this.annotationTargets = annotationTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matching(boolean topLevel) {
|
||||
if (atSet(stopAt)) return true;
|
||||
|
||||
if (at(COLON) && !(tokenBeforePrevious == AT && (previousToken == IDENTIFIER || annotationTargets.contains(previousToken)))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
tokenBeforePrevious = previousToken;
|
||||
previousToken = tt();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* functionType
|
||||
* : "(" (parameter | modifiers type){","}? ")" "->" type?
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ fun foo() {
|
||||
|
||||
for (<!WRONG_ANNOTATION_TARGET!>@Ann(3)<!> (x, @Ann(4) y) in bar()) {}
|
||||
|
||||
for (<!UNRESOLVED_REFERENCE!>@Err<!> (x,y) in bar()) {}
|
||||
for (<!UNRESOLVED_REFERENCE!>@Err<!>() (x,y) in bar()) {}
|
||||
}
|
||||
@@ -11,10 +11,8 @@ fun foo() {
|
||||
for (@Volatile x in 1..100) {}
|
||||
for (@Volatile(1) x in 1..100) {}
|
||||
for (@Volatile() (x, @Volatile y) in 1..100) {}
|
||||
for (@Volatile (x, @Volatile y) in 1..100) {}
|
||||
|
||||
for (@Volatile var x in 1..100) {}
|
||||
for (@Volatile val (x, @Volatile y) in 1..100) {}
|
||||
|
||||
for (private @Volatile var x in 1..100) {}
|
||||
for (private @Volatile val (x, @Volatile y) in 1..100) {}
|
||||
|
||||
-100
@@ -300,55 +300,6 @@ JetFile: forParameters.kt
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
MULTI_VARIABLE_DECLARATION
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Volatile')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
MULTI_VARIABLE_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(' ')
|
||||
LOOP_RANGE
|
||||
BINARY_EXPRESSION
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(RANGE)('..')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('100')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
@@ -384,57 +335,6 @@ JetFile: forParameters.kt
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
MULTI_VARIABLE_DECLARATION
|
||||
MODIFIER_LIST
|
||||
ANNOTATION_ENTRY
|
||||
PsiElement(AT)('@')
|
||||
CONSTRUCTOR_CALLEE
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Volatile')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiElement(COMMA)(',')
|
||||
PsiWhiteSpace(' ')
|
||||
MULTI_VARIABLE_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(' ')
|
||||
LOOP_RANGE
|
||||
BINARY_EXPRESSION
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(RANGE)('..')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('100')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
|
||||
Reference in New Issue
Block a user