Skip to content

Commit ccc1864

Browse files
committed
Ruby: add upgrade and downgrade scripts
1 parent d055f9a commit ccc1864

20 files changed

+6059
-0
lines changed

ruby/downgrades/1199e154f5e9b3560297633c6ebb4dfe0b191ae4/old.dbscheme

Lines changed: 1417 additions & 0 deletions
Large diffs are not rendered by default.

ruby/downgrades/1199e154f5e9b3560297633c6ebb4dfe0b191ae4/ruby.dbscheme

Lines changed: 1393 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class RubyBlockParameters extends @ruby_block_parameters {
2+
string toString() { none() }
3+
}
4+
5+
class RubyBlockParameter extends @ruby_block_parameters_child_type {
6+
string toString() { none() }
7+
}
8+
9+
from RubyBlockParameters ruby_block_parameters, int index, RubyBlockParameter param
10+
where
11+
ruby_block_parameters_child(ruby_block_parameters, index, param) or
12+
ruby_block_parameters_locals(ruby_block_parameters,
13+
index - 1 - max(int i | ruby_block_parameters_child(ruby_block_parameters, i, _)), param)
14+
select ruby_block_parameters, index, param
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class RubyAstNode extends @ruby_ast_node {
2+
string toString() { none() }
3+
}
4+
5+
class RubyCall extends RubyAstNode, @ruby_call { }
6+
7+
from RubyCall ruby_call, RubyAstNode method
8+
where
9+
ruby_call_method(ruby_call, method)
10+
or
11+
ruby_call_def(ruby_call) and
12+
not ruby_call_method(ruby_call, _) and
13+
ruby_call_arguments(ruby_call, method)
14+
select ruby_call, method
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
private class RubyAstNode extends @ruby_ast_node {
2+
string toString() { none() }
3+
}
4+
5+
from RubyAstNode node, RubyAstNode child
6+
where ruby_rational_def(node, child) and not ruby_complex_def(_, node)
7+
select node, child
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
private class RubyAstNode extends @ruby_ast_node {
2+
string toString() { none() }
3+
}
4+
5+
bindingset[old]
6+
private int newKind(int old) {
7+
old <= 3 and result = old
8+
or
9+
old >= 4 and result = old + 1
10+
}
11+
12+
private predicate complex_token(RubyAstNode node, string value) {
13+
exists(RubyAstNode token, string tokenValue | ruby_tokeninfo(token, _, tokenValue) |
14+
(
15+
ruby_complex_def(node, token) and value = tokenValue + "i"
16+
or
17+
exists(@ruby_rational rational |
18+
ruby_complex_def(node, rational) and
19+
ruby_rational_def(rational, token)
20+
) and
21+
value = tokenValue + "ri"
22+
)
23+
)
24+
}
25+
26+
private RubyAstNode parent(RubyAstNode node) { ruby_ast_node_info(node, result, _, _) }
27+
28+
from RubyAstNode token, int kind, string value
29+
where
30+
exists(int oldKind |
31+
ruby_tokeninfo(token, oldKind, value) and
32+
not complex_token(parent+(token), _) and
33+
kind = newKind(oldKind)
34+
)
35+
or
36+
complex_token(token, value) and kind = 4
37+
select token, kind, value
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
description: tree-sitter-ruby update
2+
compatibility: backwards
3+
ruby_tokeninfo.rel: run ruby_tokeninfo.qlo
4+
ruby_block_parameters_child.rel: run ruby_block_parameters_child.qlo
5+
ruby_call_def.rel: run ruby_call_def.qlo
6+
ruby_rational_def.rel: run ruby_rational_def.qlo
7+
8+
9+
ruby_call_method.rel: delete
10+
ruby_complex_def.rel: delete
11+
ruby_block_parameters_locals.rel: delete
12+
ruby_call_operator: delete

0 commit comments

Comments
 (0)