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 {
val parent : Int {
val parent : Int
get() = (this - 1) / 2
}
val left : Int {
val left : Int
get() = this * 2 + 1
}
val right : Int {
val right : Int
get() = this * 2 + 2
}
val value : T {
val value : T = foo.bar()
get() = data[this]
}
set(it) {
$value = it
}
val exists : Boolean {
val exists : Boolean
get() = (this < data.size) && (this >= 0)
}
}
private extension for T {
@@ -98,7 +101,6 @@ extension fun IMutableList<T>.swap(a : Int, b : Int) {
this[b] = t
}
extension val IList<T>.lastIndex : Int {
extension val IList<T>.lastIndex : Int
get() = this.size - 1
}
+2 -1
View File
@@ -42,7 +42,8 @@ typeParameter
;
typeConstraint
: userType ":" (userType | "this") // "this" for self-type
: userType ":" type
: "class" "object" userType ":" type
// TODO: other constraints, maybe
;
+1 -1
View File
@@ -85,7 +85,7 @@ functionBody
property
: modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)?
"{" getter? setter? "}"
(getter? setter? | setter? getter?)
;
getter
+7 -2
View File
@@ -39,17 +39,22 @@ declaration
;
expressionWithPrecedences // See the precedence table, everything associates to the left
: memberLiteral
: memberAccessExpression
: infixFunctionCall
: binOpExpression
: assignment
: unOpExpression
: castExpression
: typingExpression
: memberAccessExpression
;
memberLiteral
: expression? '#' SimpleName
;
memberAccessExpression
: (expression accessOp)? memberAccess
: (expression accessOp)? (memberAccess | expression)
;
accessOp
+3 -1
View File
@@ -46,12 +46,14 @@ public interface JetNodeTypes {
JetNodeType FUNCTION_TYPE = new JetNodeType("FUNCTION_TYPE");
JetNodeType DECOMPOSER_PROPERTY_LIST = new JetNodeType("DECOMPOSER_PROPERTY_LIST");
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 INITIALIZER_LIST = new JetNodeType("INITIALIZER_LIST");
JetNodeType THIS_CALL = new JetNodeType("THIS_CALL");
JetNodeType BLOCK = new JetNodeType("BLOCK");
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");
}
@@ -613,7 +613,7 @@ public class JetParsing extends AbstractJetParsing {
/*
* property
* : modifiers ("val" | "var") attributes (type ".")? SimpleName (":" type)? ("=" expression)?
* ("{" getter? setter? "}")?
* getter? setter?
* ;
*/
private JetNodeType parseProperty() {
@@ -646,24 +646,8 @@ public class JetParsing extends AbstractJetParsing {
myExpressionParsing.parseExpression();
}
if (!at(EOL_OR_SEMICOLON) && at(LBRACE)) {
advance(); // LBRACE
// 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 '}'");
if (parsePropertyGetterOrSetter()) {
parsePropertyGetterOrSetter();
}
consumeIf(SEMICOLON);
@@ -671,10 +655,6 @@ public class JetParsing extends AbstractJetParsing {
return PROPERTY;
}
private JetParsing createTruncatedBuilder(int eofPosition) {
return new JetParsing(new TruncatedSemanticWhitespaceAwarePsiBuilder(myBuilder, eofPosition));
}
/*
* getter
* : modifiers
@@ -684,22 +664,47 @@ public class JetParsing extends AbstractJetParsing {
* ) functionBody
* ;
*/
private void parsePropertyGetterOrSetter() {
PsiBuilder.Marker getter = mark();
private boolean parsePropertyGetterOrSetter() {
PsiBuilder.Marker getterOrSetter = mark();
parseModifierList();
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();
getter.done(PROPERTY_GETTER);
getterOrSetter.done(PROPERTY_ACCESSOR);
return true;
}
/*
@@ -1030,11 +1035,58 @@ public class JetParsing extends AbstractJetParsing {
}
expect(GT, "Missing '>'", recoverySet);
// TODO : where and stuff
if (at(WHERE_KEYWORD)) {
parseTypeConstraintList();
}
}
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
* : modifiers SimpleName (":" userType)?
@@ -1053,7 +1105,6 @@ public class JetParsing extends AbstractJetParsing {
expect(IDENTIFIER, "Type parameter name expected", TokenSet.EMPTY);
// TODO : other constraints
if (at(COLON)) {
advance(); // COLON
parseTypeRef();
@@ -1090,12 +1141,8 @@ public class JetParsing extends AbstractJetParsing {
}
if (!at(DOT)) break;
if (simpleTypeFirst.contains(lookahead(1))) {
advance(); // DOT
} else {
break;
// TODO: ERROR here?
}
if (!simpleTypeFirst.contains(lookahead(1))) break;
advance(); // DOT
}
type.done(TYPE_REFERENCE);
}
@@ -1304,4 +1351,8 @@ public class JetParsing extends AbstractJetParsing {
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 [a] foo
val foo.bar
val foo.bar.{() : ()}.foo
val foo
val [a] foo
val foo.bar
val foo.bar.{() : ()}.foo
val foo : T
val [a] foo = bar
val foo.bar {
get() {}
set() = foo
}
val foo.bar.{() : ()}.foo = foo {
get() {}
set() {}
}
val foo : T
val [a] foo = bar
val foo.bar
get() {}
set(sad) = foo
val foo.bar.{() : ()}.foo : bar = foo {
[a] public get() {}
virtual set(a : b) {}
}
val foo.bar.{() : ()}.foo = foo
get() {}
set(it) {}
val foo.bar.{() : ()}.foo : bar = foo {
virtual set(a : b) {}
}
val foo.bar.{() : ()}.foo = foo
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() {}
}
+119 -87
View File
@@ -4,7 +4,7 @@ JetFile: Properties.jet
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -17,7 +17,7 @@ JetFile: Properties.jet
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -26,7 +26,7 @@ JetFile: Properties.jet
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -52,7 +52,7 @@ JetFile: Properties.jet
PsiElement(RBRACE)('}')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -63,7 +63,7 @@ JetFile: Properties.jet
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -80,7 +80,7 @@ JetFile: Properties.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -89,31 +89,27 @@ JetFile: Properties.jet
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
PsiElement(IDENTIFIER)('bar')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('sad')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -143,31 +139,83 @@ JetFile: Properties.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('it')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
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)('(')
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
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -203,10 +251,8 @@ JetFile: Properties.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
@@ -219,37 +265,33 @@ JetFile: Properties.jet
PsiElement(public)('public')
PsiWhiteSpace(' ')
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
PsiElement(virtual)('virtual')
PsiWhiteSpace(' ')
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('b')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('b')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -285,32 +327,27 @@ JetFile: Properties.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
PsiElement(virtual)('virtual')
PsiWhiteSpace(' ')
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('b')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('b')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n\n')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -346,10 +383,8 @@ JetFile: Properties.jet
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
ATTRIBUTE_ANNOTATION
PsiElement(LBRACKET)('[')
@@ -362,12 +397,9 @@ JetFile: Properties.jet
PsiElement(public)('public')
PsiWhiteSpace(' ')
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
+8 -9
View File
@@ -5,21 +5,20 @@ val foo :
val [a foo = foo
val foo.bar.
val [a] foo : = bar
val foo.bar {
val foo.bar
public () {}
() = foo
}
val foo.bar.{() : ()}.foo = foo {
val foo.bar.{() : ()}.foo = foo
dfget() {}
set) {}
}
val foo.bar.{() : ()}.foo = foo {
val foo.bar.{() : ()}.foo = foo
get(foo) {}
set() {}
set() {}
}
val f.d.- = f
val foo {
get() -
}
val foo
get() -
+149 -165
View File
@@ -5,20 +5,20 @@ JetFile: Properties_ERR.jet
PsiWhiteSpace(' ')
PsiErrorElement:Expecting property name or receiver type
PsiElement(MINUS)('-')
PsiWhiteSpace(' ')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter
<empty list>
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(LBRACE)('{')
PsiErrorElement:Expecting a getter and/or setter
<empty list>
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
@@ -102,159 +102,148 @@ JetFile: Properties_ERR.jet
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
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)('{')
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
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
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -276,16 +265,11 @@ JetFile: Properties_ERR.jet
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PROPERTY_ACCESSOR
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting function body
PsiElement(MINUS)('-')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiElement(MINUS)('-')
+2 -2
View File
@@ -56,10 +56,10 @@ ref
val public
val private
val protected
val internal {
val internal
get() = a
set(S : s) {}
}
public protected private internal
fun abstract () : abstract
+15 -21
View File
@@ -278,39 +278,33 @@ JetFile: SoftKeywords.jet
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('internal')
PsiWhiteSpace(' ')
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PROPERTY_ACCESSOR
PsiElement(get)('get')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PROPERTY_GETTER
PROPERTY_ACCESSOR
PsiElement(set)('set')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('S')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('s')
PsiElement(RPAR)(')')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('S')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
PsiElement(IDENTIFIER)('s')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PsiWhiteSpace('\n\n\n ')
FUN
MODIFIER_LIST
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_ERR() throws Exception {doTest(true);}
public void testConstructors() throws Exception {doTest(true);}
public void testTypeConstraints() throws Exception {doTest(true);}
}