Skip to content

Commit

Permalink
Rename shortcut_ nodes to attr_shortcut_
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Feb 16, 2024
1 parent 6f41b7d commit 4a8180f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 62 deletions.
12 changes: 6 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
12 changes: 6 additions & 6 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -340,7 +340,7 @@
}
]
},
"shortcut_id": {
"attr_shortcut_id": {
"type": "SEQ",
"members": [
{
Expand All @@ -353,7 +353,7 @@
}
]
},
"shortcut_custom": {
"attr_shortcut_custom": {
"type": "TOKEN",
"content": {
"type": "PREC",
Expand Down
74 changes: 37 additions & 37 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -580,6 +580,10 @@
"type": "attr_assignment_noescape",
"named": true
},
{
"type": "attr_shortcut_custom",
"named": true
},
{
"type": "basic",
"named": false
Expand Down Expand Up @@ -660,10 +664,6 @@
"type": "scss",
"named": false
},
{
"type": "shortcut_custom",
"named": true
},
{
"type": "strict",
"named": false
Expand Down
8 changes: 4 additions & 4 deletions test/corpus/nesting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/corpus/ruby_block.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))))
Expand All @@ -53,5 +53,5 @@ Ruby block - nested blocks
(nested
(element
(attr_shortcuts
(shortcut_class
(attr_shortcut_class
(css_identifier)))))))))
14 changes: 7 additions & 7 deletions test/corpus/tags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))

===============================
Expand All @@ -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)))

Expand All @@ -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)))

Expand All @@ -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))))

0 comments on commit 4a8180f

Please sign in to comment.