Hide concrete classes for Kotlin nodes to avoid more compatibility problems

This commit is contained in:
Nikolay Krasko
2019-03-11 19:06:25 +03:00
committed by Nikolay Krasko
parent 8ab10ebda3
commit 046a35bcda
3 changed files with 65 additions and 66 deletions
@@ -34,20 +34,20 @@ public interface KtNodeTypes {
IElementType OBJECT_DECLARATION = KtStubElementTypes.OBJECT_DECLARATION;
IElementType TYPEALIAS = KtStubElementTypes.TYPEALIAS;
IElementType ENUM_ENTRY = KtStubElementTypes.ENUM_ENTRY;
IElementType CLASS_INITIALIZER = KtStubElementTypes.CLASS_INITIALIZER;
IElementType SCRIPT_INITIALIZER = new KtNodeType("SCRIPT_INITIALIZER", KtScriptInitializer.class);
IElementType ENUM_ENTRY = KtStubElementTypes.ENUM_ENTRY;
IElementType CLASS_INITIALIZER = KtStubElementTypes.CLASS_INITIALIZER;
IElementType SCRIPT_INITIALIZER = new KtNodeType("SCRIPT_INITIALIZER", KtScriptInitializer.class);
IElementType SECONDARY_CONSTRUCTOR = KtStubElementTypes.SECONDARY_CONSTRUCTOR;
IElementType PRIMARY_CONSTRUCTOR = KtStubElementTypes.PRIMARY_CONSTRUCTOR;
IElementType TYPE_PARAMETER_LIST = KtStubElementTypes.TYPE_PARAMETER_LIST;
IElementType TYPE_PARAMETER = KtStubElementTypes.TYPE_PARAMETER;
IElementType SUPER_TYPE_LIST = KtStubElementTypes.SUPER_TYPE_LIST;
IElementType DELEGATED_SUPER_TYPE_ENTRY = KtStubElementTypes.DELEGATED_SUPER_TYPE_ENTRY;
IElementType SUPER_TYPE_CALL_ENTRY = KtStubElementTypes.SUPER_TYPE_CALL_ENTRY;
IElementType SUPER_TYPE_ENTRY = KtStubElementTypes.SUPER_TYPE_ENTRY;
KtNodeType PROPERTY_DELEGATE = new KtNodeType("PROPERTY_DELEGATE", KtPropertyDelegate.class);
IElementType CONSTRUCTOR_CALLEE = KtStubElementTypes.CONSTRUCTOR_CALLEE;
IElementType TYPE_PARAMETER_LIST = KtStubElementTypes.TYPE_PARAMETER_LIST;
IElementType TYPE_PARAMETER = KtStubElementTypes.TYPE_PARAMETER;
IElementType SUPER_TYPE_LIST = KtStubElementTypes.SUPER_TYPE_LIST;
IElementType DELEGATED_SUPER_TYPE_ENTRY = KtStubElementTypes.DELEGATED_SUPER_TYPE_ENTRY;
IElementType SUPER_TYPE_CALL_ENTRY = KtStubElementTypes.SUPER_TYPE_CALL_ENTRY;
IElementType SUPER_TYPE_ENTRY = KtStubElementTypes.SUPER_TYPE_ENTRY;
IElementType PROPERTY_DELEGATE = new KtNodeType("PROPERTY_DELEGATE", KtPropertyDelegate.class);
IElementType CONSTRUCTOR_CALLEE = KtStubElementTypes.CONSTRUCTOR_CALLEE;
IElementType VALUE_PARAMETER_LIST = KtStubElementTypes.VALUE_PARAMETER_LIST;
IElementType VALUE_PARAMETER = KtStubElementTypes.VALUE_PARAMETER;
@@ -81,7 +81,7 @@ public interface KtNodeTypes {
IElementType TYPE_CONSTRAINT = KtStubElementTypes.TYPE_CONSTRAINT;
IElementType CONSTRUCTOR_DELEGATION_CALL = new KtNodeType.KtLeftBoundNodeType("CONSTRUCTOR_DELEGATION_CALL", KtConstructorDelegationCall.class);
KtNodeType CONSTRUCTOR_DELEGATION_REFERENCE = new KtNodeType.KtLeftBoundNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", KtConstructorDelegationReferenceExpression.class);
IElementType CONSTRUCTOR_DELEGATION_REFERENCE = new KtNodeType.KtLeftBoundNodeType("CONSTRUCTOR_DELEGATION_REFERENCE", KtConstructorDelegationReferenceExpression.class);
IElementType NULL = KtStubElementTypes.NULL;
IElementType BOOLEAN_CONSTANT = KtStubElementTypes.BOOLEAN_CONSTANT;
@@ -95,63 +95,63 @@ public interface KtNodeTypes {
IElementType LITERAL_STRING_TEMPLATE_ENTRY = KtStubElementTypes.LITERAL_STRING_TEMPLATE_ENTRY;
IElementType ESCAPE_STRING_TEMPLATE_ENTRY = KtStubElementTypes.ESCAPE_STRING_TEMPLATE_ENTRY;
KtNodeType PARENTHESIZED = new KtNodeType("PARENTHESIZED", KtParenthesizedExpression.class);
KtNodeType RETURN = new KtNodeType("RETURN", KtReturnExpression.class);
KtNodeType THROW = new KtNodeType("THROW", KtThrowExpression.class);
KtNodeType CONTINUE = new KtNodeType("CONTINUE", KtContinueExpression.class);
KtNodeType BREAK = new KtNodeType("BREAK", KtBreakExpression.class);
KtNodeType IF = new KtNodeType("IF", KtIfExpression.class);
KtNodeType CONDITION = new KtNodeType("CONDITION", KtContainerNode.class);
KtNodeType THEN = new KtNodeType("THEN", KtContainerNodeForControlStructureBody.class);
KtNodeType ELSE = new KtNodeType("ELSE", KtContainerNodeForControlStructureBody.class);
KtNodeType TRY = new KtNodeType("TRY", KtTryExpression.class);
KtNodeType CATCH = new KtNodeType("CATCH", KtCatchClause.class);
KtNodeType FINALLY = new KtNodeType("FINALLY", KtFinallySection.class);
KtNodeType FOR = new KtNodeType("FOR", KtForExpression.class);
KtNodeType WHILE = new KtNodeType("WHILE", KtWhileExpression.class);
KtNodeType DO_WHILE = new KtNodeType("DO_WHILE", KtDoWhileExpression.class);
KtNodeType LOOP_RANGE = new KtNodeType("LOOP_RANGE", KtContainerNode.class);
KtNodeType BODY = new KtNodeType("BODY", KtContainerNodeForControlStructureBody.class);
KtNodeType BLOCK = new KtNodeType("BLOCK", KtBlockExpression.class);
IElementType PARENTHESIZED = new KtNodeType("PARENTHESIZED", KtParenthesizedExpression.class);
IElementType RETURN = new KtNodeType("RETURN", KtReturnExpression.class);
IElementType THROW = new KtNodeType("THROW", KtThrowExpression.class);
IElementType CONTINUE = new KtNodeType("CONTINUE", KtContinueExpression.class);
IElementType BREAK = new KtNodeType("BREAK", KtBreakExpression.class);
IElementType IF = new KtNodeType("IF", KtIfExpression.class);
IElementType CONDITION = new KtNodeType("CONDITION", KtContainerNode.class);
IElementType THEN = new KtNodeType("THEN", KtContainerNodeForControlStructureBody.class);
IElementType ELSE = new KtNodeType("ELSE", KtContainerNodeForControlStructureBody.class);
IElementType TRY = new KtNodeType("TRY", KtTryExpression.class);
IElementType CATCH = new KtNodeType("CATCH", KtCatchClause.class);
IElementType FINALLY = new KtNodeType("FINALLY", KtFinallySection.class);
IElementType FOR = new KtNodeType("FOR", KtForExpression.class);
IElementType WHILE = new KtNodeType("WHILE", KtWhileExpression.class);
IElementType DO_WHILE = new KtNodeType("DO_WHILE", KtDoWhileExpression.class);
IElementType LOOP_RANGE = new KtNodeType("LOOP_RANGE", KtContainerNode.class);
IElementType BODY = new KtNodeType("BODY", KtContainerNodeForControlStructureBody.class);
IElementType BLOCK = new KtNodeType("BLOCK", KtBlockExpression.class);
IElementType LAMBDA_EXPRESSION = new LambdaExpressionElementType();
KtNodeType FUNCTION_LITERAL = new KtNodeType("FUNCTION_LITERAL", KtFunctionLiteral.class);
KtNodeType ANNOTATED_EXPRESSION = new KtNodeType("ANNOTATED_EXPRESSION", KtAnnotatedExpression.class);
IElementType FUNCTION_LITERAL = new KtNodeType("FUNCTION_LITERAL", KtFunctionLiteral.class);
IElementType ANNOTATED_EXPRESSION = new KtNodeType("ANNOTATED_EXPRESSION", KtAnnotatedExpression.class);
IElementType REFERENCE_EXPRESSION = KtStubElementTypes.REFERENCE_EXPRESSION;
IElementType ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION = KtStubElementTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION;
KtNodeType OPERATION_REFERENCE = new KtNodeType("OPERATION_REFERENCE", KtOperationReferenceExpression.class);
KtNodeType LABEL = new KtNodeType("LABEL", KtLabelReferenceExpression.class);
IElementType OPERATION_REFERENCE = new KtNodeType("OPERATION_REFERENCE", KtOperationReferenceExpression.class);
IElementType LABEL = new KtNodeType("LABEL", KtLabelReferenceExpression.class);
KtNodeType LABEL_QUALIFIER = new KtNodeType("LABEL_QUALIFIER", KtContainerNode.class);
IElementType LABEL_QUALIFIER = new KtNodeType("LABEL_QUALIFIER", KtContainerNode.class);
KtNodeType THIS_EXPRESSION = new KtNodeType("THIS_EXPRESSION", KtThisExpression.class);
KtNodeType SUPER_EXPRESSION = new KtNodeType("SUPER_EXPRESSION", KtSuperExpression.class);
KtNodeType BINARY_EXPRESSION = new KtNodeType("BINARY_EXPRESSION", KtBinaryExpression.class);
KtNodeType BINARY_WITH_TYPE = new KtNodeType("BINARY_WITH_TYPE", KtBinaryExpressionWithTypeRHS.class);
KtNodeType IS_EXPRESSION = new KtNodeType("IS_EXPRESSION", KtIsExpression.class);
KtNodeType PREFIX_EXPRESSION = new KtNodeType("PREFIX_EXPRESSION", KtPrefixExpression.class);
KtNodeType POSTFIX_EXPRESSION = new KtNodeType("POSTFIX_EXPRESSION", KtPostfixExpression.class);
KtNodeType LABELED_EXPRESSION = new KtNodeType("LABELED_EXPRESSION", KtLabeledExpression.class);
KtNodeType CALL_EXPRESSION = new KtNodeType("CALL_EXPRESSION", KtCallExpression.class);
KtNodeType ARRAY_ACCESS_EXPRESSION = new KtNodeType("ARRAY_ACCESS_EXPRESSION", KtArrayAccessExpression.class);
KtNodeType INDICES = new KtNodeType("INDICES", KtContainerNode.class);
IElementType DOT_QUALIFIED_EXPRESSION = KtStubElementTypes.DOT_QUALIFIED_EXPRESSION;
KtNodeType CALLABLE_REFERENCE_EXPRESSION = new KtNodeType("CALLABLE_REFERENCE_EXPRESSION", KtCallableReferenceExpression.class);
KtNodeType CLASS_LITERAL_EXPRESSION = new KtNodeType("CLASS_LITERAL_EXPRESSION", KtClassLiteralExpression.class);
KtNodeType SAFE_ACCESS_EXPRESSION = new KtNodeType("SAFE_ACCESS_EXPRESSION", KtSafeQualifiedExpression.class);
IElementType THIS_EXPRESSION = new KtNodeType("THIS_EXPRESSION", KtThisExpression.class);
IElementType SUPER_EXPRESSION = new KtNodeType("SUPER_EXPRESSION", KtSuperExpression.class);
IElementType BINARY_EXPRESSION = new KtNodeType("BINARY_EXPRESSION", KtBinaryExpression.class);
IElementType BINARY_WITH_TYPE = new KtNodeType("BINARY_WITH_TYPE", KtBinaryExpressionWithTypeRHS.class);
IElementType IS_EXPRESSION = new KtNodeType("IS_EXPRESSION", KtIsExpression.class);
IElementType PREFIX_EXPRESSION = new KtNodeType("PREFIX_EXPRESSION", KtPrefixExpression.class);
IElementType POSTFIX_EXPRESSION = new KtNodeType("POSTFIX_EXPRESSION", KtPostfixExpression.class);
IElementType LABELED_EXPRESSION = new KtNodeType("LABELED_EXPRESSION", KtLabeledExpression.class);
IElementType CALL_EXPRESSION = new KtNodeType("CALL_EXPRESSION", KtCallExpression.class);
IElementType ARRAY_ACCESS_EXPRESSION = new KtNodeType("ARRAY_ACCESS_EXPRESSION", KtArrayAccessExpression.class);
IElementType INDICES = new KtNodeType("INDICES", KtContainerNode.class);
IElementType DOT_QUALIFIED_EXPRESSION = KtStubElementTypes.DOT_QUALIFIED_EXPRESSION;
IElementType CALLABLE_REFERENCE_EXPRESSION = new KtNodeType("CALLABLE_REFERENCE_EXPRESSION", KtCallableReferenceExpression.class);
IElementType CLASS_LITERAL_EXPRESSION = new KtNodeType("CLASS_LITERAL_EXPRESSION", KtClassLiteralExpression.class);
IElementType SAFE_ACCESS_EXPRESSION = new KtNodeType("SAFE_ACCESS_EXPRESSION", KtSafeQualifiedExpression.class);
KtNodeType OBJECT_LITERAL = new KtNodeType("OBJECT_LITERAL", KtObjectLiteralExpression.class);
IElementType OBJECT_LITERAL = new KtNodeType("OBJECT_LITERAL", KtObjectLiteralExpression.class);
KtNodeType WHEN = new KtNodeType("WHEN", KtWhenExpression.class);
KtNodeType WHEN_ENTRY = new KtNodeType("WHEN_ENTRY", KtWhenEntry.class);
IElementType WHEN = new KtNodeType("WHEN", KtWhenExpression.class);
IElementType WHEN_ENTRY = new KtNodeType("WHEN_ENTRY", KtWhenEntry.class);
KtNodeType WHEN_CONDITION_IN_RANGE = new KtNodeType("WHEN_CONDITION_IN_RANGE", KtWhenConditionInRange.class);
KtNodeType WHEN_CONDITION_IS_PATTERN = new KtNodeType("WHEN_CONDITION_IS_PATTERN", KtWhenConditionIsPattern.class);
KtNodeType WHEN_CONDITION_EXPRESSION = new KtNodeType("WHEN_CONDITION_WITH_EXPRESSION", KtWhenConditionWithExpression.class);
IElementType WHEN_CONDITION_IN_RANGE = new KtNodeType("WHEN_CONDITION_IN_RANGE", KtWhenConditionInRange.class);
IElementType WHEN_CONDITION_IS_PATTERN = new KtNodeType("WHEN_CONDITION_IS_PATTERN", KtWhenConditionIsPattern.class);
IElementType WHEN_CONDITION_EXPRESSION = new KtNodeType("WHEN_CONDITION_WITH_EXPRESSION", KtWhenConditionWithExpression.class);
KtNodeType COLLECTION_LITERAL_EXPRESSION = new KtNodeType("COLLECTION_LITERAL_EXPRESSION", KtCollectionLiteralExpression.class);
IElementType COLLECTION_LITERAL_EXPRESSION = new KtNodeType("COLLECTION_LITERAL_EXPRESSION", KtCollectionLiteralExpression.class);
IElementType PACKAGE_DIRECTIVE = KtStubElementTypes.PACKAGE_DIRECTIVE;
@@ -22,7 +22,6 @@ import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.KtNodeType;
import org.jetbrains.kotlin.KtNodeTypes;
import org.jetbrains.kotlin.lexer.KtToken;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -155,7 +154,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
AS(AS_KEYWORD, AS_SAFE) {
@Override
public KtNodeType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
public IElementType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
parser.myKotlinParsing.parseTypeRef();
return BINARY_WITH_TYPE;
}
@@ -173,7 +172,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
ELVIS(KtTokens.ELVIS),
IN_OR_IS(IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS) {
@Override
public KtNodeType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
public IElementType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
if (operation == IS_KEYWORD || operation == NOT_IS) {
parser.myKotlinParsing.parseTypeRef();
return IS_EXPRESSION;
@@ -216,7 +215,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
* @param parser the parser object
* @return node type of the result
*/
public KtNodeType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
public IElementType parseRightHandSide(IElementType operation, KotlinExpressionParsing parser) {
parseHigherPrecedence(parser);
return BINARY_EXPRESSION;
}
@@ -316,7 +315,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
parseOperationReference();
KtNodeType resultType = precedence.parseRightHandSide(operation, this);
IElementType resultType = precedence.parseRightHandSide(operation, this);
expression.done(resultType);
expression = expression.precede();
}
@@ -1008,7 +1007,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
parseAsCollectionLiteralExpression(COLLECTION_LITERAL_EXPRESSION, true, "Expecting an element");
}
private void parseAsCollectionLiteralExpression(KtNodeType nodeType, boolean canBeEmpty, String missingElementErrorMessage) {
private void parseAsCollectionLiteralExpression(IElementType nodeType, boolean canBeEmpty, String missingElementErrorMessage) {
assert _at(LBRACKET);
PsiBuilder.Marker innerExpressions = mark();
@@ -1627,7 +1626,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
* : "continue" getEntryPoint?
* : "break" getEntryPoint?
*/
private void parseJump(KtNodeType type) {
private void parseJump(IElementType type) {
assert _at(BREAK_KEYWORD) || _at(CONTINUE_KEYWORD);
PsiBuilder.Marker marker = mark();
@@ -7,13 +7,13 @@ package org.jetbrains.kotlin.psi
import com.intellij.lang.ASTNode
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.KtNodeType
import com.intellij.psi.tree.IElementType
abstract class KtExpressionImpl(node: ASTNode) : KtElementImpl(node), KtExpression {
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D) = visitor.visitExpression(this, data)
protected fun findExpressionUnder(type: KtNodeType): KtExpression? {
protected fun findExpressionUnder(type: IElementType): KtExpression? {
val containerNode = findChildByType<KtContainerNode>(type) ?: return null
return containerNode.findChildByClass<KtExpression>(KtExpression::class.java)
}