Merge pull request #7753 from aibaars/ruby-3.1

Ruby 3.1 features
This commit is contained in:
Arthur Baars
2022-02-06 21:06:16 +01:00
committed by GitHub
47 changed files with 16454 additions and 6396 deletions

View File

@@ -52,6 +52,14 @@ jobs:
codeql dataset import -S ql/lib/upgrades/initial/ruby.dbscheme testdb empty.trap
codeql dataset upgrade testdb --additional-packs ql/lib
diff -q testdb/ruby.dbscheme ql/lib/ruby.dbscheme
- name: Check DB downgrade scripts
run: |
echo >empty.trap
rm -rf testdb; codeql dataset import -S ql/lib/ruby.dbscheme testdb empty.trap
codeql resolve upgrades --format=lines --allow-downgrades --additional-packs downgrades \
--dbscheme=ql/lib/ruby.dbscheme --target-dbscheme=downgrades/initial/ruby.dbscheme |
xargs codeql execute upgrades testdb
diff -q testdb/ruby.dbscheme downgrades/initial/ruby.dbscheme
qltest:
runs-on: ubuntu-latest
strategy:

BIN
ruby/Cargo.lock generated

Binary file not shown.

View File

@@ -0,0 +1,13 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
class Location extends @location {
string toString() { none() }
}
from AstNode ruby_block_argument, AstNode child, Location location
where
ruby_block_argument_def(ruby_block_argument, location) and
ruby_block_argument_child(ruby_block_argument, child)
select ruby_block_argument, child, location

View File

@@ -0,0 +1,13 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
class Location extends @location {
string toString() { none() }
}
from AstNode ruby_block_parameter, AstNode name, Location location
where
ruby_block_parameter_def(ruby_block_parameter, location) and
ruby_block_parameter_name(ruby_block_parameter, name)
select ruby_block_parameter, name, location

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 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
class Location extends @location {
string toString() { none() }
}
from AstNode ruby_pair, AstNode key, AstNode value, Location location
where
ruby_pair_def(ruby_pair, key, location) and
ruby_pair_value(ruby_pair, value)
select ruby_pair, key, value, location

View File

@@ -0,0 +1,9 @@
description: Update grammar
compatibility: backwards
ruby_expression_reference_pattern_def.rel: delete
ruby_block_argument_child.rel: delete
ruby_block_parameter_name.rel: delete
ruby_pair_value.rel: delete
ruby_block_argument_def.rel: run block_argument_def.qlo
ruby_block_parameter_def.rel: run block_parameter_def.qlo
ruby_pair_def.rel: run ruby_pair_def.qlo

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
name: codeql/ruby-downgrades
groups: ruby
downgrades: .
library: true

View File

@@ -11,7 +11,7 @@ flate2 = "1.0"
node-types = { path = "../node-types" }
tree-sitter = "0.19"
tree-sitter-embedded-template = "0.19"
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "888e2e563ed3b43c417f17e57f7e29c39ce9aeea" }
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "1ebfdb288842dae5a9233e2509a135949023dd82" }
clap = "3.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }

View File

@@ -12,4 +12,4 @@ 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-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "888e2e563ed3b43c417f17e57f7e29c39ce9aeea" }
tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "1ebfdb288842dae5a9233e2509a135949023dd82" }

View File

