Skip to content

Commit

Permalink
Set range for missing name anyway
Browse files Browse the repository at this point in the history
properly set offset, with a length of 0.
  • Loading branch information
mickaelistria committed Jan 20, 2025
1 parent 485d20d commit cfe5b03
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ int commonSettingsGetLength(ASTNode res, JCTree javac) {

void commonSettings(ASTNode res, JCTree javac, int length, boolean removeWhitespace) {
if( javac != null && length >= 0) {
if (!(res instanceof SimpleName name && FAKE_IDENTIFIER.equals(name.getIdentifier()))) {
if (javac.getStartPosition() >= 0) {
res.setSourceRange(javac.getStartPosition(), Math.max(0, length));
}
if( removeWhitespace ) {
Expand Down Expand Up @@ -3139,6 +3139,9 @@ Type convertToType(JCTree javac) {
if (javac instanceof JCErroneous || javac == null /* when there are syntax errors */) {
// returning null could result in upstream errors, so return a fake type
var res = this.ast.newSimpleType(this.ast.newSimpleName(FAKE_IDENTIFIER));
if (javac instanceof JCErroneous err) {
res.setSourceRange(err.getStartPosition(), 0);
}
res.setFlags(ASTNode.RECOVERED);
return res;
}
Expand Down

0 comments on commit cfe5b03

Please sign in to comment.