aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorYuan Fu2025-02-27 03:10:47 -0800
committerYuan Fu2025-02-27 17:22:04 -0800
commit1314272bf398e068385572ca16d4dfcd55a48828 (patch)
tree3b924fbd62cd223354879427fe313e3a8899d878 /java
parent625b2b02a3c9bad6d7abf57ea7f95ece29855906 (diff)
downloademacs-1314272bf398e068385572ca16d4dfcd55a48828.tar.gz
emacs-1314272bf398e068385572ca16d4dfcd55a48828.zip
Rework range facility in treesit.el to support arbitrary nesting
Make use of the newly added embed-level parser property, we now iterativeLy create/update embedded parsers at each embed level, allowing arbitrary levels of nesting. At the beginning, we start with the primary parser. We query it with each range settings, gets some ranges and their corresponding language. Then we create the first level of embedded parsers using the ranges and language we got. This is one iteration. For the next iteration/level, we start with the embedded parsers we create/updated in the previous iteration/level, and query each of them with each of the range settings, creating/updating the next level of embedded parsers. And we keep doing this until we don't get more matches from the queries. We now also support the :embed keyword in 'treesit-range-rules' to be a function that returns a language. This allows major modes like markdown and org mode to support code blocks of which the language isn't known ahead of time. * lisp/treesit.el (treesit-primary-parser): Move to front. (treesit-query-range-by-language): New function. (treesit-range-rules): Allow :embed to be a function, update docstring. (treesit-local-parsers-on): Update docstring. (treesit--parser-at-level): (treesit--update-ranges-non-local): New functions. (treesit--update-ranges-local): Use the new logic, support :embed being a function. (treesit--update-range-1): New function, has the meat of original treesit-update-ranges. (treesit-update-ranges): Implements the iteration logic using treesit--update-range-1 to do the actual work.
Diffstat (limited to 'java')
0 files changed, 0 insertions, 0 deletions