mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Replace some 'treesit-query-compile' with 'treesit-query-valid-p'.
* admin/tree-sitter/treesit-admin.el (treesit-admin--verify-major-mode-queries) (treesit-admin--validate-mode-lang): * lisp/progmodes/csharp-mode.el (csharp-ts-mode--test-this-expression) (csharp-ts-mode--test-interpolated-string-text) (csharp-ts-mode--test-string-content) (csharp-ts-mode--test-type-constraint) (csharp-ts-mode--test-type-of-expression) (csharp-ts-mode--test-typeof-expression) (csharp-ts-mode--test-name-equals) (csharp-ts-mode--test-if-directive) (csharp-ts-mode--test-method-declaration-type-field): * lisp/progmodes/php-ts-mode.el (php-ts-mode--test-namespace-name-as-prefix-p) (php-ts-mode--test-namespace-aliasing-clause-p) (php-ts-mode--test-namespace-use-group-clause-p) (php-ts-mode--test-visibility-modifier-operation-clause-p) (php-ts-mode--test-property-hook-clause-p): * lisp/progmodes/typescript-ts-mode.el (tsx-ts-mode--font-lock-compatibility-bb1f97b): Use the newer equivalent 'treesit-query-valid-p' instead of 'treesit-query-compile' with 'ignore-errors'.
This commit is contained in:
parent
573a2c09b9
commit
add8bf000a
5 changed files with 21 additions and 52 deletions
|
|
@ -156,9 +156,7 @@ queries that has problems with latest grammar."
|
|||
(unless (memq language (alist-get mode mode-language-alist))
|
||||
(push language (alist-get mode mode-language-alist)))
|
||||
;; Validate query.
|
||||
(when (not (ignore-errors
|
||||
(treesit-query-compile language query t)
|
||||
t))
|
||||
(unless (treesit-query-valid-p language query)
|
||||
(push (list mode language feature) invalid-feature-list)
|
||||
(setq all-queries-valid nil))))
|
||||
(when all-queries-valid
|
||||
|
|
@ -261,9 +259,7 @@ Return non-nil if all queries are valid, nil otherwise."
|
|||
(language (treesit-query-language query)))
|
||||
;; Validate query.
|
||||
(when (and (eq lang language)
|
||||
(not (ignore-errors
|
||||
(treesit-query-compile language query t)
|
||||
t)))
|
||||
(not (treesit-query-valid-p language query)))
|
||||
(setq all-queries-valid nil))))
|
||||
all-queries-valid))
|
||||
|
||||
|
|
|
|||
|
|
@ -674,9 +674,7 @@ MODE should be either `c' or `cpp'."
|
|||
(mapcan
|
||||
(lambda (entry)
|
||||
(let ((keywords (cdr entry)))
|
||||
(if (ignore-errors
|
||||
(treesit-query-compile 'c `([,@keywords] @cap) t)
|
||||
t)
|
||||
(if (treesit-query-valid-p 'c `([,@keywords] @cap))
|
||||
(copy-sequence keywords)
|
||||
nil)))
|
||||
c-ts-mode--optional-c-keywords)
|
||||
|
|
|
|||
|
|
@ -733,57 +733,39 @@ compilation and evaluation time conflicts."
|
|||
|
||||
(defun csharp-ts-mode--test-this-expression ()
|
||||
"Return non-nil if (this_expression) is named in csharp grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(this_expression)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(this_expression)"))
|
||||
|
||||
(defun csharp-ts-mode--test-interpolated-string-text ()
|
||||
"Return non-nil if (interpolated_string_text) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(interpolated_string_text)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(interpolated_string_text)"))
|
||||
|
||||
(defun csharp-ts-mode--test-string-content ()
|
||||
"Return non-nil if (interpolated_string_text) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(string_content)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(string_content)"))
|
||||
|
||||
(defun csharp-ts-mode--test-type-constraint ()
|
||||
"Return non-nil if (type_constraint) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(type_constraint)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(type_constraint)"))
|
||||
|
||||
(defun csharp-ts-mode--test-type-of-expression ()
|
||||
"Return non-nil if (type_of_expression) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(type_of_expression)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(type_of_expression)"))
|
||||
|
||||
(defun csharp-ts-mode--test-typeof-expression ()
|
||||
"Return non-nil if (type_of_expression) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(typeof_expression)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(typeof_expression)"))
|
||||
|
||||
(defun csharp-ts-mode--test-name-equals ()
|
||||
"Return non-nil if (name_equals) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(name_equals)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(name_equals)"))
|
||||
|
||||
(defun csharp-ts-mode--test-if-directive ()
|
||||
"Return non-nil if (if_directive) is in the grammar."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(if_directive)" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(if_directive)"))
|
||||
|
||||
(defun csharp-ts-mode--test-method-declaration-type-field ()
|
||||
"Return non-nil if (method_declaration) has a type field."
|
||||
(ignore-errors
|
||||
(treesit-query-compile 'c-sharp "(method_declaration type: (_))" t)
|
||||
t))
|
||||
(treesit-query-valid-p 'c-sharp "(method_declaration type: (_))"))
|
||||
|
||||
(defvar csharp-ts-mode--type-field
|
||||
(if (csharp-ts-mode--test-method-declaration-type-field)
|
||||
|
|
|
|||
|
|
@ -840,28 +840,23 @@ characters of the current line."
|
|||
|
||||
(defun php-ts-mode--test-namespace-name-as-prefix-p ()
|
||||
"Return t if namespace_name_as_prefix is a named node, nil otherwise."
|
||||
(ignore-errors
|
||||
(progn (treesit-query-compile 'php "(namespace_name_as_prefix)" t) t)))
|
||||
(treesit-query-valid-p 'php "(namespace_name_as_prefix)"))
|
||||
|
||||
(defun php-ts-mode--test-namespace-aliasing-clause-p ()
|
||||
"Return t if namespace_aliasing_clause is a named node, nil otherwise."
|
||||
(ignore-errors
|
||||
(progn (treesit-query-compile 'php "(namespace_aliasing_clause)" t) t)))
|
||||
(treesit-query-valid-p 'php "(namespace_aliasing_clause)"))
|
||||
|
||||
(defun php-ts-mode--test-namespace-use-group-clause-p ()
|
||||
"Return t if namespace_use_group_clause is a named node, nil otherwise."
|
||||
(ignore-errors
|
||||
(progn (treesit-query-compile 'php "(namespace_use_group_clause)" t) t)))
|
||||
(treesit-query-valid-p 'php "(namespace_use_group_clause)"))
|
||||
|
||||
(defun php-ts-mode--test-visibility-modifier-operation-clause-p ()
|
||||
"Return t if (visibility_modifier (operation)) is defined, nil otherwise."
|
||||
(ignore-errors
|
||||
(progn (treesit-query-compile 'php "(visibility_modifier (operation))" t) t)))
|
||||
(treesit-query-valid-p 'php "(visibility_modifier (operation))"))
|
||||
|
||||
(defun php-ts-mode--test-property-hook-clause-p ()
|
||||
"Return t if property_hook is a named node, nil otherwise."
|
||||
(ignore-errors
|
||||
(progn (treesit-query-compile 'php "(property_hook)" t) t)))
|
||||
(treesit-query-valid-p 'php "(property_hook)"))
|
||||
|
||||
(defun php-ts-mode--font-lock-settings ()
|
||||
"Tree-sitter font-lock settings."
|
||||
|
|
|
|||
|
|
@ -246,12 +246,10 @@ Argument LANGUAGE is either `typescript' or `tsx'."
|
|||
|
||||
(jsx_attribute (property_identifier)
|
||||
@typescript-ts-jsx-attribute-face))))
|
||||
(or (ignore-errors
|
||||
(treesit-query-compile language queries-a t)
|
||||
queries-a)
|
||||
(ignore-errors
|
||||
(treesit-query-compile language queries-b t)
|
||||
queries-b)
|
||||
(or (and (treesit-query-valid-p language queries-a)
|
||||
queries-a)
|
||||
(and (treesit-query-valid-p language queries-b)
|
||||
queries-b)
|
||||
;; Return a dummy query that doesn't do anything, if neither
|
||||
;; query works.
|
||||
'("," @_ignore))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue