From 92a2b51be03161f20c64c341af15dd81bb833a64 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Thu, 29 Aug 2024 14:49:27 +0100 Subject: [PATCH] KE2: Pass the trap writer in to the file extractor --- .../src/main/kotlin/KotlinExtractor.kt | 3 +++ .../src/main/kotlin/KotlinFileExtractor.kt | 14 +++++++++++--- .../src/main/kotlin/TrapWriter.kt | 5 +---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt index f55e8bb444f..2d610fb1230 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinExtractor.kt @@ -534,7 +534,10 @@ OLD: KE1 /* OLD: KE1 logger, +*/ sftw, +/* +OLD: KE1 linesOfCode, srcFilePath, null, diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt index 0559c111a8f..8b11e0aedf6 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt @@ -77,7 +77,10 @@ open class KotlinFileExtractor( /* OLD: KE1 override val logger: FileLogger, - override val tw: FileTrapWriter, +*/ + /* TODO override */ val tw: FileTrapWriter, +/* +OLD: KE1 val linesOfCode: LinesOfCode?, val filePath: String, dependencyCollector: OdasaOutput.TrapFileManager?, @@ -112,7 +115,6 @@ OLD: KE1 is KtNamed -> element.getNameAsName()?.asString() ?: "" else -> "" } - TODO() /* OLD: KE1 val loc = tw.getLocationString(element) @@ -122,9 +124,15 @@ OLD: KE1 val depth = context.size val depthDescription = "${"-".repeat(depth)} (${depth.toString()})" logger.trace("$depthDescription: Starting a $kind ($name) at $loc") +*/ val result = f() +/* +OLD: KE1 logger.trace("$depthDescription: Finished a $kind ($name) at $loc") +*/ return result +/* +OLD: KE1 } catch (exception: Exception) { throw Exception("While extracting a $kind ($name) at $loc", exception) } finally { @@ -135,9 +143,9 @@ OLD: KE1 fun extractFileContents(file: KtFile, id: Label) { with("file", file) { + val locId = tw.getWholeFileLocation() /* OLD: KE1 - val locId = tw.getWholeFileLocation() val pkg = file.packageFqName.asString() val pkgId = extractPackage(pkg) tw.writeHasLocation(id, locId) diff --git a/java/kotlin-extractor2/src/main/kotlin/TrapWriter.kt b/java/kotlin-extractor2/src/main/kotlin/TrapWriter.kt index 1a90c45b530..2f6c00738a6 100644 --- a/java/kotlin-extractor2/src/main/kotlin/TrapWriter.kt +++ b/java/kotlin-extractor2/src/main/kotlin/TrapWriter.kt @@ -205,8 +205,6 @@ OLD: HE1 } } -/* -OLD: HE1 /** * If you have an ID for a file, then this gets a label for the location representing the whole * of that file. @@ -214,7 +212,6 @@ OLD: HE1 fun getWholeFileLocation(fileId: Label): Label { return getLocation(fileId, 0, 0, 0, 0) } -*/ /** * Write a raw string into the TRAP file. @@ -412,11 +409,11 @@ OLD: KE1 // to be 0. return "file://$filePath" } +*/ /** Gets a label for the location representing the whole of this file. */ fun getWholeFileLocation(): Label { return getWholeFileLocation(fileId) } -*/ } /*