Move TokenSet from KtStubElementTypes
KtStubElementTypes has to have only KtStubElementType fields to provide ability to initialize stub element types lazily. #KT-53781
This commit is contained in:
committed by
Space
parent
f643cdf90b
commit
584eb9dfa9
+4
-3
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.psi.KtParameter.VAL_VAR_TOKEN_SET
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStringTemplateExpressionElementType
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runUnless
|
||||
|
||||
object LightTreePositioningStrategies {
|
||||
@@ -596,7 +597,7 @@ object LightTreePositioningStrategies {
|
||||
return super.mark(node, startOffset, endOffset, tree)
|
||||
}
|
||||
if (node.tokenType == KtNodeTypes.TYPE_REFERENCE) {
|
||||
val typeElement = tree.findChildByType(node, KtStubElementTypes.TYPE_ELEMENT_TYPES)
|
||||
val typeElement = tree.findChildByType(node, KtTokenSets.TYPE_ELEMENT_TYPES)
|
||||
if (typeElement != null) {
|
||||
val referencedTypeExpression = tree.referencedTypeExpression(typeElement)
|
||||
if (referencedTypeExpression != null) {
|
||||
@@ -612,7 +613,7 @@ object LightTreePositioningStrategies {
|
||||
return when (node.tokenType) {
|
||||
KtNodeTypes.USER_TYPE -> findChildByType(node, KtNodeTypes.REFERENCE_EXPRESSION)
|
||||
?: findChildByType(node, KtNodeTypes.ENUM_ENTRY_SUPERCLASS_REFERENCE_EXPRESSION)
|
||||
KtNodeTypes.NULLABLE_TYPE -> findChildByType(node, KtStubElementTypes.TYPE_ELEMENT_TYPES)
|
||||
KtNodeTypes.NULLABLE_TYPE -> findChildByType(node, KtTokenSets.TYPE_ELEMENT_TYPES)
|
||||
?.let { referencedTypeExpression(it) }
|
||||
else -> null
|
||||
}
|
||||
@@ -687,7 +688,7 @@ object LightTreePositioningStrategies {
|
||||
return markElement(nodeToMark, startOffset, endOffset, tree, node)
|
||||
}
|
||||
node.tokenType == KtNodeTypes.IMPORT_DIRECTIVE -> {
|
||||
val nodeToMark = tree.findChildByType(node, KtStubElementTypes.INSIDE_DIRECTIVE_EXPRESSIONS) ?: node
|
||||
val nodeToMark = tree.findChildByType(node, KtTokenSets.INSIDE_DIRECTIVE_EXPRESSIONS) ?: node
|
||||
return markElement(nodeToMark, startOffset, endOffset, tree, node)
|
||||
}
|
||||
node.tokenType != KtNodeTypes.DOT_QUALIFIED_EXPRESSION &&
|
||||
|
||||
@@ -23,8 +23,9 @@ import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.CLASS_BODY
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.MODIFIER_LIST
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets.DECLARATION_TYPES
|
||||
|
||||
class KtClassBody : KtElementImplStub<KotlinPlaceHolderStub<KtClassBody>>, KtDeclarationContainer {
|
||||
private val lBraceTokenSet = TokenSet.create(KtTokens.LBRACE)
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.lang.ASTNode
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.INSIDE_DIRECTIVE_EXPRESSIONS
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets.INSIDE_DIRECTIVE_EXPRESSIONS
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
|
||||
class KtDotQualifiedExpression : KtExpressionImplStub<KotlinPlaceHolderStub<KtDotQualifiedExpression>>, KtQualifiedExpression {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinFileStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtPlaceHolderStubElementType
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets
|
||||
|
||||
open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) :
|
||||
PsiFileBase(viewProvider, KotlinLanguage.INSTANCE),
|
||||
@@ -273,6 +274,6 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) :
|
||||
}
|
||||
|
||||
companion object {
|
||||
val FILE_DECLARATION_TYPES = TokenSet.orSet(KtStubElementTypes.DECLARATION_TYPES, TokenSet.create(KtStubElementTypes.SCRIPT))
|
||||
val FILE_DECLARATION_TYPES = TokenSet.orSet(KtTokenSets.DECLARATION_TYPES, TokenSet.create(KtStubElementTypes.SCRIPT))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets;
|
||||
import org.jetbrains.kotlin.resolve.ImportPath;
|
||||
|
||||
public class KtImportDirective extends KtElementImplStub<KotlinImportDirectiveStub> implements KtImportInfo {
|
||||
@@ -47,7 +48,7 @@ public class KtImportDirective extends KtElementImplStub<KotlinImportDirectiveSt
|
||||
@Nullable
|
||||
@IfNotParsed
|
||||
public KtExpression getImportedReference() {
|
||||
KtExpression[] references = getStubOrPsiChildren(KtStubElementTypes.INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY);
|
||||
KtExpression[] references = getStubOrPsiChildren(KtTokenSets.INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY);
|
||||
if (references.length > 0) {
|
||||
return references[0];
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -40,6 +41,6 @@ public class KtInitializerList extends KtElementImplStub<KotlinPlaceHolderStub<K
|
||||
|
||||
@NotNull
|
||||
public List<KtSuperTypeListEntry> getInitializers() {
|
||||
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
|
||||
return Arrays.asList(getStubOrPsiChildren(KtTokenSets.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -55,7 +56,7 @@ public class KtNullableType extends KtElementImplStub<KotlinPlaceHolderStub<KtNu
|
||||
@Nullable
|
||||
@IfNotParsed
|
||||
public KtTypeElement getInnerType() {
|
||||
return KtStubbedPsiUtil.getStubOrPsiChild(this, KtStubElementTypes.TYPE_ELEMENT_TYPES, KtTypeElement.ARRAY_FACTORY);
|
||||
return KtStubbedPsiUtil.getStubOrPsiChild(this, KtTokenSets.TYPE_ELEMENT_TYPES, KtTypeElement.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.psi.psiUtil.KtPsiUtilKt;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -46,7 +47,7 @@ public class KtPackageDirective extends KtModifierListOwnerStub<KotlinPlaceHolde
|
||||
// This should be either JetSimpleNameExpression, or JetDotQualifiedExpression
|
||||
@Nullable
|
||||
public KtExpression getPackageNameExpression() {
|
||||
return KtStubbedPsiUtil.getStubOrPsiChild(this, KtStubElementTypes.INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY);
|
||||
return KtStubbedPsiUtil.getStubOrPsiChild(this, KtTokenSets.INSIDE_DIRECTIVE_EXPRESSIONS, KtExpression.ARRAY_FACTORY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes;
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -67,7 +68,7 @@ public class KtSuperTypeList extends KtElementImplStub<KotlinPlaceHolderStub<KtS
|
||||
}
|
||||
|
||||
public List<KtSuperTypeListEntry> getEntries() {
|
||||
return Arrays.asList(getStubOrPsiChildren(KtStubElementTypes.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
|
||||
return Arrays.asList(getStubOrPsiChildren(KtTokenSets.SUPER_TYPE_LIST_ENTRIES, KtSuperTypeListEntry.ARRAY_FACTORY));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.psi
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.psiUtil.findDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets
|
||||
|
||||
/**
|
||||
* Type reference element.
|
||||
@@ -42,7 +42,7 @@ class KtTypeReference : KtModifierListOwnerStub<KotlinPlaceHolderStub<KtTypeRefe
|
||||
get() = ((typeElement as? KtUserType)?.referenceExpression as? KtNameReferenceExpression)?.isPlaceholder == true
|
||||
|
||||
val typeElement: KtTypeElement?
|
||||
get() = KtStubbedPsiUtil.getStubOrPsiChild(this, KtStubElementTypes.TYPE_ELEMENT_TYPES, KtTypeElement.ARRAY_FACTORY)
|
||||
get() = KtStubbedPsiUtil.getStubOrPsiChild(this, KtTokenSets.TYPE_ELEMENT_TYPES, KtTypeElement.ARRAY_FACTORY)
|
||||
|
||||
override fun getAnnotations(): List<KtAnnotation> {
|
||||
return modifierList?.annotations.orEmpty()
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi.stubs.elements;
|
||||
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
|
||||
public interface KtStubElementTypes {
|
||||
@@ -171,12 +170,4 @@ public interface KtStubElementTypes {
|
||||
|
||||
KtScriptElementType SCRIPT = new KtScriptElementType("SCRIPT");
|
||||
|
||||
TokenSet DECLARATION_TYPES =
|
||||
TokenSet.create(CLASS, OBJECT_DECLARATION, FUNCTION, PROPERTY, TYPEALIAS, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, ENUM_ENTRY);
|
||||
|
||||
TokenSet SUPER_TYPE_LIST_ENTRIES = TokenSet.create(DELEGATED_SUPER_TYPE_ENTRY, SUPER_TYPE_CALL_ENTRY, SUPER_TYPE_ENTRY);
|
||||
|
||||
TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE, DYNAMIC_TYPE, INTERSECTION_TYPE);
|
||||
|
||||
TokenSet INSIDE_DIRECTIVE_EXPRESSIONS = TokenSet.create(REFERENCE_EXPRESSION, DOT_QUALIFIED_EXPRESSION);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.psi.tree.TokenSet;
|
||||
|
||||
import static org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.*;
|
||||
|
||||
public interface KtTokenSets {
|
||||
TokenSet DECLARATION_TYPES =
|
||||
TokenSet.create(CLASS, OBJECT_DECLARATION, FUNCTION, PROPERTY, TYPEALIAS, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, ENUM_ENTRY);
|
||||
|
||||
TokenSet SUPER_TYPE_LIST_ENTRIES = TokenSet.create(DELEGATED_SUPER_TYPE_ENTRY, SUPER_TYPE_CALL_ENTRY, SUPER_TYPE_ENTRY);
|
||||
|
||||
TokenSet TYPE_ELEMENT_TYPES = TokenSet.create(USER_TYPE, NULLABLE_TYPE, FUNCTION_TYPE, DYNAMIC_TYPE, INTERSECTION_TYPE);
|
||||
|
||||
TokenSet INSIDE_DIRECTIVE_EXPRESSIONS = TokenSet.create(REFERENCE_EXPRESSION, DOT_QUALIFIED_EXPRESSION);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user