java-ts-mode: detect if text_block is supported.
A recent commit in tree-sitter-java (issue #141) removed support for the text_block node type from the grammar. To support the old released version and the new one, a helper function was added on which the string syntax highlighting now depends. (bug#61913) * lisp/progmodes/java-ts-mode.el (java-ts-mode--string-highlight-helper): New helper function that return the right query string (java-ts-mode--font-lock-settings): Use it Copyright-paperwork-exempt: yes
This commit is contained in:
parent
6fe9075ff3
commit
255eeee0e0
1 changed files with 11 additions and 2 deletions
|
@ -145,6 +145,16 @@
|
||||||
"|=" "~" ">>" ">>>" "<<" "::" "?" "&=")
|
"|=" "~" ">>" ">>>" "<<" "::" "?" "&=")
|
||||||
"Java operators for tree-sitter font-locking.")
|
"Java operators for tree-sitter font-locking.")
|
||||||
|
|
||||||
|
(defun java-ts-mode--string-highlight-helper ()
|
||||||
|
"Returns, for strings, a query based on what is supported by
|
||||||
|
the available version of Tree-sitter for java."
|
||||||
|
(condition-case nil
|
||||||
|
(progn (treesit-query-capture 'java '((text_block) @font-lock-string-face))
|
||||||
|
`((string_literal) @font-lock-string-face
|
||||||
|
(text_block) @font-lock-string-face))
|
||||||
|
(error
|
||||||
|
`((string_literal) @font-lock-string-face))))
|
||||||
|
|
||||||
(defvar java-ts-mode--font-lock-settings
|
(defvar java-ts-mode--font-lock-settings
|
||||||
(treesit-font-lock-rules
|
(treesit-font-lock-rules
|
||||||
:language 'java
|
:language 'java
|
||||||
|
@ -182,8 +192,7 @@
|
||||||
:language 'java
|
:language 'java
|
||||||
:override t
|
:override t
|
||||||
:feature 'string
|
:feature 'string
|
||||||
`((string_literal) @font-lock-string-face
|
(java-ts-mode--string-highlight-helper)
|
||||||
(text_block) @font-lock-string-face)
|
|
||||||
:language 'java
|
:language 'java
|
||||||
:override t
|
:override t
|
||||||
:feature 'literal
|
:feature 'literal
|
||||||
|
|
Loading…
Add table
Reference in a new issue