Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 059d679

Browse files
committed
Kotlin: Tweak the definition of "eqwuivalent TRAP file"
TRAP files that only differ in their comments are equivalent
1 parent c3dd35d commit 059d679

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,20 @@ class TrapWriter (
195195
}
196196
}
197197

198-
private fun identical(f1: File, f2: File): Boolean {
198+
private fun equivalentTrap(f1: File, f2: File): Boolean {
199199
f1.bufferedReader().use { bw1 ->
200200
f2.bufferedReader().use { bw2 ->
201201
while(true) {
202202
val l1 = bw1.readLine()
203203
val l2 = bw2.readLine()
204-
if (l1 != l2) {
205-
return false
206-
} else if (l1 == null) {
204+
if (l1 == null && l2 == null) {
207205
return true
206+
} else if (l1 == null || l2 == null) {
207+
return false
208+
} else if (l1 != l2) {
209+
if (!l1.startsWith("//") || !l2.startsWith("//")) {
210+
return false
211+
}
208212
}
209213
}
210214
}
@@ -242,7 +246,7 @@ fun doFile(invocationTrapFile: String, checkTrapIdentical: Boolean, logger: Logg
242246
fileExtractor.extractFile(id)
243247
}
244248
if (checkTrapIdentical && trapFile.exists()) {
245-
if(identical(trapTmpFile, trapFile)) {
249+
if(equivalentTrap(trapTmpFile, trapFile)) {
246250
if(!trapTmpFile.delete()) {
247251
logger.warn("Failed to delete $trapTmpFile")
248252
}

0 commit comments

Comments
 (0)