Closure parameters for constructor invocations

This commit is contained in:
Andrey Breslav
2011-03-25 16:07:07 +03:00
parent b4a453ddb7
commit badf79aee5
4 changed files with 111 additions and 116 deletions
+7 -3
View File
@@ -174,12 +174,16 @@ prefixUnaryOperation
postfixUnaryOperation postfixUnaryOperation
: "++" : "--" : "++" : "--"
: typeArguments? valueArguments (label? functionLiteral) : callSuffix
: typeArguments (label? functionLiteral)
: arrayAccess : arrayAccess
: memberAccessOperation postfixUnaryOperation // TODO: Review : memberAccessOperation postfixUnaryOperation // TODO: Review
; ;
callSuffix
: typeArguments? valueArguments (label? functionLiteral)
: typeArguments (label? functionLiteral)
;
memberAccessOperation memberAccessOperation
: "." : "?." : "#" : "?" : "." : "?." : "#" : "?"
; ;
@@ -221,7 +225,7 @@ expressions
; ;
constructorInvocation constructorInvocation
: userType valueArguments : userType callSuffix
; ;
arrayAccess arrayAccess
@@ -374,7 +374,10 @@ public class JetExpressionParsing extends AbstractJetParsing {
} }
/* /*
* typeParameters? valueParameters? functionLiteral* * callSuffix
* : typeArguments? valueArguments (label? functionLiteral*)
* : typeArguments (label? functionLiteral*)
* ;
*/ */
private boolean parseCallSuffix() { private boolean parseCallSuffix() {
if (parseCallWithClosure()) { if (parseCallWithClosure()) {
@@ -1361,7 +1364,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
* "new" constructorInvocation // identical to new functionCall * "new" constructorInvocation // identical to new functionCall
* *
* constructorInvocation * constructorInvocation
* : userType valueArguments * : userType callSuffix
*/ */
private void parseNew() { private void parseNew() {
assert _at(NEW_KEYWORD); assert _at(NEW_KEYWORD);
@@ -1370,7 +1373,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
advance(); // NEW_KEYWORD advance(); // NEW_KEYWORD
myJetParsing.parseTypeRef(); myJetParsing.parseTypeRef();
parseValueArgumentList(); parseCallSuffix();
creation.done(NEW); creation.done(NEW);
} }
@@ -11,12 +11,11 @@ enum class List<out T>(theSize : Int) : IList<T> {
get() = this == Nil get() = this == Nil
override fun iterator() = new IIterator() { override fun iterator() = object IIterator() {
private var current = List.this private var current = List.this
override val hasNext { override val hasNext
get() = current == Nil get() = current == Nil
}
override fun next() { override fun next() {
val result = current.value val result = current.value
+96 -107
View File
@@ -225,126 +225,115 @@ JetFile: List.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
CALL_EXPRESSION OBJECT_LITERAL
NEW PsiElement(object)('object')
PsiElement(new)('new')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('IIterator')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUNCTION_LITERAL DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CALL
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('IIterator')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
BODY PROPERTY
PROPERTY MODIFIER_LIST
MODIFIER_LIST PsiElement(private)('private')
PsiElement(private)('private') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(var)('var')
PsiElement(var)('var') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('current')
PsiElement(IDENTIFIER)('current') PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace('\n\n ')
PROPERTY
MODIFIER_LIST
PsiElement(override)('override')
PsiWhiteSpace(' ')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('hasNext')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(get)('get')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION BINARY_EXPRESSION
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('List') PsiElement(IDENTIFIER)('current')
PsiElement(DOT)('.')
THIS_EXPRESSION
PsiElement(this)('this')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
PROPERTY
MODIFIER_LIST
PsiElement(override)('override')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(EQEQ)('==')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Nil')
PsiWhiteSpace('\n\n ')
FUN
MODIFIER_LIST
PsiElement(override)('override')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('next')
TYPE_PARAMETER_LIST
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('hasNext') PsiElement(IDENTIFIER)('result')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
FUNCTION_LITERAL PsiElement(EQ)('=')
PsiElement(LBRACE)('{') PsiWhiteSpace(' ')
PsiWhiteSpace('\n ') DOT_QUALIFIED_EXPRESSION
BODY
BINARY_EXPRESSION
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('get')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(EQEQ)('==')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Nil')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
FUN
MODIFIER_LIST
PsiElement(override)('override')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('next')
TYPE_PARAMETER_LIST
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('result')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('value')
PsiWhiteSpace('\n ')
BINARY_EXPRESSION
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current') PsiElement(IDENTIFIER)('current')
PsiWhiteSpace(' ') PsiElement(DOT)('.')
OPERATION_REFERENCE
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('tail')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('result') PsiElement(IDENTIFIER)('value')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}') BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('current')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('tail')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('result')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')