Implement parsing annotations and modifiers starting with '@'

This commit is contained in:
Denis Zharkov
2015-05-04 11:50:16 +03:00
parent b13e932c3c
commit 7d8351abc6
27 changed files with 2275 additions and 88 deletions
@@ -342,7 +342,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
private void parsePrefixExpression() {
// System.out.println("pre at " + myBuilder.getTokenText());
if (at(LBRACKET)) {
if (at(LBRACKET) || at(AT)) {
if (!parseLocalDeclaration()) {
PsiBuilder.Marker expression = mark();
myJetParsing.parseAnnotations(ONLY_ESCAPED_REGULAR_ANNOTATIONS);
@@ -430,9 +430,24 @@ public class JetParsing extends AbstractJetParsing {
if (annotationParsingMode.atMemberStart && atSet(SOFT_KEYWORDS_AT_MEMBER_START)) {
break;
}
if (atSet(MODIFIER_KEYWORDS)) {
if (tokenConsumer != null) tokenConsumer.consume(tt());
advance(); // MODIFIER
if (at(AT)) {
IElementType strictlyNextToken = myBuilder.rawLookup(1);
if (strictlyNextToken == IDENTIFIER || MODIFIER_KEYWORDS.contains(strictlyNextToken)) {
if (!annotationParsingMode.allowAtAnnotations) {
errorAndAdvance("Only annotations in '[]' can be declared here"); // AT
}
if (!tryParseModifier(tokenConsumer)) {
parseAnnotationEntry();
}
}
else {
errorAndAdvance("Expected modifier or annotation after '@'"); // AT
}
}
else if (tryParseModifier(tokenConsumer)) {
// modifier advanced
}
else if (at(LBRACKET) || (annotationParsingMode.allowShortAnnotations && at(IDENTIFIER))) {
parseAnnotation(annotationParsingMode);
@@ -451,6 +466,27 @@ public class JetParsing extends AbstractJetParsing {
return !empty;
}
private boolean tryParseModifier(@Nullable Consumer<IElementType> tokenConsumer) {
PsiBuilder.Marker marker = mark();
if (at(AT)) {
advance(); // AT
}
if (atSet(MODIFIER_KEYWORDS)) {
IElementType tt = tt();
if (tokenConsumer != null) {
tokenConsumer.consume(tt);
}
advance(); // MODIFIER
marker.collapse(tt);
return true;
}
marker.rollbackTo();
return false;
}
/*
* fileAnnotationList
* : ("[" "file:" annotationEntry+ "]")*
@@ -490,6 +526,7 @@ public class JetParsing extends AbstractJetParsing {
* annotation
* : "[" ("file" ":")? annotationEntry+ "]"
* : annotationEntry
* : "@" annotationEntry
* ;
*/
private boolean parseAnnotation(AnnotationParsingMode mode) {
@@ -541,6 +578,15 @@ public class JetParsing extends AbstractJetParsing {
parseAnnotationEntry();
return true;
}
else if (mode.allowAtAnnotations && at(AT)) {
if (myBuilder.rawLookup(1) == IDENTIFIER) {
parseAnnotationEntry();
}
else {
errorAndAdvance("Expected annotation identifier after '@'", 1); // AT
}
return true;
}
return false;
}
@@ -551,10 +597,14 @@ public class JetParsing extends AbstractJetParsing {
* ;
*/
private void parseAnnotationEntry() {
assert _at(IDENTIFIER);
assert _at(IDENTIFIER) || (_at(AT) && myBuilder.rawLookup(1) == IDENTIFIER);
PsiBuilder.Marker annotation = mark();
if (at(AT)) {
advance(); // AT
}
PsiBuilder.Marker reference = mark();
PsiBuilder.Marker typeReference = mark();
parseUserType();
@@ -625,7 +675,7 @@ public class JetParsing extends AbstractJetParsing {
OptionalMarker constructorModifiersMarker = new OptionalMarker(object);
PsiBuilder.Marker beforeConstructorModifiers = mark();
PsiBuilder.Marker primaryConstructorMarker = mark();
boolean hasConstructorModifiers = parseModifierList(ONLY_ESCAPED_REGULAR_ANNOTATIONS);
boolean hasConstructorModifiers = parseModifierList(PRIMARY_CONSTRUCTOR_MODIFIER_LIST);
// Some modifiers found, but no parentheses following: class has already ended, and we are looking at something else
if (hasConstructorModifiers && !atSet(LPAR, LBRACE, COLON)) {
@@ -2096,25 +2146,29 @@ public class JetParsing extends AbstractJetParsing {
}
}
static enum AnnotationParsingMode {
FILE_ANNOTATIONS_BEFORE_PACKAGE(false, true),
FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(false, true),
ONLY_ESCAPED_REGULAR_ANNOTATIONS(false, false),
ALLOW_UNESCAPED_REGULAR_ANNOTATIONS(true, false),
ALLOW_UNESCAPED_REGULAR_ANNOTATIONS_AT_MEMBER_MODIFIER_LIST(true, false, true);
enum AnnotationParsingMode {
FILE_ANNOTATIONS_BEFORE_PACKAGE(false, true, false, false),
FILE_ANNOTATIONS_WHEN_PACKAGE_OMITTED(false, true, false, false),
ONLY_ESCAPED_REGULAR_ANNOTATIONS(false, false, false, true),
ALLOW_UNESCAPED_REGULAR_ANNOTATIONS(true, false, false, true),
ALLOW_UNESCAPED_REGULAR_ANNOTATIONS_AT_MEMBER_MODIFIER_LIST(true, false, true, true),
PRIMARY_CONSTRUCTOR_MODIFIER_LIST(false, false, false, false);
boolean allowShortAnnotations;
boolean isFileAnnotationParsingMode;
boolean atMemberStart = false;
boolean allowAtAnnotations = true;
AnnotationParsingMode(boolean allowShortAnnotations, boolean onlyFileAnnotations) {
AnnotationParsingMode(
boolean allowShortAnnotations,
boolean isFileAnnotationParsingMode,
boolean atMemberStart,
boolean allowAtAnnotations
) {
this.allowShortAnnotations = allowShortAnnotations;
this.isFileAnnotationParsingMode = onlyFileAnnotations;
}
AnnotationParsingMode(boolean allowShortAnnotations, boolean onlyFileAnnotations, boolean atMemberStart) {
this(allowShortAnnotations, onlyFileAnnotations);
this.isFileAnnotationParsingMode = isFileAnnotationParsingMode;
this.atMemberStart = atMemberStart;
this.allowAtAnnotations = allowAtAnnotations;
}
}
}
+8 -8
View File
@@ -56,8 +56,8 @@ JetFile: Labels.kt
PsiWhiteSpace(' ')
PARENTHESIZED
PsiElement(LPAR)('(')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
@@ -69,8 +69,8 @@ JetFile: Labels.kt
PsiErrorElement:Label must be named
PsiElement(AT)('@')
PsiWhiteSpace(' ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
@@ -132,16 +132,16 @@ JetFile: Labels.kt
PsiElement(return)('return')
PsiErrorElement:Label must be named
PsiElement(AT)('@')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiErrorElement:Label must be named
PsiElement(AT)('@')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
@@ -0,0 +1 @@
@ann class A
@@ -0,0 +1,16 @@
JetFile: annotationAtFileStart.kt
PACKAGE_DIRECTIVE
<empty list>
CLASS
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A')
@@ -0,0 +1,7 @@
fun foo() {
@ann ({ it -> it + 1}) // lambda parsed as argument of annotation, and annotated expression is "print(1)"
print(1)
@ann() ({ it -> it + 1}) // lambda in parenthesises annotated, "print(1)" is separated expression
print(1)
}
@@ -0,0 +1,111 @@
JetFile: annotationValueArgumentsAmbiguity.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
VALUE_PARAMETER
PsiElement(IDENTIFIER)('it')
PsiWhiteSpace(' ')
PsiElement(ARROW)('->')
PsiWhiteSpace(' ')
BLOCK
BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('it')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiComment(EOL_COMMENT)('// lambda parsed as argument of annotation, and annotated expression is "print(1)"')
PsiWhiteSpace('\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('print')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PARENTHESIZED
PsiElement(LPAR)('(')
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
VALUE_PARAMETER
PsiElement(IDENTIFIER)('it')
PsiWhiteSpace(' ')
PsiElement(ARROW)('->')
PsiWhiteSpace(' ')
BLOCK
BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('it')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiComment(EOL_COMMENT)('// lambda in parenthesises annotated, "print(1)" is separated expression')
PsiWhiteSpace('\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('print')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,28 @@
private @ [Ann1(1)] Ann3("2") class A(
@ private val x: Int,
@ private var y: Int,
@ open z: Int
) {
@ fun foo() {
@ class LocalClass
print(1)
@
[inline2] private
fun inlineLocal() {}
[Ann]
private
@
@volatile var x = 1
foo(fun(@ @ann(1) x: Int) {})
for (@ x in 1..100) {}
}
val x: Int
@ private @ open get() = 1
}
@@ -0,0 +1,316 @@
JetFile: declarationsJustAtTyped.kt
PACKAGE_DIRECTIVE
<empty list>
CLASS
MODIFIER_LIST
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann1')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann3')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
LITERAL_STRING_TEMPLATE_ENTRY
PsiElement(REGULAR_STRING_PART)('2')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A')
PRIMARY_CONSTRUCTOR
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('y')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(open)('open')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('z')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
FUN
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
CLASS
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('LocalClass')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('print')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
FUN
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace('\n\n ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inline2')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace('\n ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('inlineLocal')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY
MODIFIER_LIST
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n ')
PsiElement(private)('private')
PsiWhiteSpace('\n ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace('\n ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('volatile')
PsiWhiteSpace(' ')
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
FUN
PsiElement(fun)('fun')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
BINARY_EXPRESSION
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiErrorElement:Expecting a variable name
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiErrorElement:Expecting 'in'
PsiElement(IDENTIFIER)('x')
PsiErrorElement:Expecting ')'
<empty list>
PsiWhiteSpace(' ')
BODY
PsiErrorElement:Expecting an expression
<empty list>
OPERATION_REFERENCE
PsiElement(in)('in')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
OPERATION_REFERENCE
PsiElement(RANGE)('..')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('100')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
BLOCK
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(open)('open')
PsiWhiteSpace(' ')
PsiElement(get)('get')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,28 @@
fun foo() {
return @ 1
return (@ 2)
@ foo("")
@ 3 + @ 4 * @ 5 infix @ 6
foo.bar(@ fun(x: Int) {
})
if (@ true || true) {
}
else {}
label@ @ while (true) {
@ break@label
}
return@label @ 1
// multiline
@
ann
1
}
@@ -0,0 +1,223 @@
JetFile: expressionJustAtTyped.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiErrorElement:There should be no space or comments before '@' in label reference
<empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Label must be named
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
PARENTHESIZED
PsiElement(LPAR)('(')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('2')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
BINARY_EXPRESSION
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('3')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('4')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MUL)('*')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('5')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(IDENTIFIER)('infix')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('6')
PsiWhiteSpace('\n\n ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
FUN
MODIFIER_LIST
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
IF
PsiElement(if)('if')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(OROR)('||')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
THEN
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(else)('else')
PsiWhiteSpace(' ')
ELSE
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
LABELED_EXPRESSION
LABEL_QUALIFIER
LABEL
PsiElement(IDENTIFIER)('label')
PsiElement(AT)('@')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
WHILE
PsiElement(while)('while')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
BREAK
PsiElement(break)('break')
LABEL_QUALIFIER
LABEL
PsiElement(AT)('@')
PsiElement(IDENTIFIER)('label')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
RETURN
PsiElement(return)('return')
LABEL_QUALIFIER
LABEL
PsiElement(AT)('@')
PsiElement(IDENTIFIER)('label')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
PsiComment(EOL_COMMENT)('// multiline')
PsiWhiteSpace('\n ')
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace('\n ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace('\n ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,3 @@
fun foo() {
for (@volatile x in 1..100) {}
}
@@ -0,0 +1,52 @@
JetFile: invalidExpressions.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiErrorElement:Expecting a variable name
PsiElement(AT)('@')
PsiErrorElement:Expecting 'in'
PsiElement(IDENTIFIER)('volatile')
PsiErrorElement:Expecting ')'
<empty list>
PsiWhiteSpace(' ')
BODY
BINARY_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(in)('in')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
OPERATION_REFERENCE
PsiElement(RANGE)('..')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('100')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
BLOCK
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1 @@
@public class A
@@ -0,0 +1,10 @@
JetFile: modifierAtFileStart.kt
PACKAGE_DIRECTIVE
<empty list>
CLASS
MODIFIER_LIST
PsiElement(public)('@public')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A')
@@ -0,0 +1,9 @@
class A1 @Ann1("") ()
class A2 @Ann2("")(x: Int) : B {
}
class A3 [Ann3] private @(x: Int)
class A4 [Ann4] @private @(x: Int)
class A5 private @Ann4(x: Int) : B
class A6 [Ann5] @private @ [Ann6]()
@@ -0,0 +1,225 @@
JetFile: primaryConstructor.kt
PACKAGE_DIRECTIVE
<empty list>
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A1')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
PsiErrorElement:Only annotations in '[]' can be declared here
PsiElement(AT)('@')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann1')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A2')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
PsiErrorElement:Only annotations in '[]' can be declared here
PsiElement(AT)('@')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann2')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A3')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann3')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A4')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann4')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiErrorElement:Only annotations in '[]' can be declared here
PsiElement(AT)('@')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A5')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Only annotations in '[]' can be declared here
PsiElement(AT)('@')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann4')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
BINARY_WITH_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
OPERATION_REFERENCE
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiErrorElement:Expecting primary constructor parameter list
<empty list>
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
DELEGATION_SPECIFIER_LIST
DELEGATOR_SUPER_CLASS
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiWhiteSpace('\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A6')
PsiWhiteSpace(' ')
PRIMARY_CONSTRUCTOR
MODIFIER_LIST
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann5')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiErrorElement:Only annotations in '[]' can be declared here
PsiElement(AT)('@')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiErrorElement:Expected modifier or annotation after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann6')
PsiElement(RBRACKET)(']')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
@@ -0,0 +1,47 @@
private @open [Ann1(1)] @Ann2("1") Ann3("2") class A(
@volatile(1) private val x: @AnnType("3") @open Int,
@private var y: Int,
@open z: Int
) {
@private [Ann3(2)] @Ann4("4") fun foo() {
@data class LocalClass
print(1)
@inline(option1, option2)
[inline2] private
fun inlineLocal() {}
[Ann]
private
@abstract
@volatile var x = 1
foo(fun(@vararg @ann(1) x: Int) {})
}
val x: Int
@inject [inline] private @open get() = 1
@open @ann init {}
@companion object
@companion @private object B
@main
@private
constructor()
fun <@ann("") [ann] T : R> foo() {}
}
@private val x = 1
@inline private fun bar() = 1
fun bar() {
try {}
catch (@volatile e: Exception) {}
}
@@ -0,0 +1,579 @@
JetFile: validDeclarations.kt
PACKAGE_DIRECTIVE
<empty list>
CLASS
MODIFIER_LIST
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(open)('@open')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann1')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann2')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
LITERAL_STRING_TEMPLATE_ENTRY
PsiElement(REGULAR_STRING_PART)('1')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann3')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
LITERAL_STRING_TEMPLATE_ENTRY
PsiElement(REGULAR_STRING_PART)('2')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('A')
PRIMARY_CONSTRUCTOR
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('volatile')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('AnnType')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
LITERAL_STRING_TEMPLATE_ENTRY
PsiElement(REGULAR_STRING_PART)('3')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('open')
PsiWhiteSpace(' ')
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
PsiElement(private)('@private')
PsiWhiteSpace(' ')
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('y')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(COMMA)(',')
PsiWhiteSpace('\n ')
VALUE_PARAMETER
MODIFIER_LIST
PsiElement(open)('@open')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('z')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CLASS_BODY
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
FUN
MODIFIER_LIST
PsiElement(private)('@private')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann3')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('2')
PsiElement(RPAR)(')')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann4')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
LITERAL_STRING_TEMPLATE_ENTRY
PsiElement(REGULAR_STRING_PART)('4')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
CLASS
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('data')
PsiWhiteSpace(' ')
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('LocalClass')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('print')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
FUN
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inline')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('option1')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_ARGUMENT
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('option2')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inline2')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace('\n ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('inlineLocal')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY
MODIFIER_LIST
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Ann')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n ')
PsiElement(private)('private')
PsiWhiteSpace('\n ')
PsiElement(abstract)('@abstract')
PsiWhiteSpace('\n ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('volatile')
PsiWhiteSpace(' ')
PsiElement(var)('var')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
FUN
PsiElement(fun)('fun')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
MODIFIER_LIST
PsiElement(vararg)('@vararg')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n ')
PROPERTY_ACCESSOR
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inject')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inline')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(open)('@open')
PsiWhiteSpace(' ')
PsiElement(get)('get')
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
ANONYMOUS_INITIALIZER
MODIFIER_LIST
PsiElement(open)('@open')
PsiWhiteSpace(' ')
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
PsiElement(init)('init')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
OBJECT_DECLARATION
MODIFIER_LIST
PsiElement(companion)('@companion')
PsiWhiteSpace(' ')
PsiElement(object)('object')
PsiWhiteSpace('\n\n ')
OBJECT_DECLARATION
MODIFIER_LIST
PsiElement(companion)('@companion')
PsiWhiteSpace(' ')
PsiElement(private)('@private')
PsiWhiteSpace(' ')
PsiElement(object)('object')
PsiWhiteSpace(' ')
OBJECT_DECLARATION_NAME
PsiElement(IDENTIFIER)('B')
PsiWhiteSpace('\n\n ')
SECONDARY_CONSTRUCTOR
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('main')
PsiWhiteSpace('\n\n ')
PsiElement(private)('@private')
PsiWhiteSpace('\n ')
PsiElement(constructor)('constructor')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
TYPE_PARAMETER_LIST
PsiElement(LT)('<')
TYPE_PARAMETER
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace(' ')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('R')
PsiElement(GT)('>')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PROPERTY
MODIFIER_LIST
PsiElement(private)('@private')
PsiWhiteSpace(' ')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n')
FUN
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('inline')
PsiWhiteSpace(' ')
PsiElement(private)('private')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('bar')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
TRY
PsiElement(try)('try')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
CATCH
PsiElement(catch)('catch')
PsiWhiteSpace(' ')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('volatile')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('e')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Exception')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -0,0 +1,31 @@
fun foo() {
return @ann 1
return (@ann 2)
@ann foo("")
@ann 3 + @ann 4 * @ann("") 5 infix @ann 6
foo.bar(@ann fun(x: Int) {
})
@ann if (@ann true || true) {
}
else {}
for (i in @ann x) {}
label@ @ann while (true) {
@ann break@label
}
return@label @ann 1
label@simpleName
val x = @ann [ann] l@{
a, b, c -> a
}
}
@@ -0,0 +1,375 @@
JetFile: validExpressions.kt
PACKAGE_DIRECTIVE
<empty list>
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiErrorElement:There should be no space or comments before '@' in label reference
<empty list>
PsiWhiteSpace(' ')
LABEL_QUALIFIER
LABEL
PsiElement(AT)('@')
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n ')
RETURN
PsiElement(return)('return')
PsiWhiteSpace(' ')
PARENTHESIZED
PsiElement(LPAR)('(')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('2')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
BINARY_EXPRESSION
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('3')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(PLUS)('+')
PsiWhiteSpace(' ')
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('4')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(MUL)('*')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
STRING_TEMPLATE
PsiElement(OPEN_QUOTE)('"')
PsiElement(CLOSING_QUOTE)('"')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('5')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(IDENTIFIER)('infix')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('6')
PsiWhiteSpace('\n\n ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('foo')
PsiElement(DOT)('.')
CALL_EXPRESSION
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('bar')
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
VALUE_ARGUMENT
FUN
MODIFIER_LIST
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
PsiElement(fun)('fun')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('x')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
IF
PsiElement(if)('if')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
BINARY_EXPRESSION
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiWhiteSpace(' ')
OPERATION_REFERENCE
PsiElement(OROR)('||')
PsiWhiteSpace(' ')
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
THEN
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n ')
PsiElement(else)('else')
PsiWhiteSpace(' ')
ELSE
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
LOOP_RANGE
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('x')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
LABELED_EXPRESSION
LABEL_QUALIFIER
LABEL
PsiElement(IDENTIFIER)('label')
PsiElement(AT)('@')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
WHILE
PsiElement(while)('while')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
CONDITION
BOOLEAN_CONSTANT
PsiElement(true)('true')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
BREAK
PsiElement(break)('break')
LABEL_QUALIFIER
LABEL
PsiElement(AT)('@')
PsiElement(IDENTIFIER)('label')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
RETURN
PsiElement(return)('return')
LABEL_QUALIFIER
LABEL
PsiElement(AT)('@')
PsiElement(IDENTIFIER)('label')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiWhiteSpace('\n\n ')
LABELED_EXPRESSION
LABEL_QUALIFIER
LABEL
PsiElement(IDENTIFIER)('label')
PsiElement(AT)('@')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('simpleName')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('x')
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiWhiteSpace(' ')
ANNOTATION
PsiElement(LBRACKET)('[')
ANNOTATION_ENTRY
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ann')
PsiElement(RBRACKET)(']')
PsiWhiteSpace(' ')
LABELED_EXPRESSION
LABEL_QUALIFIER
LABEL
PsiElement(IDENTIFIER)('l')
PsiElement(AT)('@')
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
VALUE_PARAMETER_LIST
VALUE_PARAMETER
PsiElement(IDENTIFIER)('a')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('b')
PsiElement(COMMA)(',')
PsiWhiteSpace(' ')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('c')
PsiWhiteSpace(' ')
PsiElement(ARROW)('->')
PsiWhiteSpace(' ')
BLOCK
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('a')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
@@ -12,38 +12,39 @@ JetFile: oldSyntaxExpressions.kt
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('loop1')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
<empty list>
PsiWhiteSpace(' ')
FOR
PsiElement(for)('for')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('loop1')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
LOOP_RANGE
BINARY_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
OPERATION_REFERENCE
PsiElement(RANGE)('..')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('100')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace(' ')
PsiElement(RBRACE)('}')
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
LOOP_RANGE
BINARY_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
OPERATION_REFERENCE
PsiElement(RANGE)('..')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('100')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace(' ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
DOT_QUALIFIED_EXPRESSION
REFERENCE_EXPRESSION
@@ -74,17 +75,18 @@ JetFile: oldSyntaxExpressions.kt
PsiWhiteSpace(' ')
PARENTHESIZED
PsiElement(LPAR)('(')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('f')
PsiErrorElement:Expecting ')'
<empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(INTEGER_LITERAL)('3')
PsiElement(RPAR)(')')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('f')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('3')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
+16 -13
View File
@@ -23,8 +23,8 @@ JetFile: recovery.kt
OPERATION_REFERENCE
PsiElement(IDENTIFIER)('c')
PsiWhiteSpace(' ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
FUNCTION_LITERAL_EXPRESSION
@@ -123,19 +123,22 @@ JetFile: recovery.kt
RETURN
PsiElement(return)('return')
PsiWhiteSpace('\n ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('loop2')
PsiWhiteSpace(' ')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(INTEGER_LITERAL)('4')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('loop2')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('4')
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
WHILE
@@ -230,8 +233,8 @@ JetFile: recovery.kt
OPERATION_REFERENCE
PsiElement(IDENTIFIER)('l3')
PsiWhiteSpace(' ')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
PsiErrorElement:Expected annotation identifier after '@'
PsiElement(AT)('@')
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
@@ -143,14 +143,17 @@ JetFile: spaceBeforeLabelReference.kt
PsiElement(return)('return')
PsiComment(EOL_COMMENT)('//')
PsiWhiteSpace('\n')
LABELED_EXPRESSION
PsiErrorElement:Label must be named
ANNOTATED_EXPRESSION
ANNOTATION_ENTRY
PsiElement(AT)('@')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('l7')
PsiWhiteSpace(' ')
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(INTEGER_LITERAL)('4')
CONSTRUCTOR_CALLEE
TYPE_REFERENCE
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('l7')
PsiWhiteSpace(' ')
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('4')
PsiWhiteSpace('\n\n ')
PROPERTY
PsiElement(val)('val')
@@ -663,6 +663,69 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName);
}
@TestMetadata("compiler/testData/psi/annotation/at")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class At extends AbstractJetParsingTest {
public void testAllFilesPresentInAt() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/at"), Pattern.compile("^(.*)\\.kts?$"), true);
}
@TestMetadata("annotationAtFileStart.kt")
public void testAnnotationAtFileStart() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/annotationAtFileStart.kt");
doParsingTest(fileName);
}
@TestMetadata("annotationValueArgumentsAmbiguity.kt")
public void testAnnotationValueArgumentsAmbiguity() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/annotationValueArgumentsAmbiguity.kt");
doParsingTest(fileName);
}
@TestMetadata("declarationsJustAtTyped.kt")
public void testDeclarationsJustAtTyped() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/declarationsJustAtTyped.kt");
doParsingTest(fileName);
}
@TestMetadata("expressionJustAtTyped.kt")
public void testExpressionJustAtTyped() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/expressionJustAtTyped.kt");
doParsingTest(fileName);
}
@TestMetadata("invalidExpressions.kt")
public void testInvalidExpressions() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/invalidExpressions.kt");
doParsingTest(fileName);
}
@TestMetadata("modifierAtFileStart.kt")
public void testModifierAtFileStart() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/modifierAtFileStart.kt");
doParsingTest(fileName);
}
@TestMetadata("primaryConstructor.kt")
public void testPrimaryConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/primaryConstructor.kt");
doParsingTest(fileName);
}
@TestMetadata("validDeclarations.kt")
public void testValidDeclarations() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/validDeclarations.kt");
doParsingTest(fileName);
}
@TestMetadata("validExpressions.kt")
public void testValidExpressions() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/at/validExpressions.kt");
doParsingTest(fileName);
}
}
@TestMetadata("compiler/testData/psi/annotation/onFile")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
+1 -1
View File
@@ -12,5 +12,5 @@ annotation
;
annotationEntry
: SimpleName{"."} typeArguments? valueArguments?
: "@"? SimpleName{"."} typeArguments? valueArguments?
;
+1 -1
View File
@@ -3,7 +3,7 @@
*/
modifiers
: modifier*
: ("@"? modifier)*
;
modifier