mirror of
https://github.com/github/codeql.git
synced 2026-04-24 16:25:15 +02:00
Address comments
This commit is contained in:
@@ -43,14 +43,14 @@ class Toplevel extends ModuleBase, @program {
|
||||
final override string getAPrimaryQlClass() { result = "Toplevel" }
|
||||
|
||||
/**
|
||||
* Get the `n`th `BEGIN` block.
|
||||
* Gets the `n`th `BEGIN` block.
|
||||
*/
|
||||
final StmtSequence getBeginBlock(int n) { result = range.getBeginBlock(n) }
|
||||
final BeginBlock getBeginBlock(int n) { result = range.getBeginBlock(n) }
|
||||
|
||||
/**
|
||||
* Get a `BEGIN` block.
|
||||
* Gets a `BEGIN` block.
|
||||
*/
|
||||
final StmtSequence getABeginBlock() { result = getBeginBlock(_) }
|
||||
final BeginBlock getABeginBlock() { result = getBeginBlock(_) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,10 +35,22 @@ class EmptyStmt extends Stmt, @token_empty_statement {
|
||||
final override string getAPrimaryQlClass() { result = "EmptyStmt" }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `BEGIN` block.
|
||||
* ```rb
|
||||
* BEGIN { puts "starting ..." }
|
||||
* ```
|
||||
*/
|
||||
class BeginBlock extends StmtSequence, @begin_block {
|
||||
final override BeginBlock::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "BeginBlock" }
|
||||
}
|
||||
|
||||
/**
|
||||
* An `END` block.
|
||||
* ```rb
|
||||
* END{ puts "shutting down" }
|
||||
* END { puts "shutting down" }
|
||||
* ```
|
||||
*/
|
||||
class EndBlock extends StmtSequence, @end_block {
|
||||
|
||||
@@ -22,6 +22,7 @@ moduleBases
|
||||
| modules.rb:48:1:57:3 | Bar | Module |
|
||||
| modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | Class |
|
||||
| modules.rb:60:1:61:3 | MyModuleInGlobalScope | Module |
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | Toplevel |
|
||||
moduleBaseClasses
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:3:1:4:3 | Foo |
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:7:1:8:3 | Bar |
|
||||
|
||||
8
ql/test/library-tests/ast/modules/toplevel.expected
Normal file
8
ql/test/library-tests/ast/modules/toplevel.expected
Normal file
@@ -0,0 +1,8 @@
|
||||
toplevel
|
||||
| classes.rb:2:1:56:3 | classes.rb | Toplevel |
|
||||
| modules.rb:1:1:61:3 | modules.rb | Toplevel |
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | Toplevel |
|
||||
beginBlocks
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | 1 | toplevel.rb:5:1:5:22 | BEGIN { ... } |
|
||||
endBlocks
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | toplevel.rb:3:1:3:18 | END { ... } |
|
||||
9
ql/test/library-tests/ast/modules/toplevel.ql
Normal file
9
ql/test/library-tests/ast/modules/toplevel.ql
Normal file
@@ -0,0 +1,9 @@
|
||||
import ruby
|
||||
|
||||
query predicate toplevel(Toplevel m, string pClass) { pClass = m.getAPrimaryQlClass() }
|
||||
|
||||
query predicate beginBlocks(Toplevel m, int i, BeginBlock b) { b = m.getBeginBlock(i) }
|
||||
|
||||
query predicate endBlocks(Toplevel m, EndBlock b) {
|
||||
b.getLocation().getFile() = m.getLocation().getFile()
|
||||
}
|
||||
5
ql/test/library-tests/ast/modules/toplevel.rb
Normal file
5
ql/test/library-tests/ast/modules/toplevel.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
puts "world"
|
||||
|
||||
END { puts "!!!" }
|
||||
|
||||
BEGIN { puts "hello" }
|
||||
Reference in New Issue
Block a user