Skip to content

Commit

Permalink
patch var keywords forcing implicit imports into remapped source files (
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar authored Oct 14, 2024
1 parent 11db15e commit d68c8f7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,16 @@ private void remapType(SimpleName node, ITypeBinding binding) {
}

String qualifiedName = (mapping != null ? mapping.getFullDeobfuscatedName().replace('/', '.') : binding.getBinaryName()).replace('$', '.');
String newName = this.importRewrite.addImport(qualifiedName, this.importStack.peek());

if (!node.getIdentifier().equals(newName) && !node.isVar()) {
if (newName.indexOf('.') == -1) {
this.context.createASTRewrite().set(node, SimpleName.IDENTIFIER_PROPERTY, newName, null);
} else {
// Qualified name
this.context.createASTRewrite().replace(node, node.getAST().newName(newName), null);
if(!node.isVar()) {
String newName = this.importRewrite.addImport(qualifiedName, this.importStack.peek());
if(!node.getIdentifier().equals(newName)) {
if(newName.indexOf('.') == -1) {
this.context.createASTRewrite().set(node, SimpleName.IDENTIFIER_PROPERTY, newName, null);
} else {
// Qualified name
this.context.createASTRewrite().replace(node, node.getAST().newName(newName), null);
}
}
}
}
Expand Down

0 comments on commit d68c8f7

Please sign in to comment.