Skip to content

Commit

Permalink
#88: Fix excluding packages in TSRG files
Browse files Browse the repository at this point in the history
Closes #84
  • Loading branch information
Su5eD authored Jul 13, 2024
1 parent 3f7472b commit c8cfc2a
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/main/java/net/md_5/specialsource/JarMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,17 @@ private void parseCsrgLine(String line, MappingTransformer inputTransformer, Map
String oldClassName = inputTransformer.transformClassName(tokens[0]);
String newClassName = outputTransformer.transformClassName(tokens[1]);

if (reverse) {
String temp = newClassName;
newClassName = oldClassName;
oldClassName = temp;
}

if (oldClassName.endsWith("/")) {
if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored PK: " + oldClassName + " " + newClassName);
return;
}

// package names always either 1) suffixed with '/', or 2) equal to '.' to signify default package
if (!newClassName.equals(".") && !newClassName.endsWith("/")) {
Expand All @@ -465,18 +475,16 @@ private void parseCsrgLine(String line, MappingTransformer inputTransformer, Map
}

// Special case: mapping an entire hierarchy of classes
if (reverse) {
packages.put(newClassName, oldClassName);
} else {
packages.put(oldClassName, newClassName);
}
packages.put(oldClassName, newClassName);
} else {
if (reverse) {
classes.put(newClassName, oldClassName);
} else {
classes.put(oldClassName, newClassName);
}
currentClass = tokens[0];

if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored CL: " + oldClassName + " " + newClassName);
return;
}

classes.put(oldClassName, newClassName);
}
} else if (tokens.length == 3) {
String oldClassName = inputTransformer.transformClassName(tokens[0]);
Expand All @@ -495,6 +503,11 @@ private void parseCsrgLine(String line, MappingTransformer inputTransformer, Map
oldFieldName = temp;
}

if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored FD: " + oldClassName + "/" + oldFieldName + " -> " + newFieldName);
return;
}

fields.put(oldClassName + "/" + oldFieldName, newFieldName);
} else if (tokens.length == 4) {
String oldClassName = inputTransformer.transformClassName(tokens[0]);
Expand All @@ -515,6 +528,11 @@ private void parseCsrgLine(String line, MappingTransformer inputTransformer, Map
oldMethodName = temp;
}

if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored MD: " + oldClassName + "/" + oldMethodName + " -> " + newMethodName);
return;
}

methods.put(oldClassName + "/" + oldMethodName + " " + oldMethodDescriptor, newMethodName);
} else {
throw new IOException("Invalid csrg file line, token count " + tokens.length + " unexpected in " + line);
Expand Down

0 comments on commit c8cfc2a

Please sign in to comment.