Skip to content

Commit

Permalink
JavacConverter: Do not set/fix position for recovered names
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Dec 8, 2024
1 parent efb3416 commit 093e69e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 093e69e

Please sign in to comment.