Use left bound element types to tight empty delegation contructor call to declaration

CONSTRUCTOR_DELEGATION_CALL and CONSTRUCTOR_DELEGATION_REFERENCE types were modified.
This commit is contained in:
Nikolay Krasko
2016-05-11 19:41:02 +03:00
committed by Nikolay Krasko
parent 1a1c10251a
commit 52cd7109c7
14 changed files with 44 additions and 38 deletions
@@ -27,11 +27,7 @@ import org.jetbrains.kotlin.psi.KtElementImpl;
import java.lang.reflect.Constructor;
public class KtNodeType extends IElementType {
private Constructor<? extends KtElement> myPsiFactory;
public KtNodeType(@NotNull @NonNls String debugName) {
this(debugName, null);
}
private final Constructor<? extends KtElement> myPsiFactory;
public KtNodeType(@NotNull @NonNls String debugName, Class<? extends KtElement> psiClass) {
super(debugName, KotlinLanguage.INSTANCE);
@@ -54,4 +50,15 @@ public class KtNodeType extends IElementType {
throw new RuntimeException("Error creating psi element for node", e);
}
}
public static class KtLeftBoundNodeType extends KtNodeType {
public KtLeftBoundNodeType(@NotNull @NonNls String debugName, Class<? extends KtElement> psiClass) {
super(debugName, psiClass);
}
@Override
public boolean isLeftBound() {
return true;
}
}
}
@@ -81,9 +81,8 @@ public interface KtNodeTypes {
IElementType TYPE_CONSTRAINT_LIST = KtStubElementTypes.TYPE_CONSTRAINT_LIST;
IElementType TYPE_CONSTRAINT = KtStubElementTypes.TYPE_CONSTRAINT;
IElementType CONSTRUCTOR_DELEGATION_CALL = new KtNodeType("CONSTRUCTOR_DELEGATION_CALL", KtConstructorDelegationCall.class);
KtNodeType CONSTRUCTOR_DELEGATION_REFERENCE =
new KtNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", KtConstructorDelegationReferenceExpression.class);
IElementType CONSTRUCTOR_DELEGATION_CALL = new KtNodeType.KtLeftBoundNodeType("CONSTRUCTOR_DELEGATION_CALL", KtConstructorDelegationCall.class);
KtNodeType CONSTRUCTOR_DELEGATION_REFERENCE = new KtNodeType.KtLeftBoundNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", KtConstructorDelegationReferenceExpression.class);
// TODO: Not sure if we need separate NT for each kind of constants
KtNodeType NULL = new KtNodeType("NULL", KtConstantExpression.class);
+1 -1
View File
@@ -512,10 +512,10 @@ JetFile: validDeclarations.kt
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n\n ')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
+1 -1
View File
@@ -175,10 +175,10 @@ JetFile: BinaryTree.kt
PsiElement(IDENTIFIER)('T')
PsiElement(GT)('>')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
@@ -65,10 +65,10 @@ JetFile: nestedClassAmbiguity.kt
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
@@ -25,13 +25,13 @@ JetFile: firstInSecondaryConstructor.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
@@ -35,10 +35,10 @@ JetFile: secondInSecondaryConstructor.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
+2 -2
View File
@@ -16,10 +16,10 @@ JetFile: basic.kt
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -59,10 +59,10 @@ JetFile: basic.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
+2 -2
View File
@@ -16,10 +16,10 @@ JetFile: emptyBody.kt
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
@@ -41,10 +41,10 @@ JetFile: emptyBody.kt
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -85,10 +85,10 @@ JetFile: enumParsing.kt
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('Int')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -15,10 +15,10 @@ JetFile: recoveryJustConstructorKeyword.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -34,19 +34,19 @@ JetFile: recoveryJustConstructorKeyword.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
SECONDARY_CONSTRUCTOR
PsiElement(constructor)('constructor')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -55,10 +55,10 @@ JetFile: recoveryJustConstructorKeyword.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -75,13 +75,13 @@ JetFile: recoveryJustConstructorKeyword.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace('\n')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('B')
PsiElement(IDENTIFIER)('B')
@@ -15,10 +15,10 @@ JetFile: recoveryJustConstructorKeywordSameLineBrace.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -34,19 +34,19 @@ JetFile: recoveryJustConstructorKeywordSameLineBrace.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n ')
SECONDARY_CONSTRUCTOR
PsiElement(constructor)('constructor')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -55,10 +55,10 @@ JetFile: recoveryJustConstructorKeywordSameLineBrace.kt
PsiElement(constructor)('constructor')
PsiErrorElement:Expecting '('
<empty list>
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -17,10 +17,10 @@ JetFile: recoveryNoDelegationCallAfterColon.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace('\n ')
PROPERTY
PsiElement(val)('val')
PsiWhiteSpace(' ')
@@ -37,29 +37,29 @@ JetFile: recoveryNoDelegationCallAfterColon.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace('\n ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace('\n ')
SECONDARY_CONSTRUCTOR
PsiElement(constructor)('constructor')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR_DELEGATION_CALL
CONSTRUCTOR_DELEGATION_REFERENCE
<empty list>
PsiWhiteSpace('\n\n ')
SECONDARY_CONSTRUCTOR
PsiElement(constructor)('constructor')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiElement(RBRACE)('}')
@@ -78,10 +78,10 @@ JetFile: recoveryNoDelegationCallAfterColon.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace('\n')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
@@ -17,10 +17,10 @@ JetFile: recoveryWithoutBodyWrongDelegationName.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Expecting member declaration
PsiElement(IDENTIFIER)('thi')
PsiErrorElement:Expecting member declaration
@@ -45,10 +45,10 @@ JetFile: recoveryWithoutBodyWrongDelegationName.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace('\n\n ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace('\n\n ')
FUN
MODIFIER_LIST
ANNOTATION_ENTRY
@@ -72,10 +72,10 @@ JetFile: recoveryWithoutBodyWrongDelegationName.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Expecting member declaration
PsiElement(IDENTIFIER)('sup')
PsiWhiteSpace('\n\n ')
@@ -85,10 +85,10 @@ JetFile: recoveryWithoutBodyWrongDelegationName.kt
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COLON)(':')
PsiWhiteSpace(' ')
CONSTRUCTOR_DELEGATION_CALL
PsiErrorElement:Expecting a 'this' or 'super' constructor call
<empty list>
PsiWhiteSpace(' ')
PsiErrorElement:Expecting member declaration
PsiElement(IDENTIFIER)('thi')
PsiErrorElement:Expecting member declaration