mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Kotlin: Add a comment to each TRAP file linking to its invocation TRAP file
This commit is contained in:
@@ -41,7 +41,7 @@ class KotlinExtractorExtension(private val invocationTrapFile: String, private v
|
||||
logger.flush()
|
||||
val srcDir = File(System.getenv("CODEQL_EXTRACTOR_JAVA_SOURCE_ARCHIVE_DIR").takeUnless { it.isNullOrEmpty() } ?: "kotlin-extractor/src")
|
||||
srcDir.mkdirs()
|
||||
moduleFragment.files.map { doFile(checkTrapIdentical, logger, trapDir, srcDir, it) }
|
||||
moduleFragment.files.map { doFile(invocationTrapFile, checkTrapIdentical, logger, trapDir, srcDir, it) }
|
||||
logger.printLimitedWarningCounts()
|
||||
// We don't want the compiler to continue and generate class
|
||||
// files etc, so we just exit when we are finished extracting.
|
||||
@@ -211,7 +211,7 @@ private fun identical(f1: File, f2: File): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun doFile(checkTrapIdentical: Boolean, logger: Logger, trapDir: File, srcDir: File, declaration: IrFile) {
|
||||
fun doFile(invocationTrapFile: String, checkTrapIdentical: Boolean, logger: Logger, trapDir: File, srcDir: File, declaration: IrFile) {
|
||||
val filePath = declaration.path
|
||||
logger.info("Extracting file $filePath")
|
||||
logger.flush()
|
||||
@@ -230,6 +230,7 @@ fun doFile(checkTrapIdentical: Boolean, logger: Logger, trapDir: File, srcDir: F
|
||||
if (checkTrapIdentical || !trapFile.exists()) {
|
||||
val trapTmpFile = File.createTempFile("$filePath.", ".trap.tmp", trapDir)
|
||||
trapTmpFile.bufferedWriter().use { trapFileBW ->
|
||||
trapFileBW.write("// Generated by invocation ${invocationTrapFile.replace("\n", "\n// ")}\n")
|
||||
val tw = TrapWriter(fileLabel, trapFileBW, declaration)
|
||||
val id: Label<DbFile> = tw.getLabelFor(fileLabel)
|
||||
tw.writeFiles(id, filePath, basename, extension, 0)
|
||||
|
||||
Reference in New Issue
Block a user