From b980f7ca778333b801ad7a2e070646a0f6b57d0b Mon Sep 17 00:00:00 2001 From: Jason <11360596+jpenilla@users.noreply.github.com> Date: Thu, 26 May 2022 03:12:17 -0700 Subject: [PATCH] Fix remapping of records (#1) Use latest JLS for parser and add missing overrides to RemapperVisitor --- src/main/java/org/cadixdev/mercury/Mercury.java | 2 +- .../cadixdev/mercury/remapper/RemapperVisitor.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/cadixdev/mercury/Mercury.java b/src/main/java/org/cadixdev/mercury/Mercury.java index a6cdb80..c8f43d1 100644 --- a/src/main/java/org/cadixdev/mercury/Mercury.java +++ b/src/main/java/org/cadixdev/mercury/Mercury.java @@ -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 options = JavaCore.getOptions(); diff --git a/src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java b/src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java index 3447e72..3faa43c 100644 --- a/src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java +++ b/src/main/java/org/cadixdev/mercury/remapper/RemapperVisitor.java @@ -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; @@ -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()); @@ -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();