From 7bda00cb5b164b617076e4eda3a0ed2498597dda Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Mon, 18 Nov 2024 18:37:56 +0000 Subject: [PATCH] KE2: Use the right file numbers The thread that did the extraction could see the file number counter after it had been incremented (possibly multiple times) by the main thread. This fixes some consistency query failures in tests. --- java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt index ee100bb6c79..69ca187359f 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt @@ -238,6 +238,7 @@ fun doAnalysis( var fileNumber = 0 val dump_psi = System.getenv("CODEQL_EXTRACTOR_JAVA_KOTLIN_DUMP") == "true" for (psiFile in psiFiles) { + val thisFileNumber = fileNumber++ launch { extractorThreads.withPermit { if (psiFile is KtFile) { @@ -251,11 +252,11 @@ fun doAnalysis( val fileDiagnosticTrapWriter = dtw.makeSourceFileTrapWriter(psiFile, true) fileDiagnosticTrapWriter.writeCompilation_compiling_files( compilation, - fileNumber, + thisFileNumber, fileDiagnosticTrapWriter.fileId ) doFile( - fileNumber, + thisFileNumber, compression, /* OLD: KE1 @@ -277,7 +278,7 @@ fun doAnalysis( ) fileDiagnosticTrapWriter.writeCompilation_compiling_files_completed( compilation, - fileNumber, + thisFileNumber, fileExtractionProblems.extractionResult() ) // We catch Throwable rather than Exception, as we want to @@ -295,7 +296,6 @@ fun doAnalysis( } } } - fileNumber += 1 } } }