зеркало из https://github.com/github/codeql.git
Merge pull request #14529 from igfoo/igfoo/classid_fqname
Kotlin: Don't convert back and forth between ClassId and FqName
This commit is contained in:
Коммит
a4ef183a2e
|
@ -139,7 +139,7 @@ open class KotlinUsesExtractor(
|
|||
}
|
||||
|
||||
fun getJavaEquivalentClass(c: IrClass) =
|
||||
getJavaEquivalentClassId(c)?.let { getClassByFqName(pluginContext, it.asSingleFqName()) }?.owner
|
||||
getJavaEquivalentClassId(c)?.let { getClassByClassId(pluginContext, it) }?.owner
|
||||
|
||||
/**
|
||||
* Gets a KotlinFileExtractor based on this one, except it attributes locations to the file that declares the given class.
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.codeql.utils
|
|||
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
|
@ -9,6 +10,10 @@ fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSym
|
|||
return pluginContext.referenceClass(fqName)
|
||||
}
|
||||
|
||||
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
|
||||
return getClassByFqName(pluginContext, id.asSingleFqName())
|
||||
}
|
||||
|
||||
fun getFunctionsByFqName(pluginContext: IrPluginContext, pkgName: FqName, name: Name): Collection<IrSimpleFunctionSymbol> {
|
||||
val fqName = pkgName.child(name)
|
||||
return pluginContext.referenceFunctions(fqName)
|
||||
|
|
|
@ -10,6 +10,10 @@ import org.jetbrains.kotlin.name.Name
|
|||
|
||||
fun getClassByFqName(pluginContext: IrPluginContext, fqName: FqName): IrClassSymbol? {
|
||||
val id = ClassId.topLevel(fqName)
|
||||
return getClassByClassId(pluginContext, id)
|
||||
}
|
||||
|
||||
fun getClassByClassId(pluginContext: IrPluginContext, id: ClassId): IrClassSymbol? {
|
||||
return pluginContext.referenceClass(id)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче