diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtFunctionElementType.java b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtFunctionElementType.java index b78ce15dede..8f8de4aac97 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtFunctionElementType.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/stubs/elements/KtFunctionElementType.java @@ -34,6 +34,8 @@ import java.io.IOException; public class KtFunctionElementType extends KtStubElementType { + private static final String NAME = "kotlin.FUNCTION"; + public KtFunctionElementType(@NotNull @NonNls String debugName) { super(debugName, KtNamedFunction.class, KotlinFunctionStub.class); } @@ -93,4 +95,10 @@ public class KtFunctionElementType extends KtStubElementType, PsiT exten @NotNull @Override public String getExternalId() { - return "kotlin." + toString(); + return "kotlin." + getDebugName(); } @Override diff --git a/compiler/tests/org/jetbrains/kotlin/psi/KtStubElementTypesExternalIdTest.kt b/compiler/tests/org/jetbrains/kotlin/psi/KtStubElementTypesExternalIdTest.kt new file mode 100644 index 00000000000..4d6f3f34036 --- /dev/null +++ b/compiler/tests/org/jetbrains/kotlin/psi/KtStubElementTypesExternalIdTest.kt @@ -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 + +import com.intellij.psi.stubs.ObjectStubSerializer +import junit.framework.TestCase +import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes + +class KtStubElementTypesExternalIdTest : TestCase() { + fun testExternalIds() { + val clazz = KtStubElementTypes::class.java + for (declaredField in clazz.declaredFields) { + val stubSerializer = declaredField.get(null) as? ObjectStubSerializer<*, *> ?: continue + val name = declaredField.name + val externalId = stubSerializer.externalId + assertEquals("kotlin.$name", externalId) + } + } +} \ No newline at end of file