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

Skip to content

Commit 1b91a35

Browse files
smowtonigfoo
authored andcommitted
Truncate (but keep unique-ish) the names of very long file declarations
1 parent b26044b commit 1b91a35

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.github.codeql
22

33
import com.github.codeql.utils.*
44
import com.semmle.extractor.java.OdasaOutput
5+
import com.semmle.util.data.StringDigestor
56
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
67
import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf
78
import org.jetbrains.kotlin.backend.jvm.codegen.isRawType
@@ -257,7 +258,12 @@ open class KotlinUsesExtractor(
257258
}
258259

259260
val paramTypes = parameters.map { useType(erase(it.type)) }
260-
val signature = paramTypes.joinToString(separator = ",", prefix = "(", postfix = ")") { it.javaResult.signature!! }
261+
val possiblyLongSignature = paramTypes.joinToString(separator = ",", prefix = "(", postfix = ")") { it.javaResult.signature!! }
262+
// In order to avoid excessively long signatures which can lead to trap file names longer than the filesystem
263+
// limit, we truncate and add a hash to preserve uniqueness if necessary.
264+
val signature = if (possiblyLongSignature.length > 100) {
265+
possiblyLongSignature.substring(0, 42) + "#" + StringDigestor.digest(possiblyLongSignature).substring(0, 8)
266+
} else { possiblyLongSignature }
261267
dependencyCollector?.addDependency(f, signature)
262268
externalClassExtractor.extractLater(f, signature)
263269
}

0 commit comments

Comments
 (0)