Skip to content

Commit

Permalink
Fix remapping of records (#1)
Browse files Browse the repository at this point in the history
Use latest JLS for parser and add missing overrides to RemapperVisitor
  • Loading branch information
jpenilla authored May 26, 2022
1 parent e869f1a commit b980f7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/cadixdev/mercury/Mercury.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void cleanup() {
}

private void run() throws Exception {
ASTParser parser = ASTParser.newParser(AST.JLS10);
ASTParser parser = ASTParser.newParser(AST.getJLSLatest());

// Set Java version
Map<String, String> options = JavaCore.getOptions();
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.QualifiedType;
import org.eclipse.jdt.core.dom.RecordDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.TagElement;
Expand Down Expand Up @@ -428,6 +429,12 @@ public boolean visit(EnumDeclaration node) {
return true;
}

@Override
public boolean visit(RecordDeclaration node) {
pushImportContext(node.resolveBinding());
return true;
}

@Override
public boolean visit(TypeDeclaration node) {
pushImportContext(node.resolveBinding());
Expand All @@ -449,6 +456,11 @@ public void endVisit(EnumDeclaration node) {
this.importStack.pop();
}

@Override
public void endVisit(RecordDeclaration node) {
this.importStack.pop();
}

@Override
public void endVisit(TypeDeclaration node) {
this.importStack.pop();
Expand Down

0 comments on commit b980f7c

Please sign in to comment.