From eb7610c55fd12a89fda4805fd839bf7e6fe08f7c Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 17 Mar 2021 09:28:23 +0100 Subject: [PATCH] Rename `(to|from)TreeSitter` to `(to|from)Generated` --- ql/src/codeql_ruby/AST.qll | 2 +- ql/src/codeql_ruby/ast/Call.qll | 28 ++++----- ql/src/codeql_ruby/ast/Constant.qll | 4 +- ql/src/codeql_ruby/ast/Control.qll | 62 +++++++++---------- ql/src/codeql_ruby/ast/Expr.qll | 36 +++++------ ql/src/codeql_ruby/ast/Literal.qll | 34 +++++----- ql/src/codeql_ruby/ast/Method.qll | 14 ++--- ql/src/codeql_ruby/ast/Module.qll | 11 ++-- ql/src/codeql_ruby/ast/Operation.qll | 20 +++--- ql/src/codeql_ruby/ast/Parameter.qll | 4 +- ql/src/codeql_ruby/ast/Pattern.qll | 16 ++--- ql/src/codeql_ruby/ast/Scope.qll | 8 +-- ql/src/codeql_ruby/ast/Statement.qll | 14 ++--- ql/src/codeql_ruby/ast/Variable.qll | 6 +- ql/src/codeql_ruby/ast/internal/AST.qll | 4 +- ql/src/codeql_ruby/ast/internal/Variable.qll | 4 +- .../codeql_ruby/controlflow/BasicBlocks.qll | 4 +- ql/src/codeql_ruby/controlflow/CfgNodes.qll | 4 +- .../controlflow/ControlFlowGraph.qll | 4 +- .../controlflow/internal/Completion.qll | 2 +- .../internal/ControlFlowGraphImpl.qll | 10 +-- .../controlflow/internal/Splitting.qll | 20 +++--- 22 files changed, 155 insertions(+), 156 deletions(-) diff --git a/ql/src/codeql_ruby/AST.qll b/ql/src/codeql_ruby/AST.qll index 375ab3d806b..11f201ac6dd 100644 --- a/ql/src/codeql_ruby/AST.qll +++ b/ql/src/codeql_ruby/AST.qll @@ -33,7 +33,7 @@ class AstNode extends TAstNode { string toString() { none() } /** Gets the location of this node. */ - Location getLocation() { result = toTreeSitter(this).getLocation() } + Location getLocation() { result = toGenerated(this).getLocation() } /** Gets a child node of this `AstNode`. */ final AstNode getAChild() { result = this.getAChild(_) } diff --git a/ql/src/codeql_ruby/ast/Call.qll b/ql/src/codeql_ruby/ast/Call.qll index 2bbb5885f58..b38b2b37263 100644 --- a/ql/src/codeql_ruby/ast/Call.qll +++ b/ql/src/codeql_ruby/ast/Call.qll @@ -129,7 +129,7 @@ private class ScopeResolutionMethodCall extends MethodCall, TScopeResolutionMeth ScopeResolutionMethodCall() { this = TScopeResolutionMethodCall(g, i) } - final override Expr getReceiver() { toTreeSitter(result) = g.getScope() } + final override Expr getReceiver() { toGenerated(result) = g.getScope() } final override string getMethodName() { result = getMethodName(this, i.getValue()) } } @@ -140,10 +140,10 @@ private class RegularMethodCall extends MethodCall, TRegularMethodCall { RegularMethodCall() { this = TRegularMethodCall(g) } final override Expr getReceiver() { - toTreeSitter(result) = g.getReceiver() + toGenerated(result) = g.getReceiver() or not exists(g.getReceiver()) and - toTreeSitter(result) = g.getMethod().(Generated::ScopeResolution).getScope() + toGenerated(result) = g.getMethod().(Generated::ScopeResolution).getScope() } final override string getMethodName() { @@ -157,12 +157,12 @@ private class RegularMethodCall extends MethodCall, TRegularMethodCall { } final override Expr getArgument(int n) { - toTreeSitter(result) = g.getArguments().getChild(n) + toGenerated(result) = g.getArguments().getChild(n) or - toTreeSitter(result) = g.getMethod().(Generated::ArgumentList).getChild(n) + toGenerated(result) = g.getMethod().(Generated::ArgumentList).getChild(n) } - final override Block getBlock() { toTreeSitter(result) = g.getBlock() } + final override Block getBlock() { toGenerated(result) = g.getBlock() } } /** @@ -189,11 +189,11 @@ class ElementReference extends MethodCall, TElementReference { final override string getAPrimaryQlClass() { result = "ElementReference" } - final override Expr getReceiver() { toTreeSitter(result) = g.getObject() } + final override Expr getReceiver() { toGenerated(result) = g.getObject() } final override string getMethodName() { result = getMethodName(this, "[]") } - final override Expr getArgument(int n) { toTreeSitter(result) = g.getChild(n) } + final override Expr getArgument(int n) { toGenerated(result) = g.getChild(n) } final override string toString() { result = "...[...]" } } @@ -211,7 +211,7 @@ class YieldCall extends Call, TYieldCall { final override string getAPrimaryQlClass() { result = "YieldCall" } - final override Expr getArgument(int n) { toTreeSitter(result) = g.getChild().getChild(n) } + final override Expr getArgument(int n) { toGenerated(result) = g.getChild().getChild(n) } final override string toString() { result = "yield ..." } } @@ -247,9 +247,9 @@ private class RegularSuperCall extends SuperCall, TRegularSuperCall { result = getMethodName(this, g.getMethod().(Generated::Super).getValue()) } - final override Expr getArgument(int n) { toTreeSitter(result) = g.getArguments().getChild(n) } + final override Expr getArgument(int n) { toGenerated(result) = g.getArguments().getChild(n) } - final override Block getBlock() { toTreeSitter(result) = g.getBlock() } + final override Block getBlock() { toGenerated(result) = g.getBlock() } } /** @@ -272,7 +272,7 @@ class BlockArgument extends Expr, TBlockArgument { * foo(&bar) * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getChild() } + final Expr getValue() { toGenerated(result) = g.getChild() } final override string toString() { result = "&..." } @@ -299,7 +299,7 @@ class SplatArgument extends Expr, TSplatArgument { * foo(*bar) * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getChild() } + final Expr getValue() { toGenerated(result) = g.getChild() } final override string toString() { result = "*..." } @@ -326,7 +326,7 @@ class HashSplatArgument extends Expr, THashSplatArgument { * foo(**bar) * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getChild() } + final Expr getValue() { toGenerated(result) = g.getChild() } final override string toString() { result = "**..." } diff --git a/ql/src/codeql_ruby/ast/Constant.qll b/ql/src/codeql_ruby/ast/Constant.qll index 423ff6afb88..3ae3c1207b2 100644 --- a/ql/src/codeql_ruby/ast/Constant.qll +++ b/ql/src/codeql_ruby/ast/Constant.qll @@ -81,7 +81,7 @@ private class ScopeResolutionConstantReadAccess extends ConstantReadAccess, final override string getName() { result = constant.getValue() } - final override Expr getScopeExpr() { toTreeSitter(result) = g.getScope() } + final override Expr getScopeExpr() { toGenerated(result) = g.getScope() } final override predicate hasGlobalScope() { not exists(g.getScope()) } } @@ -123,7 +123,7 @@ private class ScopeResolutionConstantWriteAccess extends ConstantWriteAccess, final override string getName() { result = constant.getValue() } - final override Expr getScopeExpr() { toTreeSitter(result) = g.getScope() } + final override Expr getScopeExpr() { toGenerated(result) = g.getScope() } final override predicate hasGlobalScope() { not exists(g.getScope()) } } diff --git a/ql/src/codeql_ruby/ast/Control.qll b/ql/src/codeql_ruby/ast/Control.qll index 64977515a25..69588659002 100644 --- a/ql/src/codeql_ruby/ast/Control.qll +++ b/ql/src/codeql_ruby/ast/Control.qll @@ -113,11 +113,11 @@ private class If extends IfExpr, TIf { If() { this = TIf(g) } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } - final override Stmt getThen() { toTreeSitter(result) = g.getConsequence() } + final override Stmt getThen() { toGenerated(result) = g.getConsequence() } - final override Stmt getElse() { toTreeSitter(result) = g.getAlternative() } + final override Stmt getElse() { toGenerated(result) = g.getAlternative() } final override string toString() { result = "if ..." } } @@ -129,11 +129,11 @@ private class Elsif extends IfExpr, TElsif { final override predicate isElsif() { any() } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } - final override Stmt getThen() { toTreeSitter(result) = g.getConsequence() } + final override Stmt getThen() { toGenerated(result) = g.getConsequence() } - final override Stmt getElse() { toTreeSitter(result) = g.getAlternative() } + final override Stmt getElse() { toGenerated(result) = g.getAlternative() } final override string toString() { result = "elsif ..." } } @@ -153,7 +153,7 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr { final override string getAPrimaryQlClass() { result = "UnlessExpr" } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } /** * Gets the 'then' branch of this `unless` expression. In the following @@ -166,7 +166,7 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr { * end * ``` */ - final Stmt getThen() { toTreeSitter(result) = g.getConsequence() } + final Stmt getThen() { toGenerated(result) = g.getConsequence() } /** * Gets the 'else' branch of this `unless` expression. In the following @@ -179,7 +179,7 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr { * end * ``` */ - final Stmt getElse() { toTreeSitter(result) = g.getAlternative() } + final Stmt getElse() { toGenerated(result) = g.getAlternative() } final override Expr getBranch(boolean cond) { cond = false and result = getThen() @@ -211,7 +211,7 @@ class IfModifierExpr extends ConditionalExpr, TIfModifierExpr { final override string getAPrimaryQlClass() { result = "IfModifierExpr" } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override Stmt getBranch(boolean cond) { cond = true and result = this.getBody() } @@ -222,7 +222,7 @@ class IfModifierExpr extends ConditionalExpr, TIfModifierExpr { * foo if bar * ``` */ - final Stmt getBody() { toTreeSitter(result) = g.getBody() } + final Stmt getBody() { toGenerated(result) = g.getBody() } final override string toString() { result = "... if ..." } @@ -246,7 +246,7 @@ class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr { final override string getAPrimaryQlClass() { result = "UnlessModifierExpr" } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override Stmt getBranch(boolean cond) { cond = false and result = this.getBody() } @@ -257,7 +257,7 @@ class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr { * foo unless bar * ``` */ - final Stmt getBody() { toTreeSitter(result) = g.getBody() } + final Stmt getBody() { toGenerated(result) = g.getBody() } final override string toString() { result = "... unless ..." } @@ -281,13 +281,13 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr { final override string getAPrimaryQlClass() { result = "TernaryIfExpr" } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } /** Gets the 'then' branch of this ternary if expression. */ - final Stmt getThen() { toTreeSitter(result) = g.getConsequence() } + final Stmt getThen() { toGenerated(result) = g.getConsequence() } /** Gets the 'else' branch of this ternary if expression. */ - final Stmt getElse() { toTreeSitter(result) = g.getAlternative() } + final Stmt getElse() { toGenerated(result) = g.getAlternative() } final override Stmt getBranch(boolean cond) { cond = true and result = getThen() @@ -332,13 +332,13 @@ class CaseExpr extends ControlExpr, TCaseExpr { * end * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getValue() } + final Expr getValue() { toGenerated(result) = g.getValue() } /** * Gets the `n`th branch of this case expression, either a `WhenExpr` or a * `StmtSequence`. */ - final Expr getBranch(int n) { toTreeSitter(result) = g.getChild(n) } + final Expr getBranch(int n) { toGenerated(result) = g.getChild(n) } /** * Gets a branch of this case expression, either a `WhenExpr` or an @@ -382,7 +382,7 @@ class WhenExpr extends Expr, TWhenExpr { final override string getAPrimaryQlClass() { result = "WhenExpr" } /** Gets the body of this case-when expression. */ - final Stmt getBody() { toTreeSitter(result) = g.getBody() } + final Stmt getBody() { toGenerated(result) = g.getBody() } /** * Gets the `n`th pattern (or condition) in this case-when expression. In the @@ -395,7 +395,7 @@ class WhenExpr extends Expr, TWhenExpr { * end * ``` */ - final Expr getPattern(int n) { toTreeSitter(result) = g.getPattern(n).getChild() } + final Expr getPattern(int n) { toGenerated(result) = g.getPattern(n).getChild() } /** * Gets a pattern (or condition) in this case-when expression. @@ -459,9 +459,9 @@ class WhileExpr extends ConditionalLoop, TWhileExpr { final override string getAPrimaryQlClass() { result = "WhileExpr" } /** Gets the body of this `while` loop. */ - final override Stmt getBody() { toTreeSitter(result) = g.getBody() } + final override Stmt getBody() { toGenerated(result) = g.getBody() } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override string toString() { result = "while ..." } } @@ -483,9 +483,9 @@ class UntilExpr extends ConditionalLoop, TUntilExpr { final override string getAPrimaryQlClass() { result = "UntilExpr" } /** Gets the body of this `until` loop. */ - final override Stmt getBody() { toTreeSitter(result) = g.getBody() } + final override Stmt getBody() { toGenerated(result) = g.getBody() } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override string toString() { result = "until ..." } } @@ -501,9 +501,9 @@ class WhileModifierExpr extends ConditionalLoop, TWhileModifierExpr { WhileModifierExpr() { this = TWhileModifierExpr(g) } - final override Stmt getBody() { toTreeSitter(result) = g.getBody() } + final override Stmt getBody() { toGenerated(result) = g.getBody() } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override string getAPrimaryQlClass() { result = "WhileModifierExpr" } @@ -521,9 +521,9 @@ class UntilModifierExpr extends ConditionalLoop, TUntilModifierExpr { UntilModifierExpr() { this = TUntilModifierExpr(g) } - final override Stmt getBody() { toTreeSitter(result) = g.getBody() } + final override Stmt getBody() { toGenerated(result) = g.getBody() } - final override Expr getCondition() { toTreeSitter(result) = g.getCondition() } + final override Expr getCondition() { toGenerated(result) = g.getCondition() } final override string getAPrimaryQlClass() { result = "UntilModifierExpr" } @@ -546,10 +546,10 @@ class ForExpr extends Loop, TForExpr { final override string getAPrimaryQlClass() { result = "ForExpr" } /** Gets the body of this `for` loop. */ - final override Stmt getBody() { toTreeSitter(result) = g.getBody() } + final override Stmt getBody() { toGenerated(result) = g.getBody() } /** Gets the pattern representing the iteration argument. */ - final Pattern getPattern() { toTreeSitter(result) = g.getPattern() } + final Pattern getPattern() { toGenerated(result) = g.getPattern() } /** * Gets the value being iterated over. In the following example, the result @@ -560,7 +560,7 @@ class ForExpr extends Loop, TForExpr { * end * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getValue().getChild() } + final Expr getValue() { toGenerated(result) = g.getValue().getChild() } final override string toString() { result = "for ... in ..." } diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index f71d111c5d8..f584b7f96f7 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -39,7 +39,7 @@ class ArgumentList extends Expr, TArgumentList { /** Gets the `i`th element in this argument list. */ Expr getElement(int i) { - toTreeSitter(result) in [ + toGenerated(result) in [ g.(Generated::ArgumentList).getChild(i), g.(Generated::RightAssignmentList).getChild(i) ] } @@ -90,7 +90,7 @@ private class Then extends StmtSequence, TThen { Then() { this = TThen(g) } - override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } private class Else extends StmtSequence, TElse { @@ -98,7 +98,7 @@ private class Else extends StmtSequence, TElse { Else() { this = TElse(g) } - override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } private class Do extends StmtSequence, TDo { @@ -106,7 +106,7 @@ private class Do extends StmtSequence, TDo { Do() { this = TDo(g) } - override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } private class Ensure extends StmtSequence, TEnsure { @@ -114,7 +114,7 @@ private class Ensure extends StmtSequence, TEnsure { Ensure() { this = TEnsure(g) } - override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } final override string toString() { result = "ensure ..." } } @@ -153,7 +153,7 @@ class BodyStmt extends StmtSequence, TBodyStmt { final override Stmt getStmt(int n) { result = rank[n + 1](AstNode node, int i | - toTreeSitter(node) = this.getChild(i) and + toGenerated(node) = this.getChild(i) and not node instanceof Else and not node instanceof RescueClause and not node instanceof Ensure @@ -165,17 +165,17 @@ class BodyStmt extends StmtSequence, TBodyStmt { /** Gets the `n`th rescue clause in this block. */ final RescueClause getRescue(int n) { result = - rank[n + 1](RescueClause node, int i | toTreeSitter(node) = getChild(i) | node order by i) + rank[n + 1](RescueClause node, int i | toGenerated(node) = getChild(i) | node order by i) } /** Gets a rescue clause in this block. */ final RescueClause getARescue() { result = this.getRescue(_) } /** Gets the `else` clause in this block, if any. */ - final StmtSequence getElse() { result = unique(Else s | toTreeSitter(s) = getChild(_)) } + final StmtSequence getElse() { result = unique(Else s | toGenerated(s) = getChild(_)) } /** Gets the `ensure` clause in this block, if any. */ - final StmtSequence getEnsure() { result = unique(Ensure s | toTreeSitter(s) = getChild(_)) } + final StmtSequence getEnsure() { result = unique(Ensure s | toGenerated(s) = getChild(_)) } final predicate hasEnsure() { exists(this.getEnsure()) } @@ -220,7 +220,7 @@ class ParenthesizedExpr extends StmtSequence, TParenthesizedExpr { ) } - final override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } /** @@ -251,7 +251,7 @@ class Pair extends Expr, TPair { * { 'foo' => 123 } * ``` */ - final Expr getKey() { toTreeSitter(result) = g.getKey() } + final Expr getKey() { toGenerated(result) = g.getKey() } /** * Gets the value expression of this pair. For example, the `InteralLiteral` @@ -260,7 +260,7 @@ class Pair extends Expr, TPair { * { 'foo' => 123 } * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getValue() } + final Expr getValue() { toGenerated(result) = g.getValue() } final override string toString() { result = "Pair" } @@ -297,7 +297,7 @@ class RescueClause extends Expr, TRescueClause { * end * ``` */ - final Expr getException(int n) { toTreeSitter(result) = g.getExceptions().getChild(n) } + final Expr getException(int n) { toGenerated(result) = g.getExceptions().getChild(n) } /** * Gets an exception to match, if any. For example `FirstError` or `SecondError` in: @@ -322,12 +322,12 @@ class RescueClause extends Expr, TRescueClause { * end * ``` */ - final LhsExpr getVariableExpr() { toTreeSitter(result) = g.getVariable().getChild() } + final LhsExpr getVariableExpr() { toGenerated(result) = g.getVariable().getChild() } /** * Gets the exception handler body. */ - final StmtSequence getBody() { toTreeSitter(result) = g.getBody() } + final StmtSequence getBody() { toGenerated(result) = g.getBody() } final override string toString() { result = "rescue ..." } @@ -359,7 +359,7 @@ class RescueModifierExpr extends Expr, TRescueModifierExpr { * body rescue handler * ``` */ - final Stmt getBody() { toTreeSitter(result) = g.getBody() } + final Stmt getBody() { toGenerated(result) = g.getBody() } /** * Gets the exception handler of this `RescueModifierExpr`. @@ -367,7 +367,7 @@ class RescueModifierExpr extends Expr, TRescueModifierExpr { * body rescue handler * ``` */ - final Stmt getHandler() { toTreeSitter(result) = g.getHandler() } + final Stmt getHandler() { toGenerated(result) = g.getHandler() } final override string toString() { result = "... rescue ..." } @@ -393,7 +393,7 @@ class StringConcatenation extends Expr, TStringConcatenation { final override string getAPrimaryQlClass() { result = "StringConcatenation" } /** Gets the `n`th string literal in this concatenation. */ - final StringLiteral getString(int n) { toTreeSitter(result) = g.getChild(n) } + final StringLiteral getString(int n) { toGenerated(result) = g.getChild(n) } /** Gets a string literal in this concatenation. */ final StringLiteral getAString() { result = this.getString(_) } diff --git a/ql/src/codeql_ruby/ast/Literal.qll b/ql/src/codeql_ruby/ast/Literal.qll index 57bc28dbb99..2354084910a 100644 --- a/ql/src/codeql_ruby/ast/Literal.qll +++ b/ql/src/codeql_ruby/ast/Literal.qll @@ -226,7 +226,7 @@ class StringInterpolationComponent extends StringComponent, StmtSequence, final override string toString() { result = "#{...}" } - final override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } final override string getValueText() { none() } @@ -334,9 +334,9 @@ class StringlikeLiteral extends Literal, TStringlikeLiteral { concat(StringComponent c, int i, string s | c = this.getComponent(i) and ( - s = toTreeSitter(c).(Generated::Token).getValue() + s = toGenerated(c).(Generated::Token).getValue() or - not toTreeSitter(c) instanceof Generated::Token and + not toGenerated(c) instanceof Generated::Token and s = "#{...}" ) | @@ -374,7 +374,7 @@ private class RegularStringLiteral extends StringLiteral, TRegularStringLiteral RegularStringLiteral() { this = TRegularStringLiteral(g) } - final override StringComponent getComponent(int n) { toTreeSitter(result) = g.getChild(n) } + final override StringComponent getComponent(int n) { toGenerated(result) = g.getChild(n) } } private class BareStringLiteral extends StringLiteral, TBareStringLiteral { @@ -382,7 +382,7 @@ private class BareStringLiteral extends StringLiteral, TBareStringLiteral { BareStringLiteral() { this = TBareStringLiteral(g) } - final override StringComponent getComponent(int n) { toTreeSitter(result) = g.getChild(n) } + final override StringComponent getComponent(int n) { toGenerated(result) = g.getChild(n) } } /** @@ -399,7 +399,7 @@ class RegexLiteral extends StringlikeLiteral, TRegexLiteral { final override string getAPrimaryQlClass() { result = "RegexLiteral" } - final override StringComponent getComponent(int i) { toTreeSitter(result) = g.getChild(i) } + final override StringComponent getComponent(int i) { toGenerated(result) = g.getChild(i) } /** * Gets the regex flags as a string. @@ -464,7 +464,7 @@ private class DelimitedSymbolLiteral extends ComplexSymbolLiteral, TDelimitedSym DelimitedSymbolLiteral() { this = TDelimitedSymbolLiteral(g) } - final override StringComponent getComponent(int i) { toTreeSitter(result) = g.getChild(i) } + final override StringComponent getComponent(int i) { toGenerated(result) = g.getChild(i) } } private class BareSymbolLiteral extends ComplexSymbolLiteral, TBareSymbolLiteral { @@ -472,7 +472,7 @@ private class BareSymbolLiteral extends ComplexSymbolLiteral, TBareSymbolLiteral BareSymbolLiteral() { this = TBareSymbolLiteral(g) } - final override StringComponent getComponent(int i) { toTreeSitter(result) = g.getChild(i) } + final override StringComponent getComponent(int i) { toGenerated(result) = g.getChild(i) } } private class HashKeySymbolLiteral extends SymbolLiteral, THashKeySymbolLiteral { @@ -500,7 +500,7 @@ class SubshellLiteral extends StringlikeLiteral, TSubshellLiteral { final override string getAPrimaryQlClass() { result = "SubshellLiteral" } - final override StringComponent getComponent(int i) { toTreeSitter(result) = g.getChild(i) } + final override StringComponent getComponent(int i) { toGenerated(result) = g.getChild(i) } } /** @@ -599,7 +599,7 @@ class HereDoc extends StringlikeLiteral, THereDoc { } final override StringComponent getComponent(int n) { - toTreeSitter(result) = this.getBody().getChild(n) + toGenerated(result) = this.getBody().getChild(n) } final override string toString() { result = g.getValue() } @@ -636,7 +636,7 @@ private class RegularArrayLiteral extends ArrayLiteral, TRegularArrayLiteral { RegularArrayLiteral() { this = TRegularArrayLiteral(g) } - final override Expr getElement(int i) { toTreeSitter(result) = g.getChild(i) } + final override Expr getElement(int i) { toGenerated(result) = g.getChild(i) } final override string toString() { result = "[...]" } } @@ -646,7 +646,7 @@ private class StringArrayLiteral extends ArrayLiteral, TStringArrayLiteral { StringArrayLiteral() { this = TStringArrayLiteral(g) } - final override Expr getElement(int i) { toTreeSitter(result) = g.getChild(i) } + final override Expr getElement(int i) { toGenerated(result) = g.getChild(i) } final override string toString() { result = "%w(...)" } } @@ -656,7 +656,7 @@ private class SymbolArrayLiteral extends ArrayLiteral, TSymbolArrayLiteral { SymbolArrayLiteral() { this = TSymbolArrayLiteral(g) } - final override Expr getElement(int i) { toTreeSitter(result) = g.getChild(i) } + final override Expr getElement(int i) { toGenerated(result) = g.getChild(i) } final override string toString() { result = "%i(...)" } } @@ -685,7 +685,7 @@ class HashLiteral extends Literal, THashLiteral { * { foo: 123, **bar } * ``` */ - final Expr getElement(int n) { toTreeSitter(result) = g.getChild(n) } + final Expr getElement(int n) { toGenerated(result) = g.getChild(n) } /** Gets an element in this array literal. */ final Expr getAnElement() { result = this.getElement(_) } @@ -719,10 +719,10 @@ class RangeLiteral extends Literal, TRangeLiteral { final override string getAPrimaryQlClass() { result = "RangeLiteral" } /** Gets the begin expression of this range, if any. */ - final Expr getBegin() { toTreeSitter(result) = g.getBegin() } + final Expr getBegin() { toGenerated(result) = g.getBegin() } /** Gets the end expression of this range, if any. */ - final Expr getEnd() { toTreeSitter(result) = g.getEnd() } + final Expr getEnd() { toGenerated(result) = g.getEnd() } /** * Holds if the range is inclusive of the end value, i.e. uses the `..` @@ -755,7 +755,7 @@ class RangeLiteral extends Literal, TRangeLiteral { * ``` */ class MethodName extends Literal { - MethodName() { MethodName::range(toTreeSitter(this)) } + MethodName() { MethodName::range(toGenerated(this)) } final override string getAPrimaryQlClass() { result = "MethodName" } } diff --git a/ql/src/codeql_ruby/ast/Method.qll b/ql/src/codeql_ruby/ast/Method.qll index 3e0ad6c2b87..3836bee596b 100644 --- a/ql/src/codeql_ruby/ast/Method.qll +++ b/ql/src/codeql_ruby/ast/Method.qll @@ -57,7 +57,7 @@ class Method extends MethodBase, TMethod { final predicate isSetter() { g.getName() instanceof Generated::Setter } final override Parameter getParameter(int n) { - toTreeSitter(result) = g.getParameters().getChild(n) + toGenerated(result) = g.getParameters().getChild(n) } final override string toString() { result = this.getName() } @@ -72,7 +72,7 @@ class SingletonMethod extends MethodBase, TSingletonMethod { final override string getAPrimaryQlClass() { result = "SingletonMethod" } /** Gets the object of this singleton method. */ - final Expr getObject() { toTreeSitter(result) = g.getObject() } + final Expr getObject() { toGenerated(result) = g.getObject() } final override string getName() { result = g.getName().(Generated::Token).getValue() @@ -81,7 +81,7 @@ class SingletonMethod extends MethodBase, TSingletonMethod { } final override Parameter getParameter(int n) { - toTreeSitter(result) = g.getParameters().getChild(n) + toGenerated(result) = g.getParameters().getChild(n) } final override string toString() { result = this.getName() } @@ -107,7 +107,7 @@ class Lambda extends Callable, BodyStmt, TLambda { final override string getAPrimaryQlClass() { result = "Lambda" } final override Parameter getParameter(int n) { - toTreeSitter(result) = g.getParameters().getChild(n) + toGenerated(result) = g.getParameters().getChild(n) } final override string toString() { result = "-> { ... }" } @@ -135,7 +135,7 @@ class DoBlock extends Block, BodyStmt, TDoBlock { DoBlock() { this = TDoBlock(g) } final override Parameter getParameter(int n) { - toTreeSitter(result) = g.getParameters().getChild(n) + toGenerated(result) = g.getParameters().getChild(n) } final override string toString() { result = "do ... end" } @@ -161,10 +161,10 @@ class BraceBlock extends Block, TBraceBlock { BraceBlock() { this = TBraceBlock(g) } final override Parameter getParameter(int n) { - toTreeSitter(result) = g.getParameters().getChild(n) + toGenerated(result) = g.getParameters().getChild(n) } - final override Stmt getStmt(int i) { toTreeSitter(result) = g.getChild(i) } + final override Stmt getStmt(int i) { toGenerated(result) = g.getChild(i) } final override string toString() { result = "{ ... }" } diff --git a/ql/src/codeql_ruby/ast/Module.qll b/ql/src/codeql_ruby/ast/Module.qll index ba23d8327a5..568a5d64cac 100644 --- a/ql/src/codeql_ruby/ast/Module.qll +++ b/ql/src/codeql_ruby/ast/Module.qll @@ -47,8 +47,7 @@ class Toplevel extends ModuleBase, TToplevel { * Gets the `n`th `BEGIN` block. */ final BeginBlock getBeginBlock(int n) { - toTreeSitter(result) = - rank[n](int i, Generated::BeginBlock b | b = g.getChild(i) | b order by i) + toGenerated(result) = rank[n](int i, Generated::BeginBlock b | b = g.getChild(i) | b order by i) } /** @@ -173,7 +172,7 @@ class Class extends Namespace, TClass { * end * ``` */ - final Expr getSuperclassExpr() { toTreeSitter(result) = g.getSuperclass().getChild() } + final Expr getSuperclassExpr() { toGenerated(result) = g.getSuperclass().getChild() } final override string getName() { result = g.getName().(Generated::Token).getValue() or @@ -181,7 +180,7 @@ class Class extends Namespace, TClass { } final override Expr getScopeExpr() { - toTreeSitter(result) = g.getName().(Generated::ScopeResolution).getScope() + toGenerated(result) = g.getName().(Generated::ScopeResolution).getScope() } final override predicate hasGlobalScope() { @@ -225,7 +224,7 @@ class SingletonClass extends ModuleBase, TSingletonClass { * end * ``` */ - final Expr getValue() { toTreeSitter(result) = g.getValue() } + final Expr getValue() { toGenerated(result) = g.getValue() } final override string toString() { result = "class << ..." } @@ -274,7 +273,7 @@ class Module extends Namespace, TModule { } final override Expr getScopeExpr() { - toTreeSitter(result) = g.getName().(Generated::ScopeResolution).getScope() + toGenerated(result) = g.getName().(Generated::ScopeResolution).getScope() } final override predicate hasGlobalScope() { diff --git a/ql/src/codeql_ruby/ast/Operation.qll b/ql/src/codeql_ruby/ast/Operation.qll index 8d13367f2c3..b5acf8c8116 100644 --- a/ql/src/codeql_ruby/ast/Operation.qll +++ b/ql/src/codeql_ruby/ast/Operation.qll @@ -21,10 +21,10 @@ class Operation extends Expr, TOperation { class UnaryOperation extends Operation, TUnaryOperation { private Generated::Unary g; - UnaryOperation() { g = toTreeSitter(this) } + UnaryOperation() { g = toGenerated(this) } /** Gets the operand of this unary operation. */ - final Expr getOperand() { toTreeSitter(result) = g.getOperand() } + final Expr getOperand() { toGenerated(result) = g.getOperand() } final override string getOperator() { result = g.getOperator() } @@ -103,7 +103,7 @@ class DefinedExpr extends UnaryOperation, TDefinedExpr { class BinaryOperation extends Operation, TBinaryOperation { private Generated::Binary g; - BinaryOperation() { g = toTreeSitter(this) } + BinaryOperation() { g = toGenerated(this) } final override string getOperator() { result = g.getOperator() } @@ -122,10 +122,10 @@ class BinaryOperation extends Operation, TBinaryOperation { } /** Gets the left operand of this binary operation. */ - final Stmt getLeftOperand() { toTreeSitter(result) = g.getLeft() } + final Stmt getLeftOperand() { toGenerated(result) = g.getLeft() } /** Gets the right operand of this binary operation. */ - final Stmt getRightOperand() { toTreeSitter(result) = g.getRight() } + final Stmt getRightOperand() { toGenerated(result) = g.getRight() } } /** @@ -459,9 +459,9 @@ class AssignExpr extends Assignment, TAssignExpr { AssignExpr() { this = TAssignExpr(g) } - final override Pattern getLeftOperand() { toTreeSitter(result) = g.getLeft() } + final override Pattern getLeftOperand() { toGenerated(result) = g.getLeft() } - final override Expr getRightOperand() { toTreeSitter(result) = g.getRight() } + final override Expr getRightOperand() { toGenerated(result) = g.getRight() } final override string getOperator() { result = "=" } @@ -474,13 +474,13 @@ class AssignExpr extends Assignment, TAssignExpr { class AssignOperation extends Assignment, TAssignOperation { private Generated::OperatorAssignment g; - AssignOperation() { g = toTreeSitter(this) } + AssignOperation() { g = toGenerated(this) } final override string getOperator() { result = g.getOperator() } - final override LhsExpr getLeftOperand() { toTreeSitter(result) = g.getLeft() } + final override LhsExpr getLeftOperand() { toGenerated(result) = g.getLeft() } - final override Expr getRightOperand() { toTreeSitter(result) = g.getRight() } + final override Expr getRightOperand() { toGenerated(result) = g.getRight() } } /** diff --git a/ql/src/codeql_ruby/ast/Parameter.qll b/ql/src/codeql_ruby/ast/Parameter.qll index 1d207d1eb74..7f9c11b417b 100644 --- a/ql/src/codeql_ruby/ast/Parameter.qll +++ b/ql/src/codeql_ruby/ast/Parameter.qll @@ -154,7 +154,7 @@ class KeywordParameter extends NamedParameter, TKeywordParameter { * is not provided by the caller. If the parameter is mandatory and does not * have a default value, this predicate has no result. */ - final Expr getDefaultValue() { toTreeSitter(result) = g.getValue() } + final Expr getDefaultValue() { toGenerated(result) = g.getValue() } /** * Holds if the parameter is optional. That is, there is a default value that @@ -195,7 +195,7 @@ class OptionalParameter extends NamedParameter, TOptionalParameter { * Gets the default value, i.e. the value assigned to the parameter when one * is not provided by the caller. */ - final Expr getDefaultValue() { toTreeSitter(result) = g.getValue() } + final Expr getDefaultValue() { toGenerated(result) = g.getValue() } final override LocalVariable getVariable() { result = TLocalVariable(_, _, g.getName()) } diff --git a/ql/src/codeql_ruby/ast/Pattern.qll b/ql/src/codeql_ruby/ast/Pattern.qll index 4018fbbe68f..39ddfbab383 100644 --- a/ql/src/codeql_ruby/ast/Pattern.qll +++ b/ql/src/codeql_ruby/ast/Pattern.qll @@ -7,9 +7,9 @@ private import internal.Variable /** A pattern. */ class Pattern extends AstNode { Pattern() { - explicitAssignmentNode(toTreeSitter(this), _) or - implicitAssignmentNode(toTreeSitter(this)) or - implicitParameterAssignmentNode(toTreeSitter(this), _) + explicitAssignmentNode(toGenerated(this), _) or + implicitAssignmentNode(toGenerated(this)) or + implicitParameterAssignmentNode(toGenerated(this), _) } /** Gets a variable used in (or introduced by) this pattern. */ @@ -57,19 +57,19 @@ class TuplePattern extends Pattern, TTuplePattern { override string getAPrimaryQlClass() { result = "TuplePattern" } private Generated::AstNode getChild(int i) { - result = toTreeSitter(this).(Generated::DestructuredParameter).getChild(i) + result = toGenerated(this).(Generated::DestructuredParameter).getChild(i) or - result = toTreeSitter(this).(Generated::DestructuredLeftAssignment).getChild(i) + result = toGenerated(this).(Generated::DestructuredLeftAssignment).getChild(i) or - result = toTreeSitter(this).(Generated::LeftAssignmentList).getChild(i) + result = toGenerated(this).(Generated::LeftAssignmentList).getChild(i) } /** Gets the `i`th pattern in this tuple pattern. */ final Pattern getElement(int i) { exists(Generated::AstNode c | c = this.getChild(i) | - toTreeSitter(result) = c.(Generated::RestAssignment).getChild() + toGenerated(result) = c.(Generated::RestAssignment).getChild() or - toTreeSitter(result) = c + toGenerated(result) = c ) } diff --git a/ql/src/codeql_ruby/ast/Scope.qll b/ql/src/codeql_ruby/ast/Scope.qll index 79381b133c3..36b23e880e5 100644 --- a/ql/src/codeql_ruby/ast/Scope.qll +++ b/ql/src/codeql_ruby/ast/Scope.qll @@ -6,16 +6,16 @@ private import internal.TreeSitter class Scope extends AstNode, TScopeType { private Scope::Range range; - Scope() { range = toTreeSitter(this) } + Scope() { range = toGenerated(this) } /** Gets the enclosing module, if any. */ - ModuleBase getEnclosingModule() { toTreeSitter(result) = range.getEnclosingModule() } + ModuleBase getEnclosingModule() { toGenerated(result) = range.getEnclosingModule() } /** Gets the enclosing method, if any. */ - MethodBase getEnclosingMethod() { toTreeSitter(result) = range.getEnclosingMethod() } + MethodBase getEnclosingMethod() { toGenerated(result) = range.getEnclosingMethod() } /** Gets the scope in which this scope is nested, if any. */ - Scope getOuterScope() { toTreeSitter(result) = range.getOuterScope() } + Scope getOuterScope() { toGenerated(result) = range.getOuterScope() } /** Gets a variable that is declared in this scope. */ final Variable getAVariable() { result.getDeclaringScope() = this } diff --git a/ql/src/codeql_ruby/ast/Statement.qll b/ql/src/codeql_ruby/ast/Statement.qll index 94f1b49ec47..fcc2ac8c09f 100644 --- a/ql/src/codeql_ruby/ast/Statement.qll +++ b/ql/src/codeql_ruby/ast/Statement.qll @@ -15,7 +15,7 @@ class Stmt extends AstNode, TStmt { CfgNodes::AstCfgNode getAControlFlowNode() { result.getNode() = this } /** Gets the control-flow scope of this statement, if any. */ - CfgScope getCfgScope() { result = getCfgScope(toTreeSitter(this)) } + CfgScope getCfgScope() { result = getCfgScope(toGenerated(this)) } /** Gets the enclosing callable, if any. */ Callable getEnclosingCallable() { result = this.getCfgScope() } @@ -59,7 +59,7 @@ class BeginBlock extends StmtSequence, TBeginBlock { final override string toString() { result = "BEGIN { ... }" } - final override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } /** @@ -77,7 +77,7 @@ class EndBlock extends StmtSequence, TEndBlock { final override string toString() { result = "END { ... }" } - final override Stmt getStmt(int n) { toTreeSitter(result) = g.getChild(n) } + final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } /** @@ -94,7 +94,7 @@ class UndefStmt extends Stmt, TUndefStmt { UndefStmt() { this = TUndefStmt(g) } /** Gets the `n`th method name to undefine. */ - final MethodName getMethodName(int n) { toTreeSitter(result) = g.getChild(n) } + final MethodName getMethodName(int n) { toGenerated(result) = g.getChild(n) } /** Gets a method name to undefine. */ final MethodName getAMethodName() { result = getMethodName(_) } @@ -122,10 +122,10 @@ class AliasStmt extends Stmt, TAliasStmt { AliasStmt() { this = TAliasStmt(g) } /** Gets the new method name. */ - final MethodName getNewName() { toTreeSitter(result) = g.getName() } + final MethodName getNewName() { toGenerated(result) = g.getName() } /** Gets the original method name. */ - final MethodName getOldName() { toTreeSitter(result) = g.getAlias() } + final MethodName getOldName() { toGenerated(result) = g.getAlias() } final override string getAPrimaryQlClass() { result = "AliasStmt" } @@ -161,7 +161,7 @@ class ReturningStmt extends Stmt, TReturningStmt { /** Gets the returned value, if any. */ final Expr getValue() { - toTreeSitter(result) = + toGenerated(result) = any(Generated::AstNode res | exists(Generated::ArgumentList a, int c | a = this.getArgumentList() and c = count(a.getChild(_)) diff --git a/ql/src/codeql_ruby/ast/Variable.qll b/ql/src/codeql_ruby/ast/Variable.qll index de1b0c73941..bc2ab278e6c 100644 --- a/ql/src/codeql_ruby/ast/Variable.qll +++ b/ql/src/codeql_ruby/ast/Variable.qll @@ -22,7 +22,7 @@ class Variable extends TVariable { final Location getLocation() { result = range.getLocation() } /** Gets the scope this variable is declared in. */ - final Scope getDeclaringScope() { toTreeSitter(result) = range.getDeclaringScope() } + final Scope getDeclaringScope() { toGenerated(result) = range.getDeclaringScope() } /** Gets an access to this variable. */ VariableAccess getAnAccess() { result.getVariable() = this } @@ -94,7 +94,7 @@ class VariableAccess extends Expr, TVariableAccess { * both `a` and `b` are write accesses belonging to the same assignment. */ predicate isExplicitWrite(AstNode assignment) { - explicitWriteAccess(toTreeSitter(this), toTreeSitter(assignment)) + explicitWriteAccess(toGenerated(this), toGenerated(assignment)) } /** @@ -112,7 +112,7 @@ class VariableAccess extends Expr, TVariableAccess { * the access to `elements` in the parameter list is an implicit assignment, * as is the first access to `e`. */ - predicate isImplicitWrite() { implicitWriteAccess(toTreeSitter(this)) } + predicate isImplicitWrite() { implicitWriteAccess(toGenerated(this)) } } /** An access to a variable where the value is updated. */ diff --git a/ql/src/codeql_ruby/ast/internal/AST.qll b/ql/src/codeql_ruby/ast/internal/AST.qll index b3e73738845..23cabfa08ab 100644 --- a/ql/src/codeql_ruby/ast/internal/AST.qll +++ b/ql/src/codeql_ruby/ast/internal/AST.qll @@ -221,7 +221,7 @@ private module Cached { /** Gets the underlying TreeSitter entity for a given AST node. */ cached - Generated::AstNode toTreeSitter(AST::AstNode n) { + Generated::AstNode toGenerated(AST::AstNode n) { n = TAddExpr(result) or n = TAliasStmt(result) or n = TArgumentList(result) or @@ -367,7 +367,7 @@ private module Cached { import Cached -TAstNode fromTreeSitter(Generated::AstNode n) { n = toTreeSitter(result) } +TAstNode fromGenerated(Generated::AstNode n) { n = toGenerated(result) } class TCall = TMethodCall or TYieldCall; diff --git a/ql/src/codeql_ruby/ast/internal/Variable.qll b/ql/src/codeql_ruby/ast/internal/Variable.qll index ab9baf83cab..fcd1e428862 100644 --- a/ql/src/codeql_ruby/ast/internal/Variable.qll +++ b/ql/src/codeql_ruby/ast/internal/Variable.qll @@ -331,7 +331,7 @@ private module Cached { cached predicate isCapturedAccess(LocalVariableAccess access) { - toTreeSitter(access.getVariable().getDeclaringScope()) != scopeOf(toTreeSitter(access)) + toGenerated(access.getVariable().getDeclaringScope()) != scopeOf(toGenerated(access)) } cached @@ -398,7 +398,7 @@ module LocalVariable { final override Scope::Range getDeclaringScope() { result = scope } - final VariableAccess getDefiningAccess() { toTreeSitter(result) = i } + final VariableAccess getDefiningAccess() { toGenerated(result) = i } } } diff --git a/ql/src/codeql_ruby/controlflow/BasicBlocks.qll b/ql/src/codeql_ruby/controlflow/BasicBlocks.qll index 4356f167a1c..2926d00fe18 100644 --- a/ql/src/codeql_ruby/controlflow/BasicBlocks.qll +++ b/ql/src/codeql_ruby/controlflow/BasicBlocks.qll @@ -358,9 +358,9 @@ private module JoinBlockPredecessors { private predicate idOf(Generated::AstNode x, int y) = equivalenceRelation(id/2)(x, y) int getId(JoinBlockPredecessor jbp) { - idOf(toTreeSitter(jbp.getFirstNode().(AstCfgNode).getNode()), result) + idOf(toGenerated(jbp.getFirstNode().(AstCfgNode).getNode()), result) or - idOf(toTreeSitter(jbp.(EntryBasicBlock).getScope()), result) + idOf(toGenerated(jbp.(EntryBasicBlock).getScope()), result) } string getSplitString(JoinBlockPredecessor jbp) { diff --git a/ql/src/codeql_ruby/controlflow/CfgNodes.qll b/ql/src/codeql_ruby/controlflow/CfgNodes.qll index 49f286b6951..e2a4badff91 100644 --- a/ql/src/codeql_ruby/controlflow/CfgNodes.qll +++ b/ql/src/codeql_ruby/controlflow/CfgNodes.qll @@ -67,7 +67,7 @@ class AstCfgNode extends CfgNode, TAstCfgNode { private Splits splits; private AstNode n; - AstCfgNode() { this = TAstCfgNode(toTreeSitter(n), splits) } + AstCfgNode() { this = TAstCfgNode(toGenerated(n), splits) } final override AstNode getNode() { result = n } @@ -132,7 +132,7 @@ abstract private class ExprChildMapping extends Expr { pragma[noinline] private BasicBlock getABasicBlockInScope() { - result.getANode() = TAstCfgNode(toTreeSitter(this.getAChildStar()), _) + result.getANode() = TAstCfgNode(toGenerated(this.getAChildStar()), _) } pragma[nomagic] diff --git a/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll b/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll index b5b54e6ba0d..d1aca73b49f 100644 --- a/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll +++ b/ql/src/codeql_ruby/controlflow/ControlFlowGraph.qll @@ -11,13 +11,13 @@ private import internal.Completion /** An AST node with an associated control-flow graph. */ class CfgScope extends AST::AstNode { - CfgScope() { ASTInternal::toTreeSitter(this) instanceof CfgScope::Range_ } + CfgScope() { ASTInternal::toGenerated(this) instanceof CfgScope::Range_ } /** Gets the CFG scope that this scope is nested under, if any. */ final CfgScope getOuterCfgScope() { exists(AST::AstNode parent | parent = this.getParent() and - result = getCfgScope(ASTInternal::toTreeSitter(parent)) + result = getCfgScope(ASTInternal::toGenerated(parent)) ) } } diff --git a/ql/src/codeql_ruby/controlflow/internal/Completion.qll b/ql/src/codeql_ruby/controlflow/internal/Completion.qll index e0f7348e770..ed17cb5f125 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Completion.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Completion.qll @@ -206,7 +206,7 @@ private predicate inMatchingContext(AstNode n) { w.getPattern(_) = n ) or - toTreeSitter(n).(Trees::DefaultValueParameterTree).hasDefaultValue() + toGenerated(n).(Trees::DefaultValueParameterTree).hasDefaultValue() } /** diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index ea51daf0b06..89e3a604173 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -203,7 +203,7 @@ private predicate succImpl(AstNode pred, AstNode succ, Completion c) { } private predicate isHidden(ControlFlowTree t) { - not t = ASTInternal::toTreeSitter(_) + not t = ASTInternal::toGenerated(_) or t.isHidden() } @@ -301,7 +301,7 @@ private class ForRange extends AST::ForExpr { result = AST::ForExpr.super.getAChild(pred) or pred = "" and - result = ASTInternal::TForIn(ASTInternal::toTreeSitter(this).(For).getValue()) + result = ASTInternal::TForIn(ASTInternal::toGenerated(this).(For).getValue()) } } @@ -309,7 +309,7 @@ private class ForRange extends AST::ForExpr { predicate isValidFor(Completion c, ControlFlowTree node) { c instanceof SimpleCompletion and isHidden(node) or - c.isValidFor(ASTInternal::fromTreeSitter(node)) + c.isValidFor(ASTInternal::fromGenerated(node)) } abstract private class StandardPreOrderTree extends StandardNode, PreOrderTree { @@ -1278,7 +1278,7 @@ cached private module Cached { /** Gets the CFG scope of node `n`. */ cached - CfgScope getCfgScope(AstNode n) { ASTInternal::toTreeSitter(result) = parent*(scopeOf(n)) } + CfgScope getCfgScope(AstNode n) { ASTInternal::toGenerated(result) = parent*(scopeOf(n)) } private predicate isAbnormalExitType(SuccessorType t) { t instanceof RaiseSuccessor or t instanceof ExitSuccessor @@ -1359,5 +1359,5 @@ import Cached /** An AST node that is split into multiple control flow nodes. */ class SplitAstNode extends AstNode { - SplitAstNode() { strictcount(CfgNode n | ASTInternal::toTreeSitter(n.getNode()) = this) > 1 } + SplitAstNode() { strictcount(CfgNode n | ASTInternal::toGenerated(n.getNode()) = this) > 1 } } diff --git a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll index ea7cd31ed24..e1cf24a2815 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll @@ -219,26 +219,26 @@ private module ConditionalCompletionSplitting { succ(pred, succ, c) and last(succ, _, completion) and ( - last(ASTInternal::toTreeSitter(ASTInternal::fromTreeSitter(succ).(AST::NotExpr).getOperand()), + last(ASTInternal::toGenerated(ASTInternal::fromGenerated(succ).(AST::NotExpr).getOperand()), pred, c) and completion.(BooleanCompletion).getDual() = c or - last(ASTInternal::toTreeSitter(ASTInternal::fromTreeSitter(succ) + last(ASTInternal::toGenerated(ASTInternal::fromGenerated(succ) .(AST::LogicalAndExpr) .getAnOperand()), pred, c) and completion = c or - last(ASTInternal::toTreeSitter(ASTInternal::fromTreeSitter(succ) + last(ASTInternal::toGenerated(ASTInternal::fromGenerated(succ) .(AST::LogicalOrExpr) .getAnOperand()), pred, c) and completion = c or - last(ASTInternal::toTreeSitter(ASTInternal::fromTreeSitter(succ) + last(ASTInternal::toGenerated(ASTInternal::fromGenerated(succ) .(AST::ParenthesizedExpr) .getLastExpr()), pred, c) and completion = c or - last(ASTInternal::toTreeSitter(ASTInternal::fromTreeSitter(succ) + last(ASTInternal::toGenerated(ASTInternal::fromGenerated(succ) .(AST::ConditionalExpr) .getBranch(_)), pred, c) and completion = c @@ -255,7 +255,7 @@ private module ConditionalCompletionSplitting { override predicate hasExitScope(CfgScope scope, AstNode last, Completion c) { this.appliesTo(last) and - succExit(ASTInternal::toTreeSitter(scope), last, c) and + succExit(ASTInternal::toGenerated(scope), last, c) and if c instanceof ConditionalCompletion then completion = c else any() } @@ -472,7 +472,7 @@ module EnsureSplitting { } override predicate hasExitScope(CfgScope scope, AstNode last, Completion c) { - succExit(ASTInternal::toTreeSitter(scope), last, c) and + succExit(ASTInternal::toGenerated(scope), last, c) and ( exit(_, last, c, _) or @@ -517,7 +517,7 @@ class Splits extends TSplits { private predicate succEntrySplitsFromRank(CfgScope pred, AstNode succ, Splits splits, int rnk) { splits = TSplitsNil() and - succEntry(ASTInternal::toTreeSitter(pred), succ) and + succEntry(ASTInternal::toGenerated(pred), succ) and rnk = 0 or exists(SplitImpl head, Splits tail | succEntrySplitsCons(pred, succ, head, tail, rnk) | @@ -540,7 +540,7 @@ private predicate succEntrySplitsCons( pragma[noinline] predicate succEntrySplits(CfgScope pred, AstNode succ, Splits succSplits, SuccessorType t) { exists(int rnk | - succEntry(ASTInternal::toTreeSitter(pred), succ) and + succEntry(ASTInternal::toGenerated(pred), succ) and t instanceof NormalSuccessor and succEntrySplitsFromRank(pred, succ, succSplits, rnk) | @@ -559,7 +559,7 @@ predicate succExitSplits(AstNode last, Splits predSplits, CfgScope scope, Succes exists(Reachability::SameSplitsBlock b, Completion c | last = b.getANode() | b.isReachable(predSplits) and t = c.getAMatchingSuccessorType() and - succExit(ASTInternal::toTreeSitter(scope), last, c) and + succExit(ASTInternal::toGenerated(scope), last, c) and forall(SplitImpl predSplit | predSplit = predSplits.getASplit() | predSplit.hasExitScope(scope, last, c) )