diff --git a/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/LightTreePositioningStrategies.kt b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/LightTreePositioningStrategies.kt index 777c1c0335e..451d82813dd 100644 --- a/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/diagnostics/LightTreePositioningStrategies.kt @@ -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 && diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt index ddf561dbad2..a0c3690253a 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt @@ -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>, KtDeclarationContainer { private val lBraceTokenSet = TokenSet.create(KtTokens.LBRACE) diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtDotQualifiedExpression.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtDotQualifiedExpression.kt index 77f1e68c17b..3182ee95f91 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtDotQualifiedExpression.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtDotQualifiedExpression.kt @@ -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>, KtQualifiedExpression { diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtFile.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtFile.kt index eb31faf5800..80195aa050a 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtFile.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtFile.kt @@ -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)) } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java index 92fb7f77982..47e6944f1f9 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtImportDirective.java @@ -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 implements KtImportInfo { @@ -47,7 +48,7 @@ public class KtImportDirective extends KtElementImplStub 0) { return references[0]; } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtInitializerList.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtInitializerList.java index 9ce36b9b5ee..569969b1177 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtInitializerList.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtInitializerList.java @@ -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 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)); } } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtNullableType.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtNullableType.java index 73cd20d46a8..20c89c93cc3 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtNullableType.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtNullableType.java @@ -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 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)); } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtTypeReference.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtTypeReference.kt index c2069719b32..6284aed590c 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtTypeReference.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtTypeReference.kt @@ -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 { return modifierList?.annotations.orEmpty() diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java index 81726831539..db2fe65e4cd 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtStubElementTypes.java @@ -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); } diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtTokenSets.java b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtTokenSets.java new file mode 100644 index 00000000000..3cd9ee271e7 --- /dev/null +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtTokenSets.java @@ -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); + +}