@@ -187,7 +187,10 @@ class BlockArgument extends Expr, TBlockArgument {
* foo(&bar)
* ```
*/
final Expr getValue() { toGenerated(result) = g.getChild() }
final Expr getValue() {
toGenerated(result) = g.getChild() or
synthChild(this, 0, result)
}
final override string toString() { result = "&..." }

View File

@@ -293,13 +293,16 @@ class Pair extends Expr, TPair {
final Expr getKey() { toGenerated(result) = g.getKey() }
/**
* Gets the value expression of this pair. For example, the `InteralLiteral`
* Gets the value expression of this pair. For example, the `IntegerLiteral`
* 123 in the following hash pair:
* ```rb
* { 'foo' => 123 }
* ```
*/
final Expr getValue() { toGenerated(result) = g.getValue() }
final Expr getValue() {
toGenerated(result) = g.getValue() or
synthChild(this, 0, result)
}
final override string toString() { result = "Pair" }

View File

@@ -148,11 +148,19 @@ class BlockParameter extends NamedParameter, TBlockParameter {
BlockParameter() { this = TBlockParameter(g) }
/** Gets the name of this parameter, if any. */
final override string getName() { result = g.getName().getValue() }
final override LocalVariable getVariable() { result = TLocalVariableReal(_, _, g.getName()) }
final override LocalVariable getVariable() {
result = TLocalVariableReal(_, _, g.getName()) or
result = TLocalVariableSynth(this, 0)
}
final override string toString() { result = "&" + this.getName() }
final override string toString() {
result = "&" + this.getName()
or
not exists(this.getName()) and result = "&"
}
final override string getAPrimaryQlClass() { result = "BlockParameter" }
}

View File

@@ -80,7 +80,7 @@ deprecated class TuplePattern extends Pattern, TTuplePattern {
private class TPatternNode =
TArrayPattern or TFindPattern or THashPattern or TAlternativePattern or TAsPattern or
TParenthesizedPattern or TVariableReferencePattern;
TParenthesizedPattern or TExpressionReferencePattern or TVariableReferencePattern;
private class TPattern =
TPatternNode or TLiteral or TLambda or TConstantAccess or TLocalVariableAccess or
@@ -404,6 +404,42 @@ class ParenthesizedPattern extends CasePattern, TParenthesizedPattern {
}
/**
* A variable or value reference in a pattern, i.e. `^x`, and `^(2 * x)` in the following example:
* ```rb
* x = 10
* case expr
* in ^x then puts "ok"
* in ^(2 * x) then puts "ok"
* end
* ```
*/
class ReferencePattern extends CasePattern, TReferencePattern {
private Ruby::AstNode value;
ReferencePattern() {
value = any(Ruby::VariableReferencePattern g | this = TVariableReferencePattern(g)).getName()
or
value =
any(Ruby::ExpressionReferencePattern g | this = TExpressionReferencePattern(g)).getValue()
}
/** Gets the value this reference pattern matches against. For example `2 * x` in `^(2 * x)` */
final Expr getExpr() { toGenerated(result) = value }
final override string getAPrimaryQlClass() { result = "ReferencePattern" }
final override string toString() { result = "^..." }
final override AstNode getAChild(string pred) {
result = super.getAChild(pred)
or
pred = "getExpr" and result = this.getExpr()
}
}
/**
* DEPRECATED: Use `ReferencePattern` instead.
*
* A variable reference in a pattern, i.e. `^x` in the following example:
* ```rb
* x = 10
@@ -412,21 +448,7 @@ class ParenthesizedPattern extends CasePattern, TParenthesizedPattern {
* end
* ```
*/
class VariableReferencePattern extends CasePattern, TVariableReferencePattern {
private Ruby::VariableReferencePattern g;
VariableReferencePattern() { this = TVariableReferencePattern(g) }
deprecated class VariableReferencePattern extends ReferencePattern, TVariableReferencePattern {
/** Gets the variable access corresponding to this variable reference pattern. */
LocalVariableReadAccess getVariableAccess() { toGenerated(result) = g.getName() }
final override string getAPrimaryQlClass() { result = "VariableReferencePattern" }
final override string toString() { result = "^..." }
final override AstNode getAChild(string pred) {
result = super.getAChild(pred)
or
pred = "getVariableAccess" and result = this.getVariableAccess()
}
final VariableReadAccess getVariableAccess() { result = this.getExpr() }
}

View File

@@ -35,7 +35,10 @@ class LocalVariable extends Variable, TLocalVariable {
override LocalVariableAccess getAnAccess() { result.getVariable() = this }
/** Gets the access where this local variable is first introduced. */
VariableAccess getDefiningAccess() { result = this.(LocalVariableReal).getDefiningAccessImpl() }
VariableAccess getDefiningAccess() {
result = this.(LocalVariableReal).getDefiningAccessImpl() or
synthChild(any(BlockParameter p | this = p.getVariable()), 0, result)
}
/**
* Holds if this variable is captured. For example in
@@ -117,6 +120,8 @@ class VariableAccess extends Expr instanceof VariableAccessImpl {
this = any(SimpleParameterSynthImpl p).getDefininingAccess()
or
this = any(HashPattern p).getValue(_)
or
synthChild(any(BlockParameter p), 0, this)
}
final override string toString() { result = VariableAccessImpl.super.toString() }

View File

@@ -320,11 +320,14 @@ private module Cached {
TUntilExpr(Ruby::Until g) or
TUntilModifierExpr(Ruby::UntilModifier g) or
TVariableReferencePattern(Ruby::VariableReferencePattern g) or
TExpressionReferencePattern(Ruby::ExpressionReferencePattern g) or
TWhenClause(Ruby::When g) or
TWhileExpr(Ruby::While g) or
TWhileModifierExpr(Ruby::WhileModifier g) or
TYieldCall(Ruby::Yield g)
class TReferencePattern = TVariableReferencePattern or TExpressionReferencePattern;
class TAstNodeReal =
TAddExprReal or TAliasStmt or TAlternativePattern or TArgumentList or TArrayPattern or
TAsPattern or TAssignAddExpr or TAssignBitwiseAndExpr or TAssignBitwiseOrExpr or
@@ -359,7 +362,7 @@ private module Cached {
TTernaryIfExpr or TThen or TTokenConstantAccess or TTokenMethodName or TTokenSuperCall or
TToplevel or TTrueLiteral or TUnaryMinusExpr or TUnaryPlusExpr or TUndefStmt or
TUnlessExpr or TUnlessModifierExpr or TUntilExpr or TUntilModifierExpr or
TVariableReferencePattern or TWhenClause or TWhileExpr or TWhileModifierExpr or TYieldCall;
TReferencePattern or TWhenClause or TWhileExpr or TWhileModifierExpr or TYieldCall;
class TAstNodeSynth =
TAddExprSynth or TAssignExprSynth or TBitwiseAndExprSynth or TBitwiseOrExprSynth or
@@ -529,6 +532,7 @@ private module Cached {
n = TUntilExpr(result) or
n = TUntilModifierExpr(result) or
n = TVariableReferencePattern(result) or
n = TExpressionReferencePattern(result) or
n = TWhenClause(result) or
n = TWhileExpr(result) or
n = TWhileModifierExpr(result) or

View File

@@ -975,24 +975,107 @@ private module ForLoopDesugar {
* ```
*/
private module ImplicitHashValueSynthesis {
private Ruby::AstNode keyWithoutValue(HashPattern parent, int i) {
private Ruby::AstNode keyWithoutValue(AstNode parent, int i) {
exists(Ruby::KeywordPattern pair |
result = pair.getKey() and
result = toGenerated(parent.getKey(i)) and
result = toGenerated(parent.(HashPattern).getKey(i)) and
not exists(pair.getValue())
)
or
exists(Ruby::Pair pair |
i = 0 and
result = pair.getKey() and
pair = toGenerated(parent) and
not exists(pair.getValue())
)
}
private string keyName(Ruby::AstNode key) {
result = key.(Ruby::String).getChild(0).(Ruby::StringContent).getValue() or
result = key.(Ruby::HashKeySymbol).getValue()
}
private class ImplicitHashValueSynthesis extends Synthesis {
final override predicate child(AstNode parent, int i, Child child) {
exists(TVariableReal variable |
access(keyWithoutValue(parent, i), variable) and
child = SynthChild(LocalVariableAccessRealKind(variable))
exists(Ruby::AstNode key | key = keyWithoutValue(parent, i) |
exists(TVariableReal variable |
access(key, variable) and
child = SynthChild(LocalVariableAccessRealKind(variable))
)
or
not access(key, _) and
exists(string name | name = keyName(key) |
child = SynthChild(ConstantReadAccessKind(name)) or
child = SynthChild(MethodCallKind(name, false, 0))
)
)
}
final override predicate methodCall(string name, boolean setter, int arity) {
setter = false and
arity = 0 and
name = keyName(keyWithoutValue(_, _)) and
not name.charAt(0).isUppercase()
}
final override predicate constantReadAccess(string name) {
name = keyName(keyWithoutValue(_, _)) and
name.charAt(0).isUppercase()
}
final override predicate location(AstNode n, Location l) {
exists(HashPattern p, int i | n = p.getValue(i) and l = keyWithoutValue(p, i).getLocation())
exists(AstNode p, int i | l = keyWithoutValue(p, i).getLocation() |
n = p.(HashPattern).getValue(i)
or
i = 0 and n = p.(Pair).getValue()
)
}
}
}
/**
* ```rb
* def foo(&)
* bar(&)
* end
* ```
* desugars to,
* ```rb
* def foo(&__synth_0)
* bar(&__synth_0)
* end
* ```
*/
private module AnonymousBlockParameterSynth {
private BlockParameter anonymousBlockParameter() {
exists(Ruby::BlockParameter p | not exists(p.getName()) and toGenerated(result) = p)
}
private BlockArgument anonymousBlockArgument() {
exists(Ruby::BlockArgument p | not exists(p.getChild()) and toGenerated(result) = p)
}
private class AnonymousBlockParameterSynthesis extends Synthesis {
final override predicate child(AstNode parent, int i, Child child) {
i = 0 and
parent = anonymousBlockParameter() and
child = SynthChild(LocalVariableAccessSynthKind(TLocalVariableSynth(parent, 0)))
}
final override predicate localVariable(AstNode n, int i) {
n = anonymousBlockParameter() and i = 0
}
}
private class AnonymousBlockArgumentSynthesis extends Synthesis {
final override predicate child(AstNode parent, int i, Child child) {
i = 0 and
parent = anonymousBlockArgument() and
exists(BlockParameter param |
param = anonymousBlockParameter() and
scopeOf(toGenerated(parent)).getEnclosingMethod() = scopeOf(toGenerated(param)) and
child = SynthChild(LocalVariableAccessSynthKind(TLocalVariableSynth(param, 0)))
)
}
}
}

View File

@@ -59,6 +59,8 @@ module Ruby {
class UnderscoreMethodName extends @ruby_underscore_method_name, AstNode { }
class UnderscoreNonlocalVariable extends @ruby_underscore_nonlocal_variable, AstNode { }
class UnderscorePatternConstant extends @ruby_underscore_pattern_constant, AstNode { }
class UnderscorePatternExpr extends @ruby_underscore_pattern_expr, AstNode { }
@@ -365,13 +367,13 @@ module Ruby {
override string getAPrimaryQlClass() { result = "BlockArgument" }
/** Gets the location of this element. */
override L::Location getLocation() { ruby_block_argument_def(this, _, result) }
override L::Location getLocation() { ruby_block_argument_def(this, result) }
/** Gets the child of this node. */
UnderscoreArg getChild() { ruby_block_argument_def(this, result, _) }
UnderscoreArg getChild() { ruby_block_argument_child(this, result) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { ruby_block_argument_def(this, result, _) }
override AstNode getAFieldOrChild() { ruby_block_argument_child(this, result) }
}
/** A class representing `block_parameter` nodes. */
@@ -380,13 +382,13 @@ module Ruby {
override string getAPrimaryQlClass() { result = "BlockParameter" }
/** Gets the location of this element. */
override L::Location getLocation() { ruby_block_parameter_def(this, _, result) }
override L::Location getLocation() { ruby_block_parameter_def(this, result) }
/** Gets the node corresponding to the field `name`. */
Identifier getName() { ruby_block_parameter_def(this, result, _) }
Identifier getName() { ruby_block_parameter_name(this, result) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { ruby_block_parameter_def(this, result, _) }
override AstNode getAFieldOrChild() { ruby_block_parameter_name(this, result) }
}
/** A class representing `block_parameters` nodes. */
@@ -806,6 +808,21 @@ module Ruby {
override AstNode getAFieldOrChild() { ruby_exceptions_child(this, _, result) }
}
/** A class representing `expression_reference_pattern` nodes. */
class ExpressionReferencePattern extends @ruby_expression_reference_pattern, AstNode {
/** Gets the name of the primary QL class for this element. */
override string getAPrimaryQlClass() { result = "ExpressionReferencePattern" }
/** Gets the location of this element. */
override L::Location getLocation() { ruby_expression_reference_pattern_def(this, _, result) }
/** Gets the node corresponding to the field `value`. */
UnderscoreExpression getValue() { ruby_expression_reference_pattern_def(this, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { ruby_expression_reference_pattern_def(this, result, _) }
}
/** A class representing `false` tokens. */
class False extends @ruby_token_false, Token {
/** Gets the name of the primary QL class for this element. */
@@ -1392,17 +1409,17 @@ module Ruby {
override string getAPrimaryQlClass() { result = "Pair" }
/** Gets the location of this element. */
override L::Location getLocation() { ruby_pair_def(this, _, _, result) }
override L::Location getLocation() { ruby_pair_def(this, _, result) }
/** Gets the node corresponding to the field `key`. */
AstNode getKey() { ruby_pair_def(this, result, _, _) }
AstNode getKey() { ruby_pair_def(this, result, _) }
/** Gets the node corresponding to the field `value`. */
UnderscoreArg getValue() { ruby_pair_def(this, _, result, _) }
UnderscoreArg getValue() { ruby_pair_value(this, result) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() {
ruby_pair_def(this, result, _, _) or ruby_pair_def(this, _, result, _)
ruby_pair_def(this, result, _) or ruby_pair_value(this, result)
}
}
@@ -2041,7 +2058,7 @@ module Ruby {
override L::Location getLocation() { ruby_variable_reference_pattern_def(this, _, result) }
/** Gets the node corresponding to the field `name`. */
Identifier getName() { ruby_variable_reference_pattern_def(this, result, _) }
AstNode getName() { ruby_variable_reference_pattern_def(this, result, _) }
/** Gets a field or child node of this node. */
override AstNode getAFieldOrChild() { ruby_variable_reference_pattern_def(this, result, _) }

View File

@@ -116,6 +116,11 @@ private string variableNameInScope(Ruby::AstNode i, Scope::Range scope) {
result = i.(Ruby::String).getChild(0).(Ruby::StringContent).getValue() or
result = i.(Ruby::HashKeySymbol).getValue()
)
or
exists(Ruby::Pair p | i = p.getKey() and not exists(p.getValue()) |
result = i.(Ruby::String).getChild(0).(Ruby::StringContent).getValue() or
result = i.(Ruby::HashKeySymbol).getValue()
)
)
}
@@ -307,6 +312,8 @@ private module Cached {
i = any(Ruby::WhileModifier x).getCondition()
or
i = any(Ruby::WhileModifier x).getBody()
or
i = any(Ruby::ExpressionReferencePattern x).getValue()
}
pragma[nomagic]

View File

@@ -235,7 +235,7 @@ private predicate inMatchingContext(AstNode n) {
or
n instanceof CasePattern
or
n = any(VariableReferencePattern p).getVariableAccess()
n = any(ReferencePattern p).getExpr()
or
n.(Trees::DefaultValueParameterTree).hasDefaultValue()
}

View File

@@ -731,8 +731,8 @@ module Trees {
override ControlFlowTree getChildElement(int i) { result = this.getPattern() and i = 0 }
}
private class VariableReferencePatternTree extends StandardPreOrderTree, VariableReferencePattern {
override ControlFlowTree getChildElement(int i) { result = this.getVariableAccess() and i = 0 }
private class ReferencePatternTree extends StandardPreOrderTree, ReferencePattern {
override ControlFlowTree getChildElement(int i) { result = this.getExpr() and i = 0 }
}
private class InClauseTree extends PreOrderTree, InClause {

View File

@@ -56,13 +56,15 @@ case @diagnostic.severity of
@ruby_underscore_lhs = @ruby_call | @ruby_element_reference | @ruby_scope_resolution | @ruby_token_false | @ruby_token_nil | @ruby_token_true | @ruby_underscore_variable
@ruby_underscore_method_name = @ruby_delimited_symbol | @ruby_setter | @ruby_token_class_variable | @ruby_token_constant | @ruby_token_global_variable | @ruby_token_identifier | @ruby_token_instance_variable | @ruby_token_operator | @ruby_token_simple_symbol
@ruby_underscore_method_name = @ruby_delimited_symbol | @ruby_setter | @ruby_token_constant | @ruby_token_identifier | @ruby_token_operator | @ruby_token_simple_symbol | @ruby_underscore_nonlocal_variable
@ruby_underscore_nonlocal_variable = @ruby_token_class_variable | @ruby_token_global_variable | @ruby_token_instance_variable
@ruby_underscore_pattern_constant = @ruby_scope_resolution | @ruby_token_constant
@ruby_underscore_pattern_expr = @ruby_alternative_pattern | @ruby_as_pattern | @ruby_underscore_pattern_expr_basic
@ruby_underscore_pattern_expr_basic = @ruby_array_pattern | @ruby_find_pattern | @ruby_hash_pattern | @ruby_parenthesized_pattern | @ruby_range | @ruby_token_identifier | @ruby_underscore_pattern_constant | @ruby_underscore_pattern_primitive | @ruby_variable_reference_pattern
@ruby_underscore_pattern_expr_basic = @ruby_array_pattern | @ruby_expression_reference_pattern | @ruby_find_pattern | @ruby_hash_pattern | @ruby_parenthesized_pattern | @ruby_range | @ruby_token_identifier | @ruby_underscore_pattern_constant | @ruby_underscore_pattern_primitive | @ruby_variable_reference_pattern
@ruby_underscore_pattern_primitive = @ruby_delimited_symbol | @ruby_lambda | @ruby_regex | @ruby_string__ | @ruby_string_array | @ruby_symbol_array | @ruby_token_encoding | @ruby_token_false | @ruby_token_file | @ruby_token_line | @ruby_token_nil | @ruby_token_self | @ruby_token_simple_symbol | @ruby_token_true | @ruby_unary | @ruby_underscore_simple_numeric
@@ -74,7 +76,7 @@ case @diagnostic.severity of
@ruby_underscore_statement = @ruby_alias | @ruby_begin_block | @ruby_end_block | @ruby_if_modifier | @ruby_rescue_modifier | @ruby_undef | @ruby_underscore_expression | @ruby_unless_modifier | @ruby_until_modifier | @ruby_while_modifier
@ruby_underscore_variable = @ruby_token_class_variable | @ruby_token_constant | @ruby_token_global_variable | @ruby_token_identifier | @ruby_token_instance_variable | @ruby_token_self | @ruby_token_super
@ruby_underscore_variable = @ruby_token_constant | @ruby_token_identifier | @ruby_token_self | @ruby_token_super | @ruby_underscore_nonlocal_variable
ruby_alias_def(
unique int id: @ruby_alias,
@@ -272,15 +274,23 @@ ruby_block_def(
int loc: @location ref
);
ruby_block_argument_child(
unique int ruby_block_argument: @ruby_block_argument ref,
unique int child: @ruby_underscore_arg ref
);
ruby_block_argument_def(
unique int id: @ruby_block_argument,
int child: @ruby_underscore_arg ref,
int loc: @location ref
);
ruby_block_parameter_name(
unique int ruby_block_parameter: @ruby_block_parameter ref,
unique int name: @ruby_token_identifier ref
);
ruby_block_parameter_def(
unique int id: @ruby_block_parameter,
int name: @ruby_token_identifier ref,
int loc: @location ref
);
@@ -584,6 +594,12 @@ ruby_exceptions_def(
int loc: @location ref
);
ruby_expression_reference_pattern_def(
unique int id: @ruby_expression_reference_pattern,
int value: @ruby_underscore_expression ref,
int loc: @location ref
);
ruby_find_pattern_class(
unique int ruby_find_pattern: @ruby_find_pattern ref,
unique int class: @ruby_underscore_pattern_constant ref
@@ -905,10 +921,14 @@ ruby_optional_parameter_def(
@ruby_pair_key_type = @ruby_string__ | @ruby_token_hash_key_symbol | @ruby_underscore_arg
ruby_pair_value(
unique int ruby_pair: @ruby_pair ref,
unique int value: @ruby_underscore_arg ref
);
ruby_pair_def(
unique int id: @ruby_pair,
int key__: @ruby_pair_key_type ref,
int value: @ruby_underscore_arg ref,
int loc: @location ref
);
@@ -1308,9 +1328,11 @@ ruby_until_modifier_def(
int loc: @location ref
);
@ruby_variable_reference_pattern_name_type = @ruby_token_identifier | @ruby_underscore_nonlocal_variable
ruby_variable_reference_pattern_def(
unique int id: @ruby_variable_reference_pattern,
int name: @ruby_token_identifier ref,
int name: @ruby_variable_reference_pattern_name_type ref,
int loc: @location ref
);
@@ -1398,7 +1420,7 @@ case @ruby_token.kind of
;
@ruby_ast_node = @ruby_alias | @ruby_alternative_pattern | @ruby_argument_list | @ruby_array | @ruby_array_pattern | @ruby_as_pattern | @ruby_assignment | @ruby_bare_string | @ruby_bare_symbol | @ruby_begin | @ruby_begin_block | @ruby_binary | @ruby_block | @ruby_block_argument | @ruby_block_parameter | @ruby_block_parameters | @ruby_break | @ruby_call | @ruby_case__ | @ruby_case_match | @ruby_chained_string | @ruby_class | @ruby_conditional | @ruby_delimited_symbol | @ruby_destructured_left_assignment | @ruby_destructured_parameter | @ruby_do | @ruby_do_block | @ruby_element_reference | @ruby_else | @ruby_elsif | @ruby_end_block | @ruby_ensure | @ruby_exception_variable | @ruby_exceptions | @ruby_find_pattern | @ruby_for | @ruby_hash | @ruby_hash_pattern | @ruby_hash_splat_argument | @ruby_hash_splat_parameter | @ruby_heredoc_body | @ruby_if | @ruby_if_guard | @ruby_if_modifier | @ruby_in | @ruby_in_clause | @ruby_interpolation | @ruby_keyword_parameter | @ruby_keyword_pattern | @ruby_lambda | @ruby_lambda_parameters | @ruby_left_assignment_list | @ruby_method | @ruby_method_parameters | @ruby_module | @ruby_next | @ruby_operator_assignment | @ruby_optional_parameter | @ruby_pair | @ruby_parenthesized_pattern | @ruby_parenthesized_statements | @ruby_pattern | @ruby_program | @ruby_range | @ruby_rational | @ruby_redo | @ruby_regex | @ruby_rescue | @ruby_rescue_modifier | @ruby_rest_assignment | @ruby_retry | @ruby_return | @ruby_right_assignment_list | @ruby_scope_resolution | @ruby_setter | @ruby_singleton_class | @ruby_singleton_method | @ruby_splat_argument | @ruby_splat_parameter | @ruby_string__ | @ruby_string_array | @ruby_subshell | @ruby_superclass | @ruby_symbol_array | @ruby_then | @ruby_token | @ruby_unary | @ruby_undef | @ruby_unless | @ruby_unless_guard | @ruby_unless_modifier | @ruby_until | @ruby_until_modifier | @ruby_variable_reference_pattern | @ruby_when | @ruby_while | @ruby_while_modifier | @ruby_yield
@ruby_ast_node = @ruby_alias | @ruby_alternative_pattern | @ruby_argument_list | @ruby_array | @ruby_array_pattern | @ruby_as_pattern | @ruby_assignment | @ruby_bare_string | @ruby_bare_symbol | @ruby_begin | @ruby_begin_block | @ruby_binary | @ruby_block | @ruby_block_argument | @ruby_block_parameter | @ruby_block_parameters | @ruby_break | @ruby_call | @ruby_case__ | @ruby_case_match | @ruby_chained_string | @ruby_class | @ruby_conditional | @ruby_delimited_symbol | @ruby_destructured_left_assignment | @ruby_destructured_parameter | @ruby_do | @ruby_do_block | @ruby_element_reference | @ruby_else | @ruby_elsif | @ruby_end_block | @ruby_ensure | @ruby_exception_variable | @ruby_exceptions | @ruby_expression_reference_pattern | @ruby_find_pattern | @ruby_for | @ruby_hash | @ruby_hash_pattern | @ruby_hash_splat_argument | @ruby_hash_splat_parameter | @ruby_heredoc_body | @ruby_if | @ruby_if_guard | @ruby_if_modifier | @ruby_in | @ruby_in_clause | @ruby_interpolation | @ruby_keyword_parameter | @ruby_keyword_pattern | @ruby_lambda | @ruby_lambda_parameters | @ruby_left_assignment_list | @ruby_method | @ruby_method_parameters | @ruby_module | @ruby_next | @ruby_operator_assignment | @ruby_optional_parameter | @ruby_pair | @ruby_parenthesized_pattern | @ruby_parenthesized_statements | @ruby_pattern | @ruby_program | @ruby_range | @ruby_rational | @ruby_redo | @ruby_regex | @ruby_rescue | @ruby_rescue_modifier | @ruby_rest_assignment | @ruby_retry | @ruby_return | @ruby_right_assignment_list | @ruby_scope_resolution | @ruby_setter | @ruby_singleton_class | @ruby_singleton_method | @ruby_splat_argument | @ruby_splat_parameter | @ruby_string__ | @ruby_string_array | @ruby_subshell | @ruby_superclass | @ruby_symbol_array | @ruby_then | @ruby_token | @ruby_unary | @ruby_undef | @ruby_unless | @ruby_unless_guard | @ruby_unless_modifier | @ruby_until | @ruby_until_modifier | @ruby_variable_reference_pattern | @ruby_when | @ruby_while | @ruby_while_modifier | @ruby_yield
@ruby_ast_node_parent = @file | @ruby_ast_node

File diff suppressed because it is too large Load Diff

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,7 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
from AstNode ruby_block_argument, AstNode child
where ruby_block_argument_def(ruby_block_argument, child, _)
select ruby_block_argument, child

View File

@@ -0,0 +1,7 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
from AstNode ruby_block_parameter, AstNode name
where ruby_block_parameter_def(ruby_block_parameter, name, _)
select ruby_block_parameter, name

View File

@@ -0,0 +1,7 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
from AstNode ruby_pair, AstNode value
where ruby_pair_def(ruby_pair, _, value, _)
select ruby_pair, value

View File

@@ -0,0 +1,8 @@
description: Update grammar
compatibility: full
ruby_block_argument_child.rel: run ruby_block_argument_child.qlo
ruby_block_parameter_name.rel: run ruby_block_parameter_name.qlo
ruby_pair_value.rel: run ruby_pair_value.qlo
ruby_block_argument_def.rel: reorder ruby_block_argument_def.rel ( int id, int child, int loc ) id loc
ruby_block_parameter_def.rel: reorder ruby_block_parameter_def.rel ( int id, int name, int loc ) id loc
ruby_pair_def.rel: reorder ruby_pair_def.rel (int id, int key__, int value, int loc) id key__ loc

View File

@@ -457,6 +457,9 @@ calls/calls.rb:
# 267| getArgument: [BlockArgument] &...
# 267| getValue: [MethodCall] call to bar
# 267| getReceiver: [ConstantReadAccess] X
# 268| getStmt: [MethodCall] call to foo
# 268| getReceiver: [Self, SelfVariableAccess] self
# 268| getArgument: [BlockArgument] &...
# 270| getStmt: [MethodCall] call to foo
# 270| getReceiver: [Self, SelfVariableAccess] self
# 270| getArgument: [SplatExpr] * ...
@@ -673,6 +676,29 @@ calls/calls.rb:
# 341| getArgument: [LocalVariableAccess] x
# 341| getArgument: [LocalVariableAccess] y
# 341| getArgument: [LocalVariableAccess] z
# 344| getStmt: [MethodCall] call to foo
# 344| getReceiver: [Self, SelfVariableAccess] self
# 344| getArgument: [Pair] Pair
# 344| getKey: [SymbolLiteral] :x
# 344| getValue: [IntegerLiteral] 42
# 345| getStmt: [MethodCall] call to foo
# 345| getReceiver: [Self, SelfVariableAccess] self
# 345| getArgument: [Pair] Pair
# 345| getKey: [SymbolLiteral] :x
# 345| getValue: [LocalVariableAccess] x
# 345| getArgument: [Pair] Pair
# 345| getKey: [SymbolLiteral] :novar
# 345| getValue: [MethodCall] call to novar
# 346| getStmt: [MethodCall] call to foo
# 346| getReceiver: [Self, SelfVariableAccess] self
# 346| getArgument: [Pair] Pair
# 346| getKey: [SymbolLiteral] :X
# 346| getValue: [IntegerLiteral] 42
# 347| getStmt: [MethodCall] call to foo
# 347| getReceiver: [Self, SelfVariableAccess] self
# 347| getArgument: [Pair] Pair
# 347| getKey: [SymbolLiteral] :X
# 347| getValue: [ConstantReadAccess] X
control/cases.rb:
# 1| [Toplevel] cases.rb
# 2| getStmt: [AssignExpr] ... = ...
@@ -925,8 +951,8 @@ control/cases.rb:
# 87| getBranch: [InClause] in ... then ...
# 87| getPattern: [IntegerLiteral] 5
# 88| getBranch: [InClause] in ... then ...
# 88| getPattern: [VariableReferencePattern] ^...
# 88| getVariableAccess: [LocalVariableAccess] foo
# 88| getPattern: [ReferencePattern] ^...
# 88| getExpr: [LocalVariableAccess] foo
# 89| getBranch: [InClause] in ... then ...
# 89| getPattern: [StringLiteral] "string"
# 89| getComponent: [StringTextComponent] string
@@ -1023,8 +1049,8 @@ control/cases.rb:
# 111| getBranch: [InClause] in ... then ...
# 111| getPattern: [AlternativePattern] ... | ...
# 111| getAlternative: [IntegerLiteral] 5
# 111| getAlternative: [VariableReferencePattern] ^...
# 111| getVariableAccess: [LocalVariableAccess] foo
# 111| getAlternative: [ReferencePattern] ^...
# 111| getExpr: [LocalVariableAccess] foo
# 111| getAlternative: [StringLiteral] "string"
# 111| getComponent: [StringTextComponent] string
# 111| getAlternative: [LocalVariableAccess] var
@@ -1115,6 +1141,35 @@ control/cases.rb:
# 144| getClass: [ConstantReadAccess] Bar
# 144| getKey: [SymbolLiteral] :a
# 144| getValue: [IntegerLiteral] 1
# 147| getStmt: [CaseExpr] case ...
# 147| getValue: [MethodCall] call to expr
# 147| getReceiver: [Self, SelfVariableAccess] self
# 148| getBranch: [InClause] in ... then ...
# 148| getPattern: [ReferencePattern] ^...
# 148| getExpr: [LocalVariableAccess] foo
# 149| getBranch: [InClause] in ... then ...
# 149| getPattern: [ReferencePattern] ^...
# 149| getExpr: [GlobalVariableAccess] $foo
# 150| getBranch: [InClause] in ... then ...
# 150| getPattern: [ReferencePattern] ^...
# 150| getExpr: [InstanceVariableAccess] @foo
# 151| getBranch: [InClause] in ... then ...
# 151| getPattern: [ReferencePattern] ^...
# 151| getExpr: [ClassVariableAccess] @@foo
# 154| getStmt: [CaseExpr] case ...
# 154| getValue: [MethodCall] call to expr
# 154| getReceiver: [Self, SelfVariableAccess] self
# 155| getBranch: [InClause] in ... then ...
# 155| getPattern: [ReferencePattern] ^...
# 155| getExpr: [LocalVariableAccess] foo
# 156| getBranch: [InClause] in ... then ...
# 156| getPattern: [ReferencePattern] ^...
# 156| getExpr: [InstanceVariableAccess] @foo
# 157| getBranch: [InClause] in ... then ...
# 157| getPattern: [ReferencePattern] ^...
# 157| getExpr: [AddExpr] ... + ...
# 157| getAnOperand/getLeftOperand/getReceiver: [IntegerLiteral] 1
# 157| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 1
modules/classes.rb:
# 2| [Toplevel] classes.rb
# 3| getStmt: [ClassDeclaration] Foo
@@ -1945,6 +2000,23 @@ literals/literals.rb:
# 180| getComponent: [StringTextComponent]
# 180| cat file.txt
# 180|
# 184| getStmt: [AssignExpr] ... = ...
# 184| getAnOperand/getLeftOperand: [LocalVariableAccess] x
# 184| getAnOperand/getRightOperand: [IntegerLiteral] 42
# 185| getStmt: [HashLiteral] {...}
# 185| getElement: [Pair] Pair
# 185| getKey: [SymbolLiteral] :x
# 185| getValue: [LocalVariableAccess] x
# 185| getElement: [Pair] Pair
# 185| getKey: [SymbolLiteral] :y
# 185| getValue: [IntegerLiteral] 5
# 186| getStmt: [HashLiteral] {...}
# 186| getElement: [Pair] Pair
# 186| getKey: [SymbolLiteral] :y
# 186| getValue: [MethodCall] call to y
# 186| getElement: [Pair] Pair
# 186| getKey: [SymbolLiteral] :Z
# 186| getValue: [ConstantReadAccess] Z
control/loops.rb:
# 1| [Toplevel] loops.rb
# 2| getStmt: [AssignExpr] ... = ...
@@ -2679,6 +2751,19 @@ params/params.rb:
# 77| getParameter: [SimpleParameter] val
# 77| getDefiningAccess: [LocalVariableAccess] val
# 77| getParameter: [HashSplatNilParameter] **nil
# 81| getStmt: [Method] anonymous_block_parameter
# 81| getParameter: [SimpleParameter] array
# 81| getDefiningAccess: [LocalVariableAccess] array
# 81| getParameter: [BlockParameter] &
# 81| getDefiningAccess: [LocalVariableAccess] __synth__0
# 82| getStmt: [MethodCall] call to proc
# 82| getReceiver: [Self, SelfVariableAccess] self
# 82| getArgument: [BlockArgument] &...
# 82| getValue: [LocalVariableAccess] __synth__0
# 83| getStmt: [MethodCall] call to each
# 83| getReceiver: [LocalVariableAccess] array
# 83| getArgument: [BlockArgument] &...
# 83| getValue: [LocalVariableAccess] __synth__0
erb/template.html.erb:
# 19| [Toplevel] template.html.erb
# 19| getStmt: [StringLiteral] "hello world"

View File

@@ -477,6 +477,24 @@ literals/literals.rb:
# 118| getArgument: [HashSplatExpr] ** ...
# 118| getAnOperand/getOperand/getReceiver: [MethodCall] call to baz
# 118| getReceiver: [Self, SelfVariableAccess] self
# 185| [HashLiteral] {...}
# 185| getDesugared: [MethodCall] call to []
# 185| getReceiver: [ConstantReadAccess] Hash
# 185| getArgument: [Pair] Pair
# 185| getKey: [SymbolLiteral] :x
# 185| getValue: [LocalVariableAccess] x
# 185| getArgument: [Pair] Pair
# 185| getKey: [SymbolLiteral] :y
# 185| getValue: [IntegerLiteral] 5
# 186| [HashLiteral] {...}
# 186| getDesugared: [MethodCall] call to []
# 186| getReceiver: [ConstantReadAccess] Hash
# 186| getArgument: [Pair] Pair
# 186| getKey: [SymbolLiteral] :y
# 186| getValue: [MethodCall] call to y
# 186| getArgument: [Pair] Pair
# 186| getKey: [SymbolLiteral] :Z
# 186| getValue: [ConstantReadAccess] Z
control/loops.rb:
# 9| [ForExpr] for ... in ...
# 9| getDesugared: [MethodCall] call to each

View File

@@ -65,6 +65,13 @@
| calls/calls.rb:340:27:340:27 | 4 | 4 |
| calls/calls.rb:340:29:340:29 | 5 | 5 |
| calls/calls.rb:340:31:340:31 | 6 | 6 |
| calls/calls.rb:344:5:344:5 | :x | :x |
| calls/calls.rb:344:8:344:9 | 42 | 42 |
| calls/calls.rb:345:5:345:5 | :x | :x |
| calls/calls.rb:345:9:345:13 | :novar | :novar |
| calls/calls.rb:346:5:346:5 | :X | :X |
| calls/calls.rb:346:8:346:9 | 42 | 42 |
| calls/calls.rb:347:5:347:5 | :X | :X |
| constants/constants.rb:3:19:3:27 | "const_a" | const_a |
| constants/constants.rb:6:15:6:23 | "const_b" | const_b |
| constants/constants.rb:17:12:17:18 | "Hello" | Hello |
@@ -236,6 +243,11 @@
| control/cases.rb:142:11:142:11 | :y | :y |
| control/cases.rb:144:11:144:11 | :a | :a |
| control/cases.rb:144:14:144:14 | 1 | 1 |
| control/cases.rb:148:7:148:9 | foo | 42 |
| control/cases.rb:155:8:155:10 | foo | 42 |
| control/cases.rb:157:8:157:8 | 1 | 1 |
| control/cases.rb:157:8:157:12 | ... + ... | 2 |
| control/cases.rb:157:12:157:12 | 1 | 1 |
| control/conditionals.rb:2:5:2:5 | 0 | 0 |
| control/conditionals.rb:3:5:3:5 | 0 | 0 |
| control/conditionals.rb:4:5:4:5 | 0 | 0 |
@@ -571,6 +583,13 @@
| literals/literals.rb:162:11:162:16 | <<-BLA | \nsome text\\nand some more\n |
| literals/literals.rb:167:9:167:19 | <<~SQUIGGLY | \n indented stuff\n |
| literals/literals.rb:180:10:180:19 | <<`SCRIPT` | \n cat file.txt\n |
| literals/literals.rb:184:5:184:6 | 42 | 42 |
| literals/literals.rb:185:2:185:2 | :x | :x |
| literals/literals.rb:185:2:185:2 | x | 42 |
| literals/literals.rb:185:6:185:6 | :y | :y |
| literals/literals.rb:185:8:185:8 | 5 | 5 |
| literals/literals.rb:186:2:186:2 | :y | :y |
| literals/literals.rb:186:7:186:7 | :Z | :Z |
| misc/misc.erb:2:15:2:37 | "main_include_admin.js" | main_include_admin.js |
| misc/misc.rb:1:7:1:11 | "bar" | bar |
| misc/misc.rb:3:7:3:9 | foo | foo |

View File

@@ -15,6 +15,16 @@ keywordArguments
| calls.rb:249:15:249:30 | Pair | calls.rb:249:15:249:20 | call to foo | calls.rb:249:25:249:30 | call to bar |
| calls.rb:278:5:278:13 | Pair | calls.rb:278:5:278:8 | :blah | calls.rb:278:11:278:13 | call to bar |
| calls.rb:279:5:279:16 | Pair | calls.rb:279:5:279:8 | :blah | calls.rb:279:11:279:16 | call to bar |
| calls.rb:344:5:344:9 | Pair | calls.rb:344:5:344:5 | :x | calls.rb:344:8:344:9 | 42 |
| calls.rb:345:5:345:6 | Pair | calls.rb:345:5:345:5 | :x | calls.rb:345:5:345:5 | x |
| calls.rb:345:9:345:14 | Pair | calls.rb:345:9:345:13 | :novar | calls.rb:345:9:345:13 | call to novar |
| calls.rb:346:5:346:9 | Pair | calls.rb:346:5:346:5 | :X | calls.rb:346:8:346:9 | 42 |
| calls.rb:347:5:347:6 | Pair | calls.rb:347:5:347:5 | :X | calls.rb:347:5:347:5 | X |
keywordArgumentsByKeyword
| calls.rb:278:1:278:14 | call to foo | blah | calls.rb:278:11:278:13 | call to bar |
| calls.rb:279:1:279:17 | call to foo | blah | calls.rb:279:11:279:16 | call to bar |
| calls.rb:344:1:344:10 | call to foo | x | calls.rb:344:8:344:9 | 42 |
| calls.rb:345:1:345:15 | call to foo | novar | calls.rb:345:9:345:13 | call to novar |
| calls.rb:345:1:345:15 | call to foo | x | calls.rb:345:5:345:5 | x |
| calls.rb:346:1:346:10 | call to foo | X | calls.rb:346:8:346:9 | 42 |
| calls.rb:347:1:347:7 | call to foo | X | calls.rb:347:5:347:5 | X |

View File

@@ -3,6 +3,7 @@ callsWithNoReceiverArgumentsOrBlock
| calls.rb:286:5:286:9 | call to super | super |
| calls.rb:287:5:287:11 | call to super | super |
| calls.rb:305:5:305:9 | call to super | super |
| calls.rb:345:9:345:13 | call to novar | novar |
callsWithArguments
| calls.rb:14:1:14:11 | call to foo | foo | 0 | calls.rb:14:5:14:5 | 0 |
| calls.rb:14:1:14:11 | call to foo | foo | 1 | calls.rb:14:8:14:8 | 1 |
@@ -26,6 +27,7 @@ callsWithArguments
| calls.rb:249:1:249:32 | call to [] | [] | 1 | calls.rb:249:15:249:30 | Pair |
| calls.rb:266:1:266:9 | call to foo | foo | 0 | calls.rb:266:5:266:8 | &... |
| calls.rb:267:1:267:12 | call to foo | foo | 0 | calls.rb:267:5:267:11 | &... |
| calls.rb:268:1:268:6 | call to foo | foo | 0 | calls.rb:268:5:268:5 | &... |
| calls.rb:270:1:270:9 | call to foo | foo | 0 | calls.rb:270:5:270:8 | * ... |
| calls.rb:271:1:271:12 | call to foo | foo | 0 | calls.rb:271:5:271:11 | * ... |
| calls.rb:274:1:274:10 | call to foo | foo | 0 | calls.rb:274:5:274:9 | ** ... |
@@ -106,6 +108,11 @@ callsWithArguments
| calls.rb:341:3:341:13 | call to foo | foo | 0 | calls.rb:341:7:341:7 | x |
| calls.rb:341:3:341:13 | call to foo | foo | 1 | calls.rb:341:10:341:10 | y |
| calls.rb:341:3:341:13 | call to foo | foo | 2 | calls.rb:341:13:341:13 | z |
| calls.rb:344:1:344:10 | call to foo | foo | 0 | calls.rb:344:5:344:9 | Pair |
| calls.rb:345:1:345:15 | call to foo | foo | 0 | calls.rb:345:5:345:6 | Pair |
| calls.rb:345:1:345:15 | call to foo | foo | 1 | calls.rb:345:9:345:14 | Pair |
| calls.rb:346:1:346:10 | call to foo | foo | 0 | calls.rb:346:5:346:9 | Pair |
| calls.rb:347:1:347:7 | call to foo | foo | 0 | calls.rb:347:5:347:6 | Pair |
callsWithReceiver
| calls.rb:2:1:2:5 | call to foo | calls.rb:2:1:2:5 | self |
| calls.rb:5:1:5:10 | call to bar | calls.rb:5:1:5:3 | Foo |
@@ -267,6 +274,7 @@ callsWithReceiver
| calls.rb:266:6:266:8 | call to bar | calls.rb:266:6:266:8 | self |
| calls.rb:267:1:267:12 | call to foo | calls.rb:267:1:267:12 | self |
| calls.rb:267:6:267:11 | call to bar | calls.rb:267:6:267:6 | X |
| calls.rb:268:1:268:6 | call to foo | calls.rb:268:1:268:6 | self |
| calls.rb:270:1:270:9 | call to foo | calls.rb:270:1:270:9 | self |
| calls.rb:270:5:270:8 | * ... | calls.rb:270:6:270:8 | call to bar |
| calls.rb:270:6:270:8 | call to bar | calls.rb:270:6:270:8 | self |
@@ -356,6 +364,10 @@ callsWithReceiver
| calls.rb:340:17:340:23 | call to [] | calls.rb:340:17:340:23 | Array |
| calls.rb:340:26:340:32 | call to [] | calls.rb:340:26:340:32 | Array |
| calls.rb:341:3:341:13 | call to foo | calls.rb:341:3:341:13 | self |
| calls.rb:344:1:344:10 | call to foo | calls.rb:344:1:344:10 | self |
| calls.rb:345:1:345:15 | call to foo | calls.rb:345:1:345:15 | self |
| calls.rb:346:1:346:10 | call to foo | calls.rb:346:1:346:10 | self |
| calls.rb:347:1:347:7 | call to foo | calls.rb:347:1:347:7 | self |
callsWithBlock
| calls.rb:17:1:17:17 | call to foo | calls.rb:17:5:17:17 | { ... } |
| calls.rb:20:1:22:3 | call to foo | calls.rb:20:5:22:3 | do ... end |

View File

@@ -265,7 +265,7 @@ X::foo rescue X::bar
# block argument
foo(&bar)
foo(&X::bar)
foo(&)
# splat argument
foo(*bar)
foo(*X::bar)
@@ -340,3 +340,8 @@ end
for x, y, z in [[1,2,3], [4,5,6]]
foo x, y, z
end
foo(x: 42)
foo(x:, novar:)
foo(X: 42)
foo(X:)

View File

@@ -8,6 +8,8 @@ caseValues
| cases.rb:116:1:124:3 | case ... | cases.rb:116:6:116:9 | call to expr |
| cases.rb:128:1:133:3 | case ... | cases.rb:128:6:128:9 | call to expr |
| cases.rb:137:1:145:3 | case ... | cases.rb:137:6:137:9 | call to expr |
| cases.rb:147:1:152:3 | case ... | cases.rb:147:6:147:9 | call to expr |
| cases.rb:154:1:158:3 | case ... | cases.rb:154:6:154:9 | call to expr |
caseNoValues
| cases.rb:18:1:22:3 | case ... |
caseElseBranches
@@ -22,6 +24,8 @@ caseNoElseBranches
| cases.rb:116:1:124:3 | case ... |
| cases.rb:128:1:133:3 | case ... |
| cases.rb:137:1:145:3 | case ... |
| cases.rb:147:1:152:3 | case ... |
| cases.rb:154:1:158:3 | case ... |
caseWhenBranches
| cases.rb:8:1:15:3 | case ... | cases.rb:9:1:10:7 | when ... | 0 | cases.rb:9:6:9:6 | b | cases.rb:9:7:10:7 | then ... |
| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 0 | cases.rb:11:6:11:6 | c | cases.rb:11:10:12:7 | then ... |
@@ -121,3 +125,10 @@ caseAllBranches
| cases.rb:137:1:145:3 | case ... | 4 | cases.rb:142:3:142:14 | in ... then ... |
| cases.rb:137:1:145:3 | case ... | 5 | cases.rb:143:3:143:15 | in ... then ... |
| cases.rb:137:1:145:3 | case ... | 6 | cases.rb:144:3:144:23 | in ... then ... |
| cases.rb:147:1:152:3 | case ... | 0 | cases.rb:148:3:148:10 | in ... then ... |
| cases.rb:147:1:152:3 | case ... | 1 | cases.rb:149:3:149:11 | in ... then ... |
| cases.rb:147:1:152:3 | case ... | 2 | cases.rb:150:3:150:11 | in ... then ... |
| cases.rb:147:1:152:3 | case ... | 3 | cases.rb:151:3:151:12 | in ... then ... |
| cases.rb:154:1:158:3 | case ... | 0 | cases.rb:155:3:155:12 | in ... then ... |
| cases.rb:154:1:158:3 | case ... | 1 | cases.rb:156:3:156:13 | in ... then ... |
| cases.rb:154:1:158:3 | case ... | 2 | cases.rb:157:3:157:14 | in ... then ... |

View File

@@ -8,6 +8,8 @@
| cases.rb:116:1:124:3 | case ... | CaseExpr |
| cases.rb:128:1:133:3 | case ... | CaseExpr |
| cases.rb:137:1:145:3 | case ... | CaseExpr |
| cases.rb:147:1:152:3 | case ... | CaseExpr |
| cases.rb:154:1:158:3 | case ... | CaseExpr |
| conditionals.rb:10:1:12:3 | if ... | IfExpr |
| conditionals.rb:15:1:19:3 | if ... | IfExpr |
| conditionals.rb:22:1:30:3 | if ... | IfExpr |

View File

@@ -144,3 +144,15 @@ case expr
in Bar( a: 1, **nil);
end
case expr
in ^foo;
in ^$foo;
in ^@foo;
in ^@@foo;
end
case expr
in ^(foo);
in ^(@foo);
in ^(1 + 1);
end

View File

@@ -217,6 +217,14 @@ allLiterals
| literals.rb:171:9:171:15 | <<"DOC" | HereDoc | <none> |
| literals.rb:176:9:176:15 | <<'DOC' | HereDoc | <none> |
| literals.rb:180:10:180:19 | <<`SCRIPT` | HereDoc | \n cat file.txt\n |
| literals.rb:184:5:184:6 | 42 | IntegerLiteral | 42 |
| literals.rb:185:1:185:9 | {...} | HashLiteral | <none> |
| literals.rb:185:2:185:2 | :x | SymbolLiteral | :x |
| literals.rb:185:6:185:6 | :y | SymbolLiteral | :y |
| literals.rb:185:8:185:8 | 5 | IntegerLiteral | 5 |
| literals.rb:186:1:186:9 | {...} | HashLiteral | <none> |
| literals.rb:186:2:186:2 | :y | SymbolLiteral | :y |
| literals.rb:186:7:186:7 | :Z | SymbolLiteral | :Z |
stringlikeLiterals
| literals.rb:46:1:46:2 | "" | |
| literals.rb:47:1:47:2 | "" | |
@@ -327,6 +335,10 @@ stringlikeLiterals
| literals.rb:171:9:171:15 | <<"DOC" | <none> |
| literals.rb:176:9:176:15 | <<'DOC' | <none> |
| literals.rb:180:10:180:19 | <<`SCRIPT` | \n cat file.txt\n |
| literals.rb:185:2:185:2 | :x | :x |
| literals.rb:185:6:185:6 | :y | :y |
| literals.rb:186:2:186:2 | :y | :y |
| literals.rb:186:7:186:7 | :Z | :Z |
stringLiterals
| literals.rb:46:1:46:2 | "" | |
| literals.rb:47:1:47:2 | "" | |
@@ -435,6 +447,10 @@ symbolLiterals
| literals.rb:117:3:117:5 | :foo | :foo |
| literals.rb:117:11:117:14 | :bar | :bar |
| literals.rb:118:3:118:5 | :foo | :foo |
| literals.rb:185:2:185:2 | :x | :x |
| literals.rb:185:6:185:6 | :y | :y |
| literals.rb:186:2:186:2 | :y | :y |
| literals.rb:186:7:186:7 | :Z | :Z |
subshellLiterals
| literals.rb:130:1:130:7 | `ls -l` | ls -l |
| literals.rb:131:1:131:9 | `ls -l` | ls -l |
@@ -701,6 +717,8 @@ hashLiterals
| literals.rb:116:1:116:2 | {...} | 0 |
| literals.rb:117:1:117:33 | {...} | 3 |
| literals.rb:118:1:118:17 | {...} | 2 |
| literals.rb:185:1:185:9 | {...} | 2 |
| literals.rb:186:1:186:9 | {...} | 2 |
hashLiteralElements
| literals.rb:88:1:88:14 | {...} | 0 | literals.rb:88:3:88:12 | Pair | Pair |
| literals.rb:117:1:117:33 | {...} | 0 | literals.rb:117:3:117:8 | Pair | Pair |
@@ -708,12 +726,20 @@ hashLiteralElements
| literals.rb:117:1:117:33 | {...} | 2 | literals.rb:117:22:117:31 | Pair | Pair |
| literals.rb:118:1:118:17 | {...} | 0 | literals.rb:118:3:118:8 | Pair | Pair |
| literals.rb:118:1:118:17 | {...} | 1 | literals.rb:118:11:118:15 | ** ... | HashSplatExpr |
| literals.rb:185:1:185:9 | {...} | 0 | literals.rb:185:2:185:3 | Pair | Pair |
| literals.rb:185:1:185:9 | {...} | 1 | literals.rb:185:6:185:8 | Pair | Pair |
| literals.rb:186:1:186:9 | {...} | 0 | literals.rb:186:2:186:3 | Pair | Pair |
| literals.rb:186:1:186:9 | {...} | 1 | literals.rb:186:7:186:8 | Pair | Pair |
hashLiteralKeyValuePairs
| literals.rb:88:1:88:14 | {...} | literals.rb:88:3:88:12 | Pair | literals.rb:88:3:88:5 | :foo | literals.rb:88:8:88:12 | "bar" |
| literals.rb:117:1:117:33 | {...} | literals.rb:117:3:117:8 | Pair | literals.rb:117:3:117:5 | :foo | literals.rb:117:8:117:8 | 1 |
| literals.rb:117:1:117:33 | {...} | literals.rb:117:11:117:19 | Pair | literals.rb:117:11:117:14 | :bar | literals.rb:117:19:117:19 | 2 |
| literals.rb:117:1:117:33 | {...} | literals.rb:117:22:117:31 | Pair | literals.rb:117:22:117:26 | "baz" | literals.rb:117:31:117:31 | 3 |
| literals.rb:118:1:118:17 | {...} | literals.rb:118:3:118:8 | Pair | literals.rb:118:3:118:5 | :foo | literals.rb:118:8:118:8 | 7 |
| literals.rb:185:1:185:9 | {...} | literals.rb:185:2:185:3 | Pair | literals.rb:185:2:185:2 | :x | literals.rb:185:2:185:2 | x |
| literals.rb:185:1:185:9 | {...} | literals.rb:185:6:185:8 | Pair | literals.rb:185:6:185:6 | :y | literals.rb:185:8:185:8 | 5 |
| literals.rb:186:1:186:9 | {...} | literals.rb:186:2:186:3 | Pair | literals.rb:186:2:186:2 | :y | literals.rb:186:2:186:2 | call to y |
| literals.rb:186:1:186:9 | {...} | literals.rb:186:7:186:8 | Pair | literals.rb:186:7:186:7 | :Z | literals.rb:186:7:186:7 | Z |
finiteRangeLiterals
| literals.rb:121:2:121:6 | _ .. _ | literals.rb:121:2:121:2 | 1 | literals.rb:121:5:121:6 | 10 |
| literals.rb:122:2:122:7 | _ ... _ | literals.rb:122:2:122:2 | 1 | literals.rb:122:6:122:7 | 10 |
@@ -802,6 +828,8 @@ numericLiterals
| literals.rb:140:12:140:12 | 1 | IntegerLiteral | 1 |
| literals.rb:146:10:146:10 | 1 | IntegerLiteral | 1 |
| literals.rb:146:14:146:14 | 1 | IntegerLiteral | 1 |
| literals.rb:184:5:184:6 | 42 | IntegerLiteral | 42 |
| literals.rb:185:8:185:8 | 5 | IntegerLiteral | 5 |
integerLiterals
| literals.rb:10:1:10:4 | 1234 | IntegerLiteral | 1234 |
| literals.rb:11:1:11:5 | 5_678 | IntegerLiteral | 5678 |
@@ -865,6 +893,8 @@ integerLiterals
| literals.rb:140:12:140:12 | 1 | IntegerLiteral | 1 |
| literals.rb:146:10:146:10 | 1 | IntegerLiteral | 1 |
| literals.rb:146:14:146:14 | 1 | IntegerLiteral | 1 |
| literals.rb:184:5:184:6 | 42 | IntegerLiteral | 42 |
| literals.rb:185:8:185:8 | 5 | IntegerLiteral | 5 |
floatLiterals
| literals.rb:30:1:30:5 | 12.34 | FloatLiteral | 12.34 |
| literals.rb:31:1:31:7 | 1234e-2 | FloatLiteral | 12.34 |

View File

@@ -181,3 +181,6 @@ output = <<`SCRIPT`
cat file.txt
SCRIPT
x = 42
{x:, y:5}
{y: , Z:}

View File

@@ -35,6 +35,7 @@ idParams
| params.rb:70:48:70:48 | c | c |
| params.rb:73:27:73:32 | wibble | wibble |
| params.rb:77:16:77:18 | val | val |
| params.rb:81:31:81:35 | array | array |
blockParams
| params.rb:46:28:46:33 | &block | block |
| params.rb:62:29:62:34 | &block | block |
@@ -87,6 +88,8 @@ paramsInMethods
| params.rb:62:1:64:3 | use_block_with_optional | 0 | params.rb:62:29:62:34 | &block | BlockParameter |
| params.rb:73:1:74:3 | method_with_nil_splat | 0 | params.rb:73:27:73:32 | wibble | SimpleParameter |
| params.rb:73:1:74:3 | method_with_nil_splat | 1 | params.rb:73:35:73:39 | **nil | HashSplatNilParameter |
| params.rb:81:1:84:3 | anonymous_block_parameter | 0 | params.rb:81:31:81:35 | array | SimpleParameter |
| params.rb:81:1:84:3 | anonymous_block_parameter | 1 | params.rb:81:38:81:38 | & | BlockParameter |
paramsInBlocks
| params.rb:9:11:11:3 | do ... end | 0 | params.rb:9:15:9:17 | key | SimpleParameter |
| params.rb:9:11:11:3 | do ... end | 1 | params.rb:9:20:9:24 | value | SimpleParameter |
@@ -157,3 +160,5 @@ params
| params.rb:73:35:73:39 | **nil | 1 | HashSplatNilParameter |
| params.rb:77:16:77:18 | val | 0 | SimpleParameter |
| params.rb:77:21:77:25 | **nil | 1 | HashSplatNilParameter |
| params.rb:81:31:81:35 | array | 0 | SimpleParameter |
| params.rb:81:38:81:38 | & | 1 | BlockParameter |

View File

@@ -77,3 +77,8 @@ end
array.each do |val, **nil|
end
# Anonymous block parameter
def anonymous_block_parameter(array, &)
proc(&)
array.each(&)
end

View File

@@ -7,6 +7,7 @@ rm -Recurse -Force extractor-pack
mkdir extractor-pack | Out-Null
cp codeql-extractor.yml, ql\lib\ruby.dbscheme, ql\lib\ruby.dbscheme.stats extractor-pack
cp -Recurse tools extractor-pack
cp -Recurse downgrades extractor-pack
mkdir extractor-pack\tools\win64 | Out-Null
cp target\release\ruby-extractor.exe extractor-pack\tools\win64\extractor.exe
cp target\release\ruby-autobuilder.exe extractor-pack\tools\win64\autobuilder.exe

View File

@@ -17,7 +17,7 @@ codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
rm -rf extractor-pack
mkdir -p extractor-pack
cp -r codeql-extractor.yml tools ql/lib/ruby.dbscheme ql/lib/ruby.dbscheme.stats extractor-pack/
cp -r codeql-extractor.yml downgrades tools ql/lib/ruby.dbscheme ql/lib/ruby.dbscheme.stats extractor-pack/
mkdir -p extractor-pack/tools/${platform}
cp target/release/ruby-extractor extractor-pack/tools/${platform}/extractor
cp target/release/ruby-autobuilder extractor-pack/tools/${platform}/autobuilder

View File

@@ -63,6 +63,7 @@ fi
scheme_file="ql/lib/ruby.dbscheme"
upgrade_root="ql/lib/upgrades"
downgrade_root="downgrades"
check_hash_valid()
{
@@ -95,12 +96,28 @@ description: <INSERT DESCRIPTION HERE>
compatibility: full|backwards|partial|breaking
EOF
# Copy current and new dbscheme into the downgrade dir
downgradedir="${downgrade_root}/${current_hash}"
mkdir -p "${downgradedir}"
cp "${scheme_file}" "${downgradedir}/old.dbscheme"
git cat-file blob "${prev_hash}" > "${downgradedir}/$(basename "${scheme_file}")"
# Create the template upgrade.properties file.
cat <<EOF > "${downgradedir}/upgrade.properties"
description: <INSERT DESCRIPTION HERE>
compatibility: full|backwards|partial|breaking
EOF
# Tell user what we've done
cat <<EOF
Created upgrade directory here:
${upgradedir}
Created downgrade directory here:
${downgradedir}
Please update:
${upgradedir}/upgrade.properties
with appropriate upgrade instructions
${downgradedir}/upgrade.properties
with appropriate instructions
EOF