Skip to content

Conversation

@savetheclocktower
Copy link
Contributor

@savetheclocktower savetheclocktower commented Nov 16, 2025

EDIT: Found another Tree-sitter change worth making, so I've retroactively turned this into the “rolling fixes” PR for the upcoming version. Original description follows.


[language-java] Update to latest tree-sitter-java

…and add support for multi-line string literals.

Fixes #1376.

We hadn't updated the tree-sitter-java parser in a long time. After I confirmed that the latest version of the parser does support the multi-line string literals mentioned in #1376, I took this opportunity to bump our parser version.

Doing so added recognition of multi-line strings, but also introduced some incompatibilities in the query files having to do with renamed nodes, so that took a little while to fix.

As is my habit when I touch language-* packages, I've introduced a grammar test file to prove that these changes work. It's bare-bones right now, but it does test the multi-line string literals.

As for the other changes to the query files: those were necessary to get the Tree-sitter grammar to do anything at all, since it would've thrown an error during activation if there were any invalid syntax in a query file. Therefore if I'd done any of that wrong, or missed anything, CI would catch it because it would result in all these new grammar tests failing outright.

(I'm in a weird state because I'm submitting these PRs blind! They're against master (still running Electron 12), but my local Pulsar.app is the Electron 30 release candidate. So I'm making these changes in my Electron 30 codebase, verifying they work, then copying them over to my Electron 12 codebase and opening the PR from there. Luckily, there's nothing about the Tree-sitter infrastructure that even needed to change when we bumped to Electron 30 — the upside of all of that stuff using WebAssembly instead of native bindings in Node.)

…by allowing `@fold.end` captures to be adjusted with fold predicates.
@savetheclocktower savetheclocktower changed the title [language-java] Update to latest tree-sitter-java Tree-sitter rolling fixes, 1.131.0 edition Nov 20, 2025
@savetheclocktower
Copy link
Contributor Author

Updated this PR to add a fix for a Python folding issue.

The query syntax is quite constraining in certain situations, and the “node position descriptor” concept I came up with was ultimately a kludge. Partially because of limitations in web-tree-sitter and partially out of my obliviousness, I couldn't figure out how to handle this situation properly: a query with multiple captures that is handled in a “grouped” way where the captures can all be considered at once.

I'll remedy that in the future when I write new, more useful query predicates. For now, though, I can fix this with just a small feature addition to fold captures.

Added new specs for everything!

@savetheclocktower
Copy link
Contributor Author

GitHub is having issues with accessing raw file content, according to their status page, so that's likely why CI failed. I'll try it again later.

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.

[language-java] Support highlighting of multiline strings [language-python] Folding of if blocks breaks when comments are interleaved

2 participants