Update tree-sitter-embeded-template

This commit is contained in:
Arthur Baars
2022-06-15 13:37:34 +02:00
parent f4363e3aba
commit c5d3df087d
14 changed files with 5871 additions and 56 deletions

BIN
ruby/Cargo.lock generated

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
description: Update ERB parser
compatibility: partial
erb_comment_directive_def.rel: reorder erb_comment_directive_child.rel (int id, int child) id child
erb_comment_directive_child.rel: delete
erb_directive_def.rel: reorder erb_directive_child.rel (int id, int child) id child
erb_directive_child.rel: delete
erb_graphql_directive_def.rel: reorder erb_graphql_directive_child.rel (int id, int child) id child
erb_graphql_directive_child.rel: delete
erb_output_directive_def.rel: reorder erb_output_directive_child.rel (int id, int child) id child
erb_output_directive_child.rel: delete

View File

@@ -10,7 +10,7 @@ edition = "2018"
flate2 = "1.0"
node-types = { path = "../node-types" }
tree-sitter = "0.19"
tree-sitter-embedded-template = "0.19"
tree-sitter-embedded-template = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template.git", rev = "1a538da253d73f896b9f6c0c7d79cda58791ac5c" }
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "6334d6ab3d04a5672da695d3b155ca3301511f8d" }
clap = "3.0"
tracing = "0.1"

View File

@@ -11,5 +11,5 @@ clap = "3.0"
node-types = { path = "../node-types" }
tracing = "0.1"
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
tree-sitter-embedded-template = "0.19"
tree-sitter-embedded-template = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template.git", rev = "1a538da253d73f896b9f6c0c7d79cda58791ac5c" }
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "6334d6ab3d04a5672da695d3b155ca3301511f8d" }

View File

@@ -198,7 +198,11 @@ class ErbCommentDirective extends ErbDirective {
override ErbComment getToken() { toGenerated(result) = g.getChild() }
final override string toString() { result = "<%#" + this.getToken().toString() + "%>" }
final override string toString() {
result = "<%#" + this.getToken().toString() + "%>"
or
not exists(this.getToken()) and result = "<%#%>"
}
final override string getAPrimaryQlClass() { result = "ErbCommentDirective" }
}
@@ -223,7 +227,11 @@ class ErbGraphqlDirective extends ErbDirective {
override ErbCode getToken() { toGenerated(result) = g.getChild() }
final override string toString() { result = "<%graphql" + this.getToken().toString() + "%>" }
final override string toString() {
result = "<%graphql" + this.getToken().toString() + "%>"
or
not exists(this.getToken()) and result = "<%graphql%>"
}
final override string getAPrimaryQlClass() { result = "ErbGraphqlDirective" }
}
@@ -248,7 +256,11 @@ class ErbOutputDirective extends ErbDirective {
override ErbCode getToken() { toGenerated(result) = g.getChild() }
final override string toString() { result = "<%=" + this.getToken().toString() + "%>" }
final override string toString() {
result = "<%=" + this.getToken().toString() + "%>"
or
not exists(this.getToken()) and result = "<%=%>"
}
final override string getAPrimaryQlClass() { result = "ErbOutputDirective" }
}
@@ -266,7 +278,11 @@ class ErbExecutionDirective extends ErbDirective {
ErbExecutionDirective() { this = TDirective(g) }
final override string toString() { result = "<%" + this.getToken().toString() + "%>" }
final override string toString() {
result = "<%" + this.getToken().toString() + "%>"
or
not exists(this.getToken()) and result = "<%-%>"
}
final override string getAPrimaryQlClass() { result = "ErbExecutionDirective" }
}

View File

