mirror of
https://github.com/github/codeql.git
synced 2026-05-24 16:17:07 +02:00
Fix review findings
This commit is contained in:
@@ -1336,38 +1336,6 @@ OLD: KE1
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractValueParameter(
|
||||
id: Label<out DbParam>,
|
||||
t: IrType,
|
||||
name: String,
|
||||
locId: Label<DbLocation>,
|
||||
parent: Label<out DbCallable>,
|
||||
idx: Int,
|
||||
paramSourceDeclaration: Label<out DbParam>,
|
||||
syntheticParameterNames: Boolean,
|
||||
isVararg: Boolean,
|
||||
isNoinline: Boolean,
|
||||
isCrossinline: Boolean
|
||||
): TypeResults {
|
||||
val type = useType(t)
|
||||
tw.writeParams(id, type.javaResult.id, idx, parent, paramSourceDeclaration)
|
||||
tw.writeParamsKotlinType(id, type.kotlinResult.id)
|
||||
tw.writeHasLocation(id, locId)
|
||||
if (!syntheticParameterNames) {
|
||||
tw.writeParamName(id, name)
|
||||
}
|
||||
if (isVararg) {
|
||||
tw.writeIsVarargsParam(id)
|
||||
}
|
||||
if (isNoinline) {
|
||||
addModifiers(id, "noinline")
|
||||
}
|
||||
if (isCrossinline) {
|
||||
addModifiers(id, "crossinline")
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
/**
|
||||
* mkContainerLabel is a lambda so that we get laziness: If the container is a file, then we
|
||||
* don't want to extract the file class unless something actually needs it.
|
||||
|
||||
@@ -60,31 +60,28 @@ class TrapLabelManager {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This will only be used in a TrapWriter for a source file, not a diagnostic TRAP writer. Consider moving this out of this class
|
||||
private val locallyVisibleFunctionLabelMapping: MutableMap<KaFunctionSymbol, LocallyVisibleFunctionLabels> =
|
||||
mutableMapOf()
|
||||
|
||||
fun getLocallyVisibleFunctionLabelMapping(
|
||||
key: KaFunctionSymbol
|
||||
): LocallyVisibleFunctionLabels {
|
||||
lock.withLock {
|
||||
return locallyVisibleFunctionLabelMapping[key]!!
|
||||
}
|
||||
return locallyVisibleFunctionLabelMapping[key]!!
|
||||
}
|
||||
|
||||
fun getOrAddLocallyVisibleFunctionLabelMapping(
|
||||
key: KaFunctionSymbol,
|
||||
add: (KaFunctionSymbol) -> LocallyVisibleFunctionLabels
|
||||
): LocallyVisibleFunctionLabels {
|
||||
lock.withLock {
|
||||
val res = locallyVisibleFunctionLabelMapping[key]
|
||||
if (res != null) {
|
||||
return res
|
||||
}
|
||||
|
||||
val labels = add(key)
|
||||
locallyVisibleFunctionLabelMapping[key] = labels
|
||||
return labels
|
||||
val res = locallyVisibleFunctionLabelMapping[key]
|
||||
if (res != null) {
|
||||
return res
|
||||
}
|
||||
|
||||
val labels = add(key)
|
||||
locallyVisibleFunctionLabelMapping[key] = labels
|
||||
return labels
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -643,12 +643,11 @@ OLD: KE1
|
||||
fun KotlinFileExtractor.extractValueParameter(
|
||||
id: Label<out DbParam>,
|
||||
t: KaType,
|
||||
name: String,
|
||||
name: String?,
|
||||
locId: Label<DbLocation>,
|
||||
parent: Label<out DbCallable>,
|
||||
idx: Int,
|
||||
paramSourceDeclaration: Label<out DbParam>,
|
||||
syntheticParameterNames: Boolean,
|
||||
isVararg: Boolean,
|
||||
isNoinline: Boolean,
|
||||
isCrossinline: Boolean
|
||||
@@ -657,7 +656,7 @@ fun KotlinFileExtractor.extractValueParameter(
|
||||
tw.writeParams(id, type.javaResult.id, idx, parent, paramSourceDeclaration)
|
||||
tw.writeParamsKotlinType(id, type.kotlinResult.id)
|
||||
tw.writeHasLocation(id, locId)
|
||||
if (!syntheticParameterNames) {
|
||||
if (name != null) {
|
||||
tw.writeParamName(id, name)
|
||||
}
|
||||
if (isVararg) {
|
||||
|
||||
@@ -90,7 +90,8 @@ fun KotlinFileExtractor.extractFunctionLiteral(
|
||||
// `kotlin.FunctionX<,,,>.invoke(,,)`
|
||||
functionSymbol,
|
||||
e,
|
||||
listOf(builtinTypes.any, functionType)
|
||||
listOf(builtinTypes.any, functionType),
|
||||
CompilerGeneratedKinds.CALLABLE_CLASS
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -257,7 +258,6 @@ private fun KotlinFileExtractor.addFunctionManual(
|
||||
methodId,
|
||||
idx,
|
||||
paramId,
|
||||
syntheticParameterNames = false,
|
||||
isVararg = false,
|
||||
isNoinline = false,
|
||||
isCrossinline = false
|
||||
@@ -406,7 +406,7 @@ private fun KotlinFileExtractor.extractGeneratedClass(
|
||||
localFunction: KaFunctionSymbol,
|
||||
elementToReportOn: PsiElement,
|
||||
superTypes: List<KaType>,
|
||||
compilerGeneratedKindOverride: CompilerGeneratedKinds? = null // OLD: KE1
|
||||
compilerGeneratedKindOverride: CompilerGeneratedKinds
|
||||
): Label<out DbClassorinterface> {
|
||||
val ids = tw.lm.getLocallyVisibleFunctionLabelMapping(localFunction)
|
||||
|
||||
@@ -448,8 +448,7 @@ private fun KotlinFileExtractor.extractGeneratedClass(
|
||||
superTypes: List<KaType>,
|
||||
locId: Label<DbLocation>,
|
||||
elementToReportOn: PsiElement,
|
||||
compilerGeneratedKindOverride: CompilerGeneratedKinds? = null,
|
||||
superConstructorSelector: (KaFunctionSymbol) -> Boolean = { it.valueParameters.isEmpty() },
|
||||
compilerGeneratedKindOverride: CompilerGeneratedKinds,
|
||||
extractSuperConstructorArgs: (Label<DbSuperconstructorinvocationstmt>) -> Unit = {},
|
||||
/*
|
||||
OLD: KE1
|
||||
@@ -460,10 +459,7 @@ private fun KotlinFileExtractor.extractGeneratedClass(
|
||||
val id = ids.type.javaResult.id.cast<DbClassorinterface>()
|
||||
val pkgId = extractPackage("")
|
||||
tw.writeClasses_or_interfaces(id, "", pkgId, id)
|
||||
tw.writeCompiler_generated(
|
||||
id,
|
||||
(compilerGeneratedKindOverride ?: CompilerGeneratedKinds.CALLABLE_CLASS).kind
|
||||
)
|
||||
tw.writeCompiler_generated(id, compilerGeneratedKindOverride.kind)
|
||||
tw.writeHasLocation(id, locId)
|
||||
|
||||
// Extract constructor
|
||||
@@ -485,7 +481,7 @@ private fun KotlinFileExtractor.extractGeneratedClass(
|
||||
} else {
|
||||
val baseConstructor =
|
||||
baseClass.scope?.declarationScope?.constructors?.find {
|
||||
superConstructorSelector(it)
|
||||
it.valueParameters.isEmpty()
|
||||
}
|
||||
if (baseConstructor == null) {
|
||||
logger.warnElement("Cannot find base constructor", elementToReportOn)
|
||||
|
||||
Reference in New Issue
Block a user