Comments binding (not complete yet)
This commit is contained in:
@@ -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'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.lang.WhitespacesAndCommentsBinder int getEdgePosition(java.util.List<com.intellij.psi.tree.IElementType>, boolean, com.intellij.lang.WhitespacesAndCommentsBinder.TokenTextGetter) 0'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
<annotation name='org.jetbrains.annotations.ReadOnly'/>
|
||||
</item>
|
||||
<item
|
||||
name='com.intellij.lang.WhitespacesAndCommentsBinder int getEdgePosition(java.util.List<com.intellij.psi.tree.IElementType>, boolean, com.intellij.lang.WhitespacesAndCommentsBinder.TokenTextGetter) 2'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='com.intellij.lang.WhitespacesAndCommentsBinder.TokenTextGetter java.lang.CharSequence get(int)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -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<IElementType>, 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<IElementType>, 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
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting '('
|
||||
<empty list>
|
||||
PsiErrorElement:Expecting ')'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(EOL_COMMENT)('// prop2')
|
||||
@@ -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(' ')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<in T> = {(a : T, b : T) => Int}')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiComment(EOL_COMMENT)('//type Comparison<in T> = {(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<in T> = {(a : T, b : T) => Boolean}')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiComment(EOL_COMMENT)('//type Equality<in T> = {(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<in T> = {(obj : T) => Int}')
|
||||
PsiWhiteSpace('\n')
|
||||
TYPEDEF
|
||||
PsiComment(EOL_COMMENT)('//type HashFunction<in T> = {(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')
|
||||
|
||||
@@ -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<Edge<V, E>> = ArrayList<Edge<V, E>>()\n private val edges : IMutableList<Edge<V, E>> = 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<Vertex<V>>')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(EOL_COMMENT)('// type is IIterable<Vertex<V>>')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
<empty list>
|
||||
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')
|
||||
|
||||
@@ -7,8 +7,8 @@ JetFile: PackageRecovery.kt
|
||||
PsiElement(DOT)('.')
|
||||
PsiErrorElement:Package name must be a '.'-separated identifier list placed on a single line
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(EOL_COMMENT)('// Hello')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(EOL_COMMENT)('// Hello')
|
||||
PsiWhiteSpace('\n\n')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user