@@ -1925,10 +1925,10 @@ module Erb {
final override string getAPrimaryQlClass() { result = "CommentDirective" }
/** Gets the child of this node. */
final Comment getChild() { erb_comment_directive_def(this, result) }
final Comment getChild() { erb_comment_directive_child(this, result) }
/** Gets a field or child node of this node. */
final override AstNode getAFieldOrChild() { erb_comment_directive_def(this, result) }
final override AstNode getAFieldOrChild() { erb_comment_directive_child(this, result) }
}
/** A class representing `content` tokens. */
@@ -1943,10 +1943,10 @@ module Erb {
final override string getAPrimaryQlClass() { result = "Directive" }
/** Gets the child of this node. */
final Code getChild() { erb_directive_def(this, result) }
final Code getChild() { erb_directive_child(this, result) }
/** Gets a field or child node of this node. */
final override AstNode getAFieldOrChild() { erb_directive_def(this, result) }
final override AstNode getAFieldOrChild() { erb_directive_child(this, result) }
}
/** A class representing `graphql_directive` nodes. */
@@ -1955,10 +1955,10 @@ module Erb {
final override string getAPrimaryQlClass() { result = "GraphqlDirective" }
/** Gets the child of this node. */
final Code getChild() { erb_graphql_directive_def(this, result) }
final Code getChild() { erb_graphql_directive_child(this, result) }
/** Gets a field or child node of this node. */
final override AstNode getAFieldOrChild() { erb_graphql_directive_def(this, result) }
final override AstNode getAFieldOrChild() { erb_graphql_directive_child(this, result) }
}
/** A class representing `output_directive` nodes. */
@@ -1967,10 +1967,10 @@ module Erb {
final override string getAPrimaryQlClass() { result = "OutputDirective" }
/** Gets the child of this node. */
final Code getChild() { erb_output_directive_def(this, result) }
final Code getChild() { erb_output_directive_child(this, result) }
/** Gets a field or child node of this node. */
final override AstNode getAFieldOrChild() { erb_output_directive_def(this, result) }
final override AstNode getAFieldOrChild() { erb_output_directive_child(this, result) }
}
/** A class representing `template` nodes. */

View File

@@ -1356,24 +1356,40 @@ ruby_ast_node_info(
int loc: @location ref
);
erb_comment_directive_child(
unique int erb_comment_directive: @erb_comment_directive ref,
unique int child: @erb_token_comment ref
);
erb_comment_directive_def(
unique int id: @erb_comment_directive,
int child: @erb_token_comment ref
unique int id: @erb_comment_directive
);
erb_directive_child(
unique int erb_directive: @erb_directive ref,
unique int child: @erb_token_code ref
);
erb_directive_def(
unique int id: @erb_directive,
int child: @erb_token_code ref
unique int id: @erb_directive
);
erb_graphql_directive_child(
unique int erb_graphql_directive: @erb_graphql_directive ref,
unique int child: @erb_token_code ref
);
erb_graphql_directive_def(
unique int id: @erb_graphql_directive,
int child: @erb_token_code ref
unique int id: @erb_graphql_directive
);
erb_output_directive_child(
unique int erb_output_directive: @erb_output_directive ref,
unique int child: @erb_token_code ref
);
erb_output_directive_def(
unique int id: @erb_output_directive,
int child: @erb_token_code ref
unique int id: @erb_output_directive
);
@erb_template_child_type = @erb_comment_directive | @erb_directive | @erb_graphql_directive | @erb_output_directive | @erb_token_content

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
description: Update ERB parser
compatibility: full
erb_comment_directive_def.rel: reorder erb_comment_directive_def.rel (int id, int child) id
erb_comment_directive_child.rel: reorder erb_comment_directive_def.rel (int id, int child) id child
erb_directive_def.rel: reorder erb_directive_def.rel (int id, int child) id
erb_directive_child.rel: reorder erb_directive_def.rel (int id, int child) id child
erb_graphql_directive_def.rel: reorder erb_graphql_directive_def.rel (int id, int child) id
erb_graphql_directive_child.rel: reorder erb_graphql_directive_def.rel (int id, int child) id child
erb_output_directive_def.rel: reorder erb_output_directive_def.rel (int id, int child) id
erb_output_directive_child.rel: reorder erb_output_directive_def.rel (int id, int child) id child

View File

