Skip to content

Commit 42f5279

Browse files
committed
Set range for missing name anyway
properly set offset, with a length of 0.
1 parent 23f3e25 commit 42f5279

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ int commonSettingsGetLength(ASTNode res, JCTree javac) {
485485

486486
void commonSettings(ASTNode res, JCTree javac, int length, boolean removeWhitespace) {
487487
if( javac != null && length >= 0) {
488-
if (!(res instanceof SimpleName name && FAKE_IDENTIFIER.equals(name.getIdentifier()))) {
488+
if (javac.getStartPosition() >= 0) {
489489
res.setSourceRange(javac.getStartPosition(), Math.max(0, length));
490490
}
491491
if( removeWhitespace ) {
@@ -3139,6 +3139,9 @@ Type convertToType(JCTree javac) {
31393139
if (javac instanceof JCErroneous || javac == null /* when there are syntax errors */) {
31403140
// returning null could result in upstream errors, so return a fake type
31413141
var res = this.ast.newSimpleType(this.ast.newSimpleName(FAKE_IDENTIFIER));
3142+
if (javac instanceof JCErroneous err) {
3143+
res.setSourceRange(err.getStartPosition(), 0);
3144+
}
31423145
res.setFlags(ASTNode.RECOVERED);
31433146
return res;
31443147
}

0 commit comments

Comments
 (0)