[psi] avoid usage of SAFE_IDENTIFIER_FOR_NO_NAME

This name leads to inconsistency between FqName from stub and
FqName from ClassId.
The first one is `no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40`
but the second one is `<no name provided>`.
We can't just replace SAFE_IDENTIFIER_FOR_NO_NAME to NO_NAME_PROVIDED
due to many places with unsafe logic inside type mapping.

^KTIJ-26848 Fixed
This commit is contained in:
Dmitrii Gridin
2023-08-30 20:59:10 +02:00
committed by Space Team
parent ae02d78aff
commit bd10ee10fe
4 changed files with 7 additions and 23 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 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.
*/
@@ -11,7 +11,6 @@ import com.intellij.psi.impl.DebugUtil
import com.intellij.psi.stubs.PsiFileStub
import com.intellij.psi.stubs.StubElement
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.stubs.impl.STUB_TO_STRING_PREFIX
import org.jetbrains.kotlin.test.KotlinTestUtils
import java.nio.file.Paths
@@ -47,7 +46,7 @@ fun StubElement<out PsiElement>.serializeToString(): String {
}
private fun serializeStubToString(stubElement: StubElement<*>): String {
val treeStr = DebugUtil.stubTreeToString(stubElement).replace(SpecialNames.SAFE_IDENTIFIER_FOR_NO_NAME.asString(), "<no name>")
val treeStr = DebugUtil.stubTreeToString(stubElement)
// Nodes are stored in form "NodeType:Node" and have too many repeating information for Kotlin stubs
// Remove all repeating information (See KotlinStubBaseImpl.toString())