Skip to content

Fix formatting on antlr error recovery#668

Open
anderson4j wants to merge 7 commits intomainfrom
fixFormatterOnParserRecovery
Open

Fix formatting on antlr error recovery#668
anderson4j wants to merge 7 commits intomainfrom
fixFormatterOnParserRecovery

Conversation

@anderson4j
Copy link
Copy Markdown
Collaborator

@anderson4j anderson4j commented Apr 1, 2026

Previosly we would error when ANTLR did error recovery for nodes in the middle of a query. We could already handle cases like
MATCH (n) WHERX (n:Person) RETURN n where the parsing fails completely in the middle. The formatter then only formats up until the "unparseable" part and inserts the rest of the query as-is.

Sometimes though, like in
MATCH (n:-) RETURN n antlr recovers, inserting an error-node on the - but correctly parsing the "RETURN n" part afterward. Before this fix we would throw an error in this case, because we didnt visit the error node, causing it to not be inserted to any of the formatted chunks - thus effectively being deleted. The fix we have here is to insert missed preceding error nodes (with the content as-is) when creating a chunk in the visitTerminal and visitTerminalRaw for properly parsed rules.

Claude got a bit lost while testing things, so I interrupted it and made the final steps myself, but it's an agent-driven PR.

Closes LS-138
Fixes LS-138

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: 289abc7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@neo4j-cypher/language-support Patch
@neo4j-cypher/language-server Patch
@neo4j-cypher/lint-worker Patch
@neo4j-cypher/query-tools Patch
@neo4j-cypher/react-codemirror-playground Patch
@neo4j-cypher/react-codemirror Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anderson4j anderson4j requested a review from OskarDamkjaer April 8, 2026 09:07
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.

1 participant