From 298494fa08d11b9c374368aac4ae547b6f972f1a Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Wed, 14 Sep 2022 10:40:53 +0200 Subject: [PATCH] Drop KtStubElementTypes.FILE FILE elements are always registered eagerly on parser definition load and should not be mentioned in stubElementTypeHolder interfaces. KtFileElementType.INSTANCE was defined in 2 places, first as getFileNodeType of KotlinParserDefinition and second is KtStubElementTypes. In order to ensure that there are no conflicts in stubs the platform needs to recheck these 2 declarations, and it triggers loading of KtStubElementTypes fields. We do not need to declare FILE element in KtStubElementTypes and may just remove this declaration as excessive. This will delay init of KtStubElementTypes to the moment when Kotlin files appear in indexes. #KT-53781 --- .../kotlin/psi/stubs/elements/KtStubElementTypes.java | 2 -- .../org/jetbrains/kotlin/psi/stubs/impl/KotlinFileStubImpl.kt | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) 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 db2fe65e4cd..ecd124b3402 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 @@ -19,8 +19,6 @@ package org.jetbrains.kotlin.psi.stubs.elements; import org.jetbrains.kotlin.psi.*; public interface KtStubElementTypes { - KtFileElementType FILE = KtFileElementType.INSTANCE; - KtClassElementType CLASS = new KtClassElementType("CLASS"); KtFunctionElementType FUNCTION = new KtFunctionElementType("FUN"); KtPropertyElementType PROPERTY = new KtPropertyElementType("PROPERTY"); diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinFileStubImpl.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinFileStubImpl.kt index 009dd5bd592..bd766557919 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinFileStubImpl.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/impl/KotlinFileStubImpl.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.stubs.KotlinFileStub import org.jetbrains.kotlin.psi.stubs.KotlinImportAliasStub import org.jetbrains.kotlin.psi.stubs.KotlinImportDirectiveStub -import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.FILE +import org.jetbrains.kotlin.psi.stubs.elements.KtFileElementType import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.IMPORT_LIST import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull @@ -59,7 +59,7 @@ class KotlinFileStubImpl( override fun getPackageFqName(): FqName = FqName(packageName) override fun isScript(): Boolean = isScript - override fun getType(): IStubFileElementType = FILE + override fun getType(): IStubFileElementType = KtFileElementType.INSTANCE override fun toString(): String = "PsiJetFileStubImpl[" + "package=" + getPackageFqName().asString() + "]"