Drop 'override.' prefix from capture names in override query

Co-authored-by: Julia Risley <julia@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-01-20 10:44:33 -08:00
parent 2aa7a9e95b
commit 8dcef46842
17 changed files with 35 additions and 36 deletions

View file

@ -1421,8 +1421,8 @@ fn test_language_config_at(cx: &mut MutableAppContext) {
)
.with_override_query(
r#"
(jsx_element) @override.element
(string) @override.string
(jsx_element) @element
(string) @string
"#,
)
.unwrap();

View file

@ -829,10 +829,10 @@ impl Language {
let mut values = HashMap::default();
for (ix, name) in query.capture_names().iter().enumerate() {
if let Some(override_name) = name.strip_prefix("override.") {
let value = self.config.overrides.remove(override_name).ok_or_else(|| {
if !name.starts_with('_') {
let value = self.config.overrides.remove(name).ok_or_else(|| {
anyhow!(
"language {:?} has override in query but not in config: {override_name:?}",
"language {:?} has override in query but not in config: {name:?}",
self.config.name
)
})?;

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string_literal) @override.string
(comment) @comment
(string_literal) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string_literal) @override.string
(comment) @comment
(string_literal) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string_value) @override.string
(comment) @comment
(string_value) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
[(string) (charlist)] @override.string
(comment) @comment
[(string) (charlist)] @string

View file

@ -1,6 +1,6 @@
(comment) @override.comment
(comment) @comment
[
(interpreted_string_literal)
(raw_string_literal)
(rune_literal)
] @override.string
] @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(quoted_attribute_value) @override.string
(comment) @comment
(quoted_attribute_value) @string

View file

@ -1,9 +1,9 @@
(comment) @override.comment
(string) @override.string
(comment) @comment
(string) @string
[
(jsx_element)
(jsx_fragment)
(jsx_self_closing_element)
(jsx_expression)
] @override.element
] @element

View file

@ -1,2 +1 @@
(comment) @comment
(string) @override.string
(string) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string) @override.string
(comment) @comment
(string) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string) @override.string
(comment) @comment
(string) @string

View file

@ -1,8 +1,8 @@
[
(string_literal)
(raw_string_literal)
] @override.string
] @string
[
(line_comment)
(block_comment)
] @override.comment
] @comment

View file

@ -2,5 +2,5 @@
(comment)
(block_comment)
(directive)
] @override.comment
(string) @override.string
] @comment
(string) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string) @override.string
(comment) @comment
(string) @string

View file

@ -3,5 +3,5 @@
(jsx_fragment)
(jsx_self_closing_element)
(jsx_expression)
] @override.element
(string) @override.string
] @element
(string) @string

View file

@ -1,2 +1,2 @@
(comment) @override.comment
(string) @override.string
(comment) @comment
(string) @string