mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
Change location of methods inside parameterized types
This commit is contained in:
@@ -287,14 +287,7 @@ open class KotlinFileExtractor(
|
||||
extractClassModifiers(c, id)
|
||||
extractClassSupertypes(c, id, if (argsIncludingOuterClasses == null) ExtractSupertypesMode.Raw else ExtractSupertypesMode.Specialised(argsIncludingOuterClasses))
|
||||
|
||||
val locId = if (argsIncludingOuterClasses != null && argsIncludingOuterClasses.isNotEmpty()) {
|
||||
val binaryPath = getIrClassBinaryPath(c)
|
||||
val newTrapWriter = tw.makeFileTrapWriter(binaryPath, true)
|
||||
newTrapWriter.getWholeFileLocation()
|
||||
} else {
|
||||
tw.getLocation(c)
|
||||
}
|
||||
|
||||
val locId = getLocation(c, argsIncludingOuterClasses)
|
||||
tw.writeHasLocation(id, locId)
|
||||
|
||||
// Extract the outer <-> inner class relationship, passing on any type arguments in excess to this class' parameters.
|
||||
@@ -304,6 +297,21 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLocation(decl: IrDeclaration, typeArgs: List<IrTypeArgument>?): Label<DbLocation> {
|
||||
return if (typeArgs != null && typeArgs.isNotEmpty()) {
|
||||
val c = getContainingClassOrSelf(decl)
|
||||
if (c == null) {
|
||||
tw.getLocation(decl)
|
||||
} else {
|
||||
val binaryPath = getIrClassBinaryPath(c)
|
||||
val newTrapWriter = tw.makeFileTrapWriter(binaryPath, true)
|
||||
newTrapWriter.getWholeFileLocation()
|
||||
}
|
||||
} else {
|
||||
tw.getLocation(decl)
|
||||
}
|
||||
}
|
||||
|
||||
// `typeArgs` can be null to describe a raw generic type.
|
||||
// For non-generic types it will be zero-length list.
|
||||
fun extractMemberPrototypes(c: IrClass, argsIncludingOuterClasses: List<IrTypeArgument>?, id: Label<out DbClassorinterface>) {
|
||||
@@ -630,8 +638,6 @@ open class KotlinFileExtractor(
|
||||
|
||||
getFunctionTypeParameters(f).mapIndexed { idx, tp -> extractTypeParameter(tp, idx) }
|
||||
|
||||
val locId = tw.getLocation(f)
|
||||
|
||||
val id =
|
||||
if (idOverride != null)
|
||||
idOverride
|
||||
@@ -686,6 +692,7 @@ open class KotlinFileExtractor(
|
||||
tw.writeMethodsKotlinType(methodId, returnType.kotlinResult.id)
|
||||
}
|
||||
|
||||
val locId = getLocation(f, classTypeArgsIncludingOuterClasses)
|
||||
tw.writeHasLocation(id, locId)
|
||||
val body = f.body
|
||||
if (body != null && extractBody) {
|
||||
|
||||
Reference in New Issue
Block a user