Fix bol/bos anchors in tree-sitter :match regexps

Further regexp fixes to follow separately (bug#64019#29).

* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings):
* lisp/progmodes/cmake-ts-mode.el
(cmake-ts-mode--font-lock-settings):
* lisp/progmodes/java-ts-mode.el (java-ts-mode--font-lock-settings):
* lisp/progmodes/js.el (js--treesit-font-lock-settings):
* lisp/progmodes/python.el (python--treesit-settings):
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings):
* lisp/progmodes/sh-script.el (sh-mode--treesit-settings):
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--font-lock-settings):
* test/src/treesit-tests.el (treesit-query-api): Anchor :match
regexps at beginning/end of string, not line.
This commit is contained in:
Basil L. Contovounesios 2023-06-13 13:45:08 +01:00
parent 8225ade615
commit 8dc08333ee
9 changed files with 19 additions and 18 deletions

View file

@ -701,7 +701,7 @@ MODE is either `c' or `cpp'."
`(((call_expression `(((call_expression
(call_expression function: (identifier) @fn) (call_expression function: (identifier) @fn)
@c-ts-mode--fontify-DEFUN) @c-ts-mode--fontify-DEFUN)
(:match "^DEFUN$" @fn)) (:match "\\`DEFUN\\'" @fn))
((function_definition type: (_) @for-each-tail) ((function_definition type: (_) @for-each-tail)
@c-ts-mode--fontify-for-each-tail @c-ts-mode--fontify-for-each-tail

View file

@ -134,7 +134,8 @@
:language 'cmake :language 'cmake
:feature 'number :feature 'number
'(((unquoted_argument) @font-lock-number-face '(((unquoted_argument) @font-lock-number-face
(:match "^[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+$" @font-lock-number-face))) (:match "\\`[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'"
@font-lock-number-face)))
:language 'cmake :language 'cmake
:feature 'string :feature 'string

View file

@ -168,7 +168,7 @@ the available version of Tree-sitter for java."
:override t :override t
:feature 'constant :feature 'constant
`(((identifier) @font-lock-constant-face `(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false)] @font-lock-constant-face) [(true) (false)] @font-lock-constant-face)
:language 'java :language 'java
:override t :override t
@ -237,7 +237,7 @@ the available version of Tree-sitter for java."
(scoped_identifier (identifier) @font-lock-constant-face) (scoped_identifier (identifier) @font-lock-constant-face)
((scoped_identifier name: (identifier) @font-lock-type-face) ((scoped_identifier name: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face)) (:match "\\`[A-Z]" @font-lock-type-face))
(type_identifier) @font-lock-type-face (type_identifier) @font-lock-type-face

View file

@ -3493,7 +3493,7 @@ This function is intended for use in `after-change-functions'."
:language 'javascript :language 'javascript
:feature 'constant :feature 'constant
'(((identifier) @font-lock-constant-face '(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false) (null)] @font-lock-constant-face) [(true) (false) (null)] @font-lock-constant-face)
@ -3612,7 +3612,7 @@ This function is intended for use in `after-change-functions'."
:feature 'number :feature 'number
'((number) @font-lock-number-face '((number) @font-lock-number-face
((identifier) @font-lock-number-face ((identifier) @font-lock-number-face
(:match "^\\(:?NaN\\|Infinity\\)$" @font-lock-number-face))) (:match "\\`\\(:?NaN\\|Infinity\\)\\'" @font-lock-number-face)))
:language 'javascript :language 'javascript
:feature 'operator :feature 'operator

View file

@ -1106,7 +1106,7 @@ fontified."
:language 'python :language 'python
`([,@python--treesit-keywords] @font-lock-keyword-face `([,@python--treesit-keywords] @font-lock-keyword-face
((identifier) @font-lock-keyword-face ((identifier) @font-lock-keyword-face
(:match "^self$" @font-lock-keyword-face))) (:match "\\`self\\'" @font-lock-keyword-face)))
:feature 'definition :feature 'definition
:language 'python :language 'python

View file

