Ruby: Hide SynthBlock from the public API

This commit is contained in:
Tom Hvitved
2021-11-10 15:05:43 +01:00
parent 8603609698
commit db6f843641
2 changed files with 23 additions and 19 deletions

View File

@@ -2,6 +2,7 @@ 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. */
class Callable extends StmtSequence, Expr, Scope, TCallable {
@@ -182,6 +183,8 @@ class Block extends Callable, StmtSequence, Scope, TBlock {
or
result = StmtSequence.super.getAChild(pred)
}
override string getAPrimaryQlClass() { result = "Block" }
}
/** A block enclosed within `do` and `end`. */
@@ -226,22 +229,3 @@ class BraceBlock extends Block, TBraceBlock {
final override string getAPrimaryQlClass() { result = "BraceBlock" }
}
/**
* A synthesized block, such as the block synthesized from the body of
* a `for` loop.
*/
class SynthBlock extends Block, TBlockSynth {
SynthBlock() { this = TBlockSynth(_, _) }
final override Parameter getParameter(int n) { synthChild(this, n, result) }
final override Stmt getStmt(int i) {
i >= 0 and
synthChild(this, i + this.getNumberOfParameters(), result)
}
final override string toString() { result = "{ ... }" }
final override string getAPrimaryQlClass() { result = "SynthBlock" }
}

View File

@@ -0,0 +1,20 @@
private import codeql.ruby.AST
private import AST
private import TreeSitter
/**
* A synthesized block, such as the block synthesized from the body of
* a `for` loop.
*/
class SynthBlock extends Block, TBlockSynth {
SynthBlock() { this = TBlockSynth(_, _) }
final override Parameter getParameter(int n) { synthChild(this, n, result) }
final override Stmt getStmt(int i) {
i >= 0 and
synthChild(this, i + this.getNumberOfParameters(), result)
}
final override string toString() { result = "{ ... }" }
}