Skip to content

Commit

Permalink
alias rebase headers to $.header, not $.summary
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Dec 24, 2021
1 parent f0cb000 commit 5cd4776
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 41 deletions.
6 changes: 3 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = grammar({

_comment_body: ($) =>
choice(
$._rebase_summary,
alias($._rebase_summary, $.summary),
$.summary,
$._branch_declaration,
// fallback to regular comment words if the words are nonsense
Expand All @@ -85,9 +85,9 @@ module.exports = grammar({
$.commit,
NEWLINE
),
seq("#", alias($._rebase_header, $.summary), NEWLINE),
seq("#", alias($._rebase_header, $.header), NEWLINE),
repeat(seq("#", $.rebase_command, NEWLINE)),
seq("#", alias($._rebase_header, $.summary), NEWLINE),
seq("#", alias($._rebase_header, $.header), NEWLINE),
repeat(seq("#", $.rebase_command, NEWLINE)),
seq(
"#",
Expand Down
13 changes: 9 additions & 4 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,13 @@
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_rebase_summary"
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_rebase_summary"
},
"named": true,
"value": "summary"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -284,7 +289,7 @@
"name": "_rebase_header"
},
"named": true,
"value": "summary"
"value": "header"
},
{
"type": "PATTERN",
Expand Down Expand Up @@ -326,7 +331,7 @@
"name": "_rebase_header"
},
"named": true,
"value": "summary"
"value": "header"
},
{
"type": "PATTERN",
Expand Down
20 changes: 14 additions & 6 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"named": true,
"fields": {},
"children": {
"multiple": true,
"multiple": false,
"required": false,
"types": [
{
Expand All @@ -53,10 +53,6 @@
"type": "commit",
"named": true
},
{
"type": "rebase_command",
"named": true
},
{
"type": "scissors",
"named": true
Expand Down Expand Up @@ -136,19 +132,31 @@
"fields": {},
"children": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "branch",
"named": true
},
{
"type": "change",
"named": true
},
{
"type": "commit",
"named": true
},
{
"type": "header",
"named": true
},
{
"type": "path",
"named": true
},
{
"type": "rebase_command",
"named": true
}
]
}
Expand Down
10 changes: 5 additions & 5 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ static const char * const ts_symbol_names[] = {
[sym_message] = "message",
[sym_comment] = "comment",
[sym__comment_body] = "_comment_body",
[sym__rebase_summary] = "_rebase_summary",
[sym__rebase_header] = "summary",
[sym__rebase_summary] = "summary",
[sym__rebase_header] = "header",
[sym_summary] = "summary",
[sym__change_header] = "header",
[sym__branch_declaration] = "_branch_declaration",
Expand Down Expand Up @@ -330,8 +330,8 @@ static const TSSymbol ts_symbol_map[] = {
[sym_message] = sym_message,
[sym_comment] = sym_comment,
[sym__comment_body] = sym__comment_body,
[sym__rebase_summary] = sym__rebase_summary,
[sym__rebase_header] = sym_summary,
[sym__rebase_summary] = sym_summary,
[sym__rebase_header] = sym_header,
[sym_summary] = sym_summary,
[sym__change_header] = sym_header,
[sym__branch_declaration] = sym__branch_declaration,
Expand Down Expand Up @@ -704,7 +704,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
.named = true,
},
[sym__rebase_summary] = {
.visible = false,
.visible = true,
.named = true,
},
[sym__rebase_header] = {
Expand Down
32 changes: 17 additions & 15 deletions test/corpus/comments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,15 @@ Update onedark theme to use new scopes (#1297)
(source
(subject)
(comment
(commit)
(summary)
(rebase_command)
(rebase_command)
(summary)
(rebase_command)
(branch)
(commit))
(summary
(commit)
(header)
(rebase_command)
(rebase_command)
(header)
(rebase_command)
(branch)
(commit)))
(comment
(summary
(header)
Expand All @@ -278,13 +279,14 @@ Rebase with multiple commands done, zero commands to go

(source
(comment
(commit)
(summary)
(rebase_command)
(rebase_command)
(summary)
(branch)
(commit))
(summary
(commit)
(header)
(rebase_command)
(rebase_command)
(header)
(branch)
(commit)))
(comment
(summary
(header)
Expand Down
17 changes: 9 additions & 8 deletions test/corpus/message.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,15 @@ add submodule on tree-sitter-rebase, add to languages
(comment)
(comment)
(comment
(commit)
(summary)
(rebase_command)
(summary)
(rebase_command)
(rebase_command)
(branch)
(commit))
(summary
(commit)
(header)
(rebase_command)
(header)
(rebase_command)
(rebase_command)
(branch)
(commit)))
(comment
(summary
(header)
Expand Down
Binary file modified tree-sitter-git_commit.wasm
Binary file not shown.

0 comments on commit 5cd4776

Please sign in to comment.