KT-2627 Parse for with multiple range variables
#KT-2627 Fixed
This commit is contained in:
@@ -1481,7 +1481,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* for
|
* for
|
||||||
* : "for" "(" attributes valOrVar? SimpleName (":" type)? "in" element ")" element
|
* : "for" "(" annotations ("val" | "var")? (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" expression
|
||||||
* ;
|
* ;
|
||||||
*
|
*
|
||||||
* TODO: empty loop body (at the end of the block)?
|
* TODO: empty loop body (at the end of the block)?
|
||||||
@@ -1498,16 +1498,23 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
PsiBuilder.Marker parameter = mark();
|
PsiBuilder.Marker parameter = mark();
|
||||||
if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD
|
if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) advance(); // VAL_KEYWORD or VAR_KEYWORD
|
||||||
if (!myJetParsing.parseIdeTemplate()) {
|
if (at(LPAR)) {
|
||||||
expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON));
|
myJetParsing.parseMultiDeclarationName(TokenSet.create(IN_KEYWORD, LBRACE));
|
||||||
}
|
|
||||||
if (at(COLON)) {
|
|
||||||
advance(); // COLON
|
|
||||||
myJetParsing.parseTypeRef();
|
|
||||||
}
|
|
||||||
parameter.done(LOOP_PARAMETER);
|
|
||||||
|
|
||||||
expect(IN_KEYWORD, "Expecting 'in'");
|
parameter.done(MULTI_VARIABLE_DECLARATION);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!myJetParsing.parseIdeTemplate()) {
|
||||||
|
expect(IDENTIFIER, "Expecting a variable name", TokenSet.create(COLON));
|
||||||
|
}
|
||||||
|
if (at(COLON)) {
|
||||||
|
advance(); // COLON
|
||||||
|
myJetParsing.parseTypeRef();
|
||||||
|
}
|
||||||
|
parameter.done(LOOP_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(IN_KEYWORD, "Expecting 'in'", TokenSet.create(LPAR, LBRACE));
|
||||||
|
|
||||||
PsiBuilder.Marker range = mark();
|
PsiBuilder.Marker range = mark();
|
||||||
parseExpression();
|
parseExpression();
|
||||||
|
|||||||
@@ -908,14 +908,14 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
/*
|
/*
|
||||||
* (SimpleName (":" type)){","}
|
* (SimpleName (":" type)){","}
|
||||||
*/
|
*/
|
||||||
private void parseMultiDeclarationName(TokenSet propertyNameFollow) {
|
public void parseMultiDeclarationName(TokenSet follow) {
|
||||||
// Parsing multi-name, e.g.
|
// Parsing multi-name, e.g.
|
||||||
// val (a, b) = foo()
|
// val (a, b) = foo()
|
||||||
myBuilder.disableNewlines();
|
myBuilder.disableNewlines();
|
||||||
advance(); // LPAR
|
advance(); // LPAR
|
||||||
|
|
||||||
TokenSet recoverySet = TokenSet.orSet(PARAMETER_NAME_RECOVERY_SET, propertyNameFollow);
|
TokenSet recoverySet = TokenSet.orSet(PARAMETER_NAME_RECOVERY_SET, follow);
|
||||||
if (!atSet(propertyNameFollow)) {
|
if (!atSet(follow)) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (at(COMMA)) {
|
if (at(COMMA)) {
|
||||||
errorAndAdvance("Expecting a name");
|
errorAndAdvance("Expecting a name");
|
||||||
@@ -929,7 +929,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
if (at(COLON)) {
|
if (at(COLON)) {
|
||||||
advance(); // COLON
|
advance(); // COLON
|
||||||
parseTypeRef();
|
parseTypeRef(follow);
|
||||||
}
|
}
|
||||||
property.done(MULTI_VARIABLE_DECLARATION_ENTRY);
|
property.done(MULTI_VARIABLE_DECLARATION_ENTRY);
|
||||||
|
|
||||||
@@ -938,7 +938,7 @@ public class JetParsing extends AbstractJetParsing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(RPAR, "Expecting ')'", propertyNameFollow);
|
expect(RPAR, "Expecting ')'", follow);
|
||||||
myBuilder.restoreNewlinesState();
|
myBuilder.restoreNewlinesState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,16 @@ public class JetForExpression extends JetLoopExpression {
|
|||||||
return visitor.visitForExpression(this, data);
|
return visitor.visitForExpression(this, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable
|
||||||
public JetParameter getLoopParameter() {
|
public JetParameter getLoopParameter() {
|
||||||
return (JetParameter) findChildByType(JetNodeTypes.LOOP_PARAMETER);
|
return (JetParameter) findChildByType(JetNodeTypes.LOOP_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public JetMultiDeclaration getMultiParameter() {
|
||||||
|
return (JetMultiDeclaration) findChildByType(JetNodeTypes.MULTI_VARIABLE_DECLARATION);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable @IfNotParsed
|
@Nullable @IfNotParsed
|
||||||
public JetExpression getLoopRange() {
|
public JetExpression getLoopRange() {
|
||||||
return findExpressionUnder(JetNodeTypes.LOOP_RANGE);
|
return findExpressionUnder(JetNodeTypes.LOOP_RANGE);
|
||||||
|
|||||||
@@ -18,13 +18,11 @@ package org.jetbrains.jet.lang.psi;
|
|||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.psi.tree.TokenSet;
|
import com.intellij.psi.tree.TokenSet;
|
||||||
import com.intellij.psi.util.PsiTreeUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.JetNodeTypes;
|
import org.jetbrains.jet.JetNodeTypes;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lexer.JetTokens.EQ;
|
|
||||||
import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
|
import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
|
||||||
import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
|
import static org.jetbrains.jet.lexer.JetTokens.VAR_KEYWORD;
|
||||||
|
|
||||||
@@ -69,11 +67,8 @@ public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed impl
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public ASTNode getValOrVarNode() {
|
public ASTNode getValOrVarNode() {
|
||||||
ASTNode node = getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
|
return getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
|
||||||
assert node != null : "Val or var should always exist for property";
|
|
||||||
return node;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.jet.lang.psi;
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
public interface JetVariableDeclaration extends JetDeclaration, JetWithExpressionInitializer, JetNamedDeclaration {
|
public interface JetVariableDeclaration extends JetDeclaration, JetWithExpressionInitializer, JetNamedDeclaration {
|
||||||
boolean isVar();
|
boolean isVar();
|
||||||
|
|
||||||
@NotNull
|
@Nullable
|
||||||
ASTNode getValOrVarNode();
|
ASTNode getValOrVarNode();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
fun main() {
|
||||||
|
for ((a) in b) {}
|
||||||
|
for ((a, b) in b) {}
|
||||||
|
for ((a: Int, b: Int) in b) {}
|
||||||
|
for ((a: Int, b) in b) {}
|
||||||
|
for ((a, b: Int) in b) {}
|
||||||
|
|
||||||
|
for (val (a) in b) {}
|
||||||
|
for (val (a, b) in b) {}
|
||||||
|
for (val (a: Int, b: Int) in b) {}
|
||||||
|
for (val (a: Int, b) in b) {}
|
||||||
|
for (val (a, b: Int) in b) {}
|
||||||
|
|
||||||
|
for (var (a) in b) {}
|
||||||
|
for (var (a, b) in b) {}
|
||||||
|
for (var (a: Int, b: Int) in b) {}
|
||||||
|
for (var (a: Int, b) in b) {}
|
||||||
|
for (var (a, b: Int) in b) {}
|
||||||
|
|
||||||
|
for ((a in b) {}
|
||||||
|
for ((a, ) in b) {}
|
||||||
|
for ((a: ) in b) {}
|
||||||
|
for ((a: , ) in b) {}
|
||||||
|
for ((, b: Int) in b) {}
|
||||||
|
|
||||||
|
for ((a: in b) {}
|
||||||
|
for (( ) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
JetFile: ForWithMultiDecl.jet
|
||||||
|
NAMESPACE_HEADER
|
||||||
|
<empty list>
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('main')
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
FOR
|
||||||
|
PsiElement(for)('for')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(val)('val')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(val)('val')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(val)('val')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(val)('val')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(val)('val')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(var)('var')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(var)('var')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(var)('var')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(var)('var')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('Int')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(var)('var')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiErrorElement:Expecting ')'
|
||||||
|
<empty list>
|
||||||
|
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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiErrorElement:Expecting a name
|
||||||
|
<empty list>
|
||||||
|
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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
PsiErrorElement:Type expected
|
||||||
|
<empty list>
|
||||||
|
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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
PsiErrorElement:Type expected
|
||||||
|
<empty list>
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiErrorElement:Expecting a name
|
||||||
|
<empty list>
|
||||||
|
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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiErrorElement:Expecting a name
|
||||||
|
PsiElement(COMMA)(',')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
MULTI_VARIABLE_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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION_ENTRY
|
||||||
|
PsiElement(IDENTIFIER)('a')
|
||||||
|
PsiElement(COLON)(':')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
TYPE_REFERENCE
|
||||||
|
PsiErrorElement:Type expected
|
||||||
|
<empty list>
|
||||||
|
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)('(')
|
||||||
|
MULTI_VARIABLE_DECLARATION
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiErrorElement:Expecting a name
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiErrorElement:Expecting 'in'
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
LOOP_RANGE
|
||||||
|
FUNCTION_LITERAL_EXPRESSION
|
||||||
|
FUNCTION_LITERAL
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
BLOCK
|
||||||
|
<empty list>
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiErrorElement:Expecting ')'
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
BODY
|
||||||
|
PsiErrorElement:Expecting an expression
|
||||||
|
<empty list>
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
@@ -85,10 +85,14 @@ variableDeclarationEntry
|
|||||||
: SimpleName (":" type)?
|
: SimpleName (":" type)?
|
||||||
;
|
;
|
||||||
|
|
||||||
|
multipleVariableDeclarations
|
||||||
|
: "(" variableDeclarationEntry{","} ")"
|
||||||
|
;
|
||||||
|
|
||||||
property
|
property
|
||||||
: modifiers ("val" | "var")
|
: modifiers ("val" | "var")
|
||||||
typeParameters? (type "." | annotations)?
|
typeParameters? (type "." | annotations)?
|
||||||
("(" variableDeclarationEntry{","} ")" | variableDeclarationEntry)
|
(multipleVariableDeclarations | variableDeclarationEntry)
|
||||||
typeConstraints
|
typeConstraints
|
||||||
("=" expression SEMI?)?
|
("=" expression SEMI?)?
|
||||||
(getter? setter? | setter? getter?) SEMI?
|
(getter? setter? | setter? getter?) SEMI?
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ loop
|
|||||||
;
|
;
|
||||||
|
|
||||||
for
|
for
|
||||||
: "for" "(" annotations ("val" | "var")? SimpleName (":" type)? "in" expression ")" expression
|
: "for" "(" annotations ("val" | "var")? (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" expression
|
||||||
;
|
;
|
||||||
|
|
||||||
while
|
while
|
||||||
|
|||||||
Reference in New Issue
Block a user