@@ -3,27 +3,31 @@ erbFiles
erbAstNodes
| template.html.erb:1:1:1:9 | <%graphql |
| template.html.erb:1:1:17:2 | <%graphql\n fragment Foo on Bar {\n ...%> |
| template.html.erb:1:1:32:6 | erb template |
| template.html.erb:1:1:38:1 | erb template |
| template.html.erb:1:10:16:4 | \n fragment Foo on Bar {\n ... |
| template.html.erb:1:10:16:4 | \n fragment Foo on Bar {\n ... |
| template.html.erb:17:1:17:2 | %> |
| template.html.erb:17:3:19:3 | \n\n<%= |
| template.html.erb:17:3:19:20 | <%= "hello world" %> |
| template.html.erb:17:3:18:1 | \n\n |
| template.html.erb:19:1:19:3 | <%= |
| template.html.erb:19:1:19:20 | <%= "hello world" %> |
| template.html.erb:19:4:19:18 | "hello world" |
| template.html.erb:19:4:19:18 | "hello world" |
| template.html.erb:19:19:19:20 | %> |
| template.html.erb:19:21:21:3 | \n\n<%# |
| template.html.erb:19:21:21:31 | <%#= "this is commented out" %> |
| template.html.erb:19:21:20:1 | \n\n |
| template.html.erb:21:1:21:3 | <%# |
| template.html.erb:21:1:21:31 | <%#= "this is commented out" %> |
| template.html.erb:21:4:21:29 | = "this is commented out" |
| template.html.erb:21:4:21:29 | = "this is commented out" |
| template.html.erb:21:30:21:31 | %> |
| template.html.erb:21:32:23:3 | \n\n<%# |
| template.html.erb:21:32:23:35 | <%# "this is also commented out" %> |
| template.html.erb:21:32:22:1 | \n\n |
| template.html.erb:23:1:23:3 | <%# |
| template.html.erb:23:1:23:35 | <%# "this is also commented out" %> |
| template.html.erb:23:4:23:33 | "this is also commented out" |
| template.html.erb:23:4:23:33 | "this is also commented out" |
| template.html.erb:23:34:23:35 | %> |
| template.html.erb:23:36:25:2 | \n\n<% |
| template.html.erb:23:36:25:13 | <% xs = "" %> |
| template.html.erb:23:36:24:1 | \n\n |
| template.html.erb:25:1:25:2 | <% |
| template.html.erb:25:1:25:13 | <% xs = "" %> |
| template.html.erb:25:3:25:11 | xs = "" |
| template.html.erb:25:3:25:11 | xs = "" |
| template.html.erb:25:12:25:13 | %> |
@@ -45,65 +49,94 @@ erbAstNodes
| template.html.erb:31:5:31:9 | end |
| template.html.erb:31:5:31:9 | end |
| template.html.erb:31:10:31:11 | %> |
| template.html.erb:31:12:32:6 | \n</ul>\n |
| template.html.erb:31:12:33:5 | \n</ul>\n<%%>\n |
| template.html.erb:33:1:33:3 | <%% |
| template.html.erb:34:1:34:3 | <%- |
| template.html.erb:34:1:34:5 | <%=%> |
| template.html.erb:34:4:34:5 | %> |
| template.html.erb:34:6:34:6 | \n |
| template.html.erb:35:1:35:3 | <%# |
| template.html.erb:35:1:35:5 | <%#%> |
| template.html.erb:35:4:35:5 | %> |
| template.html.erb:35:6:35:6 | \n |
| template.html.erb:36:1:36:9 | <%graphql |
| template.html.erb:36:1:36:11 | <%graphql%> |
| template.html.erb:36:10:36:11 | %> |
| template.html.erb:36:12:36:12 | \n |
| template.html.erb:37:1:37:3 | <%= |
| template.html.erb:37:1:37:5 | <%=%> |
| template.html.erb:37:4:37:5 | %> |
| template.html.erb:37:6:38:1 | \n\n |
erbTemplates
| template.html.erb:1:1:32:6 | erb template |
| template.html.erb:1:1:38:1 | erb template |
erbDirectives
| template.html.erb:1:1:17:2 | <%graphql\n fragment Foo on Bar {\n ...%> |
| template.html.erb:17:3:19:20 | <%= "hello world" %> |
| template.html.erb:19:21:21:31 | <%#= "this is commented out" %> |
| template.html.erb:21:32:23:35 | <%# "this is also commented out" %> |
| template.html.erb:23:36:25:13 | <% xs = "" %> |
| template.html.erb:19:1:19:20 | <%= "hello world" %> |
| template.html.erb:21:1:21:31 | <%#= "this is commented out" %> |
| template.html.erb:23:1:23:35 | <%# "this is also commented out" %> |
| template.html.erb:25:1:25:13 | <% xs = "" %> |
| template.html.erb:27:3:27:41 | <% for x in ["foo", "bar", "baz...%> |
| template.html.erb:28:7:30:12 | <%= xs += x\n xs\n %> |
| template.html.erb:31:3:31:11 | <% end %> |
| template.html.erb:34:1:34:5 | <%=%> |
| template.html.erb:35:1:35:5 | <%#%> |
| template.html.erb:36:1:36:11 | <%graphql%> |
| template.html.erb:37:1:37:5 | <%=%> |
erbCommentDirectives
| template.html.erb:19:21:21:31 | <%#= "this is commented out" %> |
| template.html.erb:21:32:23:35 | <%# "this is also commented out" %> |
| template.html.erb:21:1:21:31 | <%#= "this is commented out" %> |
| template.html.erb:23:1:23:35 | <%# "this is also commented out" %> |
| template.html.erb:35:1:35:5 | <%#%> |
erbGraphqlDirectives
| template.html.erb:1:1:17:2 | <%graphql\n fragment Foo on Bar {\n ...%> |
| template.html.erb:36:1:36:11 | <%graphql%> |
erbOutputDirectives
| template.html.erb:17:3:19:20 | <%= "hello world" %> |
| template.html.erb:19:1:19:20 | <%= "hello world" %> |
| template.html.erb:28:7:30:12 | <%= xs += x\n xs\n %> |
| template.html.erb:34:1:34:5 | <%=%> |
| template.html.erb:37:1:37:5 | <%=%> |
erbExecutionDirectives
| template.html.erb:23:36:25:13 | <% xs = "" %> |
| template.html.erb:25:1:25:13 | <% xs = "" %> |
| template.html.erb:27:3:27:41 | <% for x in ["foo", "bar", "baz...%> |
| template.html.erb:31:3:31:11 | <% end %> |
childStmts
| template.html.erb:17:3:19:20 | <%= "hello world" %> | template.html.erb:19:5:19:17 | "hello world" |
| template.html.erb:23:36:25:13 | <% xs = "" %> | template.html.erb:25:4:25:10 | ... = ... |
| template.html.erb:19:1:19:20 | <%= "hello world" %> | template.html.erb:19:5:19:17 | "hello world" |
| template.html.erb:25:1:25:13 | <% xs = "" %> | template.html.erb:25:4:25:10 | ... = ... |
| template.html.erb:27:3:27:41 | <% for x in ["foo", "bar", "baz...%> | template.html.erb:27:6:31:8 | for ... in ... |
| template.html.erb:28:7:30:12 | <%= xs += x\n xs\n %> | template.html.erb:28:11:28:17 | ... += ... |
| template.html.erb:28:7:30:12 | <%= xs += x\n xs\n %> | template.html.erb:29:11:29:12 | xs |
terminalStatements
| template.html.erb:17:3:19:20 | <%= "hello world" %> | template.html.erb:19:5:19:17 | "hello world" |
| template.html.erb:23:36:25:13 | <% xs = "" %> | template.html.erb:25:4:25:10 | ... = ... |
| template.html.erb:19:1:19:20 | <%= "hello world" %> | template.html.erb:19:5:19:17 | "hello world" |
| template.html.erb:25:1:25:13 | <% xs = "" %> | template.html.erb:25:4:25:10 | ... = ... |
| template.html.erb:27:3:27:41 | <% for x in ["foo", "bar", "baz...%> | template.html.erb:27:6:31:8 | for ... in ... |
| template.html.erb:28:7:30:12 | <%= xs += x\n xs\n %> | template.html.erb:29:11:29:12 | xs |
primaryQlClasses
| template.html.erb:1:1:1:9 | <%graphql | ErbToken |
| template.html.erb:1:1:17:2 | <%graphql\n fragment Foo on Bar {\n ...%> | ErbGraphqlDirective |
| template.html.erb:1:1:32:6 | erb template | ErbTemplate |
| template.html.erb:1:1:38:1 | erb template | ErbTemplate |
| template.html.erb:1:10:16:4 | \n fragment Foo on Bar {\n ... | ErbCode |
| template.html.erb:1:10:16:4 | \n fragment Foo on Bar {\n ... | ErbToken |
| template.html.erb:17:1:17:2 | %> | ErbToken |
| template.html.erb:17:3:19:3 | \n\n<%= | ErbToken |
| template.html.erb:17:3:19:20 | <%= "hello world" %> | ErbOutputDirective |
| template.html.erb:17:3:18:1 | \n\n | ErbToken |
| template.html.erb:19:1:19:3 | <%= | ErbToken |
| template.html.erb:19:1:19:20 | <%= "hello world" %> | ErbOutputDirective |
| template.html.erb:19:4:19:18 | "hello world" | ErbCode |
| template.html.erb:19:4:19:18 | "hello world" | ErbToken |
| template.html.erb:19:19:19:20 | %> | ErbToken |
| template.html.erb:19:21:21:3 | \n\n<%# | ErbToken |
| template.html.erb:19:21:21:31 | <%#= "this is commented out" %> | ErbCommentDirective |
| template.html.erb:19:21:20:1 | \n\n | ErbToken |
| template.html.erb:21:1:21:3 | <%# | ErbToken |
| template.html.erb:21:1:21:31 | <%#= "this is commented out" %> | ErbCommentDirective |
| template.html.erb:21:4:21:29 | = "this is commented out" | ErbComment |
| template.html.erb:21:4:21:29 | = "this is commented out" | ErbToken |
| template.html.erb:21:30:21:31 | %> | ErbToken |
| template.html.erb:21:32:23:3 | \n\n<%# | ErbToken |
| template.html.erb:21:32:23:35 | <%# "this is also commented out" %> | ErbCommentDirective |
| template.html.erb:21:32:22:1 | \n\n | ErbToken |
| template.html.erb:23:1:23:3 | <%# | ErbToken |
| template.html.erb:23:1:23:35 | <%# "this is also commented out" %> | ErbCommentDirective |
| template.html.erb:23:4:23:33 | "this is also commented out" | ErbComment |
| template.html.erb:23:4:23:33 | "this is also commented out" | ErbToken |
| template.html.erb:23:34:23:35 | %> | ErbToken |
| template.html.erb:23:36:25:2 | \n\n<% | ErbToken |
| template.html.erb:23:36:25:13 | <% xs = "" %> | ErbExecutionDirective |
| template.html.erb:23:36:24:1 | \n\n | ErbToken |
| template.html.erb:25:1:25:2 | <% | ErbToken |
| template.html.erb:25:1:25:13 | <% xs = "" %> | ErbExecutionDirective |
| template.html.erb:25:3:25:11 | xs = "" | ErbCode |
| template.html.erb:25:3:25:11 | xs = "" | ErbToken |
| template.html.erb:25:12:25:13 | %> | ErbToken |
@@ -125,6 +158,23 @@ primaryQlClasses
| template.html.erb:31:5:31:9 | end | ErbCode |
| template.html.erb:31:5:31:9 | end | ErbToken |
| template.html.erb:31:10:31:11 | %> | ErbToken |
| template.html.erb:31:12:32:6 | \n</ul>\n | ErbToken |
| template.html.erb:31:12:33:5 | \n</ul>\n<%%>\n | ErbToken |
| template.html.erb:33:1:33:3 | <%% | ErbToken |
| template.html.erb:34:1:34:3 | <%- | ErbToken |
| template.html.erb:34:1:34:5 | <%=%> | ErbOutputDirective |
| template.html.erb:34:4:34:5 | %> | ErbToken |
| template.html.erb:34:6:34:6 | \n | ErbToken |
| template.html.erb:35:1:35:3 | <%# | ErbToken |
| template.html.erb:35:1:35:5 | <%#%> | ErbCommentDirective |
| template.html.erb:35:4:35:5 | %> | ErbToken |
| template.html.erb:35:6:35:6 | \n | ErbToken |
| template.html.erb:36:1:36:9 | <%graphql | ErbToken |
| template.html.erb:36:1:36:11 | <%graphql%> | ErbGraphqlDirective |
| template.html.erb:36:10:36:11 | %> | ErbToken |
| template.html.erb:36:12:36:12 | \n | ErbToken |
| template.html.erb:37:1:37:3 | <%= | ErbToken |
| template.html.erb:37:1:37:5 | <%=%> | ErbOutputDirective |
| template.html.erb:37:4:37:5 | %> | ErbToken |
| template.html.erb:37:6:38:1 | \n\n | ErbToken |
erbFileTemplates
| template.html.erb:0:0:0:0 | template.html.erb | template.html.erb:1:1:32:6 | erb template |
| template.html.erb:0:0:0:0 | template.html.erb | template.html.erb:1:1:38:1 | erb template |

View File

@@ -30,3 +30,9 @@
%></li>
<% end %>
</ul>
<%%>
<%-%>
<%#%>
<%graphql%>
<%=%>