Get stubbed expressions in value arguments (KT-23738)
This commit is contained in:
@@ -34,4 +34,14 @@ public class KtLiteralStringTemplateEntry extends KtStringTemplateEntry {
|
||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitLiteralStringTemplateEntry(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
KotlinPlaceHolderWithTextStub<? extends KtStringTemplateEntry> stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.text();
|
||||
}
|
||||
|
||||
return super.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.KtNodeTypes;
|
||||
@@ -45,9 +46,29 @@ public class KtValueArgument extends KtElementImplStub<KotlinPlaceHolderStub<? e
|
||||
return visitor.visitArgument(this, data);
|
||||
}
|
||||
|
||||
private 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.STRING_TEMPLATE
|
||||
);
|
||||
|
||||
@Override
|
||||
@Nullable @IfNotParsed
|
||||
public KtExpression getArgumentExpression() {
|
||||
KotlinPlaceHolderStub<? extends KtValueArgument> stub = getStub();
|
||||
if (stub != null) {
|
||||
KtExpression[] constantExpressions = stub.getChildrenByType(CONSTANT_EXPRESSIONS_TYPES, KtExpression.EMPTY_ARRAY);
|
||||
if (constantExpressions.length != 0) {
|
||||
return constantExpressions[0];
|
||||
}
|
||||
}
|
||||
|
||||
return findChildByClass(KtExpression.class);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user