Closed jdneo closed 3 weeks ago
When the error is on the same line, there may be issues recovering the statement by the AST Parser. Ultimately, StringRangeFinder
(which is just an AST Visitor) fails to visit the StringLiteral
(never recovered).
Easy fix seems to be to call parser.setStatementsRecovery(true);
around https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/PasteEventHandler.java#L225-L226 . It might not recover every case, but it certainly does a better job. I can put together a PR.
https://github.com/user-attachments/assets/33bfdf76-f971-4285-b437-3c8986f29e3c