mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Replace Generated module with Ruby
This commit is contained in:
@@ -150,7 +150,7 @@ class ElementReference extends MethodCall, TElementReference {
|
||||
* ```
|
||||
*/
|
||||
class YieldCall extends Call, TYieldCall {
|
||||
Generated::Yield g;
|
||||
Ruby::Yield g;
|
||||
|
||||
YieldCall() { this = TYieldCall(g) }
|
||||
|
||||
@@ -180,7 +180,7 @@ class SuperCall extends MethodCall, TSuperCall {
|
||||
* ```
|
||||
*/
|
||||
class BlockArgument extends Expr, TBlockArgument {
|
||||
private Generated::BlockArgument g;
|
||||
private Ruby::BlockArgument g;
|
||||
|
||||
BlockArgument() { this = TBlockArgument(g) }
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class ConstantAccess extends Expr, TConstantAccess {
|
||||
}
|
||||
|
||||
private class TokenConstantAccess extends ConstantAccess, TTokenConstantAccess {
|
||||
private Generated::Constant g;
|
||||
private Ruby::Constant g;
|
||||
|
||||
TokenConstantAccess() { this = TTokenConstantAccess(g) }
|
||||
|
||||
@@ -55,8 +55,8 @@ private class TokenConstantAccess extends ConstantAccess, TTokenConstantAccess {
|
||||
}
|
||||
|
||||
private class ScopeResolutionConstantAccess extends ConstantAccess, TScopeResolutionConstantAccess {
|
||||
private Generated::ScopeResolution g;
|
||||
private Generated::Constant constant;
|
||||
private Ruby::ScopeResolution g;
|
||||
private Ruby::Constant constant;
|
||||
|
||||
ScopeResolutionConstantAccess() { this = TScopeResolutionConstantAccess(g, constant) }
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class IfExpr extends ConditionalExpr, TIfExpr {
|
||||
}
|
||||
|
||||
private class If extends IfExpr, TIf {
|
||||
private Generated::If g;
|
||||
private Ruby::If g;
|
||||
|
||||
If() { this = TIf(g) }
|
||||
|
||||
@@ -125,7 +125,7 @@ private class If extends IfExpr, TIf {
|
||||
}
|
||||
|
||||
private class Elsif extends IfExpr, TElsif {
|
||||
private Generated::Elsif g;
|
||||
private Ruby::Elsif g;
|
||||
|
||||
Elsif() { this = TElsif(g) }
|
||||
|
||||
@@ -149,7 +149,7 @@ private class Elsif extends IfExpr, TElsif {
|
||||
* ```
|
||||
*/
|
||||
class UnlessExpr extends ConditionalExpr, TUnlessExpr {
|
||||
private Generated::Unless g;
|
||||
private Ruby::Unless g;
|
||||
|
||||
UnlessExpr() { this = TUnlessExpr(g) }
|
||||
|
||||
@@ -207,7 +207,7 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr {
|
||||
* ```
|
||||
*/
|
||||
class IfModifierExpr extends ConditionalExpr, TIfModifierExpr {
|
||||
private Generated::IfModifier g;
|
||||
private Ruby::IfModifier g;
|
||||
|
||||
IfModifierExpr() { this = TIfModifierExpr(g) }
|
||||
|
||||
@@ -242,7 +242,7 @@ class IfModifierExpr extends ConditionalExpr, TIfModifierExpr {
|
||||
* ```
|
||||
*/
|
||||
class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr {
|
||||
private Generated::UnlessModifier g;
|
||||
private Ruby::UnlessModifier g;
|
||||
|
||||
UnlessModifierExpr() { this = TUnlessModifierExpr(g) }
|
||||
|
||||
@@ -277,7 +277,7 @@ class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr {
|
||||
* ```
|
||||
*/
|
||||
class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr {
|
||||
private Generated::Conditional g;
|
||||
private Ruby::Conditional g;
|
||||
|
||||
TernaryIfExpr() { this = TTernaryIfExpr(g) }
|
||||
|
||||
@@ -309,7 +309,7 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr {
|
||||
}
|
||||
|
||||
class CaseExpr extends ControlExpr, TCaseExpr {
|
||||
private Generated::Case g;
|
||||
private Ruby::Case g;
|
||||
|
||||
CaseExpr() { this = TCaseExpr(g) }
|
||||
|
||||
@@ -379,7 +379,7 @@ class CaseExpr extends ControlExpr, TCaseExpr {
|
||||
* ```
|
||||
*/
|
||||
class WhenExpr extends Expr, TWhenExpr {
|
||||
private Generated::When g;
|
||||
private Ruby::When g;
|
||||
|
||||
WhenExpr() { this = TWhenExpr(g) }
|
||||
|
||||
@@ -465,7 +465,7 @@ class ConditionalLoop extends Loop, TConditionalLoop {
|
||||
* ```
|
||||
*/
|
||||
class WhileExpr extends ConditionalLoop, TWhileExpr {
|
||||
private Generated::While g;
|
||||
private Ruby::While g;
|
||||
|
||||
WhileExpr() { this = TWhileExpr(g) }
|
||||
|
||||
@@ -495,7 +495,7 @@ class WhileExpr extends ConditionalLoop, TWhileExpr {
|
||||
* ```
|
||||
*/
|
||||
class UntilExpr extends ConditionalLoop, TUntilExpr {
|
||||
private Generated::Until g;
|
||||
private Ruby::Until g;
|
||||
|
||||
UntilExpr() { this = TUntilExpr(g) }
|
||||
|
||||
@@ -522,7 +522,7 @@ class UntilExpr extends ConditionalLoop, TUntilExpr {
|
||||
* ```
|
||||
*/
|
||||
class WhileModifierExpr extends ConditionalLoop, TWhileModifierExpr {
|
||||
private Generated::WhileModifier g;
|
||||
private Ruby::WhileModifier g;
|
||||
|
||||
WhileModifierExpr() { this = TWhileModifierExpr(g) }
|
||||
|
||||
@@ -548,7 +548,7 @@ class WhileModifierExpr extends ConditionalLoop, TWhileModifierExpr {
|
||||
* ```
|
||||
*/
|
||||
class UntilModifierExpr extends ConditionalLoop, TUntilModifierExpr {
|
||||
private Generated::UntilModifier g;
|
||||
private Ruby::UntilModifier g;
|
||||
|
||||
UntilModifierExpr() { this = TUntilModifierExpr(g) }
|
||||
|
||||
@@ -576,7 +576,7 @@ class UntilModifierExpr extends ConditionalLoop, TUntilModifierExpr {
|
||||
* ```
|
||||
*/
|
||||
class ForExpr extends Loop, TForExpr {
|
||||
private Generated::For g;
|
||||
private Ruby::For g;
|
||||
|
||||
ForExpr() { this = TForExpr(g) }
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ class Self extends Expr, TSelf {
|
||||
* ```
|
||||
*/
|
||||
class ArgumentList extends Expr, TArgumentList {
|
||||
private Generated::AstNode g;
|
||||
private Ruby::AstNode g;
|
||||
|
||||
ArgumentList() { this = TArgumentList(g) }
|
||||
|
||||
/** Gets the `i`th element in this argument list. */
|
||||
Expr getElement(int i) {
|
||||
toGenerated(result) in [
|
||||
g.(Generated::ArgumentList).getChild(i), g.(Generated::RightAssignmentList).getChild(i)
|
||||
g.(Ruby::ArgumentList).getChild(i), g.(Ruby::RightAssignmentList).getChild(i)
|
||||
]
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ private class StmtSequenceSynth extends StmtSequence, TStmtSequenceSynth {
|
||||
}
|
||||
|
||||
private class Then extends StmtSequence, TThen {
|
||||
private Generated::Then g;
|
||||
private Ruby::Then g;
|
||||
|
||||
Then() { this = TThen(g) }
|
||||
|
||||
@@ -102,7 +102,7 @@ private class Then extends StmtSequence, TThen {
|
||||
}
|
||||
|
||||
private class Else extends StmtSequence, TElse {
|
||||
private Generated::Else g;
|
||||
private Ruby::Else g;
|
||||
|
||||
Else() { this = TElse(g) }
|
||||
|
||||
@@ -112,7 +112,7 @@ private class Else extends StmtSequence, TElse {
|
||||
}
|
||||
|
||||
private class Do extends StmtSequence, TDo {
|
||||
private Generated::Do g;
|
||||
private Ruby::Do g;
|
||||
|
||||
Do() { this = TDo(g) }
|
||||
|
||||
@@ -122,7 +122,7 @@ private class Do extends StmtSequence, TDo {
|
||||
}
|
||||
|
||||
private class Ensure extends StmtSequence, TEnsure {
|
||||
private Generated::Ensure g;
|
||||
private Ruby::Ensure g;
|
||||
|
||||
Ensure() { this = TEnsure(g) }
|
||||
|
||||
@@ -138,28 +138,28 @@ private class Ensure extends StmtSequence, TEnsure {
|
||||
*/
|
||||
class BodyStmt extends StmtSequence, TBodyStmt {
|
||||
// Not defined by dispatch, as it should not be exposed
|
||||
private Generated::AstNode getChild(int i) {
|
||||
result = any(Generated::Method g | this = TMethod(g)).getChild(i)
|
||||
private Ruby::AstNode getChild(int i) {
|
||||
result = any(Ruby::Method g | this = TMethod(g)).getChild(i)
|
||||
or
|
||||
result = any(Generated::SingletonMethod g | this = TSingletonMethod(g)).getChild(i)
|
||||
result = any(Ruby::SingletonMethod g | this = TSingletonMethod(g)).getChild(i)
|
||||
or
|
||||
exists(Generated::Lambda g | this = TLambda(g) |
|
||||
result = g.getBody().(Generated::DoBlock).getChild(i) or
|
||||
result = g.getBody().(Generated::Block).getChild(i)
|
||||
exists(Ruby::Lambda g | this = TLambda(g) |
|
||||
result = g.getBody().(Ruby::DoBlock).getChild(i) or
|
||||
result = g.getBody().(Ruby::Block).getChild(i)
|
||||
)
|
||||
or
|
||||
result = any(Generated::DoBlock g | this = TDoBlock(g)).getChild(i)
|
||||
result = any(Ruby::DoBlock g | this = TDoBlock(g)).getChild(i)
|
||||
or
|
||||
result = any(Generated::Program g | this = TToplevel(g)).getChild(i) and
|
||||
not result instanceof Generated::BeginBlock
|
||||
result = any(Ruby::Program g | this = TToplevel(g)).getChild(i) and
|
||||
not result instanceof Ruby::BeginBlock
|
||||
or
|
||||
result = any(Generated::Class g | this = TClassDeclaration(g)).getChild(i)
|
||||
result = any(Ruby::Class g | this = TClassDeclaration(g)).getChild(i)
|
||||
or
|
||||
result = any(Generated::SingletonClass g | this = TSingletonClass(g)).getChild(i)
|
||||
result = any(Ruby::SingletonClass g | this = TSingletonClass(g)).getChild(i)
|
||||
or
|
||||
result = any(Generated::Module g | this = TModuleDeclaration(g)).getChild(i)
|
||||
result = any(Ruby::Module g | this = TModuleDeclaration(g)).getChild(i)
|
||||
or
|
||||
result = any(Generated::Begin g | this = TBeginExpr(g)).getChild(i)
|
||||
result = any(Ruby::Begin g | this = TBeginExpr(g)).getChild(i)
|
||||
}
|
||||
|
||||
final override Stmt getStmt(int n) {
|
||||
@@ -218,7 +218,7 @@ class BodyStmt extends StmtSequence, TBodyStmt {
|
||||
* ```
|
||||
*/
|
||||
class ParenthesizedExpr extends StmtSequence, TParenthesizedExpr {
|
||||
private Generated::ParenthesizedStatements g;
|
||||
private Ruby::ParenthesizedStatements g;
|
||||
|
||||
ParenthesizedExpr() { this = TParenthesizedExpr(g) }
|
||||
|
||||
@@ -240,7 +240,7 @@ class ParenthesizedExpr extends StmtSequence, TParenthesizedExpr {
|
||||
* ```
|
||||
*/
|
||||
class Pair extends Expr, TPair {
|
||||
private Generated::Pair g;
|
||||
private Ruby::Pair g;
|
||||
|
||||
Pair() { this = TPair(g) }
|
||||
|
||||
@@ -289,7 +289,7 @@ class Pair extends Expr, TPair {
|
||||
* end
|
||||
*/
|
||||
class RescueClause extends Expr, TRescueClause {
|
||||
private Generated::Rescue g;
|
||||
private Ruby::Rescue g;
|
||||
|
||||
RescueClause() { this = TRescueClause(g) }
|
||||
|
||||
@@ -357,7 +357,7 @@ class RescueClause extends Expr, TRescueClause {
|
||||
* ```
|
||||
*/
|
||||
class RescueModifierExpr extends Expr, TRescueModifierExpr {
|
||||
private Generated::RescueModifier g;
|
||||
private Ruby::RescueModifier g;
|
||||
|
||||
RescueModifierExpr() { this = TRescueModifierExpr(g) }
|
||||
|
||||
@@ -398,7 +398,7 @@ class RescueModifierExpr extends Expr, TRescueModifierExpr {
|
||||
* ```
|
||||
*/
|
||||
class StringConcatenation extends Expr, TStringConcatenation {
|
||||
private Generated::ChainedString g;
|
||||
private Ruby::ChainedString g;
|
||||
|
||||
StringConcatenation() { this = TStringConcatenation(g) }
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class IntegerLiteral extends NumericLiteral, TIntegerLiteral {
|
||||
}
|
||||
|
||||
private class IntegerLiteralReal extends IntegerLiteral, TIntegerLiteralReal {
|
||||
private Generated::Integer g;
|
||||
private Ruby::Integer g;
|
||||
|
||||
IntegerLiteralReal() { this = TIntegerLiteralReal(g) }
|
||||
|
||||
@@ -113,7 +113,7 @@ private class IntegerLiteralSynth extends IntegerLiteral, TIntegerLiteralSynth {
|
||||
* ```
|
||||
*/
|
||||
class FloatLiteral extends NumericLiteral, TFloatLiteral {
|
||||
private Generated::Float g;
|
||||
private Ruby::Float g;
|
||||
|
||||
FloatLiteral() { this = TFloatLiteral(g) }
|
||||
|
||||
@@ -132,11 +132,11 @@ class FloatLiteral extends NumericLiteral, TFloatLiteral {
|
||||
* ```
|
||||
*/
|
||||
class RationalLiteral extends NumericLiteral, TRationalLiteral {
|
||||
private Generated::Rational g;
|
||||
private Ruby::Rational g;
|
||||
|
||||
RationalLiteral() { this = TRationalLiteral(g) }
|
||||
|
||||
final override string getValueText() { result = g.getChild().(Generated::Token).getValue() + "r" }
|
||||
final override string getValueText() { result = g.getChild().(Ruby::Token).getValue() + "r" }
|
||||
|
||||
final override string toString() { result = this.getValueText() }
|
||||
|
||||
@@ -151,7 +151,7 @@ class RationalLiteral extends NumericLiteral, TRationalLiteral {
|
||||
* ```
|
||||
*/
|
||||
class ComplexLiteral extends NumericLiteral, TComplexLiteral {
|
||||
private Generated::Complex g;
|
||||
private Ruby::Complex g;
|
||||
|
||||
ComplexLiteral() { this = TComplexLiteral(g) }
|
||||
|
||||
@@ -164,7 +164,7 @@ class ComplexLiteral extends NumericLiteral, TComplexLiteral {
|
||||
|
||||
/** A `nil` literal. */
|
||||
class NilLiteral extends Literal, TNilLiteral {
|
||||
private Generated::Nil g;
|
||||
private Ruby::Nil g;
|
||||
|
||||
NilLiteral() { this = TNilLiteral(g) }
|
||||
|
||||
@@ -197,7 +197,7 @@ class BooleanLiteral extends Literal, TBooleanLiteral {
|
||||
}
|
||||
|
||||
private class TrueLiteral extends BooleanLiteral, TTrueLiteral {
|
||||
private Generated::True g;
|
||||
private Ruby::True g;
|
||||
|
||||
TrueLiteral() { this = TTrueLiteral(g) }
|
||||
|
||||
@@ -207,7 +207,7 @@ private class TrueLiteral extends BooleanLiteral, TTrueLiteral {
|
||||
}
|
||||
|
||||
private class FalseLiteral extends BooleanLiteral, TFalseLiteral {
|
||||
private Generated::False g;
|
||||
private Ruby::False g;
|
||||
|
||||
FalseLiteral() { this = TFalseLiteral(g) }
|
||||
|
||||
@@ -241,7 +241,7 @@ class StringComponent extends AstNode, TStringComponent {
|
||||
* ```
|
||||
*/
|
||||
class StringTextComponent extends StringComponent, TStringTextComponent {
|
||||
private Generated::Token g;
|
||||
private Ruby::Token g;
|
||||
|
||||
StringTextComponent() { this = TStringTextComponent(g) }
|
||||
|
||||
@@ -256,7 +256,7 @@ class StringTextComponent extends StringComponent, TStringTextComponent {
|
||||
* An escape sequence component of a string or string-like literal.
|
||||
*/
|
||||
class StringEscapeSequenceComponent extends StringComponent, TStringEscapeSequenceComponent {
|
||||
private Generated::EscapeSequence g;
|
||||
private Ruby::EscapeSequence g;
|
||||
|
||||
StringEscapeSequenceComponent() { this = TStringEscapeSequenceComponent(g) }
|
||||
|
||||
@@ -272,7 +272,7 @@ class StringEscapeSequenceComponent extends StringComponent, TStringEscapeSequen
|
||||
*/
|
||||
class StringInterpolationComponent extends StringComponent, StmtSequence,
|
||||
TStringInterpolationComponent {
|
||||
private Generated::Interpolation g;
|
||||
private Ruby::Interpolation g;
|
||||
|
||||
StringInterpolationComponent() { this = TStringInterpolationComponent(g) }
|
||||
|
||||
@@ -386,9 +386,9 @@ class StringlikeLiteral extends Literal, TStringlikeLiteral {
|
||||
concat(StringComponent c, int i, string s |
|
||||
c = this.getComponent(i) and
|
||||
(
|
||||
s = toGenerated(c).(Generated::Token).getValue()
|
||||
s = toGenerated(c).(Ruby::Token).getValue()
|
||||
or
|
||||
not toGenerated(c) instanceof Generated::Token and
|
||||
not toGenerated(c) instanceof Ruby::Token and
|
||||
s = "#{...}"
|
||||
)
|
||||
|
|
||||
@@ -424,7 +424,7 @@ class StringLiteral extends StringlikeLiteral, TStringLiteral {
|
||||
}
|
||||
|
||||
private class RegularStringLiteral extends StringLiteral, TRegularStringLiteral {
|
||||
private Generated::String g;
|
||||
private Ruby::String g;
|
||||
|
||||
RegularStringLiteral() { this = TRegularStringLiteral(g) }
|
||||
|
||||
@@ -432,7 +432,7 @@ private class RegularStringLiteral extends StringLiteral, TRegularStringLiteral
|
||||
}
|
||||
|
||||
private class BareStringLiteral extends StringLiteral, TBareStringLiteral {
|
||||
private Generated::BareString g;
|
||||
private Ruby::BareString g;
|
||||
|
||||
BareStringLiteral() { this = TBareStringLiteral(g) }
|
||||
|
||||
@@ -447,7 +447,7 @@ private class BareStringLiteral extends StringLiteral, TBareStringLiteral {
|
||||
* ```
|
||||
*/
|
||||
class RegExpLiteral extends StringlikeLiteral, TRegExpLiteral {
|
||||
private Generated::Regex g;
|
||||
private Ruby::Regex g;
|
||||
|
||||
RegExpLiteral() { this = TRegExpLiteral(g) }
|
||||
|
||||
@@ -467,11 +467,7 @@ class RegExpLiteral extends StringlikeLiteral, TRegExpLiteral {
|
||||
// For `/foo/i`, there should be an `/i` token in the database with `this`
|
||||
// as its parents. Strip the delimiter, which can vary.
|
||||
result =
|
||||
max(Generated::Token t |
|
||||
t.getParent() = g
|
||||
|
|
||||
t.getValue().suffix(1) order by t.getParentIndex()
|
||||
)
|
||||
max(Ruby::Token t | t.getParent() = g | t.getValue().suffix(1) order by t.getParentIndex())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,7 +524,7 @@ class SymbolLiteral extends StringlikeLiteral, TSymbolLiteral {
|
||||
}
|
||||
|
||||
private class SimpleSymbolLiteral extends SymbolLiteral, TSimpleSymbolLiteral {
|
||||
private Generated::SimpleSymbol g;
|
||||
private Ruby::SimpleSymbol g;
|
||||
|
||||
SimpleSymbolLiteral() { this = TSimpleSymbolLiteral(g) }
|
||||
|
||||
@@ -541,7 +537,7 @@ private class SimpleSymbolLiteral extends SymbolLiteral, TSimpleSymbolLiteral {
|
||||
private class ComplexSymbolLiteral extends SymbolLiteral, TComplexSymbolLiteral { }
|
||||
|
||||
private class DelimitedSymbolLiteral extends ComplexSymbolLiteral, TDelimitedSymbolLiteral {
|
||||
private Generated::DelimitedSymbol g;
|
||||
private Ruby::DelimitedSymbol g;
|
||||
|
||||
DelimitedSymbolLiteral() { this = TDelimitedSymbolLiteral(g) }
|
||||
|
||||
@@ -549,7 +545,7 @@ private class DelimitedSymbolLiteral extends ComplexSymbolLiteral, TDelimitedSym
|
||||
}
|
||||
|
||||
private class BareSymbolLiteral extends ComplexSymbolLiteral, TBareSymbolLiteral {
|
||||
private Generated::BareSymbol g;
|
||||
private Ruby::BareSymbol g;
|
||||
|
||||
BareSymbolLiteral() { this = TBareSymbolLiteral(g) }
|
||||
|
||||
@@ -557,7 +553,7 @@ private class BareSymbolLiteral extends ComplexSymbolLiteral, TBareSymbolLiteral
|
||||
}
|
||||
|
||||
private class HashKeySymbolLiteral extends SymbolLiteral, THashKeySymbolLiteral {
|
||||
private Generated::HashKeySymbol g;
|
||||
private Ruby::HashKeySymbol g;
|
||||
|
||||
HashKeySymbolLiteral() { this = THashKeySymbolLiteral(g) }
|
||||
|
||||
@@ -575,7 +571,7 @@ private class HashKeySymbolLiteral extends SymbolLiteral, THashKeySymbolLiteral
|
||||
* ```
|
||||
*/
|
||||
class SubshellLiteral extends StringlikeLiteral, TSubshellLiteral {
|
||||
private Generated::Subshell g;
|
||||
private Ruby::Subshell g;
|
||||
|
||||
SubshellLiteral() { this = TSubshellLiteral(g) }
|
||||
|
||||
@@ -593,7 +589,7 @@ class SubshellLiteral extends StringlikeLiteral, TSubshellLiteral {
|
||||
* ```
|
||||
*/
|
||||
class CharacterLiteral extends Literal, TCharacterLiteral {
|
||||
private Generated::Character g;
|
||||
private Ruby::Character g;
|
||||
|
||||
CharacterLiteral() { this = TCharacterLiteral(g) }
|
||||
|
||||
@@ -614,7 +610,7 @@ class CharacterLiteral extends Literal, TCharacterLiteral {
|
||||
* ```
|
||||
*/
|
||||
class HereDoc extends StringlikeLiteral, THereDoc {
|
||||
private Generated::HeredocBeginning g;
|
||||
private Ruby::HeredocBeginning g;
|
||||
|
||||
HereDoc() { this = THereDoc(g) }
|
||||
|
||||
@@ -698,7 +694,7 @@ class ArrayLiteral extends Literal, TArrayLiteral {
|
||||
}
|
||||
|
||||
private class RegularArrayLiteral extends ArrayLiteral, TRegularArrayLiteral {
|
||||
private Generated::Array g;
|
||||
private Ruby::Array g;
|
||||
|
||||
RegularArrayLiteral() { this = TRegularArrayLiteral(g) }
|
||||
|
||||
@@ -708,7 +704,7 @@ private class RegularArrayLiteral extends ArrayLiteral, TRegularArrayLiteral {
|
||||
}
|
||||
|
||||
private class StringArrayLiteral extends ArrayLiteral, TStringArrayLiteral {
|
||||
private Generated::StringArray g;
|
||||
private Ruby::StringArray g;
|
||||
|
||||
StringArrayLiteral() { this = TStringArrayLiteral(g) }
|
||||
|
||||
@@ -718,7 +714,7 @@ private class StringArrayLiteral extends ArrayLiteral, TStringArrayLiteral {
|
||||
}
|
||||
|
||||
private class SymbolArrayLiteral extends ArrayLiteral, TSymbolArrayLiteral {
|
||||
private Generated::SymbolArray g;
|
||||
private Ruby::SymbolArray g;
|
||||
|
||||
SymbolArrayLiteral() { this = TSymbolArrayLiteral(g) }
|
||||
|
||||
@@ -735,7 +731,7 @@ private class SymbolArrayLiteral extends ArrayLiteral, TSymbolArrayLiteral {
|
||||
* ```
|
||||
*/
|
||||
class HashLiteral extends Literal, THashLiteral {
|
||||
private Generated::Hash g;
|
||||
private Ruby::Hash g;
|
||||
|
||||
HashLiteral() { this = THashLiteral(g) }
|
||||
|
||||
@@ -820,7 +816,7 @@ class RangeLiteral extends Literal, TRangeLiteral {
|
||||
}
|
||||
|
||||
private class RangeLiteralReal extends RangeLiteral, TRangeLiteralReal {
|
||||
private Generated::Range g;
|
||||
private Ruby::Range g;
|
||||
|
||||
RangeLiteralReal() { this = TRangeLiteralReal(g) }
|
||||
|
||||
@@ -868,9 +864,9 @@ private class TokenMethodName extends MethodName, TTokenMethodName {
|
||||
TokenMethodName() { this = TTokenMethodName(g) }
|
||||
|
||||
final override string getValueText() {
|
||||
result = g.(Generated::Token).getValue()
|
||||
result = g.(Ruby::Token).getValue()
|
||||
or
|
||||
result = g.(Generated::Setter).getName().getValue() + "="
|
||||
result = g.(Ruby::Setter).getName().getValue() + "="
|
||||
}
|
||||
|
||||
final override string toString() { result = this.getValueText() }
|
||||
|
||||
@@ -40,15 +40,15 @@ private class Private extends MethodCall {
|
||||
|
||||
/** A normal method. */
|
||||
class Method extends MethodBase, TMethod {
|
||||
private Generated::Method g;
|
||||
private Ruby::Method g;
|
||||
|
||||
Method() { this = TMethod(g) }
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "Method" }
|
||||
|
||||
final override string getName() {
|
||||
result = g.getName().(Generated::Token).getValue() or
|
||||
result = g.getName().(Generated::Setter).getName().getValue() + "="
|
||||
result = g.getName().(Ruby::Token).getValue() or
|
||||
result = g.getName().(Ruby::Setter).getName().getValue() + "="
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ class Method extends MethodBase, TMethod {
|
||||
* end
|
||||
* ```
|
||||
*/
|
||||
final predicate isSetter() { g.getName() instanceof Generated::Setter }
|
||||
final predicate isSetter() { g.getName() instanceof Ruby::Setter }
|
||||
|
||||
/**
|
||||
* Holds if this method is private. All methods with the name prefix
|
||||
@@ -118,7 +118,7 @@ class Method extends MethodBase, TMethod {
|
||||
|
||||
/** A singleton method. */
|
||||
class SingletonMethod extends MethodBase, TSingletonMethod {
|
||||
private Generated::SingletonMethod g;
|
||||
private Ruby::SingletonMethod g;
|
||||
|
||||
SingletonMethod() { this = TSingletonMethod(g) }
|
||||
|
||||
@@ -128,9 +128,9 @@ class SingletonMethod extends MethodBase, TSingletonMethod {
|
||||
final Expr getObject() { toGenerated(result) = g.getObject() }
|
||||
|
||||
final override string getName() {
|
||||
result = g.getName().(Generated::Token).getValue()
|
||||
result = g.getName().(Ruby::Token).getValue()
|
||||
or
|
||||
result = g.getName().(Generated::Setter).getName().getValue() + "="
|
||||
result = g.getName().(Ruby::Setter).getName().getValue() + "="
|
||||
}
|
||||
|
||||
final override Parameter getParameter(int n) {
|
||||
@@ -153,7 +153,7 @@ class SingletonMethod extends MethodBase, TSingletonMethod {
|
||||
* ```
|
||||
*/
|
||||
class Lambda extends Callable, BodyStmt, TLambda {
|
||||
private Generated::Lambda g;
|
||||
private Ruby::Lambda g;
|
||||
|
||||
Lambda() { this = TLambda(g) }
|
||||
|
||||
@@ -183,7 +183,7 @@ class Block extends Callable, StmtSequence, Scope, TBlock {
|
||||
|
||||
/** A block enclosed within `do` and `end`. */
|
||||
class DoBlock extends Block, BodyStmt, TDoBlock {
|
||||
private Generated::DoBlock g;
|
||||
private Ruby::DoBlock g;
|
||||
|
||||
DoBlock() { this = TDoBlock(g) }
|
||||
|
||||
@@ -209,7 +209,7 @@ class DoBlock extends Block, BodyStmt, TDoBlock {
|
||||
* ```
|
||||
*/
|
||||
class BraceBlock extends Block, TBraceBlock {
|
||||
private Generated::Block g;
|
||||
private Ruby::Block g;
|
||||
|
||||
BraceBlock() { this = TBraceBlock(g) }
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class ModuleBase extends BodyStmt, Scope, TModuleBase {
|
||||
* ```
|
||||
*/
|
||||
class Toplevel extends ModuleBase, TToplevel {
|
||||
private Generated::Program g;
|
||||
private Ruby::Program g;
|
||||
|
||||
Toplevel() { this = TToplevel(g) }
|
||||
|
||||
@@ -119,8 +119,7 @@ class Toplevel extends ModuleBase, TToplevel {
|
||||
* Gets the `n`th `BEGIN` block.
|
||||
*/
|
||||
final BeginBlock getBeginBlock(int n) {
|
||||
toGenerated(result) =
|
||||
rank[n + 1](int i, Generated::BeginBlock b | b = g.getChild(i) | b order by i)
|
||||
toGenerated(result) = rank[n + 1](int i, Ruby::BeginBlock b | b = g.getChild(i) | b order by i)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +230,7 @@ class Namespace extends ModuleBase, ConstantWriteAccess, TNamespace {
|
||||
* ```
|
||||
*/
|
||||
class ClassDeclaration extends Namespace, TClassDeclaration {
|
||||
private Generated::Class g;
|
||||
private Ruby::Class g;
|
||||
|
||||
ClassDeclaration() { this = TClassDeclaration(g) }
|
||||
|
||||
@@ -256,16 +255,16 @@ class ClassDeclaration extends Namespace, TClassDeclaration {
|
||||
final Expr getSuperclassExpr() { toGenerated(result) = g.getSuperclass().getChild() }
|
||||
|
||||
final override string getName() {
|
||||
result = g.getName().(Generated::Token).getValue() or
|
||||
result = g.getName().(Generated::ScopeResolution).getName().(Generated::Token).getValue()
|
||||
result = g.getName().(Ruby::Token).getValue() or
|
||||
result = g.getName().(Ruby::ScopeResolution).getName().(Ruby::Token).getValue()
|
||||
}
|
||||
|
||||
final override Expr getScopeExpr() {
|
||||
toGenerated(result) = g.getName().(Generated::ScopeResolution).getScope()
|
||||
toGenerated(result) = g.getName().(Ruby::ScopeResolution).getScope()
|
||||
}
|
||||
|
||||
final override predicate hasGlobalScope() {
|
||||
exists(Generated::ScopeResolution sr |
|
||||
exists(Ruby::ScopeResolution sr |
|
||||
sr = g.getName() and
|
||||
not exists(sr.getScope())
|
||||
)
|
||||
@@ -290,7 +289,7 @@ class ClassDeclaration extends Namespace, TClassDeclaration {
|
||||
* ```
|
||||
*/
|
||||
class SingletonClass extends ModuleBase, TSingletonClass {
|
||||
private Generated::SingletonClass g;
|
||||
private Ruby::SingletonClass g;
|
||||
|
||||
SingletonClass() { this = TSingletonClass(g) }
|
||||
|
||||
@@ -342,23 +341,23 @@ class SingletonClass extends ModuleBase, TSingletonClass {
|
||||
* ```
|
||||
*/
|
||||
class ModuleDeclaration extends Namespace, TModuleDeclaration {
|
||||
private Generated::Module g;
|
||||
private Ruby::Module g;
|
||||
|
||||
ModuleDeclaration() { this = TModuleDeclaration(g) }
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "ModuleDeclaration" }
|
||||
|
||||
final override string getName() {
|
||||
result = g.getName().(Generated::Token).getValue() or
|
||||
result = g.getName().(Generated::ScopeResolution).getName().(Generated::Token).getValue()
|
||||
result = g.getName().(Ruby::Token).getValue() or
|
||||
result = g.getName().(Ruby::ScopeResolution).getName().(Ruby::Token).getValue()
|
||||
}
|
||||
|
||||
final override Expr getScopeExpr() {
|
||||
toGenerated(result) = g.getName().(Generated::ScopeResolution).getScope()
|
||||
toGenerated(result) = g.getName().(Ruby::ScopeResolution).getScope()
|
||||
}
|
||||
|
||||
final override predicate hasGlobalScope() {
|
||||
exists(Generated::ScopeResolution sr |
|
||||
exists(Ruby::ScopeResolution sr |
|
||||
sr = g.getName() and
|
||||
not exists(sr.getScope())
|
||||
)
|
||||
|
||||
@@ -39,7 +39,7 @@ class UnaryOperation extends Operation, TUnaryOperation {
|
||||
}
|
||||
|
||||
private class UnaryOperationGenerated extends UnaryOperation, TUnaryOperation {
|
||||
private Generated::Unary g;
|
||||
private Ruby::Unary g;
|
||||
|
||||
UnaryOperationGenerated() { g = toGenerated(this) }
|
||||
|
||||
@@ -106,7 +106,7 @@ class SplatExpr extends UnaryOperation, TSplatExpr {
|
||||
* ```
|
||||
*/
|
||||
class HashSplatExpr extends UnaryOperation, THashSplatExpr {
|
||||
private Generated::HashSplatArgument g;
|
||||
private Ruby::HashSplatArgument g;
|
||||
|
||||
HashSplatExpr() { this = THashSplatExpr(g) }
|
||||
|
||||
@@ -164,7 +164,7 @@ class BinaryOperation extends Operation, TBinaryOperation {
|
||||
}
|
||||
|
||||
private class BinaryOperationReal extends BinaryOperation {
|
||||
private Generated::Binary g;
|
||||
private Ruby::Binary g;
|
||||
|
||||
BinaryOperationReal() { g = toGenerated(this) }
|
||||
|
||||
@@ -569,7 +569,7 @@ class AssignExpr extends Assignment, TAssignExpr {
|
||||
* A binary assignment operation other than `=`.
|
||||
*/
|
||||
class AssignOperation extends Assignment, TAssignOperation {
|
||||
Generated::OperatorAssignment g;
|
||||
Ruby::OperatorAssignment g;
|
||||
|
||||
AssignOperation() { g = toGenerated(this) }
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class NamedParameter extends Parameter, TNamedParameter {
|
||||
|
||||
/** A simple (normal) parameter. */
|
||||
class SimpleParameter extends NamedParameter, PatternParameter, VariablePattern, TSimpleParameter {
|
||||
private Generated::Identifier g;
|
||||
private Ruby::Identifier g;
|
||||
|
||||
SimpleParameter() { this = TSimpleParameter(g) }
|
||||
|
||||
@@ -90,7 +90,7 @@ class SimpleParameter extends NamedParameter, PatternParameter, VariablePattern,
|
||||
* ```
|
||||
*/
|
||||
class BlockParameter extends NamedParameter, TBlockParameter {
|
||||
private Generated::BlockParameter g;
|
||||
private Ruby::BlockParameter g;
|
||||
|
||||
BlockParameter() { this = TBlockParameter(g) }
|
||||
|
||||
@@ -113,7 +113,7 @@ class BlockParameter extends NamedParameter, TBlockParameter {
|
||||
* ```
|
||||
*/
|
||||
class HashSplatParameter extends NamedParameter, THashSplatParameter {
|
||||
private Generated::HashSplatParameter g;
|
||||
private Ruby::HashSplatParameter g;
|
||||
|
||||
HashSplatParameter() { this = THashSplatParameter(g) }
|
||||
|
||||
@@ -138,7 +138,7 @@ class HashSplatParameter extends NamedParameter, THashSplatParameter {
|
||||
* ```
|
||||
*/
|
||||
class KeywordParameter extends NamedParameter, TKeywordParameter {
|
||||
private Generated::KeywordParameter g;
|
||||
private Ruby::KeywordParameter g;
|
||||
|
||||
KeywordParameter() { this = TKeywordParameter(g) }
|
||||
|
||||
@@ -182,7 +182,7 @@ class KeywordParameter extends NamedParameter, TKeywordParameter {
|
||||
* ```
|
||||
*/
|
||||
class OptionalParameter extends NamedParameter, TOptionalParameter {
|
||||
private Generated::OptionalParameter g;
|
||||
private Ruby::OptionalParameter g;
|
||||
|
||||
OptionalParameter() { this = TOptionalParameter(g) }
|
||||
|
||||
@@ -218,7 +218,7 @@ class OptionalParameter extends NamedParameter, TOptionalParameter {
|
||||
* ```
|
||||
*/
|
||||
class SplatParameter extends NamedParameter, TSplatParameter {
|
||||
private Generated::SplatParameter g;
|
||||
private Ruby::SplatParameter g;
|
||||
|
||||
SplatParameter() { this = TSplatParameter(g) }
|
||||
|
||||
|
||||
@@ -65,12 +65,12 @@ class TuplePattern extends Pattern, TTuplePattern {
|
||||
|
||||
private TuplePatternImpl getImpl() { result = toGenerated(this) }
|
||||
|
||||
private Generated::AstNode getChild(int i) { result = this.getImpl().getChildNode(i) }
|
||||
private Ruby::AstNode getChild(int i) { result = this.getImpl().getChildNode(i) }
|
||||
|
||||
/** Gets the `i`th pattern in this tuple pattern. */
|
||||
final Pattern getElement(int i) {
|
||||
exists(Generated::AstNode c | c = this.getChild(i) |
|
||||
toGenerated(result) = c.(Generated::RestAssignment).getChild()
|
||||
exists(Ruby::AstNode c | c = this.getChild(i) |
|
||||
toGenerated(result) = c.(Ruby::RestAssignment).getChild()
|
||||
or
|
||||
toGenerated(result) = c
|
||||
)
|
||||
|
||||
@@ -51,7 +51,7 @@ class BeginExpr extends BodyStmt, TBeginExpr {
|
||||
* ```
|
||||
*/
|
||||
class BeginBlock extends StmtSequence, TBeginBlock {
|
||||
private Generated::BeginBlock g;
|
||||
private Ruby::BeginBlock g;
|
||||
|
||||
BeginBlock() { this = TBeginBlock(g) }
|
||||
|
||||
@@ -69,7 +69,7 @@ class BeginBlock extends StmtSequence, TBeginBlock {
|
||||
* ```
|
||||
*/
|
||||
class EndBlock extends StmtSequence, TEndBlock {
|
||||
private Generated::EndBlock g;
|
||||
private Ruby::EndBlock g;
|
||||
|
||||
EndBlock() { this = TEndBlock(g) }
|
||||
|
||||
@@ -89,7 +89,7 @@ class EndBlock extends StmtSequence, TEndBlock {
|
||||
* ```
|
||||
*/
|
||||
class UndefStmt extends Stmt, TUndefStmt {
|
||||
private Generated::Undef g;
|
||||
private Ruby::Undef g;
|
||||
|
||||
UndefStmt() { this = TUndefStmt(g) }
|
||||
|
||||
@@ -119,7 +119,7 @@ class UndefStmt extends Stmt, TUndefStmt {
|
||||
* ```
|
||||
*/
|
||||
class AliasStmt extends Stmt, TAliasStmt {
|
||||
private Generated::Alias g;
|
||||
private Ruby::Alias g;
|
||||
|
||||
AliasStmt() { this = TAliasStmt(g) }
|
||||
|
||||
@@ -155,19 +155,19 @@ class AliasStmt extends Stmt, TAliasStmt {
|
||||
* ```
|
||||
*/
|
||||
class ReturningStmt extends Stmt, TReturningStmt {
|
||||
private Generated::ArgumentList getArgumentList() {
|
||||
result = any(Generated::Return g | this = TReturnStmt(g)).getChild()
|
||||
private Ruby::ArgumentList getArgumentList() {
|
||||
result = any(Ruby::Return g | this = TReturnStmt(g)).getChild()
|
||||
or
|
||||
result = any(Generated::Break g | this = TBreakStmt(g)).getChild()
|
||||
result = any(Ruby::Break g | this = TBreakStmt(g)).getChild()
|
||||
or
|
||||
result = any(Generated::Next g | this = TNextStmt(g)).getChild()
|
||||
result = any(Ruby::Next g | this = TNextStmt(g)).getChild()
|
||||
}
|
||||
|
||||
/** Gets the returned value, if any. */
|
||||
final Expr getValue() {
|
||||
toGenerated(result) =
|
||||
any(Generated::AstNode res |
|
||||
exists(Generated::ArgumentList a, int c |
|
||||
any(Ruby::AstNode res |
|
||||
exists(Ruby::ArgumentList a, int c |
|
||||
a = this.getArgumentList() and c = count(a.getChild(_))
|
||||
|
|
||||
res = a.getChild(0) and c = 1
|
||||
|
||||
@@ -7,10 +7,10 @@ private import codeql_ruby.AST as AST
|
||||
private import Synthesis
|
||||
|
||||
module MethodName {
|
||||
predicate range(Generated::UnderscoreMethodName g) {
|
||||
exists(Generated::Undef u | u.getChild(_) = g)
|
||||
predicate range(Ruby::UnderscoreMethodName g) {
|
||||
exists(Ruby::Undef u | u.getChild(_) = g)
|
||||
or
|
||||
exists(Generated::Alias a | a.getName() = g or a.getAlias() = g)
|
||||
exists(Ruby::Alias a | a.getName() = g or a.getAlias() = g)
|
||||
}
|
||||
|
||||
class Token =
|
||||
@@ -27,150 +27,142 @@ cached
|
||||
private module Cached {
|
||||
cached
|
||||
newtype TAstNode =
|
||||
TAddExprReal(Generated::Binary g) { g instanceof @ruby_binary_plus } or
|
||||
TAddExprReal(Ruby::Binary g) { g instanceof @ruby_binary_plus } or
|
||||
TAddExprSynth(AST::AstNode parent, int i) { mkSynthChild(AddExprKind(), parent, i) } or
|
||||
TAliasStmt(Generated::Alias g) or
|
||||
TArgumentList(Generated::AstNode g) {
|
||||
TAliasStmt(Ruby::Alias g) or
|
||||
TArgumentList(Ruby::AstNode g) {
|
||||
(
|
||||
g.getParent() instanceof Generated::Break or
|
||||
g.getParent() instanceof Generated::Return or
|
||||
g.getParent() instanceof Generated::Next or
|
||||
g.getParent() instanceof Generated::Assignment or
|
||||
g.getParent() instanceof Generated::OperatorAssignment
|
||||
g.getParent() instanceof Ruby::Break or
|
||||
g.getParent() instanceof Ruby::Return or
|
||||
g.getParent() instanceof Ruby::Next or
|
||||
g.getParent() instanceof Ruby::Assignment or
|
||||
g.getParent() instanceof Ruby::OperatorAssignment
|
||||
) and
|
||||
(
|
||||
strictcount(g.(Generated::ArgumentList).getChild(_)) > 1
|
||||
strictcount(g.(Ruby::ArgumentList).getChild(_)) > 1
|
||||
or
|
||||
g instanceof Generated::RightAssignmentList
|
||||
g instanceof Ruby::RightAssignmentList
|
||||
)
|
||||
} or
|
||||
TAssignAddExpr(Generated::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_plusequal
|
||||
} or
|
||||
TAssignBitwiseAndExpr(Generated::OperatorAssignment g) {
|
||||
TAssignAddExpr(Ruby::OperatorAssignment g) { g instanceof @ruby_operator_assignment_plusequal } or
|
||||
TAssignBitwiseAndExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_ampersandequal
|
||||
} or
|
||||
TAssignBitwiseOrExpr(Generated::OperatorAssignment g) {
|
||||
TAssignBitwiseOrExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_pipeequal
|
||||
} or
|
||||
TAssignBitwiseXorExpr(Generated::OperatorAssignment g) {
|
||||
TAssignBitwiseXorExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_caretequal
|
||||
} or
|
||||
TAssignDivExpr(Generated::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_slashequal
|
||||
} or
|
||||
TAssignExponentExpr(Generated::OperatorAssignment g) {
|
||||
TAssignDivExpr(Ruby::OperatorAssignment g) { g instanceof @ruby_operator_assignment_slashequal } or
|
||||
TAssignExponentExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_starstarequal
|
||||
} or
|
||||
TAssignExprReal(Generated::Assignment g) or
|
||||
TAssignExprReal(Ruby::Assignment g) or
|
||||
TAssignExprSynth(AST::AstNode parent, int i) { mkSynthChild(AssignExprKind(), parent, i) } or
|
||||
TAssignLShiftExpr(Generated::OperatorAssignment g) {
|
||||
TAssignLShiftExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_langlelangleequal
|
||||
} or
|
||||
TAssignLogicalAndExpr(Generated::OperatorAssignment g) {
|
||||
TAssignLogicalAndExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_ampersandampersandequal
|
||||
} or
|
||||
TAssignLogicalOrExpr(Generated::OperatorAssignment g) {
|
||||
TAssignLogicalOrExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_pipepipeequal
|
||||
} or
|
||||
TAssignModuloExpr(Generated::OperatorAssignment g) {
|
||||
TAssignModuloExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_percentequal
|
||||
} or
|
||||
TAssignMulExpr(Generated::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_starequal
|
||||
} or
|
||||
TAssignRShiftExpr(Generated::OperatorAssignment g) {
|
||||
TAssignMulExpr(Ruby::OperatorAssignment g) { g instanceof @ruby_operator_assignment_starequal } or
|
||||
TAssignRShiftExpr(Ruby::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_ranglerangleequal
|
||||
} or
|
||||
TAssignSubExpr(Generated::OperatorAssignment g) {
|
||||
g instanceof @ruby_operator_assignment_minusequal
|
||||
} or
|
||||
TBareStringLiteral(Generated::BareString g) or
|
||||
TBareSymbolLiteral(Generated::BareSymbol g) or
|
||||
TBeginBlock(Generated::BeginBlock g) or
|
||||
TBeginExpr(Generated::Begin g) or
|
||||
TBitwiseAndExprReal(Generated::Binary g) { g instanceof @ruby_binary_ampersand } or
|
||||
TAssignSubExpr(Ruby::OperatorAssignment g) { g instanceof @ruby_operator_assignment_minusequal } or
|
||||
TBareStringLiteral(Ruby::BareString g) or
|
||||
TBareSymbolLiteral(Ruby::BareSymbol g) or
|
||||
TBeginBlock(Ruby::BeginBlock g) or
|
||||
TBeginExpr(Ruby::Begin g) or
|
||||
TBitwiseAndExprReal(Ruby::Binary g) { g instanceof @ruby_binary_ampersand } or
|
||||
TBitwiseAndExprSynth(AST::AstNode parent, int i) {
|
||||
mkSynthChild(BitwiseAndExprKind(), parent, i)
|
||||
} or
|
||||
TBitwiseOrExprReal(Generated::Binary g) { g instanceof @ruby_binary_pipe } or
|
||||
TBitwiseOrExprReal(Ruby::Binary g) { g instanceof @ruby_binary_pipe } or
|
||||
TBitwiseOrExprSynth(AST::AstNode parent, int i) { mkSynthChild(BitwiseOrExprKind(), parent, i) } or
|
||||
TBitwiseXorExprReal(Generated::Binary g) { g instanceof @ruby_binary_caret } or
|
||||
TBitwiseXorExprReal(Ruby::Binary g) { g instanceof @ruby_binary_caret } or
|
||||
TBitwiseXorExprSynth(AST::AstNode parent, int i) {
|
||||
mkSynthChild(BitwiseXorExprKind(), parent, i)
|
||||
} or
|
||||
TBlockArgument(Generated::BlockArgument g) or
|
||||
TBlockParameter(Generated::BlockParameter g) or
|
||||
TBraceBlock(Generated::Block g) { not g.getParent() instanceof Generated::Lambda } or
|
||||
TBreakStmt(Generated::Break g) or
|
||||
TCaseEqExpr(Generated::Binary g) { g instanceof @ruby_binary_equalequalequal } or
|
||||
TCaseExpr(Generated::Case g) or
|
||||
TCharacterLiteral(Generated::Character g) or
|
||||
TClassDeclaration(Generated::Class g) or
|
||||
TClassVariableAccessReal(Generated::ClassVariable g, AST::ClassVariable v) {
|
||||
TBlockArgument(Ruby::BlockArgument g) or
|
||||
TBlockParameter(Ruby::BlockParameter g) or
|
||||
TBraceBlock(Ruby::Block g) { not g.getParent() instanceof Ruby::Lambda } or
|
||||
TBreakStmt(Ruby::Break g) or
|
||||
TCaseEqExpr(Ruby::Binary g) { g instanceof @ruby_binary_equalequalequal } or
|
||||
TCaseExpr(Ruby::Case g) or
|
||||
TCharacterLiteral(Ruby::Character g) or
|
||||
TClassDeclaration(Ruby::Class g) or
|
||||
TClassVariableAccessReal(Ruby::ClassVariable g, AST::ClassVariable v) {
|
||||
ClassVariableAccess::range(g, v)
|
||||
} or
|
||||
TClassVariableAccessSynth(AST::AstNode parent, int i, AST::ClassVariable v) {
|
||||
mkSynthChild(ClassVariableAccessKind(v), parent, i)
|
||||
} or
|
||||
TComplementExpr(Generated::Unary g) { g instanceof @ruby_unary_tilde } or
|
||||
TComplexLiteral(Generated::Complex g) or
|
||||
TDefinedExpr(Generated::Unary g) { g instanceof @ruby_unary_definedquestion } or
|
||||
TDelimitedSymbolLiteral(Generated::DelimitedSymbol g) or
|
||||
TDestructuredLeftAssignment(Generated::DestructuredLeftAssignment g) {
|
||||
not strictcount(int i | exists(g.getParent().(Generated::LeftAssignmentList).getChild(i))) = 1
|
||||
TComplementExpr(Ruby::Unary g) { g instanceof @ruby_unary_tilde } or
|
||||
TComplexLiteral(Ruby::Complex g) or
|
||||
TDefinedExpr(Ruby::Unary g) { g instanceof @ruby_unary_definedquestion } or
|
||||
TDelimitedSymbolLiteral(Ruby::DelimitedSymbol g) or
|
||||
TDestructuredLeftAssignment(Ruby::DestructuredLeftAssignment g) {
|
||||
not strictcount(int i | exists(g.getParent().(Ruby::LeftAssignmentList).getChild(i))) = 1
|
||||
} or
|
||||
TDivExprReal(Generated::Binary g) { g instanceof @ruby_binary_slash } or
|
||||
TDivExprReal(Ruby::Binary g) { g instanceof @ruby_binary_slash } or
|
||||
TDivExprSynth(AST::AstNode parent, int i) { mkSynthChild(DivExprKind(), parent, i) } or
|
||||
TDo(Generated::Do g) or
|
||||
TDoBlock(Generated::DoBlock g) { not g.getParent() instanceof Generated::Lambda } or
|
||||
TElementReference(Generated::ElementReference g) or
|
||||
TElse(Generated::Else g) or
|
||||
TElsif(Generated::Elsif g) or
|
||||
TEmptyStmt(Generated::EmptyStatement g) or
|
||||
TEndBlock(Generated::EndBlock g) or
|
||||
TEnsure(Generated::Ensure g) or
|
||||
TEqExpr(Generated::Binary g) { g instanceof @ruby_binary_equalequal } or
|
||||
TExponentExprReal(Generated::Binary g) { g instanceof @ruby_binary_starstar } or
|
||||
TDo(Ruby::Do g) or
|
||||
TDoBlock(Ruby::DoBlock g) { not g.getParent() instanceof Ruby::Lambda } or
|
||||
TElementReference(Ruby::ElementReference g) or
|
||||
TElse(Ruby::Else g) or
|
||||
TElsif(Ruby::Elsif g) or
|
||||
TEmptyStmt(Ruby::EmptyStatement g) or
|
||||
TEndBlock(Ruby::EndBlock g) or
|
||||
TEnsure(Ruby::Ensure g) or
|
||||
TEqExpr(Ruby::Binary g) { g instanceof @ruby_binary_equalequal } or
|
||||
TExponentExprReal(Ruby::Binary g) { g instanceof @ruby_binary_starstar } or
|
||||
TExponentExprSynth(AST::AstNode parent, int i) { mkSynthChild(ExponentExprKind(), parent, i) } or
|
||||
TFalseLiteral(Generated::False g) or
|
||||
TFloatLiteral(Generated::Float g) { not any(Generated::Rational r).getChild() = g } or
|
||||
TForExpr(Generated::For g) or
|
||||
TForIn(Generated::In g) or // TODO REMOVE
|
||||
TGEExpr(Generated::Binary g) { g instanceof @ruby_binary_rangleequal } or
|
||||
TGTExpr(Generated::Binary g) { g instanceof @ruby_binary_rangle } or
|
||||
TGlobalVariableAccessReal(Generated::GlobalVariable g, AST::GlobalVariable v) {
|
||||
TFalseLiteral(Ruby::False g) or
|
||||
TFloatLiteral(Ruby::Float g) { not any(Ruby::Rational r).getChild() = g } or
|
||||
TForExpr(Ruby::For g) or
|
||||
TForIn(Ruby::In g) or // TODO REMOVE
|
||||
TGEExpr(Ruby::Binary g) { g instanceof @ruby_binary_rangleequal } or
|
||||
TGTExpr(Ruby::Binary g) { g instanceof @ruby_binary_rangle } or
|
||||
TGlobalVariableAccessReal(Ruby::GlobalVariable g, AST::GlobalVariable v) {
|
||||
GlobalVariableAccess::range(g, v)
|
||||
} or
|
||||
TGlobalVariableAccessSynth(AST::AstNode parent, int i, AST::GlobalVariable v) {
|
||||
mkSynthChild(GlobalVariableAccessKind(v), parent, i)
|
||||
} or
|
||||
THashKeySymbolLiteral(Generated::HashKeySymbol g) or
|
||||
THashLiteral(Generated::Hash g) or
|
||||
THashSplatExpr(Generated::HashSplatArgument g) or
|
||||
THashSplatParameter(Generated::HashSplatParameter g) or
|
||||
THereDoc(Generated::HeredocBeginning g) or
|
||||
TIdentifierMethodCall(Generated::Identifier g) { isIdentifierMethodCall(g) } or
|
||||
TIf(Generated::If g) or
|
||||
TIfModifierExpr(Generated::IfModifier g) or
|
||||
TInstanceVariableAccessReal(Generated::InstanceVariable g, AST::InstanceVariable v) {
|
||||
THashKeySymbolLiteral(Ruby::HashKeySymbol g) or
|
||||
THashLiteral(Ruby::Hash g) or
|
||||
THashSplatExpr(Ruby::HashSplatArgument g) or
|
||||
THashSplatParameter(Ruby::HashSplatParameter g) or
|
||||
THereDoc(Ruby::HeredocBeginning g) or
|
||||
TIdentifierMethodCall(Ruby::Identifier g) { isIdentifierMethodCall(g) } or
|
||||
TIf(Ruby::If g) or
|
||||
TIfModifierExpr(Ruby::IfModifier g) or
|
||||
TInstanceVariableAccessReal(Ruby::InstanceVariable g, AST::InstanceVariable v) {
|
||||
InstanceVariableAccess::range(g, v)
|
||||
} or
|
||||
TInstanceVariableAccessSynth(AST::AstNode parent, int i, AST::InstanceVariable v) {
|
||||
mkSynthChild(InstanceVariableAccessKind(v), parent, i)
|
||||
} or
|
||||
TIntegerLiteralReal(Generated::Integer g) { not any(Generated::Rational r).getChild() = g } or
|
||||
TIntegerLiteralReal(Ruby::Integer g) { not any(Ruby::Rational r).getChild() = g } or
|
||||
TIntegerLiteralSynth(AST::AstNode parent, int i, int value) {
|
||||
mkSynthChild(IntegerLiteralKind(value), parent, i)
|
||||
} or
|
||||
TKeywordParameter(Generated::KeywordParameter g) or
|
||||
TLEExpr(Generated::Binary g) { g instanceof @ruby_binary_langleequal } or
|
||||
TLShiftExprReal(Generated::Binary g) { g instanceof @ruby_binary_langlelangle } or
|
||||
TKeywordParameter(Ruby::KeywordParameter g) or
|
||||
TLEExpr(Ruby::Binary g) { g instanceof @ruby_binary_langleequal } or
|
||||
TLShiftExprReal(Ruby::Binary g) { g instanceof @ruby_binary_langlelangle } or
|
||||
TLShiftExprSynth(AST::AstNode parent, int i) { mkSynthChild(LShiftExprKind(), parent, i) } or
|
||||
TLTExpr(Generated::Binary g) { g instanceof @ruby_binary_langle } or
|
||||
TLambda(Generated::Lambda g) or
|
||||
TLeftAssignmentList(Generated::LeftAssignmentList g) or
|
||||
TLocalVariableAccessReal(Generated::Identifier g, AST::LocalVariable v) {
|
||||
TLTExpr(Ruby::Binary g) { g instanceof @ruby_binary_langle } or
|
||||
TLambda(Ruby::Lambda g) or
|
||||
TLeftAssignmentList(Ruby::LeftAssignmentList g) or
|
||||
TLocalVariableAccessReal(Ruby::Identifier g, AST::LocalVariable v) {
|
||||
LocalVariableAccess::range(g, v)
|
||||
} or
|
||||
TLocalVariableAccessSynth(AST::AstNode parent, int i, AST::LocalVariable v) {
|
||||
@@ -178,52 +170,52 @@ private module Cached {
|
||||
or
|
||||
mkSynthChild(LocalVariableAccessSynthKind(v), parent, i)
|
||||
} or
|
||||
TLogicalAndExprReal(Generated::Binary g) {
|
||||
TLogicalAndExprReal(Ruby::Binary g) {
|
||||
g instanceof @ruby_binary_and or g instanceof @ruby_binary_ampersandampersand
|
||||
} or
|
||||
TLogicalAndExprSynth(AST::AstNode parent, int i) {
|
||||
mkSynthChild(LogicalAndExprKind(), parent, i)
|
||||
} or
|
||||
TLogicalOrExprReal(Generated::Binary g) {
|
||||
TLogicalOrExprReal(Ruby::Binary g) {
|
||||
g instanceof @ruby_binary_or or g instanceof @ruby_binary_pipepipe
|
||||
} or
|
||||
TLogicalOrExprSynth(AST::AstNode parent, int i) { mkSynthChild(LogicalOrExprKind(), parent, i) } or
|
||||
TMethod(Generated::Method g) or
|
||||
TMethod(Ruby::Method g) or
|
||||
TMethodCallSynth(AST::AstNode parent, int i, string name, boolean setter, int arity) {
|
||||
mkSynthChild(MethodCallKind(name, setter, arity), parent, i)
|
||||
} or
|
||||
TModuleDeclaration(Generated::Module g) or
|
||||
TModuloExprReal(Generated::Binary g) { g instanceof @ruby_binary_percent } or
|
||||
TModuleDeclaration(Ruby::Module g) or
|
||||
TModuloExprReal(Ruby::Binary g) { g instanceof @ruby_binary_percent } or
|
||||
TModuloExprSynth(AST::AstNode parent, int i) { mkSynthChild(ModuloExprKind(), parent, i) } or
|
||||
TMulExprReal(Generated::Binary g) { g instanceof @ruby_binary_star } or
|
||||
TMulExprReal(Ruby::Binary g) { g instanceof @ruby_binary_star } or
|
||||
TMulExprSynth(AST::AstNode parent, int i) { mkSynthChild(MulExprKind(), parent, i) } or
|
||||
TNEExpr(Generated::Binary g) { g instanceof @ruby_binary_bangequal } or
|
||||
TNextStmt(Generated::Next g) or
|
||||
TNilLiteral(Generated::Nil g) or
|
||||
TNoRegExpMatchExpr(Generated::Binary g) { g instanceof @ruby_binary_bangtilde } or
|
||||
TNotExpr(Generated::Unary g) { g instanceof @ruby_unary_bang or g instanceof @ruby_unary_not } or
|
||||
TOptionalParameter(Generated::OptionalParameter g) or
|
||||
TPair(Generated::Pair g) or
|
||||
TParenthesizedExpr(Generated::ParenthesizedStatements g) or
|
||||
TRShiftExprReal(Generated::Binary g) { g instanceof @ruby_binary_ranglerangle } or
|
||||
TNEExpr(Ruby::Binary g) { g instanceof @ruby_binary_bangequal } or
|
||||
TNextStmt(Ruby::Next g) or
|
||||
TNilLiteral(Ruby::Nil g) or
|
||||
TNoRegExpMatchExpr(Ruby::Binary g) { g instanceof @ruby_binary_bangtilde } or
|
||||
TNotExpr(Ruby::Unary g) { g instanceof @ruby_unary_bang or g instanceof @ruby_unary_not } or
|
||||
TOptionalParameter(Ruby::OptionalParameter g) or
|
||||
TPair(Ruby::Pair g) or
|
||||
TParenthesizedExpr(Ruby::ParenthesizedStatements g) or
|
||||
TRShiftExprReal(Ruby::Binary g) { g instanceof @ruby_binary_ranglerangle } or
|
||||
TRShiftExprSynth(AST::AstNode parent, int i) { mkSynthChild(RShiftExprKind(), parent, i) } or
|
||||
TRangeLiteralReal(Generated::Range g) or
|
||||
TRangeLiteralReal(Ruby::Range g) or
|
||||
TRangeLiteralSynth(AST::AstNode parent, int i, boolean inclusive) {
|
||||
mkSynthChild(RangeLiteralKind(inclusive), parent, i)
|
||||
} or
|
||||
TRationalLiteral(Generated::Rational g) or
|
||||
TRedoStmt(Generated::Redo g) or
|
||||
TRegExpLiteral(Generated::Regex g) or
|
||||
TRegExpMatchExpr(Generated::Binary g) { g instanceof @ruby_binary_equaltilde } or
|
||||
TRegularArrayLiteral(Generated::Array g) or
|
||||
TRegularMethodCall(Generated::Call g) { isRegularMethodCall(g) } or
|
||||
TRegularStringLiteral(Generated::String g) or
|
||||
TRegularSuperCall(Generated::Call g) { g.getMethod() instanceof Generated::Super } or
|
||||
TRescueClause(Generated::Rescue g) or
|
||||
TRescueModifierExpr(Generated::RescueModifier g) or
|
||||
TRetryStmt(Generated::Retry g) or
|
||||
TReturnStmt(Generated::Return g) or
|
||||
TScopeResolutionConstantAccess(Generated::ScopeResolution g, Generated::Constant constant) {
|
||||
TRationalLiteral(Ruby::Rational g) or
|
||||
TRedoStmt(Ruby::Redo g) or
|
||||
TRegExpLiteral(Ruby::Regex g) or
|
||||
TRegExpMatchExpr(Ruby::Binary g) { g instanceof @ruby_binary_equaltilde } or
|
||||
TRegularArrayLiteral(Ruby::Array g) or
|
||||
TRegularMethodCall(Ruby::Call g) { isRegularMethodCall(g) } or
|
||||
TRegularStringLiteral(Ruby::String g) or
|
||||
TRegularSuperCall(Ruby::Call g) { g.getMethod() instanceof Ruby::Super } or
|
||||
TRescueClause(Ruby::Rescue g) or
|
||||
TRescueModifierExpr(Ruby::RescueModifier g) or
|
||||
TRetryStmt(Ruby::Retry g) or
|
||||
TReturnStmt(Ruby::Return g) or
|
||||
TScopeResolutionConstantAccess(Ruby::ScopeResolution g, Ruby::Constant constant) {
|
||||
constant = g.getName() and
|
||||
(
|
||||
// A tree-sitter `scope_resolution` node with a `constant` name field is a
|
||||
@@ -234,34 +226,34 @@ private module Cached {
|
||||
explicitAssignmentNode(g, _)
|
||||
)
|
||||
} or
|
||||
TScopeResolutionMethodCall(Generated::ScopeResolution g, Generated::Identifier i) {
|
||||
TScopeResolutionMethodCall(Ruby::ScopeResolution g, Ruby::Identifier i) {
|
||||
isScopeResolutionMethodCall(g, i)
|
||||
} or
|
||||
TSelfReal(Generated::Self g) or
|
||||
TSelfReal(Ruby::Self g) or
|
||||
TSelfSynth(AST::AstNode parent, int i) { mkSynthChild(SelfKind(), parent, i) } or
|
||||
TSimpleParameter(Generated::Identifier g) { g instanceof Parameter::Range } or
|
||||
TSimpleSymbolLiteral(Generated::SimpleSymbol g) or
|
||||
TSingletonClass(Generated::SingletonClass g) or
|
||||
TSingletonMethod(Generated::SingletonMethod g) or
|
||||
TSpaceshipExpr(Generated::Binary g) { g instanceof @ruby_binary_langleequalrangle } or
|
||||
TSplatExprReal(Generated::SplatArgument g) or
|
||||
TSimpleParameter(Ruby::Identifier g) { g instanceof Parameter::Range } or
|
||||
TSimpleSymbolLiteral(Ruby::SimpleSymbol g) or
|
||||
TSingletonClass(Ruby::SingletonClass g) or
|
||||
TSingletonMethod(Ruby::SingletonMethod g) or
|
||||
TSpaceshipExpr(Ruby::Binary g) { g instanceof @ruby_binary_langleequalrangle } or
|
||||
TSplatExprReal(Ruby::SplatArgument g) or
|
||||
TSplatExprSynth(AST::AstNode parent, int i) { mkSynthChild(SplatExprKind(), parent, i) } or
|
||||
TSplatParameter(Generated::SplatParameter g) or
|
||||
TSplatParameter(Ruby::SplatParameter g) or
|
||||
TStmtSequenceSynth(AST::AstNode parent, int i) { mkSynthChild(StmtSequenceKind(), parent, i) } or
|
||||
TStringArrayLiteral(Generated::StringArray g) or
|
||||
TStringConcatenation(Generated::ChainedString g) or
|
||||
TStringEscapeSequenceComponent(Generated::EscapeSequence g) or
|
||||
TStringInterpolationComponent(Generated::Interpolation g) or
|
||||
TStringTextComponent(Generated::Token g) {
|
||||
g instanceof Generated::StringContent or g instanceof Generated::HeredocContent
|
||||
TStringArrayLiteral(Ruby::StringArray g) or
|
||||
TStringConcatenation(Ruby::ChainedString g) or
|
||||
TStringEscapeSequenceComponent(Ruby::EscapeSequence g) or
|
||||
TStringInterpolationComponent(Ruby::Interpolation g) or
|
||||
TStringTextComponent(Ruby::Token g) {
|
||||
g instanceof Ruby::StringContent or g instanceof Ruby::HeredocContent
|
||||
} or
|
||||
TSubExprReal(Generated::Binary g) { g instanceof @ruby_binary_minus } or
|
||||
TSubExprReal(Ruby::Binary g) { g instanceof @ruby_binary_minus } or
|
||||
TSubExprSynth(AST::AstNode parent, int i) { mkSynthChild(SubExprKind(), parent, i) } or
|
||||
TSubshellLiteral(Generated::Subshell g) or
|
||||
TSymbolArrayLiteral(Generated::SymbolArray g) or
|
||||
TTernaryIfExpr(Generated::Conditional g) or
|
||||
TThen(Generated::Then g) or
|
||||
TTokenConstantAccess(Generated::Constant g) {
|
||||
TSubshellLiteral(Ruby::Subshell g) or
|
||||
TSymbolArrayLiteral(Ruby::SymbolArray g) or
|
||||
TTernaryIfExpr(Ruby::Conditional g) or
|
||||
TThen(Ruby::Then g) or
|
||||
TTokenConstantAccess(Ruby::Constant g) {
|
||||
// A tree-sitter `constant` token is a read of that constant in any context
|
||||
// where an identifier would be a vcall.
|
||||
vcall(g)
|
||||
@@ -269,21 +261,21 @@ private module Cached {
|
||||
explicitAssignmentNode(g, _)
|
||||
} or
|
||||
TTokenMethodName(MethodName::Token g) { MethodName::range(g) } or
|
||||
TTokenSuperCall(Generated::Super g) { vcall(g) } or
|
||||
TToplevel(Generated::Program g) { g.getLocation().getFile().getExtension() != "erb" } or
|
||||
TTrueLiteral(Generated::True g) or
|
||||
TTuplePatternParameter(Generated::DestructuredParameter g) or
|
||||
TUnaryMinusExpr(Generated::Unary g) { g instanceof @ruby_unary_minus } or
|
||||
TUnaryPlusExpr(Generated::Unary g) { g instanceof @ruby_unary_plus } or
|
||||
TUndefStmt(Generated::Undef g) or
|
||||
TUnlessExpr(Generated::Unless g) or
|
||||
TUnlessModifierExpr(Generated::UnlessModifier g) or
|
||||
TUntilExpr(Generated::Until g) or
|
||||
TUntilModifierExpr(Generated::UntilModifier g) or
|
||||
TWhenExpr(Generated::When g) or
|
||||
TWhileExpr(Generated::While g) or
|
||||
TWhileModifierExpr(Generated::WhileModifier g) or
|
||||
TYieldCall(Generated::Yield g)
|
||||
TTokenSuperCall(Ruby::Super g) { vcall(g) } or
|
||||
TToplevel(Ruby::Program g) { g.getLocation().getFile().getExtension() != "erb" } or
|
||||
TTrueLiteral(Ruby::True g) or
|
||||
TTuplePatternParameter(Ruby::DestructuredParameter g) or
|
||||
TUnaryMinusExpr(Ruby::Unary g) { g instanceof @ruby_unary_minus } or
|
||||
TUnaryPlusExpr(Ruby::Unary g) { g instanceof @ruby_unary_plus } or
|
||||
TUndefStmt(Ruby::Undef g) or
|
||||
TUnlessExpr(Ruby::Unless g) or
|
||||
TUnlessModifierExpr(Ruby::UnlessModifier g) or
|
||||
TUntilExpr(Ruby::Until g) or
|
||||
TUntilModifierExpr(Ruby::UntilModifier g) or
|
||||
TWhenExpr(Ruby::When g) or
|
||||
TWhileExpr(Ruby::While g) or
|
||||
TWhileModifierExpr(Ruby::WhileModifier g) or
|
||||
TYieldCall(Ruby::Yield g)
|
||||
|
||||
/**
|
||||
* Gets the underlying TreeSitter entity for a given AST node. This does not
|
||||
@@ -291,7 +283,7 @@ private module Cached {
|
||||
* for any given generated node.
|
||||
*/
|
||||
cached
|
||||
Generated::AstNode toGenerated(AST::AstNode n) {
|
||||
Ruby::AstNode toGenerated(AST::AstNode n) {
|
||||
n = TAddExprReal(result) or
|
||||
n = TAliasStmt(result) or
|
||||
n = TArgumentList(result) or
|
||||
@@ -500,7 +492,7 @@ private module Cached {
|
||||
* nodes.
|
||||
*/
|
||||
cached
|
||||
Generated::AstNode toGeneratedInclSynth(AST::AstNode n) {
|
||||
Ruby::AstNode toGeneratedInclSynth(AST::AstNode n) {
|
||||
result = toGenerated(n)
|
||||
or
|
||||
not exists(toGenerated(n)) and
|
||||
@@ -524,7 +516,7 @@ private module Cached {
|
||||
|
||||
import Cached
|
||||
|
||||
TAstNode fromGenerated(Generated::AstNode n) { n = toGenerated(result) }
|
||||
TAstNode fromGenerated(Ruby::AstNode n) { n = toGenerated(result) }
|
||||
|
||||
class TCall = TMethodCall or TYieldCall;
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ private import Variable
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.ast.internal.AST
|
||||
|
||||
predicate isIdentifierMethodCall(Generated::Identifier g) { vcall(g) and not access(g, _) }
|
||||
predicate isIdentifierMethodCall(Ruby::Identifier g) { vcall(g) and not access(g, _) }
|
||||
|
||||
predicate isRegularMethodCall(Generated::Call g) { not g.getMethod() instanceof Generated::Super }
|
||||
predicate isRegularMethodCall(Ruby::Call g) { not g.getMethod() instanceof Ruby::Super }
|
||||
|
||||
predicate isScopeResolutionMethodCall(Generated::ScopeResolution g, Generated::Identifier i) {
|
||||
predicate isScopeResolutionMethodCall(Ruby::ScopeResolution g, Ruby::Identifier i) {
|
||||
i = g.getName() and
|
||||
not exists(Generated::Call c | c.getMethod() = g)
|
||||
not exists(Ruby::Call c | c.getMethod() = g)
|
||||
}
|
||||
|
||||
abstract class CallImpl extends Call {
|
||||
@@ -50,7 +50,7 @@ class MethodCallSynth extends MethodCallImpl, TMethodCallSynth {
|
||||
}
|
||||
|
||||
class IdentifierMethodCall extends MethodCallImpl, TIdentifierMethodCall {
|
||||
private Generated::Identifier g;
|
||||
private Ruby::Identifier g;
|
||||
|
||||
IdentifierMethodCall() { this = TIdentifierMethodCall(g) }
|
||||
|
||||
@@ -64,8 +64,8 @@ class IdentifierMethodCall extends MethodCallImpl, TIdentifierMethodCall {
|
||||
}
|
||||
|
||||
class ScopeResolutionMethodCall extends MethodCallImpl, TScopeResolutionMethodCall {
|
||||
private Generated::ScopeResolution g;
|
||||
private Generated::Identifier i;
|
||||
private Ruby::ScopeResolution g;
|
||||
private Ruby::Identifier i;
|
||||
|
||||
ScopeResolutionMethodCall() { this = TScopeResolutionMethodCall(g, i) }
|
||||
|
||||
@@ -79,7 +79,7 @@ class ScopeResolutionMethodCall extends MethodCallImpl, TScopeResolutionMethodCa
|
||||
}
|
||||
|
||||
class RegularMethodCall extends MethodCallImpl, TRegularMethodCall {
|
||||
private Generated::Call g;
|
||||
private Ruby::Call g;
|
||||
|
||||
RegularMethodCall() { this = TRegularMethodCall(g) }
|
||||
|
||||
@@ -87,7 +87,7 @@ class RegularMethodCall extends MethodCallImpl, TRegularMethodCall {
|
||||
toGenerated(result) = g.getReceiver()
|
||||
or
|
||||
not exists(g.getReceiver()) and
|
||||
toGenerated(result) = g.getMethod().(Generated::ScopeResolution).getScope()
|
||||
toGenerated(result) = g.getMethod().(Ruby::ScopeResolution).getScope()
|
||||
or
|
||||
result = TSelfSynth(this, 0)
|
||||
}
|
||||
@@ -95,31 +95,30 @@ class RegularMethodCall extends MethodCallImpl, TRegularMethodCall {
|
||||
final override string getMethodNameImpl() {
|
||||
isRegularMethodCall(g) and
|
||||
(
|
||||
result = "call" and g.getMethod() instanceof Generated::ArgumentList
|
||||
result = "call" and g.getMethod() instanceof Ruby::ArgumentList
|
||||
or
|
||||
result = g.getMethod().(Generated::Token).getValue()
|
||||
result = g.getMethod().(Ruby::Token).getValue()
|
||||
or
|
||||
result = g.getMethod().(Generated::ScopeResolution).getName().(Generated::Token).getValue()
|
||||
result = g.getMethod().(Ruby::ScopeResolution).getName().(Ruby::Token).getValue()
|
||||
)
|
||||
}
|
||||
|
||||
final override Expr getArgumentImpl(int n) {
|
||||
toGenerated(result) = g.getArguments().getChild(n)
|
||||
or
|
||||
toGenerated(result) = g.getMethod().(Generated::ArgumentList).getChild(n)
|
||||
toGenerated(result) = g.getMethod().(Ruby::ArgumentList).getChild(n)
|
||||
}
|
||||
|
||||
final override int getNumberOfArgumentsImpl() {
|
||||
result =
|
||||
count(g.getArguments().getChild(_)) +
|
||||
count(g.getMethod().(Generated::ArgumentList).getChild(_))
|
||||
count(g.getArguments().getChild(_)) + count(g.getMethod().(Ruby::ArgumentList).getChild(_))
|
||||
}
|
||||
|
||||
final override Block getBlock() { toGenerated(result) = g.getBlock() }
|
||||
}
|
||||
|
||||
class ElementReferenceImpl extends MethodCallImpl, TElementReference {
|
||||
private Generated::ElementReference g;
|
||||
private Ruby::ElementReference g;
|
||||
|
||||
ElementReferenceImpl() { this = TElementReference(g) }
|
||||
|
||||
@@ -133,7 +132,7 @@ class ElementReferenceImpl extends MethodCallImpl, TElementReference {
|
||||
}
|
||||
|
||||
class TokenSuperCall extends SuperCall, MethodCallImpl, TTokenSuperCall {
|
||||
private Generated::Super g;
|
||||
private Ruby::Super g;
|
||||
|
||||
TokenSuperCall() { this = TTokenSuperCall(g) }
|
||||
|
||||
@@ -147,11 +146,11 @@ class TokenSuperCall extends SuperCall, MethodCallImpl, TTokenSuperCall {
|
||||
}
|
||||
|
||||
class RegularSuperCall extends SuperCall, MethodCallImpl, TRegularSuperCall {
|
||||
private Generated::Call g;
|
||||
private Ruby::Call g;
|
||||
|
||||
RegularSuperCall() { this = TRegularSuperCall(g) }
|
||||
|
||||
final override string getMethodNameImpl() { result = g.getMethod().(Generated::Super).getValue() }
|
||||
final override string getMethodNameImpl() { result = g.getMethod().(Ruby::Super).getValue() }
|
||||
|
||||
final override Expr getReceiverImpl() { none() }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class AssignmentImpl extends Operation, TAssignment {
|
||||
}
|
||||
|
||||
class AssignExprReal extends AssignmentImpl, AssignExpr, TAssignExprReal {
|
||||
private Generated::Assignment g;
|
||||
private Ruby::Assignment g;
|
||||
|
||||
AssignExprReal() { this = TAssignExprReal(g) }
|
||||
|
||||
@@ -35,7 +35,7 @@ abstract class SplatExprImpl extends SplatExpr {
|
||||
}
|
||||
|
||||
class SplatExprReal extends SplatExprImpl, TSplatExprReal {
|
||||
private Generated::SplatArgument g;
|
||||
private Ruby::SplatArgument g;
|
||||
|
||||
SplatExprReal() { this = TSplatExprReal(g) }
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ private import AST
|
||||
private import TreeSitter
|
||||
|
||||
module Parameter {
|
||||
class Range extends Generated::AstNode {
|
||||
class Range extends Ruby::AstNode {
|
||||
private int pos;
|
||||
|
||||
Range() {
|
||||
this = any(Generated::BlockParameters bp).getChild(pos)
|
||||
this = any(Ruby::BlockParameters bp).getChild(pos)
|
||||
or
|
||||
this = any(Generated::MethodParameters mp).getChild(pos)
|
||||
this = any(Ruby::MethodParameters mp).getChild(pos)
|
||||
or
|
||||
this = any(Generated::LambdaParameters lp).getChild(pos)
|
||||
this = any(Ruby::LambdaParameters lp).getChild(pos)
|
||||
}
|
||||
|
||||
int getPosition() { result = pos }
|
||||
|
||||
@@ -2,30 +2,30 @@ private import codeql_ruby.AST
|
||||
private import AST
|
||||
private import TreeSitter
|
||||
|
||||
abstract class TuplePatternImpl extends Generated::AstNode {
|
||||
abstract Generated::AstNode getChildNode(int i);
|
||||
abstract class TuplePatternImpl extends Ruby::AstNode {
|
||||
abstract Ruby::AstNode getChildNode(int i);
|
||||
|
||||
final int getRestIndex() {
|
||||
result = unique(int i | this.getChildNode(i) instanceof Generated::RestAssignment)
|
||||
result = unique(int i | this.getChildNode(i) instanceof Ruby::RestAssignment)
|
||||
}
|
||||
}
|
||||
|
||||
class TuplePatternParameterImpl extends TuplePatternImpl, Generated::DestructuredParameter {
|
||||
override Generated::AstNode getChildNode(int i) { result = this.getChild(i) }
|
||||
class TuplePatternParameterImpl extends TuplePatternImpl, Ruby::DestructuredParameter {
|
||||
override Ruby::AstNode getChildNode(int i) { result = this.getChild(i) }
|
||||
}
|
||||
|
||||
class DestructuredLeftAssignmentImpl extends TuplePatternImpl, Generated::DestructuredLeftAssignment {
|
||||
override Generated::AstNode getChildNode(int i) { result = this.getChild(i) }
|
||||
class DestructuredLeftAssignmentImpl extends TuplePatternImpl, Ruby::DestructuredLeftAssignment {
|
||||
override Ruby::AstNode getChildNode(int i) { result = this.getChild(i) }
|
||||
}
|
||||
|
||||
class LeftAssignmentListImpl extends TuplePatternImpl, Generated::LeftAssignmentList {
|
||||
override Generated::AstNode getChildNode(int i) {
|
||||
class LeftAssignmentListImpl extends TuplePatternImpl, Ruby::LeftAssignmentList {
|
||||
override Ruby::AstNode getChildNode(int i) {
|
||||
this =
|
||||
any(Generated::LeftAssignmentList lal |
|
||||
any(Ruby::LeftAssignmentList lal |
|
||||
if
|
||||
strictcount(int j | exists(lal.getChild(j))) = 1 and
|
||||
lal.getChild(0) instanceof Generated::DestructuredLeftAssignment
|
||||
then result = lal.getChild(0).(Generated::DestructuredLeftAssignment).getChild(i)
|
||||
lal.getChild(0) instanceof Ruby::DestructuredLeftAssignment
|
||||
then result = lal.getChild(0).(Ruby::DestructuredLeftAssignment).getChild(i)
|
||||
else result = lal.getChild(i)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ private class TModuleLike = TToplevel or TModuleDeclaration or TClassDeclaration
|
||||
module Scope {
|
||||
class TypeRange = Callable::TypeRange or ModuleBase::TypeRange or @ruby_end_block;
|
||||
|
||||
class Range extends Generated::AstNode, TypeRange {
|
||||
Range() { not this = any(Generated::Lambda l).getBody() }
|
||||
class Range extends Ruby::AstNode, TypeRange {
|
||||
Range() { not this = any(Ruby::Lambda l).getBody() }
|
||||
|
||||
ModuleBase::Range getEnclosingModule() {
|
||||
result = this
|
||||
@@ -44,11 +44,11 @@ module Callable {
|
||||
|
||||
class Range extends Scope::Range, TypeRange {
|
||||
Parameter::Range getParameter(int i) {
|
||||
result = this.(Generated::Method).getParameters().getChild(i) or
|
||||
result = this.(Generated::SingletonMethod).getParameters().getChild(i) or
|
||||
result = this.(Generated::DoBlock).getParameters().getChild(i) or
|
||||
result = this.(Generated::Lambda).getParameters().getChild(i) or
|
||||
result = this.(Generated::Block).getParameters().getChild(i)
|
||||
result = this.(Ruby::Method).getParameters().getChild(i) or
|
||||
result = this.(Ruby::SingletonMethod).getParameters().getChild(i) or
|
||||
result = this.(Ruby::DoBlock).getParameters().getChild(i) or
|
||||
result = this.(Ruby::Lambda).getParameters().getChild(i) or
|
||||
result = this.(Ruby::Block).getParameters().getChild(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,19 +60,19 @@ module ModuleBase {
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
private predicate rankHeredocBody(File f, Generated::HeredocBody b, int i) {
|
||||
private predicate rankHeredocBody(File f, Ruby::HeredocBody b, int i) {
|
||||
b =
|
||||
rank[i](Generated::HeredocBody b0 |
|
||||
rank[i](Ruby::HeredocBody b0 |
|
||||
f = b0.getLocation().getFile()
|
||||
|
|
||||
b0 order by b0.getLocation().getStartLine(), b0.getLocation().getStartColumn()
|
||||
)
|
||||
}
|
||||
|
||||
Generated::HeredocBody getHereDocBody(Generated::HeredocBeginning g) {
|
||||
Ruby::HeredocBody getHereDocBody(Ruby::HeredocBeginning g) {
|
||||
exists(int i, File f |
|
||||
g =
|
||||
rank[i](Generated::HeredocBeginning b |
|
||||
rank[i](Ruby::HeredocBeginning b |
|
||||
f = b.getLocation().getFile()
|
||||
|
|
||||
b order by b.getLocation().getStartLine(), b.getLocation().getStartColumn()
|
||||
@@ -81,17 +81,17 @@ Generated::HeredocBody getHereDocBody(Generated::HeredocBeginning g) {
|
||||
)
|
||||
}
|
||||
|
||||
private Generated::AstNode parentOf(Generated::AstNode n) {
|
||||
private Ruby::AstNode parentOf(Ruby::AstNode n) {
|
||||
n = getHereDocBody(result)
|
||||
or
|
||||
exists(Generated::AstNode parent | parent = n.getParent() |
|
||||
exists(Ruby::AstNode parent | parent = n.getParent() |
|
||||
if
|
||||
n =
|
||||
[
|
||||
parent.(Generated::Module).getName(), parent.(Generated::Class).getName(),
|
||||
parent.(Generated::Class).getSuperclass(), parent.(Generated::SingletonClass).getValue(),
|
||||
parent.(Generated::Method).getName(), parent.(Generated::SingletonMethod).getName(),
|
||||
parent.(Generated::SingletonMethod).getObject()
|
||||
parent.(Ruby::Module).getName(), parent.(Ruby::Class).getName(),
|
||||
parent.(Ruby::Class).getSuperclass(), parent.(Ruby::SingletonClass).getValue(),
|
||||
parent.(Ruby::Method).getName(), parent.(Ruby::SingletonMethod).getName(),
|
||||
parent.(Ruby::SingletonMethod).getObject()
|
||||
]
|
||||
then result = parent.getParent()
|
||||
else result = parent
|
||||
@@ -100,8 +100,8 @@ private Generated::AstNode parentOf(Generated::AstNode n) {
|
||||
|
||||
/** Gets the enclosing scope of a node */
|
||||
cached
|
||||
Scope::Range scopeOf(Generated::AstNode n) {
|
||||
exists(Generated::AstNode p | p = parentOf(n) |
|
||||
Scope::Range scopeOf(Ruby::AstNode n) {
|
||||
exists(Ruby::AstNode p | p = parentOf(n) |
|
||||
p = result
|
||||
or
|
||||
not p instanceof Scope::Range and result = scopeOf(p)
|
||||
|
||||
@@ -149,13 +149,13 @@ private module ImplicitSelfSynthesis {
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate regularMethodCallSelfSynthesis(TRegularMethodCall mc, int i, Child child) {
|
||||
exists(Generated::AstNode g |
|
||||
exists(Ruby::AstNode g |
|
||||
mc = TRegularMethodCall(g) and
|
||||
// If there's no explicit receiver (or scope resolution that acts like a
|
||||
// receiver), then the receiver is implicitly `self`. N.B. `::Foo()` is
|
||||
// not valid Ruby.
|
||||
not exists(g.(Generated::Call).getReceiver()) and
|
||||
not exists(g.(Generated::Call).getMethod().(Generated::ScopeResolution).getScope())
|
||||
not exists(g.(Ruby::Call).getReceiver()) and
|
||||
not exists(g.(Ruby::Call).getMethod().(Ruby::ScopeResolution).getScope())
|
||||
) and
|
||||
child = SynthChild(SelfKind()) and
|
||||
i = 0
|
||||
@@ -316,7 +316,7 @@ private module AssignOperationDesugar {
|
||||
}
|
||||
|
||||
private Location getAssignOperationLocation(AssignOperation ao) {
|
||||
exists(Generated::OperatorAssignment g, Generated::Token op |
|
||||
exists(Ruby::OperatorAssignment g, Ruby::Token op |
|
||||
g = toGenerated(ao) and
|
||||
op.getParent() = g and
|
||||
op.getParentIndex() = 1 and
|
||||
|
||||
@@ -9,73 +9,73 @@ private import codeql_ruby.ast.internal.Synthesis
|
||||
/**
|
||||
* Holds if `n` is in the left-hand-side of an explicit assignment `assignment`.
|
||||
*/
|
||||
predicate explicitAssignmentNode(Generated::AstNode n, Generated::AstNode assignment) {
|
||||
n = assignment.(Generated::Assignment).getLeft()
|
||||
predicate explicitAssignmentNode(Ruby::AstNode n, Ruby::AstNode assignment) {
|
||||
n = assignment.(Ruby::Assignment).getLeft()
|
||||
or
|
||||
n = assignment.(Generated::OperatorAssignment).getLeft()
|
||||
n = assignment.(Ruby::OperatorAssignment).getLeft()
|
||||
or
|
||||
exists(Generated::AstNode parent |
|
||||
exists(Ruby::AstNode parent |
|
||||
parent = n.getParent() and
|
||||
explicitAssignmentNode(parent, assignment)
|
||||
|
|
||||
parent instanceof Generated::DestructuredLeftAssignment
|
||||
parent instanceof Ruby::DestructuredLeftAssignment
|
||||
or
|
||||
parent instanceof Generated::LeftAssignmentList
|
||||
parent instanceof Ruby::LeftAssignmentList
|
||||
or
|
||||
parent instanceof Generated::RestAssignment
|
||||
parent instanceof Ruby::RestAssignment
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `n` is inside an implicit assignment. */
|
||||
predicate implicitAssignmentNode(Generated::AstNode n) {
|
||||
n = any(Generated::ExceptionVariable ev).getChild()
|
||||
predicate implicitAssignmentNode(Ruby::AstNode n) {
|
||||
n = any(Ruby::ExceptionVariable ev).getChild()
|
||||
or
|
||||
n = any(Generated::For for).getPattern()
|
||||
n = any(Ruby::For for).getPattern()
|
||||
or
|
||||
implicitAssignmentNode(n.getParent())
|
||||
}
|
||||
|
||||
/** Holds if `n` is inside a parameter. */
|
||||
predicate implicitParameterAssignmentNode(Generated::AstNode n, Callable::Range c) {
|
||||
predicate implicitParameterAssignmentNode(Ruby::AstNode n, Callable::Range c) {
|
||||
n = c.getParameter(_)
|
||||
or
|
||||
implicitParameterAssignmentNode(n.getParent().(Generated::DestructuredParameter), c)
|
||||
implicitParameterAssignmentNode(n.getParent().(Ruby::DestructuredParameter), c)
|
||||
}
|
||||
|
||||
private predicate instanceVariableAccess(
|
||||
Generated::InstanceVariable var, string name, Scope::Range scope, boolean instance
|
||||
Ruby::InstanceVariable var, string name, Scope::Range scope, boolean instance
|
||||
) {
|
||||
name = var.getValue() and
|
||||
scope = enclosingModuleOrClass(var) and
|
||||
if hasEnclosingMethod(var) then instance = true else instance = false
|
||||
}
|
||||
|
||||
private predicate classVariableAccess(Generated::ClassVariable var, string name, Scope::Range scope) {
|
||||
private predicate classVariableAccess(Ruby::ClassVariable var, string name, Scope::Range scope) {
|
||||
name = var.getValue() and
|
||||
scope = enclosingModuleOrClass(var)
|
||||
}
|
||||
|
||||
private predicate hasEnclosingMethod(Generated::AstNode node) {
|
||||
private predicate hasEnclosingMethod(Ruby::AstNode node) {
|
||||
exists(Scope::Range s | scopeOf(node) = s and exists(s.getEnclosingMethod()))
|
||||
}
|
||||
|
||||
private ModuleBase::Range enclosingModuleOrClass(Generated::AstNode node) {
|
||||
private ModuleBase::Range enclosingModuleOrClass(Ruby::AstNode node) {
|
||||
exists(Scope::Range s | scopeOf(node) = s and result = s.getEnclosingModule())
|
||||
}
|
||||
|
||||
private predicate parameterAssignment(Callable::Range scope, string name, Generated::Identifier i) {
|
||||
private predicate parameterAssignment(Callable::Range scope, string name, Ruby::Identifier i) {
|
||||
implicitParameterAssignmentNode(i, scope) and
|
||||
name = i.getValue()
|
||||
}
|
||||
|
||||
/** Holds if `scope` defines `name` in its parameter declaration at `i`. */
|
||||
private predicate scopeDefinesParameterVariable(
|
||||
Callable::Range scope, string name, Generated::Identifier i
|
||||
Callable::Range scope, string name, Ruby::Identifier i
|
||||
) {
|
||||
// In case of overlapping parameter names (e.g. `_`), only the first
|
||||
// parameter will give rise to a variable
|
||||
i =
|
||||
min(Generated::Identifier other |
|
||||
min(Ruby::Identifier other |
|
||||
parameterAssignment(scope, name, other)
|
||||
|
|
||||
other order by other.getLocation().getStartLine(), other.getLocation().getStartColumn()
|
||||
@@ -85,16 +85,16 @@ private predicate scopeDefinesParameterVariable(
|
||||
p = scope.getParameter(_) and
|
||||
name = i.getValue()
|
||||
|
|
||||
i = p.(Generated::BlockParameter).getName() or
|
||||
i = p.(Generated::HashSplatParameter).getName() or
|
||||
i = p.(Generated::KeywordParameter).getName() or
|
||||
i = p.(Generated::OptionalParameter).getName() or
|
||||
i = p.(Generated::SplatParameter).getName()
|
||||
i = p.(Ruby::BlockParameter).getName() or
|
||||
i = p.(Ruby::HashSplatParameter).getName() or
|
||||
i = p.(Ruby::KeywordParameter).getName() or
|
||||
i = p.(Ruby::OptionalParameter).getName() or
|
||||
i = p.(Ruby::SplatParameter).getName()
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `name` is assigned in `scope` at `i`. */
|
||||
private predicate scopeAssigns(Scope::Range scope, string name, Generated::Identifier i) {
|
||||
private predicate scopeAssigns(Scope::Range scope, string name, Ruby::Identifier i) {
|
||||
(explicitAssignmentNode(i, _) or implicitAssignmentNode(i)) and
|
||||
name = i.getValue() and
|
||||
scope = scopeOf(i)
|
||||
@@ -112,28 +112,28 @@ cached
|
||||
private module Cached {
|
||||
cached
|
||||
newtype TVariable =
|
||||
TGlobalVariable(string name) { name = any(Generated::GlobalVariable var).getValue() } or
|
||||
TClassVariable(Scope::Range scope, string name, Generated::AstNode decl) {
|
||||
TGlobalVariable(string name) { name = any(Ruby::GlobalVariable var).getValue() } or
|
||||
TClassVariable(Scope::Range scope, string name, Ruby::AstNode decl) {
|
||||
decl =
|
||||
min(Generated::ClassVariable other |
|
||||
min(Ruby::ClassVariable other |
|
||||
classVariableAccess(other, name, scope)
|
||||
|
|
||||
other order by other.getLocation().getStartLine(), other.getLocation().getStartColumn()
|
||||
)
|
||||
} or
|
||||
TInstanceVariable(Scope::Range scope, string name, boolean instance, Generated::AstNode decl) {
|
||||
TInstanceVariable(Scope::Range scope, string name, boolean instance, Ruby::AstNode decl) {
|
||||
decl =
|
||||
min(Generated::InstanceVariable other |
|
||||
min(Ruby::InstanceVariable other |
|
||||
instanceVariableAccess(other, name, scope, instance)
|
||||
|
|
||||
other order by other.getLocation().getStartLine(), other.getLocation().getStartColumn()
|
||||
)
|
||||
} or
|
||||
TLocalVariableReal(Scope::Range scope, string name, Generated::Identifier i) {
|
||||
TLocalVariableReal(Scope::Range scope, string name, Ruby::Identifier i) {
|
||||
scopeDefinesParameterVariable(scope, name, i)
|
||||
or
|
||||
i =
|
||||
min(Generated::Identifier other |
|
||||
min(Ruby::Identifier other |
|
||||
scopeAssigns(scope, name, other)
|
||||
|
|
||||
other order by other.getLocation().getStartLine(), other.getLocation().getStartColumn()
|
||||
@@ -162,135 +162,135 @@ private module Cached {
|
||||
*/
|
||||
cached
|
||||
predicate vcall(VcallToken i) {
|
||||
i = any(Generated::ArgumentList x).getChild(_)
|
||||
i = any(Ruby::ArgumentList x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Array x).getChild(_)
|
||||
i = any(Ruby::Array x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Assignment x).getRight()
|
||||
i = any(Ruby::Assignment x).getRight()
|
||||
or
|
||||
i = any(Generated::Begin x).getChild(_)
|
||||
i = any(Ruby::Begin x).getChild(_)
|
||||
or
|
||||
i = any(Generated::BeginBlock x).getChild(_)
|
||||
i = any(Ruby::BeginBlock x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Binary x).getLeft()
|
||||
i = any(Ruby::Binary x).getLeft()
|
||||
or
|
||||
i = any(Generated::Binary x).getRight()
|
||||
i = any(Ruby::Binary x).getRight()
|
||||
or
|
||||
i = any(Generated::Block x).getChild(_)
|
||||
i = any(Ruby::Block x).getChild(_)
|
||||
or
|
||||
i = any(Generated::BlockArgument x).getChild()
|
||||
i = any(Ruby::BlockArgument x).getChild()
|
||||
or
|
||||
i = any(Generated::Call x).getReceiver()
|
||||
i = any(Ruby::Call x).getReceiver()
|
||||
or
|
||||
i = any(Generated::Case x).getValue()
|
||||
i = any(Ruby::Case x).getValue()
|
||||
or
|
||||
i = any(Generated::Class x).getChild(_)
|
||||
i = any(Ruby::Class x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Conditional x).getCondition()
|
||||
i = any(Ruby::Conditional x).getCondition()
|
||||
or
|
||||
i = any(Generated::Conditional x).getConsequence()
|
||||
i = any(Ruby::Conditional x).getConsequence()
|
||||
or
|
||||
i = any(Generated::Conditional x).getAlternative()
|
||||
i = any(Ruby::Conditional x).getAlternative()
|
||||
or
|
||||
i = any(Generated::Do x).getChild(_)
|
||||
i = any(Ruby::Do x).getChild(_)
|
||||
or
|
||||
i = any(Generated::DoBlock x).getChild(_)
|
||||
i = any(Ruby::DoBlock x).getChild(_)
|
||||
or
|
||||
i = any(Generated::ElementReference x).getChild(_)
|
||||
i = any(Ruby::ElementReference x).getChild(_)
|
||||
or
|
||||
i = any(Generated::ElementReference x).getObject()
|
||||
i = any(Ruby::ElementReference x).getObject()
|
||||
or
|
||||
i = any(Generated::Else x).getChild(_)
|
||||
i = any(Ruby::Else x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Elsif x).getCondition()
|
||||
i = any(Ruby::Elsif x).getCondition()
|
||||
or
|
||||
i = any(Generated::EndBlock x).getChild(_)
|
||||
i = any(Ruby::EndBlock x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Ensure x).getChild(_)
|
||||
i = any(Ruby::Ensure x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Exceptions x).getChild(_)
|
||||
i = any(Ruby::Exceptions x).getChild(_)
|
||||
or
|
||||
i = any(Generated::HashSplatArgument x).getChild()
|
||||
i = any(Ruby::HashSplatArgument x).getChild()
|
||||
or
|
||||
i = any(Generated::If x).getCondition()
|
||||
i = any(Ruby::If x).getCondition()
|
||||
or
|
||||
i = any(Generated::IfModifier x).getCondition()
|
||||
i = any(Ruby::IfModifier x).getCondition()
|
||||
or
|
||||
i = any(Generated::IfModifier x).getBody()
|
||||
i = any(Ruby::IfModifier x).getBody()
|
||||
or
|
||||
i = any(Generated::In x).getChild()
|
||||
i = any(Ruby::In x).getChild()
|
||||
or
|
||||
i = any(Generated::Interpolation x).getChild(_)
|
||||
i = any(Ruby::Interpolation x).getChild(_)
|
||||
or
|
||||
i = any(Generated::KeywordParameter x).getValue()
|
||||
i = any(Ruby::KeywordParameter x).getValue()
|
||||
or
|
||||
i = any(Generated::Method x).getChild(_)
|
||||
i = any(Ruby::Method x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Module x).getChild(_)
|
||||
i = any(Ruby::Module x).getChild(_)
|
||||
or
|
||||
i = any(Generated::OperatorAssignment x).getRight()
|
||||
i = any(Ruby::OperatorAssignment x).getRight()
|
||||
or
|
||||
i = any(Generated::OptionalParameter x).getValue()
|
||||
i = any(Ruby::OptionalParameter x).getValue()
|
||||
or
|
||||
i = any(Generated::Pair x).getKey()
|
||||
i = any(Ruby::Pair x).getKey()
|
||||
or
|
||||
i = any(Generated::Pair x).getValue()
|
||||
i = any(Ruby::Pair x).getValue()
|
||||
or
|
||||
i = any(Generated::ParenthesizedStatements x).getChild(_)
|
||||
i = any(Ruby::ParenthesizedStatements x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Pattern x).getChild()
|
||||
i = any(Ruby::Pattern x).getChild()
|
||||
or
|
||||
i = any(Generated::Program x).getChild(_)
|
||||
i = any(Ruby::Program x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Range x).getBegin()
|
||||
i = any(Ruby::Range x).getBegin()
|
||||
or
|
||||
i = any(Generated::Range x).getEnd()
|
||||
i = any(Ruby::Range x).getEnd()
|
||||
or
|
||||
i = any(Generated::RescueModifier x).getBody()
|
||||
i = any(Ruby::RescueModifier x).getBody()
|
||||
or
|
||||
i = any(Generated::RescueModifier x).getHandler()
|
||||
i = any(Ruby::RescueModifier x).getHandler()
|
||||
or
|
||||
i = any(Generated::RightAssignmentList x).getChild(_)
|
||||
i = any(Ruby::RightAssignmentList x).getChild(_)
|
||||
or
|
||||
i = any(Generated::ScopeResolution x).getScope()
|
||||
i = any(Ruby::ScopeResolution x).getScope()
|
||||
or
|
||||
i = any(Generated::SingletonClass x).getValue()
|
||||
i = any(Ruby::SingletonClass x).getValue()
|
||||
or
|
||||
i = any(Generated::SingletonClass x).getChild(_)
|
||||
i = any(Ruby::SingletonClass x).getChild(_)
|
||||
or
|
||||
i = any(Generated::SingletonMethod x).getChild(_)
|
||||
i = any(Ruby::SingletonMethod x).getChild(_)
|
||||
or
|
||||
i = any(Generated::SingletonMethod x).getObject()
|
||||
i = any(Ruby::SingletonMethod x).getObject()
|
||||
or
|
||||
i = any(Generated::SplatArgument x).getChild()
|
||||
i = any(Ruby::SplatArgument x).getChild()
|
||||
or
|
||||
i = any(Generated::Superclass x).getChild()
|
||||
i = any(Ruby::Superclass x).getChild()
|
||||
or
|
||||
i = any(Generated::Then x).getChild(_)
|
||||
i = any(Ruby::Then x).getChild(_)
|
||||
or
|
||||
i = any(Generated::Unary x).getOperand()
|
||||
i = any(Ruby::Unary x).getOperand()
|
||||
or
|
||||
i = any(Generated::Unless x).getCondition()
|
||||
i = any(Ruby::Unless x).getCondition()
|
||||
or
|
||||
i = any(Generated::UnlessModifier x).getCondition()
|
||||
i = any(Ruby::UnlessModifier x).getCondition()
|
||||
or
|
||||
i = any(Generated::UnlessModifier x).getBody()
|
||||
i = any(Ruby::UnlessModifier x).getBody()
|
||||
or
|
||||
i = any(Generated::Until x).getCondition()
|
||||
i = any(Ruby::Until x).getCondition()
|
||||
or
|
||||
i = any(Generated::UntilModifier x).getCondition()
|
||||
i = any(Ruby::UntilModifier x).getCondition()
|
||||
or
|
||||
i = any(Generated::UntilModifier x).getBody()
|
||||
i = any(Ruby::UntilModifier x).getBody()
|
||||
or
|
||||
i = any(Generated::While x).getCondition()
|
||||
i = any(Ruby::While x).getCondition()
|
||||
or
|
||||
i = any(Generated::WhileModifier x).getCondition()
|
||||
i = any(Ruby::WhileModifier x).getCondition()
|
||||
or
|
||||
i = any(Generated::WhileModifier x).getBody()
|
||||
i = any(Ruby::WhileModifier x).getBody()
|
||||
}
|
||||
|
||||
cached
|
||||
predicate access(Generated::Identifier access, VariableReal::Range variable) {
|
||||
predicate access(Ruby::Identifier access, VariableReal::Range variable) {
|
||||
exists(string name |
|
||||
variable.getName() = name and
|
||||
name = access.getValue()
|
||||
@@ -310,17 +310,17 @@ private module Cached {
|
||||
)
|
||||
}
|
||||
|
||||
private class Access extends Generated::Token {
|
||||
private class Access extends Ruby::Token {
|
||||
Access() {
|
||||
access(this, _) or
|
||||
this instanceof Generated::GlobalVariable or
|
||||
this instanceof Generated::InstanceVariable or
|
||||
this instanceof Generated::ClassVariable
|
||||
this instanceof Ruby::GlobalVariable or
|
||||
this instanceof Ruby::InstanceVariable or
|
||||
this instanceof Ruby::ClassVariable
|
||||
}
|
||||
}
|
||||
|
||||
cached
|
||||
predicate explicitWriteAccess(Access access, Generated::AstNode assignment) {
|
||||
predicate explicitWriteAccess(Access access, Ruby::AstNode assignment) {
|
||||
explicitAssignmentNode(access, assignment)
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
predicate instanceVariableAccess(Generated::InstanceVariable var, InstanceVariable v) {
|
||||
predicate instanceVariableAccess(Ruby::InstanceVariable var, InstanceVariable v) {
|
||||
exists(string name, Scope::Range scope, boolean instance |
|
||||
v = TInstanceVariable(scope, name, instance, _) and
|
||||
instanceVariableAccess(var, name, scope, instance)
|
||||
@@ -345,7 +345,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
predicate classVariableAccess(Generated::ClassVariable var, ClassVariable variable) {
|
||||
predicate classVariableAccess(Ruby::ClassVariable var, ClassVariable variable) {
|
||||
exists(Scope::Range scope, string name |
|
||||
variable = TClassVariable(scope, name, _) and
|
||||
classVariableAccess(var, name, scope)
|
||||
@@ -357,14 +357,14 @@ import Cached
|
||||
|
||||
/** Holds if this scope inherits `name` from an outer scope `outer`. */
|
||||
private predicate inherits(Scope::Range scope, string name, Scope::Range outer) {
|
||||
(scope instanceof Generated::Block or scope instanceof Generated::DoBlock) and
|
||||
(scope instanceof Ruby::Block or scope instanceof Ruby::DoBlock) and
|
||||
not scopeDefinesParameterVariable(scope, name, _) and
|
||||
(
|
||||
outer = scope.getOuterScope() and
|
||||
(
|
||||
scopeDefinesParameterVariable(outer, name, _)
|
||||
or
|
||||
exists(Generated::Identifier i |
|
||||
exists(Ruby::Identifier i |
|
||||
scopeAssigns(outer, name, i) and
|
||||
strictlyBefore(i.getLocation(), scope.getLocation())
|
||||
)
|
||||
@@ -394,7 +394,7 @@ module LocalVariable {
|
||||
class Range extends VariableReal::Range, TLocalVariableReal {
|
||||
private Scope::Range scope;
|
||||
private string name;
|
||||
private Generated::Identifier i;
|
||||
private Ruby::Identifier i;
|
||||
|
||||
Range() { this = TLocalVariableReal(scope, name, i) }
|
||||
|
||||
@@ -464,7 +464,7 @@ module InstanceVariable {
|
||||
private ModuleBase::Range scope;
|
||||
private boolean instance;
|
||||
private string name;
|
||||
private Generated::AstNode decl;
|
||||
private Ruby::AstNode decl;
|
||||
|
||||
Range() { this = TInstanceVariable(scope, name, instance, decl) }
|
||||
|
||||
@@ -482,7 +482,7 @@ module ClassVariable {
|
||||
class Range extends VariableReal::Range, TClassVariable {
|
||||
private ModuleBase::Range scope;
|
||||
private string name;
|
||||
private Generated::AstNode decl;
|
||||
private Ruby::AstNode decl;
|
||||
|
||||
Range() { this = TClassVariable(scope, name, decl) }
|
||||
|
||||
@@ -499,7 +499,7 @@ abstract class VariableAccessImpl extends VariableAccess {
|
||||
}
|
||||
|
||||
module LocalVariableAccess {
|
||||
predicate range(Generated::Identifier id, LocalVariable v) {
|
||||
predicate range(Ruby::Identifier id, LocalVariable v) {
|
||||
access(id, v) and
|
||||
(
|
||||
explicitWriteAccess(id, _)
|
||||
@@ -517,7 +517,7 @@ class TVariableAccessReal =
|
||||
|
||||
private class LocalVariableAccessReal extends VariableAccessImpl, LocalVariableAccess,
|
||||
TLocalVariableAccessReal {
|
||||
private Generated::Identifier g;
|
||||
private Ruby::Identifier g;
|
||||
private LocalVariable v;
|
||||
|
||||
LocalVariableAccessReal() { this = TLocalVariableAccessReal(g, v) }
|
||||
@@ -539,12 +539,12 @@ private class LocalVariableAccessSynth extends VariableAccessImpl, LocalVariable
|
||||
}
|
||||
|
||||
module GlobalVariableAccess {
|
||||
predicate range(Generated::GlobalVariable n, GlobalVariable v) { n.getValue() = v.getName() }
|
||||
predicate range(Ruby::GlobalVariable n, GlobalVariable v) { n.getValue() = v.getName() }
|
||||
}
|
||||
|
||||
private class GlobalVariableAccessReal extends GlobalVariableAccess, VariableAccessImpl,
|
||||
TGlobalVariableAccessReal {
|
||||
private Generated::GlobalVariable g;
|
||||
private Ruby::GlobalVariable g;
|
||||
private GlobalVariable v;
|
||||
|
||||
GlobalVariableAccessReal() { this = TGlobalVariableAccessReal(g, v) }
|
||||
@@ -566,14 +566,12 @@ private class GlobalVariableAccessSynth extends GlobalVariableAccess, VariableAc
|
||||
}
|
||||
|
||||
module InstanceVariableAccess {
|
||||
predicate range(Generated::InstanceVariable n, InstanceVariable v) {
|
||||
instanceVariableAccess(n, v)
|
||||
}
|
||||
predicate range(Ruby::InstanceVariable n, InstanceVariable v) { instanceVariableAccess(n, v) }
|
||||
}
|
||||
|
||||
private class InstanceVariableAccessReal extends InstanceVariableAccess, VariableAccessImpl,
|
||||
TInstanceVariableAccessReal {
|
||||
private Generated::InstanceVariable g;
|
||||
private Ruby::InstanceVariable g;
|
||||
private InstanceVariable v;
|
||||
|
||||
InstanceVariableAccessReal() { this = TInstanceVariableAccessReal(g, v) }
|
||||
@@ -595,12 +593,12 @@ private class InstanceVariableAccessSynth extends InstanceVariableAccess, Variab
|
||||
}
|
||||
|
||||
module ClassVariableAccess {
|
||||
predicate range(Generated::ClassVariable n, ClassVariable v) { classVariableAccess(n, v) }
|
||||
predicate range(Ruby::ClassVariable n, ClassVariable v) { classVariableAccess(n, v) }
|
||||
}
|
||||
|
||||
private class ClassVariableAccessReal extends ClassVariableAccess, VariableAccessImpl,
|
||||
TClassVariableAccessReal {
|
||||
private Generated::ClassVariable g;
|
||||
private Ruby::ClassVariable g;
|
||||
private ClassVariable v;
|
||||
|
||||
ClassVariableAccessReal() { this = TClassVariableAccessReal(g, v) }
|
||||
|
||||
@@ -353,9 +353,9 @@ class ExitBasicBlock extends BasicBlock {
|
||||
}
|
||||
|
||||
private module JoinBlockPredecessors {
|
||||
private predicate id(Generated::AstNode x, Generated::AstNode y) { x = y }
|
||||
private predicate id(Ruby::AstNode x, Ruby::AstNode y) { x = y }
|
||||
|
||||
private predicate idOf(Generated::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
|
||||
private predicate idOf(Ruby::AstNode x, int y) = equivalenceRelation(id/2)(x, y)
|
||||
|
||||
int getId(JoinBlockPredecessor jbp) {
|
||||
idOf(toGeneratedInclSynth(jbp.getFirstNode().(AstCfgNode).getNode()), result)
|
||||
|
||||
@@ -202,7 +202,7 @@ private class ForRange extends ForExpr {
|
||||
}
|
||||
|
||||
ForIn getIn() {
|
||||
result = ASTInternal::TForIn(ASTInternal::toGenerated(this).(Generated::For).getValue())
|
||||
result = ASTInternal::TForIn(ASTInternal::toGenerated(this).(Ruby::For).getValue())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@ import codeql_ruby.ast.internal.TreeSitter
|
||||
/**
|
||||
* A class representing line comments in Ruby.
|
||||
*/
|
||||
class LineComment extends Generated::Comment {
|
||||
class LineComment extends Ruby::Comment {
|
||||
string getContents() { result = this.getValue().suffix(1) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user