Align externalId
externalId for any field in stubElementTypeHolder has to be prefix (`kotlin`) + dot (`.`) + field name #KT-53781
This commit is contained in:
committed by
Space
parent
24dfb14654
commit
79d1ca0504
@@ -34,6 +34,8 @@ import java.io.IOException;
|
||||
|
||||
public class KtFunctionElementType extends KtStubElementType<KotlinFunctionStub, KtNamedFunction> {
|
||||
|
||||
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<KotlinFunctionStub,
|
||||
public void indexStub(@NotNull KotlinFunctionStub stub, @NotNull IndexSink sink) {
|
||||
StubIndexService.getInstance().indexFunction(stub, sink);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalId() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public abstract class KtStubElementType<StubT extends StubElement<?>, PsiT exten
|
||||
@NotNull
|
||||
@Override
|
||||
public String getExternalId() {
|
||||
return "kotlin." + toString();
|
||||
return "kotlin." + getDebugName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user