Add 'default' alias

This makes it appear in the tree as a named node.
This commit is contained in:
Bruno BELANYI 2024-04-09 13:08:02 +01:00
parent d297f38e6a
commit 8db7b053f5
6 changed files with 16 additions and 7 deletions

View file

@ -166,7 +166,7 @@ module.exports = grammar({
), ),
default_case: ($) => seq( default_case: ($) => seq(
field("pattern", "default"), field("pattern", alias("default", $.default)),
":", ":",
field("value", $._case_value), field("value", $._case_value),
), ),

View file

@ -49,7 +49,7 @@
; Built-ins {{{ ; Built-ins {{{
[ [
(unset) (unset)
"default" (default)
] @variable.builtin ] @variable.builtin
(selection_type) @function.builtin (selection_type) @function.builtin
; }}} ; }}}

5
src/grammar.json generated
View file

@ -686,9 +686,14 @@
{ {
"type": "FIELD", "type": "FIELD",
"name": "pattern", "name": "pattern",
"content": {
"type": "ALIAS",
"content": { "content": {
"type": "STRING", "type": "STRING",
"value": "default" "value": "default"
},
"named": true,
"value": "default"
} }
}, },
{ {

4
src/node-types.json generated
View file

@ -187,7 +187,7 @@
"types": [ "types": [
{ {
"type": "default", "type": "default",
"named": false "named": true
} }
] ]
}, },
@ -668,7 +668,7 @@
}, },
{ {
"type": "default", "type": "default",
"named": false "named": true
}, },
{ {
"type": "escape_sequence", "type": "escape_sequence",

2
src/parser.c generated
View file

@ -335,7 +335,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
}, },
[anon_sym_default] = { [anon_sym_default] = {
.visible = true, .visible = true,
.named = false, .named = true,
}, },
[anon_sym_unset] = { [anon_sym_unset] = {
.visible = true, .visible = true,

View file

@ -22,6 +22,7 @@ foo = select(release_variable("RELEASE_TEST"), {
(interpreted_string_literal) (interpreted_string_literal)
(interpreted_string_literal)) (interpreted_string_literal))
(default_case (default_case
(default)
(unset)))))) (unset))))))
================================================================================ ================================================================================
@ -136,6 +137,7 @@ foo = select(variant("VARIANT"), {
(interpreted_string_literal)) (interpreted_string_literal))
(ERROR (ERROR
(default_case (default_case
(default)
(unset))) (unset)))
(select_case (select_case
(interpreted_string_literal) (interpreted_string_literal)
@ -168,6 +170,7 @@ foo = select(variant(), {
(interpreted_string_literal) (interpreted_string_literal)
(unset)) (unset))
(default_case (default_case
(default)
(interpreted_string_literal)))))) (interpreted_string_literal))))))
================================================================================ ================================================================================
@ -189,7 +192,8 @@ foo = select(some_unknown_type("CONDITION"), {
(identifier) (identifier)
(identifier) (identifier)
(interpreted_string_literal) (interpreted_string_literal)
(interpreted_string_literal)) (interpreted_string_literal)
(default))
(interpreted_string_literal)) (interpreted_string_literal))
(ERROR)) (ERROR))