From 093e69e0c63cca0aea7920b2df0f733fb5d37bc6 Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Sun, 8 Dec 2024 18:12:46 +0100 Subject: [PATCH] JavacConverter: Do not set/fix position for recovered names --- .../src/org/eclipse/jdt/core/dom/JavacConverter.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java index a5269350bbd..bd66548a04a 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java @@ -49,8 +49,9 @@ import com.sun.tools.javac.parser.ParserFactory; import com.sun.tools.javac.parser.Tokens.Comment; import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; -import com.sun.tools.javac.tree.DCTree.DCDocComment; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeInfo; +import com.sun.tools.javac.tree.DCTree.DCDocComment; import com.sun.tools.javac.tree.JCTree.JCAnnotatedType; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCAnyPattern; @@ -124,7 +125,6 @@ import com.sun.tools.javac.tree.JCTree.JCWildcard; import com.sun.tools.javac.tree.JCTree.JCYield; import com.sun.tools.javac.tree.JCTree.Tag; -import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.JCDiagnostic; import com.sun.tools.javac.util.Log; @@ -434,7 +434,9 @@ int commonSettingsGetLength(ASTNode res, JCTree javac) { void commonSettings(ASTNode res, JCTree javac, int length, boolean removeWhitespace) { if( javac != null && length >= 0) { - res.setSourceRange(javac.getStartPosition(), Math.max(0, length)); + if (!(res instanceof SimpleName name && FAKE_IDENTIFIER.equals(name.getIdentifier()))) { + res.setSourceRange(javac.getStartPosition(), Math.max(0, length)); + } if( removeWhitespace ) { removeSurroundingWhitespaceFromRange(res); } @@ -3479,7 +3481,7 @@ public void endVisit(QualifiedName node) { @Override public boolean visit(SimpleName name) { - if (name.getStartPosition() < 0) { + if (name.getStartPosition() < 0 && ! FAKE_IDENTIFIER.equals(name.getIdentifier())) { int foundOffset = findPositionOfText(name.getIdentifier(), name.getParent(), siblingsOf(name)); if (foundOffset >= 0) { name.setSourceRange(foundOffset, name.getIdentifier().length());