From 4a8180ff999b900ed22f7c5f112922eb39daf0cb Mon Sep 17 00:00:00 2001 From: kolen Date: Sat, 17 Feb 2024 01:19:12 +0300 Subject: [PATCH] Rename shortcut_ nodes to attr_shortcut_ --- grammar.js | 12 +++---- src/grammar.json | 12 +++---- src/node-types.json | 74 +++++++++++++++++++------------------- test/corpus/nesting.txt | 8 ++--- test/corpus/ruby_block.txt | 4 +-- test/corpus/tags.txt | 14 ++++---- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/grammar.js b/grammar.js index 8742b0a..787f484 100644 --- a/grammar.js +++ b/grammar.js @@ -118,15 +118,15 @@ module.exports = grammar({ tag_name: $ => /(\w+|\w[\w:-]+\w)/, _attr_shortcut: $ => choice( - $.shortcut_class, - $.shortcut_id, - $.shortcut_custom + $.attr_shortcut_class, + $.attr_shortcut_id, + $.attr_shortcut_custom ), - shortcut_class: $ => seq('.', $.css_identifier), - shortcut_id: $ => seq('#', $.css_identifier), + attr_shortcut_class: $ => seq('.', $.css_identifier), + attr_shortcut_id: $ => seq('#', $.css_identifier), // In real slim, custom shortcuts only parsed if prefix is // configured, otherwise parsed as inline text - shortcut_custom: $ => token(prec(-1, /[^ \t\na-zA-Z0-9_-]+[a-zA-Z0-9_-]*/)), + attr_shortcut_custom: $ => token(prec(-1, /[^ \t\na-zA-Z0-9_-]+[a-zA-Z0-9_-]*/)), nested: $ => $._block, diff --git a/src/grammar.json b/src/grammar.json index 951037a..e594729 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -315,19 +315,19 @@ "members": [ { "type": "SYMBOL", - "name": "shortcut_class" + "name": "attr_shortcut_class" }, { "type": "SYMBOL", - "name": "shortcut_id" + "name": "attr_shortcut_id" }, { "type": "SYMBOL", - "name": "shortcut_custom" + "name": "attr_shortcut_custom" } ] }, - "shortcut_class": { + "attr_shortcut_class": { "type": "SEQ", "members": [ { @@ -340,7 +340,7 @@ } ] }, - "shortcut_id": { + "attr_shortcut_id": { "type": "SEQ", "members": [ { @@ -353,7 +353,7 @@ } ] }, - "shortcut_custom": { + "attr_shortcut_custom": { "type": "TOKEN", "content": { "type": "PREC", diff --git a/src/node-types.json b/src/node-types.json index 75e1101..f326fdf 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -44,6 +44,36 @@ "named": true, "fields": {} }, + { + "type": "attr_shortcut_class", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "css_identifier", + "named": true + } + ] + } + }, + { + "type": "attr_shortcut_id", + "named": true, + "fields": {}, + "children": { + "multiple": false, + "required": true, + "types": [ + { + "type": "css_identifier", + "named": true + } + ] + } + }, { "type": "attr_shortcuts", "named": true, @@ -53,15 +83,15 @@ "required": true, "types": [ { - "type": "shortcut_class", + "type": "attr_shortcut_class", "named": true }, { - "type": "shortcut_custom", + "type": "attr_shortcut_custom", "named": true }, { - "type": "shortcut_id", + "type": "attr_shortcut_id", "named": true } ] @@ -436,36 +466,6 @@ ] } }, - { - "type": "shortcut_class", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "css_identifier", - "named": true - } - ] - } - }, - { - "type": "shortcut_id", - "named": true, - "fields": {}, - "children": { - "multiple": false, - "required": true, - "types": [ - { - "type": "css_identifier", - "named": true - } - ] - } - }, { "type": "source_file", "named": true, @@ -580,6 +580,10 @@ "type": "attr_assignment_noescape", "named": true }, + { + "type": "attr_shortcut_custom", + "named": true + }, { "type": "basic", "named": false @@ -660,10 +664,6 @@ "type": "scss", "named": false }, - { - "type": "shortcut_custom", - "named": true - }, { "type": "strict", "named": false diff --git a/test/corpus/nesting.txt b/test/corpus/nesting.txt index 8846e54..314a23b 100644 --- a/test/corpus/nesting.txt +++ b/test/corpus/nesting.txt @@ -11,14 +11,14 @@ Element nesting (source_file (element - attr_shortcuts: (attr_shortcuts (shortcut_class (css_identifier))) + attr_shortcuts: (attr_shortcuts (attr_shortcut_class (css_identifier))) (nested (element - attr_shortcuts: (attr_shortcuts (shortcut_class (css_identifier)))) + attr_shortcuts: (attr_shortcuts (attr_shortcut_class (css_identifier)))) (element - attr_shortcuts: (attr_shortcuts (shortcut_class (css_identifier)))))) + attr_shortcuts: (attr_shortcuts (attr_shortcut_class (css_identifier)))))) (element - attr_shortcuts: (attr_shortcuts (shortcut_class (css_identifier))))) + attr_shortcuts: (attr_shortcuts (attr_shortcut_class (css_identifier))))) =================== Element nesting (2) diff --git a/test/corpus/ruby_block.txt b/test/corpus/ruby_block.txt index 8c3dd72..c992376 100644 --- a/test/corpus/ruby_block.txt +++ b/test/corpus/ruby_block.txt @@ -29,7 +29,7 @@ Ruby block with nested blocks (nested (element (attr_shortcuts - (shortcut_class (css_identifier))) + (attr_shortcut_class (css_identifier))) (nested (ruby_block_output (ruby))))))) @@ -53,5 +53,5 @@ Ruby block - nested blocks (nested (element (attr_shortcuts - (shortcut_class + (attr_shortcut_class (css_identifier))))))))) diff --git a/test/corpus/tags.txt b/test/corpus/tags.txt index 0a3dd38..56d7f85 100644 --- a/test/corpus/tags.txt +++ b/test/corpus/tags.txt @@ -10,9 +10,9 @@ span.menu.active (element (tag_name) (attr_shortcuts - (shortcut_class + (attr_shortcut_class (css_identifier)) - (shortcut_class + (attr_shortcut_class (css_identifier))))) =============================== @@ -26,7 +26,7 @@ Tag with traling space modifier (source_file (element (attr_shortcuts - (shortcut_class + (attr_shortcut_class (css_identifier))) (output_modifier_leading_whitespace))) @@ -41,7 +41,7 @@ Tag with space before traling space modifier (source_file (element (attr_shortcuts - (shortcut_class + (attr_shortcut_class (css_identifier))) (element_text))) @@ -57,7 +57,7 @@ span.example@@example*example (element (tag_name) (attr_shortcuts - (shortcut_class + (attr_shortcut_class (css_identifier)) - (shortcut_custom) - (shortcut_custom)))) + (attr_shortcut_custom) + (attr_shortcut_custom))))