diff --git a/annotations/com/intellij/lang/annotations.xml b/annotations/com/intellij/lang/annotations.xml
index 4f2bde8c2f6..79a5a30eb8a 100644
--- a/annotations/com/intellij/lang/annotations.xml
+++ b/annotations/com/intellij/lang/annotations.xml
@@ -9,4 +9,16 @@
name='com.intellij.lang.SmartEnterProcessorWithFixers.FixEnterProcessor boolean doEnter(com.intellij.psi.PsiElement, com.intellij.psi.PsiFile, com.intellij.openapi.editor.Editor, boolean) 0'>
+ -
+
+
+
+ -
+
+
+ -
+
+
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/CommentBinders.kt b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/CommentBinders.kt
new file mode 100644
index 00000000000..ab2c0f8e132
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/CommentBinders.kt
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.lang.parsing
+
+import com.intellij.lang.WhitespacesAndCommentsBinder
+import com.intellij.psi.tree.IElementType
+import org.jetbrains.jet.lexer.JetTokens
+import com.intellij.openapi.util.text.StringUtil
+
+object PrecedingWhitespacesAndCommentsBinder : WhitespacesAndCommentsBinder {
+
+ override fun getEdgePosition(tokens: List, atStreamEdge: Boolean, getter: WhitespacesAndCommentsBinder.TokenTextGetter): Int {
+ if (tokens.size() == 0) return 0
+
+ // 1. bind doc comment
+ for (idx in tokens.indices.reversed()) {
+ if (tokens.get(idx) == JetTokens.DOC_COMMENT) return idx
+ }
+
+ // 2. bind plain comments
+ var result = tokens.size()
+ for (idx in tokens.indices.reversed()) {
+ val tokenType = tokens[idx]
+ if (tokenType == JetTokens.WHITE_SPACE) {
+ if (StringUtil.getLineBreakCount(getter[idx]) > 1) break
+ }
+ else if (tokenType in JetTokens.COMMENTS && tokenType != JetTokens.DOC_COMMENT) {
+ if (atStreamEdge ||
+ idx > 0 && tokens[idx - 1] == JetTokens.WHITE_SPACE && StringUtil.containsLineBreak(getter[idx - 1])) {
+ result = idx
+ }
+ }
+ else {
+ break
+ }
+ }
+
+ return result
+ }
+}
+
+// Binds comments on the same line
+object TrailingWhitespacesAndCommentsBinder : WhitespacesAndCommentsBinder {
+
+ override fun getEdgePosition(tokens: List, atStreamEdge: Boolean, getter: WhitespacesAndCommentsBinder.TokenTextGetter): Int {
+ if (tokens.isEmpty()) return 0
+
+ var result = 0
+ for (idx in tokens.indices) {
+ val tokenType = tokens.get(idx)
+ if (tokenType == JetTokens.WHITE_SPACE) {
+ if (StringUtil.containsLineBreak(getter.get(idx))) break
+ }
+ else if (tokenType in JetTokens.COMMENTS) {
+ result = idx + 1
+ }
+ else {
+ break
+ }
+ }
+
+ return result
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
index f71d9aae075..e5559e9e998 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java
@@ -959,6 +959,8 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (declType != null) {
decl.done(declType);
+ decl.setCustomEdgeTokenBinders(null/* for local declaration we do not take preceding comments*/,
+ TrailingWhitespacesAndCommentsBinder.INSTANCE$);
return true;
}
else {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java
index 73a236ad3c4..36db3998ac0 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java
@@ -209,6 +209,7 @@ public class JetParsing extends AbstractJetParsing {
packageDirective = mark();
}
packageDirective.done(PACKAGE_DIRECTIVE);
+ packageDirective.setCustomEdgeTokenBinders(null, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
parseImportDirectives();
}
@@ -314,6 +315,7 @@ public class JetParsing extends AbstractJetParsing {
}
consumeIf(SEMICOLON);
importDirective.done(IMPORT_DIRECTIVE);
+ importDirective.setCustomEdgeTokenBinders(null, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
}
private boolean closeImportWithErrorIfNewline(PsiBuilder.Marker importDirective, String errorMessage) {
@@ -381,6 +383,7 @@ public class JetParsing extends AbstractJetParsing {
}
else {
decl.done(declType);
+ decl.setCustomEdgeTokenBinders(PrecedingWhitespacesAndCommentsBinder.INSTANCE$, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
}
}
@@ -681,6 +684,8 @@ public class JetParsing extends AbstractJetParsing {
}
else {
entryOrMember.done(type);
+ entryOrMember.setCustomEdgeTokenBinders(PrecedingWhitespacesAndCommentsBinder.INSTANCE$,
+ TrailingWhitespacesAndCommentsBinder.INSTANCE$);
}
}
@@ -701,6 +706,8 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker nameAsDeclaration = mark();
advance(); // IDENTIFIER
nameAsDeclaration.done(OBJECT_DECLARATION_NAME);
+ nameAsDeclaration.setCustomEdgeTokenBinders(PrecedingWhitespacesAndCommentsBinder.INSTANCE$,
+ TrailingWhitespacesAndCommentsBinder.INSTANCE$);
if (at(COLON)) {
advance(); // COLON
@@ -771,6 +778,7 @@ public class JetParsing extends AbstractJetParsing {
}
else {
decl.done(declType);
+ decl.setCustomEdgeTokenBinders(PrecedingWhitespacesAndCommentsBinder.INSTANCE$, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
}
}
@@ -869,6 +877,8 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker objectDeclaration = mark();
parseObject(false, true);
objectDeclaration.done(OBJECT_DECLARATION);
+ objectDeclaration.setCustomEdgeTokenBinders(PrecedingWhitespacesAndCommentsBinder.INSTANCE$,
+ TrailingWhitespacesAndCommentsBinder.INSTANCE$);
return CLASS_OBJECT;
}
@@ -1888,6 +1898,7 @@ public class JetParsing extends AbstractJetParsing {
parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); // lazy, out, ref
parseTypeRef();
valueParameter.done(VALUE_PARAMETER);
+ valueParameter.setCustomEdgeTokenBinders(null, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
}
}
else {
@@ -1938,6 +1949,7 @@ public class JetParsing extends AbstractJetParsing {
}
parameter.done(VALUE_PARAMETER);
+ parameter.setCustomEdgeTokenBinders(null, TrailingWhitespacesAndCommentsBinder.INSTANCE$);
return true;
}
diff --git a/compiler/testData/psi/CommentsBinding.kt b/compiler/testData/psi/CommentsBinding.kt
new file mode 100644
index 00000000000..41636e10c88
--- /dev/null
+++ b/compiler/testData/psi/CommentsBinding.kt
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2010-2014 JetBrains s.r.o.
+ */
+package foo.bar // package directive
+
+import java.util.* // we need classes from java.util
+import javax.* // and from here too
+
+// other imports
+import a.b
+import c.d
+
+/**
+ * Doc comment for A
+ */
+class A {}
+// after class A
+
+// comment for B 1
+// comment for B 2
+class B {} // end of class B
+
+/* Simple comment */
+class C // no body
+
+class D {
+ // This is v1
+ val v1 = 1 // use 1
+ /** v2 doc comment */
+ val v2 = 2
+
+ // Function foo()
+ fun foo(/* parameters */ p1: Int/* p1 */, p2: Int /* p2 */) {
+ } // end of foo
+
+ // class object
+ class object {
+ } // end of class object
+}
+
+// This is v
+val v = 1 // one
+
+// This is fun
+public fun foo() {
+ val local = 1 // this is local
+ // declare another local
+ val local2 = 2
+} // end
+
+enum class E {
+ A // this is A
+ /** This is B */ B
+ /* And this is C */ C
+ /** This is X */
+ X {
+ override fun toString() = "X"
+ } // end of X
+}
+
+var prop: Int // Int
+ get() = 1 // this is getter
+ set(value) {} // this is setter
+
+val prop2: Int get = 1 // prop2
diff --git a/compiler/testData/psi/CommentsBinding.txt b/compiler/testData/psi/CommentsBinding.txt
new file mode 100644
index 00000000000..19fad077896
--- /dev/null
+++ b/compiler/testData/psi/CommentsBinding.txt
@@ -0,0 +1,391 @@
+JetFile: CommentsBinding.kt
+ PsiComment(BLOCK_COMMENT)('/*\n * Copyright 2010-2014 JetBrains s.r.o.\n */')
+ PsiWhiteSpace('\n')
+ PACKAGE_DIRECTIVE
+ PsiElement(package)('package')
+ PsiWhiteSpace(' ')
+ DOT_QUALIFIED_EXPRESSION
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('foo')
+ PsiElement(DOT)('.')
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('bar')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// package directive')
+ PsiWhiteSpace('\n\n')
+ IMPORT_LIST
+ IMPORT_DIRECTIVE
+ PsiElement(import)('import')
+ PsiWhiteSpace(' ')
+ DOT_QUALIFIED_EXPRESSION
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('java')
+ PsiElement(DOT)('.')
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('util')
+ PsiElement(DOT)('.')
+ PsiElement(MUL)('*')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// we need classes from java.util')
+ PsiWhiteSpace('\n')
+ IMPORT_DIRECTIVE
+ PsiElement(import)('import')
+ PsiWhiteSpace(' ')
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('javax')
+ PsiElement(DOT)('.')
+ PsiElement(MUL)('*')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// and from here too')
+ PsiWhiteSpace('\n\n')
+ PsiComment(EOL_COMMENT)('// other imports')
+ PsiWhiteSpace('\n')
+ IMPORT_DIRECTIVE
+ PsiElement(import)('import')
+ PsiWhiteSpace(' ')
+ DOT_QUALIFIED_EXPRESSION
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('a')
+ PsiElement(DOT)('.')
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('b')
+ PsiWhiteSpace('\n')
+ IMPORT_DIRECTIVE
+ PsiElement(import)('import')
+ PsiWhiteSpace(' ')
+ DOT_QUALIFIED_EXPRESSION
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('c')
+ PsiElement(DOT)('.')
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('d')
+ PsiWhiteSpace('\n\n')
+ CLASS
+ KDoc
+ PsiElement(KDOC_START)('/**')
+ PsiWhiteSpace('\n ')
+ PsiElement(KDOC_LEADING_ASTERISK)('*')
+ PsiElement(KDOC_TEXT)(' Doc comment for A')
+ PsiWhiteSpace('\n ')
+ PsiElement(KDOC_END)('*/')
+ PsiWhiteSpace('\n')
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('A')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace('\n')
+ PsiComment(EOL_COMMENT)('// after class A')
+ PsiWhiteSpace('\n\n')
+ CLASS
+ PsiComment(EOL_COMMENT)('// comment for B 1')
+ PsiWhiteSpace('\n')
+ PsiComment(EOL_COMMENT)('// comment for B 2')
+ PsiWhiteSpace('\n')
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('B')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// end of class B')
+ PsiWhiteSpace('\n\n')
+ CLASS
+ PsiComment(BLOCK_COMMENT)('/* Simple comment */')
+ PsiWhiteSpace('\n')
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('C')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// no body')
+ PsiWhiteSpace('\n\n')
+ CLASS
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('D')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ PROPERTY
+ PsiComment(EOL_COMMENT)('// This is v1')
+ PsiWhiteSpace('\n ')
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('v1')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('1')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// use 1')
+ PsiWhiteSpace('\n ')
+ PROPERTY
+ KDoc
+ PsiElement(KDOC_START)('/**')
+ PsiElement(KDOC_TEXT)(' v2 doc comment ')
+ PsiElement(KDOC_END)('*/')
+ PsiWhiteSpace('\n ')
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('v2')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('2')
+ PsiWhiteSpace('\n\n ')
+ FUN
+ PsiComment(EOL_COMMENT)('// Function foo()')
+ PsiWhiteSpace('\n ')
+ PsiElement(fun)('fun')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('foo')
+ VALUE_PARAMETER_LIST
+ PsiElement(LPAR)('(')
+ PsiComment(BLOCK_COMMENT)('/* parameters */')
+ PsiWhiteSpace(' ')
+ VALUE_PARAMETER
+ PsiElement(IDENTIFIER)('p1')
+ PsiElement(COLON)(':')
+ PsiWhiteSpace(' ')
+ TYPE_REFERENCE
+ USER_TYPE
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('Int')
+ PsiComment(BLOCK_COMMENT)('/* p1 */')
+ PsiElement(COMMA)(',')
+ PsiWhiteSpace(' ')
+ VALUE_PARAMETER
+ PsiElement(IDENTIFIER)('p2')
+ PsiElement(COLON)(':')
+ PsiWhiteSpace(' ')
+ TYPE_REFERENCE
+ USER_TYPE
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('Int')
+ PsiWhiteSpace(' ')
+ PsiComment(BLOCK_COMMENT)('/* p2 */')
+ PsiElement(RPAR)(')')
+ PsiWhiteSpace(' ')
+ BLOCK
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// end of foo')
+ PsiWhiteSpace('\n\n ')
+ CLASS_OBJECT
+ PsiComment(EOL_COMMENT)('// class object')
+ PsiWhiteSpace('\n ')
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ OBJECT_DECLARATION
+ PsiElement(object)('object')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// end of class object')
+ PsiWhiteSpace('\n')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace('\n\n')
+ PROPERTY
+ PsiComment(EOL_COMMENT)('// This is v')
+ PsiWhiteSpace('\n')
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('v')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('1')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// one')
+ PsiWhiteSpace('\n\n')
+ FUN
+ PsiComment(EOL_COMMENT)('// This is fun')
+ PsiWhiteSpace('\n')
+ MODIFIER_LIST
+ PsiElement(public)('public')
+ PsiWhiteSpace(' ')
+ PsiElement(fun)('fun')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('foo')
+ VALUE_PARAMETER_LIST
+ PsiElement(LPAR)('(')
+ PsiElement(RPAR)(')')
+ PsiWhiteSpace(' ')
+ BLOCK
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ PROPERTY
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('local')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('1')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// this is local')
+ PsiWhiteSpace('\n ')
+ PsiComment(EOL_COMMENT)('// declare another local')
+ PsiWhiteSpace('\n ')
+ PROPERTY
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('local2')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('2')
+ PsiWhiteSpace('\n')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// end')
+ PsiWhiteSpace('\n\n')
+ CLASS
+ MODIFIER_LIST
+ PsiElement(enum)('enum')
+ PsiWhiteSpace(' ')
+ PsiElement(class)('class')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('E')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ ENUM_ENTRY
+ OBJECT_DECLARATION_NAME
+ PsiElement(IDENTIFIER)('A')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// this is A')
+ PsiWhiteSpace('\n ')
+ ENUM_ENTRY
+ OBJECT_DECLARATION_NAME
+ KDoc
+ PsiElement(KDOC_START)('/**')
+ PsiElement(KDOC_TEXT)(' This is B ')
+ PsiElement(KDOC_END)('*/')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('B')
+ PsiWhiteSpace('\n ')
+ ENUM_ENTRY
+ PsiComment(BLOCK_COMMENT)('/* And this is C */')
+ PsiWhiteSpace(' ')
+ OBJECT_DECLARATION_NAME
+ PsiElement(IDENTIFIER)('C')
+ PsiWhiteSpace('\n ')
+ ENUM_ENTRY
+ OBJECT_DECLARATION_NAME
+ KDoc
+ PsiElement(KDOC_START)('/**')
+ PsiElement(KDOC_TEXT)(' This is X ')
+ PsiElement(KDOC_END)('*/')
+ PsiWhiteSpace('\n ')
+ PsiElement(IDENTIFIER)('X')
+ PsiWhiteSpace(' ')
+ CLASS_BODY
+ PsiElement(LBRACE)('{')
+ PsiWhiteSpace('\n ')
+ FUN
+ MODIFIER_LIST
+ PsiElement(override)('override')
+ PsiWhiteSpace(' ')
+ PsiElement(fun)('fun')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('toString')
+ VALUE_PARAMETER_LIST
+ PsiElement(LPAR)('(')
+ PsiElement(RPAR)(')')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ STRING_TEMPLATE
+ PsiElement(OPEN_QUOTE)('"')
+ LITERAL_STRING_TEMPLATE_ENTRY
+ PsiElement(REGULAR_STRING_PART)('X')
+ PsiElement(CLOSING_QUOTE)('"')
+ PsiWhiteSpace('\n ')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// end of X')
+ PsiWhiteSpace('\n')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace('\n\n')
+ PROPERTY
+ PsiElement(var)('var')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('prop')
+ PsiElement(COLON)(':')
+ PsiWhiteSpace(' ')
+ TYPE_REFERENCE
+ USER_TYPE
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('Int')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// Int')
+ PsiWhiteSpace('\n ')
+ PROPERTY_ACCESSOR
+ PsiElement(get)('get')
+ PsiElement(LPAR)('(')
+ PsiElement(RPAR)(')')
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('1')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// this is getter')
+ PsiWhiteSpace('\n ')
+ PROPERTY_ACCESSOR
+ PsiElement(set)('set')
+ PsiElement(LPAR)('(')
+ VALUE_PARAMETER_LIST
+ VALUE_PARAMETER
+ PsiElement(IDENTIFIER)('value')
+ PsiElement(RPAR)(')')
+ PsiWhiteSpace(' ')
+ BLOCK
+ PsiElement(LBRACE)('{')
+ PsiElement(RBRACE)('}')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// this is setter')
+ PsiWhiteSpace('\n\n')
+ PROPERTY
+ PsiElement(val)('val')
+ PsiWhiteSpace(' ')
+ PsiElement(IDENTIFIER)('prop2')
+ PsiElement(COLON)(':')
+ PsiWhiteSpace(' ')
+ TYPE_REFERENCE
+ USER_TYPE
+ REFERENCE_EXPRESSION
+ PsiElement(IDENTIFIER)('Int')
+ PsiWhiteSpace(' ')
+ PROPERTY_ACCESSOR
+ PsiElement(get)('get')
+ PsiErrorElement:Accessor body expected
+
+ PsiErrorElement:Expecting '('
+
+ PsiErrorElement:Expecting ')'
+
+ PsiWhiteSpace(' ')
+ PsiElement(EQ)('=')
+ PsiWhiteSpace(' ')
+ INTEGER_CONSTANT
+ PsiElement(INTEGER_LITERAL)('1')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// prop2')
\ No newline at end of file
diff --git a/compiler/testData/psi/examples/BinaryTree.txt b/compiler/testData/psi/examples/BinaryTree.txt
index 0d54d6a022f..4257ceb13ae 100644
--- a/compiler/testData/psi/examples/BinaryTree.txt
+++ b/compiler/testData/psi/examples/BinaryTree.txt
@@ -1596,9 +1596,9 @@ JetFile: BinaryTree.kt
PsiWhiteSpace('\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
- PsiComment(EOL_COMMENT)('// Relies on tail-recursion optimization')
- PsiWhiteSpace('\n ')
FUN
+ PsiComment(EOL_COMMENT)('// Relies on tail-recursion optimization')
+ PsiWhiteSpace('\n ')
MODIFIER_LIST
PsiElement(private)('private')
PsiWhiteSpace(' ')
diff --git a/compiler/testData/psi/examples/Builder.txt b/compiler/testData/psi/examples/Builder.txt
index b90e6d5b8d4..2d2024e5081 100644
--- a/compiler/testData/psi/examples/Builder.txt
+++ b/compiler/testData/psi/examples/Builder.txt
@@ -291,7 +291,7 @@ JetFile: Builder.kt
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ClassPathEntry')
- PsiComment(BLOCK_COMMENT)('/*...*/')
+ PsiComment(BLOCK_COMMENT)('/*...*/')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
@@ -371,7 +371,7 @@ JetFile: Builder.kt
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('ClassPathEntry')
- PsiComment(BLOCK_COMMENT)('/*...*/')
+ PsiComment(BLOCK_COMMENT)('/*...*/')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
diff --git a/compiler/testData/psi/examples/FunctionsAndTypes.txt b/compiler/testData/psi/examples/FunctionsAndTypes.txt
index 7eb63b4348e..e64a22a9a50 100644
--- a/compiler/testData/psi/examples/FunctionsAndTypes.txt
+++ b/compiler/testData/psi/examples/FunctionsAndTypes.txt
@@ -26,9 +26,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('X')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('// type f1 = {(T) => X}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('// type f1 = {(T) => X}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f2')
@@ -60,9 +60,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('X')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('// type f2 = {(T, E) => X}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('// type f2 = {(T, E) => X}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f_tuple')
@@ -102,9 +102,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('X')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type f_tuple = {((T, E)) => X}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type f_tuple = {((T, E)) => X}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('hof')
@@ -142,9 +142,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Y')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type hof = { (X) => {(T) => Y} }')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type hof = { (X) => {(T) => Y} }')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('hof2')
@@ -246,9 +246,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type Comparison = {(a : T, b : T) => Int}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type Comparison = {(a : T, b : T) => Int}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Equality')
@@ -296,9 +296,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Boolean')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type Equality = {(a : T, b : T) => Boolean}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type Equality = {(a : T, b : T) => Boolean}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('HashFunction')
@@ -335,9 +335,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type HashFunction = {(obj : T) => Int}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type HashFunction = {(obj : T) => Int}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Runnable')
@@ -357,9 +357,9 @@ JetFile: FunctionsAndTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Unit')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//type Runnable = {() => ()}')
- PsiWhiteSpace('\n')
TYPEDEF
+ PsiComment(EOL_COMMENT)('//type Runnable = {() => ()}')
+ PsiWhiteSpace('\n')
PsiElement(typealias)('typealias')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('Function1')
diff --git a/compiler/testData/psi/examples/Graph.txt b/compiler/testData/psi/examples/Graph.txt
index 0cd91cb80b2..018a70821da 100644
--- a/compiler/testData/psi/examples/Graph.txt
+++ b/compiler/testData/psi/examples/Graph.txt
@@ -135,8 +135,8 @@ JetFile: Graph.kt
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('// type is ArrayList, but I want IMutableList')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// type is ArrayList, but I want IMutableList')
PsiWhiteSpace('\n')
PsiComment(BLOCK_COMMENT)('/* options:\n private val edges : IMutableList> = ArrayList>()\n private val edges : IMutableList> = ArrayList() // not an erasure, but a request to infer parameters\n*/')
PsiWhiteSpace('\n\n ')
@@ -457,8 +457,8 @@ JetFile: Graph.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('to')
PsiElement(RBRACE)('}')
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('// type is IIterable>')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// type is IIterable>')
PsiWhiteSpace('\n\n ')
FUN
PsiElement(fun)('fun')
diff --git a/compiler/testData/psi/examples/UpdateOperation.txt b/compiler/testData/psi/examples/UpdateOperation.txt
index 8423ddc9825..23744373ef8 100644
--- a/compiler/testData/psi/examples/UpdateOperation.txt
+++ b/compiler/testData/psi/examples/UpdateOperation.txt
@@ -119,9 +119,9 @@ JetFile: UpdateOperation.kt
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
- PsiComment(EOL_COMMENT)('// One can say:')
- PsiWhiteSpace('\n')
PROPERTY
+ PsiComment(EOL_COMMENT)('// One can say:')
+ PsiWhiteSpace('\n')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('p')
diff --git a/compiler/testData/psi/examples/io/IOSamples.txt b/compiler/testData/psi/examples/io/IOSamples.txt
index c7a8b006008..26ebeec9599 100644
--- a/compiler/testData/psi/examples/io/IOSamples.txt
+++ b/compiler/testData/psi/examples/io/IOSamples.txt
@@ -555,8 +555,8 @@ JetFile: IOSamples.kt
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('File')
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('//= ...')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('//= ...')
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
@@ -569,8 +569,8 @@ JetFile: IOSamples.kt
USER_TYPE
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('File')
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('//= ...')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('//= ...')
PsiWhiteSpace('\n\n ')
CALL_EXPRESSION
REFERENCE_EXPRESSION
diff --git a/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceivers.txt b/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceivers.txt
index fcc090b7909..30113d3e82b 100644
--- a/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceivers.txt
+++ b/compiler/testData/psi/functionReceivers/FunctionsWithFunctionReceivers.txt
@@ -409,9 +409,9 @@ JetFile: FunctionsWithFunctionReceivers.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n')
- PsiComment(EOL_COMMENT)('//--------------')
- PsiWhiteSpace('\n')
FUN
+ PsiComment(EOL_COMMENT)('//--------------')
+ PsiWhiteSpace('\n')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('f')
diff --git a/compiler/testData/psi/greatSyntacticShift/FunctionTypesAsArguments.txt b/compiler/testData/psi/greatSyntacticShift/FunctionTypesAsArguments.txt
index 85e54bdfe42..9dca168f2fc 100644
--- a/compiler/testData/psi/greatSyntacticShift/FunctionTypesAsArguments.txt
+++ b/compiler/testData/psi/greatSyntacticShift/FunctionTypesAsArguments.txt
@@ -45,8 +45,8 @@ JetFile: FunctionTypesAsArguments.kt
VALUE_ARGUMENT_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('// multiple errors')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// multiple errors')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
diff --git a/compiler/testData/psi/greatSyntacticShift/functionTypes.txt b/compiler/testData/psi/greatSyntacticShift/functionTypes.txt
index 15c810be84b..15cfc794dca 100644
--- a/compiler/testData/psi/greatSyntacticShift/functionTypes.txt
+++ b/compiler/testData/psi/greatSyntacticShift/functionTypes.txt
@@ -788,11 +788,11 @@ JetFile: functionTypes.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('B')
PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//val a9 : (A, B)')
- PsiWhiteSpace('\n')
- PsiComment(EOL_COMMENT)('//val a10 : (B)? -> B')
- PsiWhiteSpace('\n ')
PROPERTY
+ PsiComment(EOL_COMMENT)('//val a9 : (A, B)')
+ PsiWhiteSpace('\n')
+ PsiComment(EOL_COMMENT)('//val a10 : (B)? -> B')
+ PsiWhiteSpace('\n ')
PsiElement(val)('val')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('a11')
diff --git a/compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.txt b/compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.txt
index 57068e7e5c4..56e68844d64 100644
--- a/compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.txt
+++ b/compiler/testData/psi/recovery/InvalidCharInSingleLineLambda.txt
@@ -1,9 +1,9 @@
JetFile: InvalidCharInSingleLineLambda.kt
- PsiComment(EOL_COMMENT)('// checks that invalid characters (inserted e.g. by completion) inside single-line block do not cause wrong scopes for declarations below')
- PsiWhiteSpace('\n')
PACKAGE_DIRECTIVE
FUN
+ PsiComment(EOL_COMMENT)('// checks that invalid characters (inserted e.g. by completion) inside single-line block do not cause wrong scopes for declarations below')
+ PsiWhiteSpace('\n')
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
diff --git a/compiler/testData/psi/recovery/PackageRecovery.txt b/compiler/testData/psi/recovery/PackageRecovery.txt
index 09f8b1341eb..604d60b39b0 100644
--- a/compiler/testData/psi/recovery/PackageRecovery.txt
+++ b/compiler/testData/psi/recovery/PackageRecovery.txt
@@ -7,8 +7,8 @@ JetFile: PackageRecovery.kt
PsiElement(DOT)('.')
PsiErrorElement:Package name must be a '.'-separated identifier list placed on a single line
- PsiWhiteSpace(' ')
- PsiComment(EOL_COMMENT)('// Hello')
+ PsiWhiteSpace(' ')
+ PsiComment(EOL_COMMENT)('// Hello')
PsiWhiteSpace('\n\n')
PROPERTY
PsiElement(val)('val')
diff --git a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java
index 74e3f6fba68..190000231a6 100644
--- a/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java
+++ b/compiler/tests/org/jetbrains/jet/parsing/JetParsingTestGenerated.java
@@ -118,6 +118,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
doParsingTest(fileName);
}
+ @TestMetadata("CommentsBinding.kt")
+ public void testCommentsBinding() throws Exception {
+ String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/CommentsBinding.kt");
+ doParsingTest(fileName);
+ }
+
@TestMetadata("Constructors.kt")
public void testConstructors() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Constructors.kt");