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

Skip to content

Commit 2f0ad50

Browse files
tamasvajkigfoo
authored andcommitted
Adjust trap file names of external file class declarations
1 parent f5383bb commit 2f0ad50

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

java/kotlin-extractor/src/main/java/com/semmle/extractor/java/OdasaOutput.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,19 @@ private File trapFileForDecl(IrDeclaration sym, String signature) {
213213
private final Map<String, String> memberTrapPaths = new LinkedHashMap<String, String>();
214214
private static final Pattern dots = Pattern.compile(".", Pattern.LITERAL);
215215
private String trapFilePathForDecl(IrDeclaration sym, String signature) {
216-
String binaryName = getIrDeclBinaryName(sym, signature);
216+
String binaryName = getIrDeclBinaryName(sym);
217+
String binaryNameWithSignature = binaryName + signature;
217218
// TODO: Reinstate this?
218219
//if (getTrackClassOrigins())
219220
// classId += "-" + StringDigestor.digest(sym.getSourceFileId());
220-
String result = memberTrapPaths.get(binaryName);
221+
String result = memberTrapPaths.get(binaryNameWithSignature);
221222
if (result == null) {
222223
result = CLASSES_DIR + "/" +
223224
dots.matcher(binaryName).replaceAll("/") +
225+
signature +
224226
".members" +
225227
".trap.gz";
226-
memberTrapPaths.put(binaryName, result);
228+
memberTrapPaths.put(binaryNameWithSignature, result);
227229
}
228230
return result;
229231
}

java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
1313
// Adapted from Kotlin's interpreter/Utils.kt function 'internalName'
1414
// Translates class names into their JLS section 13.1 binary name,
1515
// and declarations within them into the parent class' JLS 13.1 name as
16-
// specified above, followed by a `$` separator and then a unique identifier
17-
// for `that`, consisting of its short name followed by any supplied signature.
18-
fun getIrDeclBinaryName(that: IrDeclaration, signature: String): String {
16+
// specified above, followed by a `$` separator and then the short name
17+
// for `that`.
18+
fun getIrDeclBinaryName(that: IrDeclaration): String {
1919
val shortName = when(that) {
2020
is IrDeclarationWithName -> that.name.asString()
2121
else -> "(unknown-name)"
2222
}
23-
val internalName = StringBuilder(shortName + signature);
23+
val internalName = StringBuilder(shortName);
2424
generateSequence(that.parent) { (it as? IrDeclaration)?.parent }
2525
.forEach {
2626
when (it) {
@@ -75,5 +75,5 @@ fun getRawIrClassBinaryPath(irClass: IrClass) =
7575
fun getIrClassBinaryPath(irClass: IrClass): String {
7676
return getRawIrClassBinaryPath(irClass)
7777
// Otherwise, make up a fake location:
78-
?: "/!unknown-binary-location/${getIrDeclBinaryName(irClass, "").replace(".", "/")}.class"
78+
?: "/!unknown-binary-location/${getIrDeclBinaryName(irClass).replace(".", "/")}.class"
7979
}

0 commit comments

Comments
 (0)