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( .with_override_query(
r#" r#"
(jsx_element) @override.element (jsx_element) @element
(string) @override.string (string) @string
"#, "#,
) )
.unwrap(); .unwrap();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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