[psi] define common constant expressions types

This commit is contained in:
Anna Kozlova
2023-03-29 14:29:37 +02:00
committed by teamcity
parent 956294821b
commit 1102dc1d0e
3 changed files with 20 additions and 19 deletions
@@ -65,7 +65,7 @@ public class KtCollectionLiteralExpression extends KtElementImplStub<KotlinColle
public List<KtExpression> getInnerExpressions() {
KotlinCollectionLiteralExpressionStub stub = getStub();
if (stub != null) {
return Arrays.asList(stub.getChildrenByType(KtValueArgument.CONSTANT_EXPRESSIONS_TYPES, KtExpression.EMPTY_ARRAY));
return Arrays.asList(stub.getChildrenByType(KtStubElementTypes.CONSTANT_EXPRESSIONS_TYPES, KtExpression.EMPTY_ARRAY));
}
return PsiTreeUtil.getChildrenOfTypeAsList(this, KtExpression.class);
}
@@ -46,23 +46,6 @@ public class KtValueArgument extends KtElementImplStub<KotlinValueArgumentStub<?
return visitor.visitArgument(this, data);
}
public static final TokenSet CONSTANT_EXPRESSIONS_TYPES = TokenSet.create(
KtStubElementTypes.NULL,
KtStubElementTypes.BOOLEAN_CONSTANT,
KtStubElementTypes.FLOAT_CONSTANT,
KtStubElementTypes.CHARACTER_CONSTANT,
KtStubElementTypes.INTEGER_CONSTANT,
KtStubElementTypes.REFERENCE_EXPRESSION,
KtStubElementTypes.DOT_QUALIFIED_EXPRESSION,
KtStubElementTypes.STRING_TEMPLATE,
KtStubElementTypes.CLASS_LITERAL_EXPRESSION,
KtStubElementTypes.COLLECTION_LITERAL_EXPRESSION
);
private static final TokenSet STRING_TEMPLATE_EXPRESSIONS_TYPES = TokenSet.create(
KtStubElementTypes.STRING_TEMPLATE
);
@@ -72,7 +55,7 @@ public class KtValueArgument extends KtElementImplStub<KotlinValueArgumentStub<?
public KtExpression getArgumentExpression() {
KotlinPlaceHolderStub<? extends KtValueArgument> stub = getStub();
if (stub != null) {
KtExpression[] constantExpressions = stub.getChildrenByType(CONSTANT_EXPRESSIONS_TYPES, KtExpression.EMPTY_ARRAY);
KtExpression[] constantExpressions = stub.getChildrenByType(KtStubElementTypes.CONSTANT_EXPRESSIONS_TYPES, KtExpression.EMPTY_ARRAY);
if (constantExpressions.length != 0) {
return constantExpressions[0];
}
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.psi.stubs.elements;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.kotlin.psi.*;
public interface KtStubElementTypes {
@@ -165,6 +166,23 @@ public interface KtStubElementTypes {
KtPlaceHolderStubElementType<KtStringTemplateExpression> STRING_TEMPLATE =
new KtStringTemplateExpressionElementType("STRING_TEMPLATE");
TokenSet CONSTANT_EXPRESSIONS_TYPES = TokenSet.create(
NULL,
BOOLEAN_CONSTANT,
FLOAT_CONSTANT,
CHARACTER_CONSTANT,
INTEGER_CONSTANT,
REFERENCE_EXPRESSION,
DOT_QUALIFIED_EXPRESSION,
STRING_TEMPLATE,
CLASS_LITERAL_EXPRESSION,
COLLECTION_LITERAL_EXPRESSION
);
KtPlaceHolderWithTextStubElementType<KtBlockStringTemplateEntry> LONG_STRING_TEMPLATE_ENTRY =
new KtPlaceHolderWithTextStubElementType<>("LONG_STRING_TEMPLATE_ENTRY", KtBlockStringTemplateEntry.class);