@ -143,7 +143,7 @@
eol)) eol))
@font-lock-builtin-face))) @font-lock-builtin-face)))
((identifier) @font-lock-type-face ((identifier) @font-lock-type-face
(:match "^\\(:?Err\\|Ok\\|None\\|Some\\)$" @font-lock-type-face))) (:match "\\`\\(:?Err\\|Ok\\|None\\|Some\\)\\'" @font-lock-type-face)))
:language 'rust :language 'rust
:feature 'comment :feature 'comment
@ -212,11 +212,11 @@
(scoped_use_list path: (scoped_identifier (scoped_use_list path: (scoped_identifier
name: (identifier) @font-lock-constant-face)) name: (identifier) @font-lock-constant-face))
((use_as_clause alias: (identifier) @font-lock-type-face) ((use_as_clause alias: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face)) (:match "\\`[A-Z]" @font-lock-type-face))
((use_as_clause path: (identifier) @font-lock-type-face) ((use_as_clause path: (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face)) (:match "\\`[A-Z]" @font-lock-type-face))
((use_list (identifier) @font-lock-type-face) ((use_list (identifier) @font-lock-type-face)
(:match "^[A-Z]" @font-lock-type-face)) (:match "\\`[A-Z]" @font-lock-type-face))
(use_wildcard [(identifier) @rust-ts-mode--fontify-scope (use_wildcard [(identifier) @rust-ts-mode--fontify-scope
(scoped_identifier (scoped_identifier
name: (identifier) @rust-ts-mode--fontify-scope)]) name: (identifier) @rust-ts-mode--fontify-scope)])
@ -233,7 +233,7 @@
((scoped_identifier name: (identifier) @rust-ts-mode--fontify-tail)) ((scoped_identifier name: (identifier) @rust-ts-mode--fontify-tail))
((scoped_identifier path: (identifier) @font-lock-type-face) ((scoped_identifier path: (identifier) @font-lock-type-face)
(:match (:match
"^\\(u8\\|u16\\|u32\\|u64\\|u128\\|usize\\|i8\\|i16\\|i32\\|i64\\|i128\\|isize\\|char\\|str\\)$" "\\`\\(u8\\|u16\\|u32\\|u64\\|u128\\|usize\\|i8\\|i16\\|i32\\|i64\\|i128\\|isize\\|char\\|str\\)\\'"
@font-lock-type-face)) @font-lock-type-face))
((scoped_identifier path: (identifier) @rust-ts-mode--fontify-scope)) ((scoped_identifier path: (identifier) @rust-ts-mode--fontify-scope))
((scoped_type_identifier path: (identifier) @rust-ts-mode--fontify-scope)) ((scoped_type_identifier path: (identifier) @rust-ts-mode--fontify-scope))
@ -249,7 +249,7 @@
:feature 'constant :feature 'constant
`((boolean_literal) @font-lock-constant-face `((boolean_literal) @font-lock-constant-face
((identifier) @font-lock-constant-face ((identifier) @font-lock-constant-face
(:match "^[A-Z][A-Z\\d_]*$" @font-lock-constant-face))) (:match "\\`[A-Z][A-Z\\d_]*\\'" @font-lock-constant-face)))
:language 'rust :language 'rust
:feature 'variable :feature 'variable

View file

@ -3363,7 +3363,7 @@ See `sh-mode--treesit-other-keywords' and
:feature 'number :feature 'number
:language 'bash :language 'bash
`(((word) @font-lock-number-face `(((word) @font-lock-number-face
(:match "^[0-9]+$" @font-lock-number-face))) (:match "\\`[0-9]+\\'" @font-lock-number-face)))
:feature 'bracket :feature 'bracket
:language 'bash :language 'bash

View file

@ -153,7 +153,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
:language language :language language
:feature 'constant :feature 'constant
`(((identifier) @font-lock-constant-face `(((identifier) @font-lock-constant-face
(:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) (:match "\\`[A-Z_][A-Z_\\d]*\\'" @font-lock-constant-face))
[(true) (false) (null)] @font-lock-constant-face) [(true) (false) (null)] @font-lock-constant-face)
:language language :language language
@ -311,7 +311,7 @@ Argument LANGUAGE is either `typescript' or `tsx'."
:feature 'number :feature 'number
`((number) @font-lock-number-face `((number) @font-lock-number-face
((identifier) @font-lock-number-face ((identifier) @font-lock-number-face
(:match "^\\(:?NaN\\|Infinity\\)$" @font-lock-number-face))) (:match "\\`\\(:?NaN\\|Infinity\\)\\'" @font-lock-number-face)))
:language language :language language
:feature 'operator :feature 'operator

View file

@ -368,14 +368,14 @@ BODY is the test body."
;; String query. ;; String query.
'("(string) @string '("(string) @string
(pair key: (_) @keyword) (pair key: (_) @keyword)
((_) @bob (#match \"^B.b$\" @bob)) ((_) @bob (#match \"\\\\`B.b\\\\'\" @bob))
(number) @number (number) @number
((number) @n3 (#equal \"3\" @n3)) ((number) @n3 (#equal \"3\" @n3))
((number) @n3p (#pred treesit--ert-pred-last-sibling @n3p))" ((number) @n3p (#pred treesit--ert-pred-last-sibling @n3p))"
;; Sexp query. ;; Sexp query.
((string) @string ((string) @string
(pair key: (_) @keyword) (pair key: (_) @keyword)
((_) @bob (:match "^B.b$" @bob)) ((_) @bob (:match "\\`B.b\\'" @bob))
(number) @number (number) @number
((number) @n3 (:equal "3" @n3)) ((number) @n3 (:equal "3" @n3))
((number) @n3p (:pred treesit--ert-pred-last-sibling ((number) @n3p (:pred treesit--ert-pred-last-sibling