[Analysis API FIR] Use stable module name when mangling internal name
^KTIJ-25046
This commit is contained in:
committed by
teamcity
parent
a7396d8c10
commit
c956b4aeae
@@ -10,6 +10,7 @@ dependencies {
|
|||||||
api(project(":compiler:frontend.common.jvm"))
|
api(project(":compiler:frontend.common.jvm"))
|
||||||
api(project(":compiler:resolution.common.jvm"))
|
api(project(":compiler:resolution.common.jvm"))
|
||||||
api(project(":core:compiler.common.jvm"))
|
api(project(":core:compiler.common.jvm"))
|
||||||
|
implementation(project(":analysis:project-structure"))
|
||||||
compileOnly(intellijCore())
|
compileOnly(intellijCore())
|
||||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.asJava
|
|||||||
import com.intellij.lang.jvm.JvmModifier
|
import com.intellij.lang.jvm.JvmModifier
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
|
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtFakeLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtFakeLightClass
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
import org.jetbrains.kotlin.asJava.elements.*
|
import org.jetbrains.kotlin.asJava.elements.*
|
||||||
@@ -194,7 +195,8 @@ fun demangleInternalName(name: String): String? {
|
|||||||
return if (indexOfDollar >= 0) name.substring(0, indexOfDollar) else null
|
return if (indexOfDollar >= 0) name.substring(0, indexOfDollar) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mangleInternalName(name: String, moduleName: String): String {
|
fun mangleInternalName(name: String, module: KtSourceModule): String {
|
||||||
|
val moduleName = (module.stableModuleName ?: module.moduleName).removeSurrounding("<", ">")
|
||||||
return name + "$" + NameUtils.sanitizeAsJavaIdentifier(moduleName)
|
return name + "$" + NameUtils.sanitizeAsJavaIdentifier(moduleName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -92,6 +92,13 @@ public sealed interface KtModule {
|
|||||||
public interface KtSourceModule : KtModule {
|
public interface KtSourceModule : KtModule {
|
||||||
public val moduleName: String
|
public val moduleName: String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A stable binary name of module from the *Kotlin* point of view.
|
||||||
|
* Having correct module name is critical for `internal`-visibility mangling. See [org.jetbrains.kotlin.asJava.mangleInternalName]
|
||||||
|
*/
|
||||||
|
public val stableModuleName: String?
|
||||||
|
get() = null
|
||||||
|
|
||||||
override val moduleDescription: String
|
override val moduleDescription: String
|
||||||
get() = "Sources of $moduleName"
|
get() = "Sources of $moduleName"
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -117,8 +117,8 @@ internal abstract class SymbolLightMethodBase(
|
|||||||
if (containingClass is KtLightClassForFacade) return defaultName
|
if (containingClass is KtLightClassForFacade) return defaultName
|
||||||
if (hasPublishedApiAnnotation(annotationUseSiteTarget.toFilter())) return defaultName
|
if (hasPublishedApiAnnotation(annotationUseSiteTarget.toFilter())) return defaultName
|
||||||
|
|
||||||
val moduleName = (ktModule as? KtSourceModule)?.moduleName ?: return defaultName
|
val sourceModule = ktModule as? KtSourceModule ?: return defaultName
|
||||||
return mangleInternalName(defaultName, moduleName)
|
return mangleInternalName(defaultName, sourceModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fun isOverride(): Boolean
|
abstract fun isOverride(): Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user