New syntax for property accessors

This commit is contained in:
Andrey Breslav
2010-12-22 19:28:22 +03:00
parent 7547b36eb0
commit cfcb9d7d7d
15 changed files with 487 additions and 363 deletions
+14 -12
View File
@@ -65,25 +65,28 @@ class BinaryHeap<T> : IPriorityQueue<T> {
} }
private extension HeapIndex for Int { private extension HeapIndex for Int {
val parent : Int { val parent : Int
get() = (this - 1) / 2 get() = (this - 1) / 2
}
val left : Int {
val left : Int
get() = this * 2 + 1 get() = this * 2 + 1
}
val right : Int {
val right : Int
get() = this * 2 + 2 get() = this * 2 + 2
}
val value : T {
val value : T = foo.bar()
get() = data[this] get() = data[this]
} set(it) {
$value = it
}
val exists : Boolean {
val exists : Boolean
get() = (this < data.size) && (this >= 0) get() = (this < data.size) && (this >= 0)
}
} }
private extension for T { private extension for T {
@@ -98,7 +101,6 @@ extension fun IMutableList<T>.swap(a : Int, b : Int) {
this[b] = t this[b] = t
} }
extension val IList<T>.lastIndex : Int { extension val IList<T>.lastIndex : Int
get() = this.size - 1 get() = this.size - 1
}
+2 -1
View File
@@ -42,7 +42,8 @@ typeParameter
; ;
typeConstraint typeConstraint
: userType ":" (userType | "this") // "this" for self-type : userType ":" type
: "class" "object" userType ":" type
// TODO: other constraints, maybe // TODO: other constraints, maybe
; ;
+1 -1
View File
@@ -85,7 +85,7 @@ functionBody
property property
: modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)? : modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)?
"{" getter? setter? "}" (getter? setter? | setter? getter?)
; ;
getter getter
+7 -2
View File
@@ -39,17 +39,22 @@ declaration
; ;
expressionWithPrecedences // See the precedence table, everything associates to the left expressionWithPrecedences // See the precedence table, everything associates to the left
: memberLiteral
: memberAccessExpression
: infixFunctionCall : infixFunctionCall
: binOpExpression : binOpExpression
: assignment : assignment
: unOpExpression : unOpExpression
: castExpression : castExpression
: typingExpression : typingExpression
: memberAccessExpression ;
memberLiteral
: expression? '#' SimpleName
; ;
memberAccessExpression memberAccessExpression
: (expression accessOp)? memberAccess : (expression accessOp)? (memberAccess | expression)
; ;
accessOp accessOp
+3 -1
View File
@@ -46,12 +46,14 @@ public interface JetNodeTypes {
JetNodeType FUNCTION_TYPE = new JetNodeType("FUNCTION_TYPE"); JetNodeType FUNCTION_TYPE = new JetNodeType("FUNCTION_TYPE");
JetNodeType DECOMPOSER_PROPERTY_LIST = new JetNodeType("DECOMPOSER_PROPERTY_LIST"); JetNodeType DECOMPOSER_PROPERTY_LIST = new JetNodeType("DECOMPOSER_PROPERTY_LIST");
JetNodeType RECEIVER_TYPE_ATTRIBUTES = new JetNodeType("RECEIVER_TYPE_ATTRIBUTES"); JetNodeType RECEIVER_TYPE_ATTRIBUTES = new JetNodeType("RECEIVER_TYPE_ATTRIBUTES");
JetNodeType PROPERTY_GETTER = new JetNodeType("PROPERTY_GETTER"); JetNodeType PROPERTY_ACCESSOR = new JetNodeType("PROPERTY_ACCESSOR");
JetNodeType CONSTRUCTOR = new JetNodeType("CONSTRUCTOR"); JetNodeType CONSTRUCTOR = new JetNodeType("CONSTRUCTOR");
JetNodeType INITIALIZER_LIST = new JetNodeType("INITIALIZER_LIST"); JetNodeType INITIALIZER_LIST = new JetNodeType("INITIALIZER_LIST");
JetNodeType THIS_CALL = new JetNodeType("THIS_CALL"); JetNodeType THIS_CALL = new JetNodeType("THIS_CALL");
JetNodeType BLOCK = new JetNodeType("BLOCK"); JetNodeType BLOCK = new JetNodeType("BLOCK");
JetNodeType CLASS_OBJECT = new JetNodeType("CLASS_OBJECT"); JetNodeType CLASS_OBJECT = new JetNodeType("CLASS_OBJECT");
JetNodeType TYPE_CONSTRAINT_LIST = new JetNodeType("TYPE_CONSTRAINT_LIST");
JetNodeType TYPE_CONSTRAINT = new JetNodeType("TYPE_CONSTRAINT");
IElementType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME"); IElementType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME");
} }
@@ -613,7 +613,7 @@ public class JetParsing extends AbstractJetParsing {
/* /*
* property * property
* : modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)? * : modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)?
* ("{" getter? setter? "}")? * getter? setter?
* ; * ;
*/ */
private JetNodeType parseProperty() { private JetNodeType parseProperty() {
@@ -646,24 +646,8 @@ public class JetParsing extends AbstractJetParsing {
myExpressionParsing.parseExpression(); myExpressionParsing.parseExpression();
} }
if (!at(EOL_OR_SEMICOLON) && at(LBRACE)) { if (parsePropertyGetterOrSetter()) {
advance(); // LBRACE parsePropertyGetterOrSetter();
// TODO: review
// TODO: $field = foo or something like this
if (at(RBRACE)) {
error("Expecting a getter and/or setter");
}
else {
parsePropertyGetterOrSetter();
}
if (!at(RBRACE)) parsePropertyGetterOrSetter();
if (!at(RBRACE)) {
errorUntil("Expecting '}'", TokenSet.create(RBRACE));
}
expect(RBRACE, "Expecting '}'");
} }
consumeIf(SEMICOLON); consumeIf(SEMICOLON);
@@ -671,10 +655,6 @@ public class JetParsing extends AbstractJetParsing {
return PROPERTY; return PROPERTY;
} }
private JetParsing createTruncatedBuilder(int eofPosition) {
return new JetParsing(new TruncatedSemanticWhitespaceAwarePsiBuilder(myBuilder, eofPosition));
}
/* /*
* getter * getter
* : modifiers * : modifiers
@@ -684,22 +664,47 @@ public class JetParsing extends AbstractJetParsing {
* ) functionBody * ) functionBody
* ; * ;
*/ */
private void parsePropertyGetterOrSetter() { private boolean parsePropertyGetterOrSetter() {
PsiBuilder.Marker getter = mark(); PsiBuilder.Marker getterOrSetter = mark();
parseModifierList(); parseModifierList();
if (!at(GET_KEYWORD) && !at(SET_KEYWORD)) { if (!at(GET_KEYWORD) && !at(SET_KEYWORD)) {
errorWithRecovery("Expecting 'get' or 'set'", TokenSet.create(LPAR, RBRACE)); getterOrSetter.rollbackTo();
return false;
} }
else {
advance(); // GET_KEYWORD or SET_KEYWORD boolean setter = at(SET_KEYWORD);
advance(); // GET_KEYWORD or SET_KEYWORD
expect(LPAR, "Expecting '('", TokenSet.create(RPAR, IDENTIFIER, COLON, LBRACE, EQ));
if (setter) {
PsiBuilder.Marker setterParameter = mark();
int lastId = findLastBefore(TokenSet.create(IDENTIFIER), TokenSet.create(RPAR, COMMA, COLON), false);
createTruncatedBuilder(lastId).parseModifierList();
expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(RPAR, COLON, LBRACE, EQ));
if (at(COLON)) {
advance();
parseTypeRef();
}
setterParameter.done(VALUE_PARAMETER);
}
if (!at(RPAR)) errorUntil("Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ, EOL_OR_SEMICOLON));
expect(RPAR, "Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ));
if (at(COLON)) {
advance();
parseTypeRef();
} }
parseValueParameterList(false, TokenSet.create(RPAR));
parseFunctionBody(); parseFunctionBody();
getter.done(PROPERTY_GETTER); getterOrSetter.done(PROPERTY_ACCESSOR);
return true;
} }
/* /*
@@ -1030,11 +1035,58 @@ public class JetParsing extends AbstractJetParsing {
} }
expect(GT, "Missing '>'", recoverySet); expect(GT, "Missing '>'", recoverySet);
// TODO : where and stuff
if (at(WHERE_KEYWORD)) {
parseTypeConstraintList();
}
} }
list.done(TYPE_PARAMETER_LIST); list.done(TYPE_PARAMETER_LIST);
} }
/*
* typeConstraint{","}
*/
private void parseTypeConstraintList() {
assert at(WHERE_KEYWORD);
advance(); // WHERE_KEYWORD
PsiBuilder.Marker list = mark();
while (true) {
if (at(COMMA)) errorAndAdvance("Type constraint expected");
parseTypeConstraint();
if (!at(COMMA)) break;
advance(); // COMMA
}
list.done(TYPE_CONSTRAINT_LIST);
}
/*
* typeConstraint
* : userType ":" type
* : "class" "object" userType ":" type
* ;
*/
private void parseTypeConstraint() {
PsiBuilder.Marker constraint = mark();
if (at(CLASS_KEYWORD)) {
advance(); // CLASS_KEYWORD
expect(OBJECT_KEYWORD, "Expecting 'object'", TYPE_REF_FIRST);
}
parseTypeRef();
expect(COLON, "Expecting ':' before the upper bound", TYPE_REF_FIRST);
parseTypeRef();
constraint.done(TYPE_CONSTRAINT);
}
/* /*
* typeParameter * typeParameter
* : modifiers SimpleName (":" userType)? * : modifiers SimpleName (":" userType)?
@@ -1053,7 +1105,6 @@ public class JetParsing extends AbstractJetParsing {
expect(IDENTIFIER, "Type parameter name expected", TokenSet.EMPTY); expect(IDENTIFIER, "Type parameter name expected", TokenSet.EMPTY);
// TODO : other constraints
if (at(COLON)) { if (at(COLON)) {
advance(); // COLON advance(); // COLON
parseTypeRef(); parseTypeRef();
@@ -1090,12 +1141,8 @@ public class JetParsing extends AbstractJetParsing {
} }
if (!at(DOT)) break; if (!at(DOT)) break;
if (simpleTypeFirst.contains(lookahead(1))) { if (!simpleTypeFirst.contains(lookahead(1))) break;
advance(); // DOT advance(); // DOT
} else {
break;
// TODO: ERROR here?
}
} }
type.done(TYPE_REFERENCE); type.done(TYPE_REFERENCE);
} }
@@ -1304,4 +1351,8 @@ public class JetParsing extends AbstractJetParsing {
parameter.done(VALUE_PARAMETER); parameter.done(VALUE_PARAMETER);
} }
private JetParsing createTruncatedBuilder(int eofPosition) {
return new JetParsing(new TruncatedSemanticWhitespaceAwarePsiBuilder(myBuilder, eofPosition));
}
} }
+28 -24
View File
@@ -1,28 +1,32 @@
val foo val foo
val [a] foo val [a] foo
val foo.bar val foo.bar
val foo.bar.{() : ()}.foo val foo.bar.{() : ()}.foo
val foo : T val foo : T
val [a] foo = bar val [a] foo = bar
val foo.bar { val foo.bar
get() {} get() {}
set() = foo set(sad) = foo
}
val foo.bar.{() : ()}.foo = foo {
get() {}
set() {}
}
val foo.bar.{() : ()}.foo : bar = foo { val foo.bar.{() : ()}.foo = foo
[a] public get() {} get() {}
virtual set(a : b) {} set(it) {}
}
val foo.bar.{() : ()}.foo : bar = foo { val foo.bar.{() : ()}.foo = foo
virtual set(a : b) {} get() : Foo {}
} set(it) {}
val foo.bar.{() : ()}.foo : bar = foo
[a] public get() {}
virtual set(a : b) {}
val foo.bar.{() : ()}.foo : bar = foo
virtual set(a : b) {}
val foo.bar.{() : ()}.foo : bar = foo
[a] public get() {}
val foo.bar.{() : ()}.foo : bar = foo {
[a] public get() {}
}
+118 -86
View File
@@ -4,7 +4,7 @@ JetFile: Properties.jet
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -17,7 +17,7 @@ JetFile: Properties.jet
PsiElement(RBRACKET)(']') PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -26,7 +26,7 @@ JetFile: Properties.jet
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -52,7 +52,7 @@ JetFile: Properties.jet
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n\n ') PsiWhiteSpace('\n\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -63,7 +63,7 @@ JetFile: Properties.jet
TYPE_REFERENCE TYPE_REFERENCE
USER_TYPE USER_TYPE
PsiElement(IDENTIFIER)('T') PsiElement(IDENTIFIER)('T')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -80,7 +80,7 @@ JetFile: Properties.jet
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -89,31 +89,27 @@ JetFile: Properties.jet
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(LBRACE)('{') PROPERTY_ACCESSOR
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
PsiElement(set)('set') PsiElement(set)('set')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
PsiElement(RPAR)(')') PsiElement(IDENTIFIER)('sad')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -143,31 +139,83 @@ JetFile: Properties.jet
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(LBRACE)('{') PROPERTY_ACCESSOR
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
PsiElement(set)('set') PsiElement(set)('set')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
PsiElement(RPAR)(')') PsiElement(IDENTIFIER)('it')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}') PROPERTY
PsiWhiteSpace('\n\n ') PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(get)('get')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('Foo')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(set)('set')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('it')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -203,10 +251,8 @@ JetFile: Properties.jet
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(LBRACE)('{') PROPERTY_ACCESSOR
PsiWhiteSpace('\n ')
PROPERTY_GETTER
MODIFIER_LIST MODIFIER_LIST
ATTRIBUTE_ANNOTATION ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[') PsiElement(LBRACKET)('[')
@@ -219,37 +265,33 @@ JetFile: Properties.jet
PsiElement(public)('public') PsiElement(public)('public')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
MODIFIER_LIST MODIFIER_LIST
PsiElement(virtual)('virtual') PsiElement(virtual)('virtual')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(set)('set') PsiElement(set)('set')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
VALUE_PARAMETER PsiElement(IDENTIFIER)('a')
PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE PsiElement(IDENTIFIER)('b')
PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n\n\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -285,32 +327,27 @@ JetFile: Properties.jet
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(LBRACE)('{') PROPERTY_ACCESSOR
PsiWhiteSpace('\n ')
PROPERTY_GETTER
MODIFIER_LIST MODIFIER_LIST
PsiElement(virtual)('virtual') PsiElement(virtual)('virtual')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(set)('set') PsiElement(set)('set')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
VALUE_PARAMETER PsiElement(IDENTIFIER)('a')
PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE PsiElement(IDENTIFIER)('b')
PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n\n\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -346,10 +383,8 @@ JetFile: Properties.jet
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
PsiElement(LBRACE)('{') PROPERTY_ACCESSOR
PsiWhiteSpace('\n ')
PROPERTY_GETTER
MODIFIER_LIST MODIFIER_LIST
ATTRIBUTE_ANNOTATION ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[') PsiElement(LBRACKET)('[')
@@ -362,12 +397,9 @@ JetFile: Properties.jet
PsiElement(public)('public') PsiElement(public)('public')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
+7 -8
View File
@@ -5,21 +5,20 @@ val foo :
val [a foo = foo val [a foo = foo
val foo.bar. val foo.bar.
val [a] foo : = bar val [a] foo : = bar
val foo.bar { val foo.bar
public () {} public () {}
() = foo () = foo
}
val foo.bar.{() : ()}.foo = foo { val foo.bar.{() : ()}.foo = foo
dfget() {} dfget() {}
set) {} set) {}
}
val foo.bar.{() : ()}.foo = foo { val foo.bar.{() : ()}.foo = foo
get(foo) {} get(foo) {}
set() {} set() {}
set() {} set() {}
}
val f.d.- = f val f.d.- = f
val foo { val foo
get() - get() -
}
+148 -164
View File
@@ -5,20 +5,20 @@ JetFile: Properties_ERR.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting property name or receiver type PsiErrorElement:Expecting property name or receiver type
PsiElement(MINUS)('-') PsiElement(MINUS)('-')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter PsiErrorElement:Expecting namespace or top level declaration
<empty list>
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
PROPERTY PROPERTY
PsiElement(var)('var') PsiElement(var)('var')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f') PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter PsiErrorElement:Expecting namespace or top level declaration
<empty list>
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
PROPERTY PROPERTY
@@ -102,159 +102,148 @@ JetFile: Properties_ERR.jet
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.') PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar') PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ') PsiWhiteSpace('\n ')
MODIFIER_LIST
PsiElement(public)('public')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
MODIFIER_LIST
PsiElement(public)('public')
PsiErrorElement:Expecting 'get' or 'set'
<empty list>
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiErrorElement:Expecting 'get' or 'set'
<empty list>
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiErrorElement:Expecting 'get' or 'set'
PsiElement(IDENTIFIER)('dfget')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiErrorElement:Expecting '(
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('foo')
PsiErrorElement:Parameters must have type annotation
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting '}'
PsiElement(IDENTIFIER)('set')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiErrorElement:Expecting namespace or top level declaration PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n') PsiWhiteSpace('\n ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('dfget')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('set')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
USER_TYPE
PsiElement(IDENTIFIER)('bar')
PsiElement(DOT)('.')
FUNCTION_TYPE
PsiElement(LBRACE)('{')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
TUPLE_TYPE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(get)('get')
PsiElement(LPAR)('(')
PsiErrorElement:Expecting ')'
PsiElement(IDENTIFIER)('foo')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(set)('set')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiErrorElement:Expecting parameter name
<empty list>
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(IDENTIFIER)('set')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LPAR)('(')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
PROPERTY PROPERTY
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
@@ -276,16 +265,11 @@ JetFile: Properties_ERR.jet
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo') PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiErrorElement:Expecting function body PsiErrorElement:Expecting function body
PsiElement(MINUS)('-') PsiElement(MINUS)('-')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
+2 -2
View File
@@ -56,10 +56,10 @@ ref
val public val public
val private val private
val protected val protected
val internal { val internal
get() = a get() = a
set(S : s) {} set(S : s) {}
}
public protected private internal public protected private internal
fun abstract () : abstract fun abstract () : abstract
+15 -21
View File
@@ -278,39 +278,33 @@ JetFile: SoftKeywords.jet
PsiElement(val)('val') PsiElement(val)('val')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('internal') PsiElement(IDENTIFIER)('internal')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
PsiElement(get)('get') PsiElement(get)('get')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('a') PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PROPERTY_GETTER PROPERTY_ACCESSOR
PsiElement(set)('set') PsiElement(set)('set')
VALUE_PARAMETER_LIST PsiElement(LPAR)('(')
PsiElement(LPAR)('(') VALUE_PARAMETER
VALUE_PARAMETER PsiElement(IDENTIFIER)('S')
PsiElement(IDENTIFIER)('S') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') PsiElement(COLON)(':')
PsiElement(COLON)(':') PsiWhiteSpace(' ')
PsiWhiteSpace(' ') TYPE_REFERENCE
TYPE_REFERENCE USER_TYPE
USER_TYPE PsiElement(IDENTIFIER)('s')
PsiElement(IDENTIFIER)('s') PsiElement(RPAR)(')')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
BLOCK BLOCK
PsiElement(LBRACE)('{') PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
FUN FUN
MODIFIER_LIST MODIFIER_LIST
PsiElement(public)('public') PsiElement(public)('public')
+3
View File
@@ -0,0 +1,3 @@
class foo<T> where T : T, class object T : T {
}
+46
View File
@@ -0,0 +1,46 @@
JetFile: TypeConstraints.jet
NAMESPACE
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(where)('where')
PsiWhiteSpace(' ')
TYPE_CONSTRAINT_LIST
TYPE_CONSTRAINT
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
TYPE_CONSTRAINT
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(object)('object')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n')
PsiElement(RBRACE)('}')
@@ -56,4 +56,5 @@ public class JetParsingTest extends ParsingTestCase {
public void testSimpleClassMembers() throws Exception {doTest(true);} public void testSimpleClassMembers() throws Exception {doTest(true);}
public void testSimpleClassMembers_ERR() throws Exception {doTest(true);} public void testSimpleClassMembers_ERR() throws Exception {doTest(true);}
public void testConstructors() throws Exception {doTest(true);} public void testConstructors() throws Exception {doTest(true);}
public void testTypeConstraints() throws Exception {doTest(true);}
} }