Skip to content

Conversation

@datho7561
Copy link
Contributor

@datho7561 datho7561 commented Nov 6, 2025

What it does

Fixes #4530.

Recover statements in method bodies with syntax errors when parsing using ASTParser.

Also recover expressions as expression statements.

How to test

I've added unit tests.

Author checklist

@datho7561
Copy link
Contributor Author

datho7561 commented Nov 7, 2025

This recovers statements after the lambda statement but does not recover "String".var into "String".var = $missing$;, so the postfix completion doesn't work as expected.

It should recover "String".var into "String".var = $missing$; now.

@datho7561 datho7561 force-pushed the fix-lambda-recovery branch 2 times, most recently from 4d00832 to 2f8d482 Compare November 12, 2025 21:24
@datho7561 datho7561 changed the title [WIP] Fix lambda statement recovery in AST generated by ASTParser Improve statement recovery in AST generated by ASTParser when there's a lambda Nov 12, 2025
@datho7561 datho7561 marked this pull request as ready for review November 12, 2025 21:26
@datho7561 datho7561 force-pushed the fix-lambda-recovery branch 5 times, most recently from 8043c1a to 51a3e29 Compare November 18, 2025 20:06
@datho7561
Copy link
Contributor Author

I'm trying to remember if the error in Jenkins secretly means I've caused too many test errors for Jenkins to process or perhaps one of the test failures has a really long result string, but I'm not really sure. I usually see this error when Jenkins isn't functioning correctly.

@datho7561
Copy link
Contributor Author

Tests are failing (locally) because using this aggressive statement recovery gets rid of some of the compiler errors somehow (eg. missing ; errors are not reported). I'll need to continue to investigate.

Also, recover expressions as an expression statement.

i.e. when there is this source in a method:

```java
{
    ...
    "String".var
    ...
...
}
```

jdt.ui expects it to be recovered like this:

```java
{
    ...
    "String".var = $missing$;
    ...
```

Where `$missing$` is a fake, empty identifier.

Currently, in some cases, the `"String".var` is being completely
discarded, and this should improve that.

Related to eclipse-jdt#4530

Signed-off-by: David Thompson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stream chained method call doesn't show up in the AST when there are compiler problems after it

1 participant