mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Kotlin: Add TrapWriter.writeComment
This commit is contained in:
@@ -132,8 +132,8 @@ fun doFile(invocationTrapFile: String,
|
||||
if (checkTrapIdentical || !trapFile.exists()) {
|
||||
val trapTmpFile = File.createTempFile("$filePath.", ".trap.tmp", trapFileDir)
|
||||
trapTmpFile.bufferedWriter().use { trapFileBW ->
|
||||
trapFileBW.write("// Generated by invocation ${invocationTrapFile.replace("\n", "\n// ")}\n")
|
||||
val tw = SourceFileTrapWriter(TrapLabelManager(), trapFileBW, file)
|
||||
tw.writeComment("Generated by invocation $invocationTrapFile")
|
||||
val externalClassExtractor = ExternalClassExtractor(logger, file.path, pluginContext)
|
||||
val fileExtractor = KotlinSourceFileExtractor(logger, tw, file, externalClassExtractor, pluginContext)
|
||||
fileExtractor.extractFileContents(tw.fileId)
|
||||
|
||||
@@ -71,6 +71,9 @@ open class TrapWriter (val lm: TrapLabelManager, val bw: BufferedWriter) {
|
||||
fun writeTrap(trap: String) {
|
||||
bw.write(trap)
|
||||
}
|
||||
fun writeComment(comment: String) {
|
||||
writeTrap("// ${comment.replace("\n", "\n// ")}\n")
|
||||
}
|
||||
fun flush() {
|
||||
bw.flush()
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ open class Logger(val logCounter: LogCounter, open val tw: TrapWriter) {
|
||||
}
|
||||
fun info(msg: String) {
|
||||
val fullMsg = "${timestamp()} $msg"
|
||||
tw.writeTrap("// " + fullMsg.replace("\n", "\n//") + "\n")
|
||||
tw.writeComment(fullMsg)
|
||||
println(fullMsg)
|
||||
}
|
||||
fun trace(msg: String) {
|
||||
@@ -104,7 +104,7 @@ open class Logger(val logCounter: LogCounter, open val tw: TrapWriter) {
|
||||
for((caller, count) in logCounter.warningCounts) {
|
||||
if(count >= logCounter.warningLimit) {
|
||||
val msg = "Total of $count warnings from $caller.\n"
|
||||
tw.writeTrap("// $msg")
|
||||
tw.writeComment(msg)
|
||||
print(msg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user