mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Kotlin: getFunctionLabel: Small refactoring
We now pass the IrDeclarationParent of the function to the final getFunctionLabel function, and that takes care of finding the enclosing class.
This commit is contained in:
@@ -648,14 +648,14 @@ class X {
|
||||
classTypeArguments: List<IrTypeArgument>?
|
||||
): String {
|
||||
val parentId = useDeclarationParent(parent, false, classTypeArguments, true)
|
||||
return getFunctionLabel(getEnclosingClass(parent), parentId, name, parameters, returnType, extensionReceiverParameter, functionTypeParameters, classTypeArguments)
|
||||
return getFunctionLabel(parent, parentId, name, parameters, returnType, extensionReceiverParameter, functionTypeParameters, classTypeArguments)
|
||||
}
|
||||
|
||||
fun getFunctionLabel(f: IrFunction, parentId: Label<out DbElement>, classTypeArgsIncludingOuterClasses: List<IrTypeArgument>?) =
|
||||
getFunctionLabel(getEnclosingClass(f), parentId, getFunctionShortName(f), f.valueParameters, f.returnType, f.extensionReceiverParameter, getFunctionTypeParameters(f), classTypeArgsIncludingOuterClasses)
|
||||
getFunctionLabel(f.parent, parentId, getFunctionShortName(f), f.valueParameters, f.returnType, f.extensionReceiverParameter, getFunctionTypeParameters(f), classTypeArgsIncludingOuterClasses)
|
||||
|
||||
fun getFunctionLabel(
|
||||
enclosingClass: IrClass?,
|
||||
parent: IrDeclarationParent,
|
||||
parentId: Label<out DbElement>,
|
||||
name: String,
|
||||
parameters: List<IrValueParameter>,
|
||||
@@ -673,10 +673,12 @@ class X {
|
||||
}
|
||||
|
||||
val substitutionMap = classTypeArgsIncludingOuterClasses?.let { notNullArgs ->
|
||||
if (notNullArgs.isEmpty())
|
||||
if (notNullArgs.isEmpty()) {
|
||||
null
|
||||
else
|
||||
} else {
|
||||
val enclosingClass = getEnclosingClass(parent)
|
||||
enclosingClass?.let { notNullClass -> makeTypeGenericSubstitutionMap(notNullClass, notNullArgs) }
|
||||
}
|
||||
}
|
||||
val getIdForFunctionLabel = { it: IrValueParameter ->
|
||||
// Mimic the Java extractor's behaviour: functions with type parameters are named for their erased types;
|
||||
|
||||
Reference in New Issue
Block a user