Stub element for KtStringTemplateExpression (KT-23738)
This commit is contained in:
@@ -92,7 +92,7 @@ public interface KtNodeTypes {
|
|||||||
IElementType CHARACTER_CONSTANT = KtStubElementTypes.CHARACTER_CONSTANT;
|
IElementType CHARACTER_CONSTANT = KtStubElementTypes.CHARACTER_CONSTANT;
|
||||||
IElementType INTEGER_CONSTANT = KtStubElementTypes.INTEGER_CONSTANT;
|
IElementType INTEGER_CONSTANT = KtStubElementTypes.INTEGER_CONSTANT;
|
||||||
|
|
||||||
KtNodeType STRING_TEMPLATE = new KtNodeType("STRING_TEMPLATE", KtStringTemplateExpression.class);
|
IElementType STRING_TEMPLATE = KtStubElementTypes.STRING_TEMPLATE;
|
||||||
KtNodeType LONG_STRING_TEMPLATE_ENTRY = new KtNodeType("LONG_STRING_TEMPLATE_ENTRY", KtBlockStringTemplateEntry.class);
|
KtNodeType LONG_STRING_TEMPLATE_ENTRY = new KtNodeType("LONG_STRING_TEMPLATE_ENTRY", KtBlockStringTemplateEntry.class);
|
||||||
KtNodeType SHORT_STRING_TEMPLATE_ENTRY = new KtNodeType("SHORT_STRING_TEMPLATE_ENTRY", KtSimpleNameStringTemplateEntry.class);
|
KtNodeType SHORT_STRING_TEMPLATE_ENTRY = new KtNodeType("SHORT_STRING_TEMPLATE_ENTRY", KtSimpleNameStringTemplateEntry.class);
|
||||||
KtNodeType LITERAL_STRING_TEMPLATE_ENTRY = new KtNodeType("LITERAL_STRING_TEMPLATE_ENTRY", KtLiteralStringTemplateEntry.class);
|
KtNodeType LITERAL_STRING_TEMPLATE_ENTRY = new KtNodeType("LITERAL_STRING_TEMPLATE_ENTRY", KtLiteralStringTemplateEntry.class);
|
||||||
|
|||||||
@@ -22,16 +22,28 @@ import com.intellij.psi.LiteralTextEscaper;
|
|||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiLanguageInjectionHost;
|
import com.intellij.psi.PsiLanguageInjectionHost;
|
||||||
import com.intellij.psi.tree.TokenSet;
|
import com.intellij.psi.tree.TokenSet;
|
||||||
|
import com.intellij.util.IncorrectOperationException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||||
|
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||||
|
|
||||||
public class KtStringTemplateExpression extends KtExpressionImpl implements PsiLanguageInjectionHost {
|
public class KtStringTemplateExpression extends KtElementImplStub<KotlinPlaceHolderStub<KtStringTemplateExpression>> implements KtExpression, PsiLanguageInjectionHost {
|
||||||
private static final TokenSet CLOSE_QUOTE_TOKEN_SET = TokenSet.create(KtTokens.CLOSING_QUOTE);
|
private static final TokenSet CLOSE_QUOTE_TOKEN_SET = TokenSet.create(KtTokens.CLOSING_QUOTE);
|
||||||
|
|
||||||
public KtStringTemplateExpression(@NotNull ASTNode node) {
|
public KtStringTemplateExpression(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KtStringTemplateExpression(@NotNull KotlinPlaceHolderStub<KtStringTemplateExpression> stub) {
|
||||||
|
super(stub, KtStubElementTypes.STRING_TEMPLATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
|
||||||
|
return KtExpressionImpl.Companion.replaceExpression(this, newElement, true, super::replace);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
public <R, D> R accept(@NotNull KtVisitor<R, D> visitor, D data) {
|
||||||
return visitor.visitStringTemplateExpression(this, data);
|
return visitor.visitStringTemplateExpression(this, data);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ object KotlinStubVersions {
|
|||||||
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
|
// Though only kotlin declarations (no code in the bodies) are stubbed, please do increase this version
|
||||||
// if you are not 100% sure it can be avoided.
|
// if you are not 100% sure it can be avoided.
|
||||||
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
|
// Increasing this version will lead to reindexing of all kotlin source files on the first IDE startup with the new version.
|
||||||
const val SOURCE_STUB_VERSION = 131
|
const val SOURCE_STUB_VERSION = 132
|
||||||
|
|
||||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.psi.stubs.elements
|
||||||
|
|
||||||
|
import com.intellij.lang.ASTNode
|
||||||
|
import org.jetbrains.annotations.NonNls
|
||||||
|
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
||||||
|
|
||||||
|
class KtStringTemplateExpressionElementType(@NonNls debugName: String) :
|
||||||
|
KtPlaceHolderStubElementType<KtStringTemplateExpression>(debugName, KtStringTemplateExpression::class.java) {
|
||||||
|
|
||||||
|
override fun shouldCreateStub(node: ASTNode): Boolean {
|
||||||
|
if (node.treeParent?.elementType != KtStubElementTypes.VALUE_ARGUMENT) return false
|
||||||
|
return super.shouldCreateStub(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -135,6 +135,9 @@ public interface KtStubElementTypes {
|
|||||||
KtConstantExpressionElementType CHARACTER_CONSTANT = new KtConstantExpressionElementType("CHARACTER_CONSTANT");
|
KtConstantExpressionElementType CHARACTER_CONSTANT = new KtConstantExpressionElementType("CHARACTER_CONSTANT");
|
||||||
KtConstantExpressionElementType INTEGER_CONSTANT = new KtConstantExpressionElementType("INTEGER_CONSTANT");
|
KtConstantExpressionElementType INTEGER_CONSTANT = new KtConstantExpressionElementType("INTEGER_CONSTANT");
|
||||||
|
|
||||||
|
KtPlaceHolderStubElementType<KtStringTemplateExpression> STRING_TEMPLATE =
|
||||||
|
new KtStringTemplateExpressionElementType("STRING_TEMPLATE");
|
||||||
|
|
||||||
KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT");
|
KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT");
|
||||||
|
|
||||||
TokenSet DECLARATION_TYPES =
|
TokenSet DECLARATION_TYPES =
|
||||||
|
|||||||
@@ -109,8 +109,11 @@ PsiJetFileStubImpl[package=test]
|
|||||||
REFERENCE_EXPRESSION[referencedName=StringLiteral]
|
REFERENCE_EXPRESSION[referencedName=StringLiteral]
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
CLASS[fqName=test.E, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=E, superNames=[]]
|
CLASS[fqName=test.E, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=E, superNames=[]]
|
||||||
MODIFIER_LIST[enum]
|
MODIFIER_LIST[enum]
|
||||||
CLASS_BODY
|
CLASS_BODY
|
||||||
@@ -279,6 +282,7 @@ PsiJetFileStubImpl[package=test]
|
|||||||
REFERENCE_EXPRESSION[referencedName=Outer]
|
REFERENCE_EXPRESSION[referencedName=Outer]
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
VALUE_ARGUMENT_NAME
|
VALUE_ARGUMENT_NAME
|
||||||
REFERENCE_EXPRESSION[referencedName=nested]
|
REFERENCE_EXPRESSION[referencedName=nested]
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ PsiJetFileStubImpl[package=]
|
|||||||
REFERENCE_EXPRESSION[referencedName=Test]
|
REFERENCE_EXPRESSION[referencedName=Test]
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
VALUE_ARGUMENT_NAME
|
VALUE_ARGUMENT_NAME
|
||||||
REFERENCE_EXPRESSION[referencedName=other]
|
REFERENCE_EXPRESSION[referencedName=other]
|
||||||
|
STRING_TEMPLATE
|
||||||
|
|||||||
+1
@@ -8,6 +8,7 @@ PsiJetFileStubImpl[package=test]
|
|||||||
REFERENCE_EXPRESSION[referencedName=Suppress]
|
REFERENCE_EXPRESSION[referencedName=Suppress]
|
||||||
VALUE_ARGUMENT_LIST
|
VALUE_ARGUMENT_LIST
|
||||||
VALUE_ARGUMENT
|
VALUE_ARGUMENT
|
||||||
|
STRING_TEMPLATE
|
||||||
PACKAGE_DIRECTIVE
|
PACKAGE_DIRECTIVE
|
||||||
REFERENCE_EXPRESSION[referencedName=test]
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
IMPORT_LIST
|
IMPORT_LIST
|
||||||
|
|||||||
Reference in New Issue
Block a user