mirror of
https://github.com/github/codeql.git
synced 2026-02-20 08:53:49 +01:00
Remove imports of TreeSitter
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.controlflow.ControlFlowGraph
|
||||
private import internal.AST
|
||||
private import internal.TreeSitter
|
||||
private import internal.Method
|
||||
|
||||
/** A callable. */
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
private import codeql_ruby.AST
|
||||
private import internal.Pattern
|
||||
private import internal.TreeSitter
|
||||
private import internal.Variable
|
||||
private import internal.Parameter
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
private import codeql_ruby.AST
|
||||
private import codeql.Locations
|
||||
private import internal.Pattern
|
||||
private import internal.TreeSitter
|
||||
private import internal.Variable
|
||||
|
||||
/** A pattern. */
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
private import codeql_ruby.AST
|
||||
private import codeql.Locations
|
||||
private import internal.TreeSitter
|
||||
private import internal.Variable
|
||||
|
||||
/** A scope in which variables can be declared. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Provides classes representing basic blocks. */
|
||||
|
||||
private import codeql.Locations
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.controlflow.ControlFlowGraph
|
||||
private import internal.ControlFlowGraphImpl
|
||||
private import CfgNodes
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/** Provides classes representing nodes in a control flow graph. */
|
||||
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.ast.internal.TreeSitter
|
||||
private import codeql_ruby.controlflow.BasicBlocks
|
||||
private import ControlFlowGraph
|
||||
private import internal.ControlFlowGraphImpl
|
||||
@@ -65,7 +64,7 @@ class ExitNode extends CfgNode, TExitNode {
|
||||
*/
|
||||
class AstCfgNode extends CfgNode, TAstNode {
|
||||
private Splits splits;
|
||||
private Generated::AstNode n;
|
||||
private AstNode n;
|
||||
|
||||
AstCfgNode() { this = TAstNode(n, splits) }
|
||||
|
||||
@@ -74,28 +73,7 @@ class AstCfgNode extends CfgNode, TAstNode {
|
||||
override Location getLocation() { result = n.getLocation() }
|
||||
|
||||
final override string toString() {
|
||||
exists(string s |
|
||||
// TODO: Replace the two disjuncts below with `s = n.(AstNode).toString()` once
|
||||
// `RemoveWhenFullCoverage` has been removed
|
||||
s = n.(AstNode).toString() and
|
||||
s != "AstNode"
|
||||
or
|
||||
n.(AstNode).toString() = "AstNode" and
|
||||
s = n.toString()
|
||||
or
|
||||
n = any(Generated::For f).getValue() and
|
||||
s = "In"
|
||||
or
|
||||
// TODO: Remove these nodes from the CFG
|
||||
n = any(Generated::Class c).getName() and
|
||||
s = n.toString()
|
||||
or
|
||||
n = any(Generated::Module m).getName() and
|
||||
s = n.toString()
|
||||
or
|
||||
n = any(Generated::ScopeResolution sc).getName() and
|
||||
s = n.toString()
|
||||
|
|
||||
exists(string s | s = n.(AstNode).toString() |
|
||||
result = "[" + this.getSplitsString() + "] " + s
|
||||
or
|
||||
not exists(this.getSplitsString()) and result = s
|
||||
@@ -145,10 +123,10 @@ abstract private class ExprChildMapping extends Expr {
|
||||
*/
|
||||
abstract predicate relevantChild(Expr child);
|
||||
|
||||
private Generated::AstNode getAChildStar() {
|
||||
private AstNode getAChildStar() {
|
||||
result = this
|
||||
or
|
||||
result.(Generated::AstNode).getParent() = this.getAChildStar()
|
||||
result.getParent() = this.getAChildStar()
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
private import codeql.Locations
|
||||
private import codeql_ruby.AST as AST
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.controlflow.BasicBlocks
|
||||
private import SuccessorTypes
|
||||
private import internal.ControlFlowGraphImpl
|
||||
@@ -15,8 +14,8 @@ class CfgScope extends AST::AstNode {
|
||||
|
||||
/** Gets the CFG scope that this scope is nested under, if any. */
|
||||
final CfgScope getOuterCfgScope() {
|
||||
exists(AstNode parent |
|
||||
parent.getAFieldOrChild() = this and
|
||||
exists(AST::AstNode parent |
|
||||
parent = this.getParent() and
|
||||
result = getCfgScope(parent)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.CFG
|
||||
private import Completion
|
||||
private import Splitting
|
||||
|
||||
@@ -208,6 +208,12 @@ private predicate isHidden(ControlFlowTree t) {
|
||||
or
|
||||
t = any(Method m).getName()
|
||||
or
|
||||
t = any(Class m).getName()
|
||||
or
|
||||
t = any(Module m).getName()
|
||||
or
|
||||
t = any(ScopeResolution m).getName()
|
||||
or
|
||||
t = any(SingletonMethod m).getName()
|
||||
or
|
||||
t = any(Call c).getMethod() and
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/** Provides a simple analysis for identifying calls that will not return. */
|
||||
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.AST
|
||||
private import Completion
|
||||
|
||||
/** A call that definitely does not return (conservative analysis). */
|
||||
abstract class NonReturningCall extends AstNode {
|
||||
abstract class NonReturningCall extends MethodCall {
|
||||
/** Gets a valid completion for this non-returning call. */
|
||||
abstract Completion getACompletion();
|
||||
}
|
||||
|
||||
private class RaiseCall extends NonReturningCall, Call {
|
||||
RaiseCall() { this.getMethod().toString() = "raise" }
|
||||
private class RaiseCall extends NonReturningCall {
|
||||
RaiseCall() { this.getMethodName() = "raise" }
|
||||
|
||||
override RaiseCompletion getACompletion() { not result instanceof NestedCompletion }
|
||||
}
|
||||
|
||||
private class ExitCall extends NonReturningCall, Call {
|
||||
ExitCall() { this.getMethod().toString() in ["abort", "exit"] }
|
||||
private class ExitCall extends NonReturningCall {
|
||||
ExitCall() { this.getMethodName() in ["abort", "exit"] }
|
||||
|
||||
override ExitCompletion getACompletion() { not result instanceof NestedCompletion }
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Provides classes and predicates relevant for splitting the control flow graph.
|
||||
*/
|
||||
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import codeql_ruby.AST
|
||||
private import AstNodes
|
||||
private import Completion
|
||||
private import ControlFlowGraphImpl
|
||||
|
||||
Reference in New Issue
Block a user