mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
Move files to ruby subfolder
This commit is contained in:
42
ruby/ql/test/library-tests/ast/modules/classes.expected
Normal file
42
ruby/ql/test/library-tests/ast/modules/classes.expected
Normal file
@@ -0,0 +1,42 @@
|
||||
classes
|
||||
| classes.rb:3:1:4:3 | Foo | ClassDeclaration | Foo |
|
||||
| classes.rb:7:1:8:3 | Bar | ClassDeclaration | Bar |
|
||||
| classes.rb:11:1:12:3 | Baz | ClassDeclaration | Baz |
|
||||
| classes.rb:16:1:17:3 | MyClass | ClassDeclaration | MyClass |
|
||||
| classes.rb:20:1:37:3 | Wibble | ClassDeclaration | Wibble |
|
||||
| classes.rb:32:3:33:5 | ClassInWibble | ClassDeclaration | ClassInWibble |
|
||||
| classes.rb:55:1:56:3 | MyClassInGlobalScope | ClassDeclaration | MyClassInGlobalScope |
|
||||
| modules.rb:6:5:7:7 | ClassInFooBar | ClassDeclaration | ClassInFooBar |
|
||||
| modules.rb:19:3:20:5 | ClassInFoo | ClassDeclaration | ClassInFoo |
|
||||
| modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo | ClassDeclaration | ClassInAnotherDefinitionOfFoo |
|
||||
| modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | ClassDeclaration | ClassInAnotherDefinitionOfFooBar |
|
||||
| modules.rb:66:5:67:7 | Bar | ClassDeclaration | Bar |
|
||||
| modules.rb:72:5:73:7 | Bar | ClassDeclaration | Bar |
|
||||
| modules.rb:78:5:79:7 | Bar | ClassDeclaration | Bar |
|
||||
| modules.rb:112:1:113:3 | YY | ClassDeclaration | YY |
|
||||
| modules.rb:116:7:117:9 | YY | ClassDeclaration | YY |
|
||||
classesWithNameScopeExprs
|
||||
| classes.rb:16:1:17:3 | MyClass | classes.rb:16:7:16:14 | MyModule |
|
||||
| modules.rb:66:5:67:7 | Bar | modules.rb:66:11:66:14 | Foo1 |
|
||||
| modules.rb:72:5:73:7 | Bar | modules.rb:72:11:72:14 | Foo2 |
|
||||
| modules.rb:78:5:79:7 | Bar | modules.rb:78:11:78:14 | Foo3 |
|
||||
classesWithGlobalNameScopeExprs
|
||||
| classes.rb:55:1:56:3 | MyClassInGlobalScope |
|
||||
exprsInClasses
|
||||
| classes.rb:20:1:37:3 | Wibble | 0 | classes.rb:21:3:23:5 | method_a | Method |
|
||||
| classes.rb:20:1:37:3 | Wibble | 1 | classes.rb:25:3:27:5 | method_b | Method |
|
||||
| classes.rb:20:1:37:3 | Wibble | 2 | classes.rb:29:3:29:20 | call to some_method_call | MethodCall |
|
||||
| classes.rb:20:1:37:3 | Wibble | 3 | classes.rb:30:3:30:19 | ... = ... | AssignExpr |
|
||||
| classes.rb:20:1:37:3 | Wibble | 4 | classes.rb:32:3:33:5 | ClassInWibble | ClassDeclaration |
|
||||
| classes.rb:20:1:37:3 | Wibble | 5 | classes.rb:35:3:36:5 | ModuleInWibble | ModuleDeclaration |
|
||||
methodsInClasses
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:21:3:23:5 | method_a | method_a |
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:25:3:27:5 | method_b | method_b |
|
||||
classesInClasses
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:32:3:33:5 | ClassInWibble | ClassInWibble |
|
||||
modulesInClasses
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:35:3:36:5 | ModuleInWibble | ModuleInWibble |
|
||||
classesWithASuperclass
|
||||
| classes.rb:7:1:8:3 | Bar | classes.rb:7:13:7:21 | BaseClass |
|
||||
| classes.rb:11:1:12:3 | Baz | classes.rb:11:13:11:32 | call to superclass_for |
|
||||
| modules.rb:116:7:117:9 | YY | modules.rb:116:18:116:19 | YY |
|
||||
29
ruby/ql/test/library-tests/ast/modules/classes.ql
Normal file
29
ruby/ql/test/library-tests/ast/modules/classes.ql
Normal file
@@ -0,0 +1,29 @@
|
||||
import ruby
|
||||
|
||||
query predicate classes(ClassDeclaration c, string pClass, string name) {
|
||||
pClass = c.getAPrimaryQlClass() and name = c.getName()
|
||||
}
|
||||
|
||||
query predicate classesWithNameScopeExprs(ClassDeclaration c, Expr se) { se = c.getScopeExpr() }
|
||||
|
||||
query predicate classesWithGlobalNameScopeExprs(ClassDeclaration c) { c.hasGlobalScope() }
|
||||
|
||||
query predicate exprsInClasses(ClassDeclaration c, int i, Expr e, string eClass) {
|
||||
e = c.getStmt(i) and eClass = e.getAPrimaryQlClass()
|
||||
}
|
||||
|
||||
query predicate methodsInClasses(ClassDeclaration c, Method m, string name) {
|
||||
m = c.getMethod(name)
|
||||
}
|
||||
|
||||
query predicate classesInClasses(ClassDeclaration c, ClassDeclaration child, string name) {
|
||||
child = c.getClass(name)
|
||||
}
|
||||
|
||||
query predicate modulesInClasses(ClassDeclaration c, ModuleDeclaration m, string name) {
|
||||
m = c.getModule(name)
|
||||
}
|
||||
|
||||
query predicate classesWithASuperclass(ClassDeclaration c, Expr scExpr) {
|
||||
scExpr = c.getSuperclassExpr()
|
||||
}
|
||||
56
ruby/ql/test/library-tests/ast/modules/classes.rb
Normal file
56
ruby/ql/test/library-tests/ast/modules/classes.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
# a class with no superclass specified
|
||||
class Foo
|
||||
end
|
||||
|
||||
# a class where the superclass is a constant
|
||||
class Bar < BaseClass
|
||||
end
|
||||
|
||||
# a class where the superclass is a call expression
|
||||
class Baz < superclass_for(:baz)
|
||||
end
|
||||
|
||||
# a class where the name is a scope resolution
|
||||
module MyModule; end
|
||||
class MyModule::MyClass
|
||||
end
|
||||
|
||||
# a class with various expressions
|
||||
class Wibble
|
||||
def method_a
|
||||
puts 'a'
|
||||
end
|
||||
|
||||
def method_b
|
||||
puts 'b'
|
||||
end
|
||||
|
||||
some_method_call()
|
||||
$global_var = 123
|
||||
|
||||
class ClassInWibble
|
||||
end
|
||||
|
||||
module ModuleInWibble
|
||||
end
|
||||
end
|
||||
|
||||
# a singleton class with some methods and some other arbitrary expressions
|
||||
x = 'hello'
|
||||
class << x
|
||||
def length
|
||||
100 * super
|
||||
end
|
||||
|
||||
def wibble
|
||||
puts 'wibble'
|
||||
end
|
||||
|
||||
another_method_call
|
||||
$global_var2 = 456
|
||||
end
|
||||
|
||||
# a class where the name is a scope resolution using the global scope
|
||||
class ::MyClassInGlobalScope
|
||||
end
|
||||
102
ruby/ql/test/library-tests/ast/modules/module_base.expected
Normal file
102
ruby/ql/test/library-tests/ast/modules/module_base.expected
Normal file
@@ -0,0 +1,102 @@
|
||||
moduleBases
|
||||
| classes.rb:2:1:56:3 | classes.rb | Toplevel |
|
||||
| classes.rb:3:1:4:3 | Foo | ClassDeclaration |
|
||||
| classes.rb:7:1:8:3 | Bar | ClassDeclaration |
|
||||
| classes.rb:11:1:12:3 | Baz | ClassDeclaration |
|
||||
| classes.rb:15:1:15:20 | MyModule | ModuleDeclaration |
|
||||
| classes.rb:16:1:17:3 | MyClass | ClassDeclaration |
|
||||
| classes.rb:20:1:37:3 | Wibble | ClassDeclaration |
|
||||
| classes.rb:32:3:33:5 | ClassInWibble | ClassDeclaration |
|
||||
| classes.rb:35:3:36:5 | ModuleInWibble | ModuleDeclaration |
|
||||
| classes.rb:41:1:52:3 | class << ... | SingletonClass |
|
||||
| classes.rb:55:1:56:3 | MyClassInGlobalScope | ClassDeclaration |
|
||||
| modules.rb:1:1:2:3 | Empty | ModuleDeclaration |
|
||||
| modules.rb:1:1:122:1 | modules.rb | Toplevel |
|
||||
| modules.rb:4:1:24:3 | Foo | ModuleDeclaration |
|
||||
| modules.rb:5:3:14:5 | Bar | ModuleDeclaration |
|
||||
| modules.rb:6:5:7:7 | ClassInFooBar | ClassDeclaration |
|
||||
| modules.rb:19:3:20:5 | ClassInFoo | ClassDeclaration |
|
||||
| modules.rb:26:1:35:3 | Foo | ModuleDeclaration |
|
||||
| modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo | ClassDeclaration |
|
||||
| modules.rb:37:1:46:3 | Bar | ModuleDeclaration |
|
||||
| modules.rb:48:1:57:3 | Bar | ModuleDeclaration |
|
||||
| modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | ClassDeclaration |
|
||||
| modules.rb:60:1:61:3 | MyModuleInGlobalScope | ModuleDeclaration |
|
||||
| modules.rb:63:1:81:3 | Test | ModuleDeclaration |
|
||||
| modules.rb:65:3:68:5 | Foo1 | ModuleDeclaration |
|
||||
| modules.rb:66:5:67:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:70:3:74:5 | Foo2 | ModuleDeclaration |
|
||||
| modules.rb:71:5:71:19 | Foo2 | ModuleDeclaration |
|
||||
| modules.rb:72:5:73:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:76:3:80:5 | Foo3 | ModuleDeclaration |
|
||||
| modules.rb:78:5:79:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:83:1:86:3 | Other | ModuleDeclaration |
|
||||
| modules.rb:84:3:85:5 | Foo1 | ModuleDeclaration |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | ModuleDeclaration |
|
||||
| modules.rb:91:3:92:5 | Y | ModuleDeclaration |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | ModuleDeclaration |
|
||||
| modules.rb:97:3:98:5 | Z | ModuleDeclaration |
|
||||
| modules.rb:101:1:105:3 | PrependTest | ModuleDeclaration |
|
||||
| modules.rb:103:3:104:5 | Y | ModuleDeclaration |
|
||||
| modules.rb:107:1:110:3 | MM | ModuleDeclaration |
|
||||
| modules.rb:108:3:109:5 | MM | ModuleDeclaration |
|
||||
| modules.rb:112:1:113:3 | YY | ClassDeclaration |
|
||||
| modules.rb:115:1:118:3 | XX | ModuleDeclaration |
|
||||
| modules.rb:116:7:117:9 | YY | ClassDeclaration |
|
||||
| modules.rb:120:1:121:3 | Baz | ModuleDeclaration |
|
||||
| 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 |
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:11:1:12:3 | Baz |
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:16:1:17:3 | MyClass |
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:20:1:37:3 | Wibble |
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:55:1:56:3 | MyClassInGlobalScope |
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:32:3:33:5 | ClassInWibble |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:112:1:113:3 | YY |
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:19:3:20:5 | ClassInFoo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:6:5:7:7 | ClassInFooBar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar |
|
||||
| modules.rb:65:3:68:5 | Foo1 | modules.rb:66:5:67:7 | Bar |
|
||||
| modules.rb:70:3:74:5 | Foo2 | modules.rb:72:5:73:7 | Bar |
|
||||
| modules.rb:76:3:80:5 | Foo3 | modules.rb:78:5:79:7 | Bar |
|
||||
| modules.rb:115:1:118:3 | XX | modules.rb:116:7:117:9 | YY |
|
||||
moduleBaseMethods
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:21:3:23:5 | method_a |
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:25:3:27:5 | method_b |
|
||||
| classes.rb:41:1:52:3 | class << ... | classes.rb:42:3:44:5 | length |
|
||||
| classes.rb:41:1:52:3 | class << ... | classes.rb:46:3:48:5 | wibble |
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:16:3:17:5 | method_in_foo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:9:5:10:7 | method_in_foo_bar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:27:3:28:5 | method_in_another_definition_of_foo |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:38:3:39:5 | method_a |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:41:3:42:5 | method_b |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar |
|
||||
moduleBaseModules
|
||||
| classes.rb:2:1:56:3 | classes.rb | classes.rb:15:1:15:20 | MyModule |
|
||||
| classes.rb:20:1:37:3 | Wibble | classes.rb:35:3:36:5 | ModuleInWibble |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:1:1:2:3 | Empty |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:4:1:24:3 | Foo |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:26:1:35:3 | Foo |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:37:1:46:3 | Bar |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:48:1:57:3 | Bar |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:60:1:61:3 | MyModuleInGlobalScope |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:63:1:81:3 | Test |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:83:1:86:3 | Other |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:88:1:93:3 | IncludeTest |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:95:1:99:3 | IncludeTest2 |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:101:1:105:3 | PrependTest |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:107:1:110:3 | MM |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:115:1:118:3 | XX |
|
||||
| modules.rb:1:1:122:1 | modules.rb | modules.rb:120:1:121:3 | Baz |
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:5:3:14:5 | Bar |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:65:3:68:5 | Foo1 |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:70:3:74:5 | Foo2 |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:76:3:80:5 | Foo3 |
|
||||
| modules.rb:70:3:74:5 | Foo2 | modules.rb:71:5:71:19 | Foo2 |
|
||||
| modules.rb:83:1:86:3 | Other | modules.rb:84:3:85:5 | Foo1 |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | modules.rb:91:3:92:5 | Y |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | modules.rb:97:3:98:5 | Z |
|
||||
| modules.rb:101:1:105:3 | PrependTest | modules.rb:103:3:104:5 | Y |
|
||||
| modules.rb:107:1:110:3 | MM | modules.rb:108:3:109:5 | MM |
|
||||
9
ruby/ql/test/library-tests/ast/modules/module_base.ql
Normal file
9
ruby/ql/test/library-tests/ast/modules/module_base.ql
Normal file
@@ -0,0 +1,9 @@
|
||||
import ruby
|
||||
|
||||
query predicate moduleBases(ModuleBase mb, string pClass) { pClass = mb.getAPrimaryQlClass() }
|
||||
|
||||
query predicate moduleBaseClasses(ModuleBase mb, ClassDeclaration c) { c = mb.getAClass() }
|
||||
|
||||
query predicate moduleBaseMethods(ModuleBase mb, Method m) { m = mb.getAMethod() }
|
||||
|
||||
query predicate moduleBaseModules(ModuleBase mb, ModuleDeclaration m) { m = mb.getAModule() }
|
||||
103
ruby/ql/test/library-tests/ast/modules/modules.expected
Normal file
103
ruby/ql/test/library-tests/ast/modules/modules.expected
Normal file
@@ -0,0 +1,103 @@
|
||||
modules
|
||||
| classes.rb:15:1:15:20 | MyModule | ModuleDeclaration | MyModule |
|
||||
| classes.rb:35:3:36:5 | ModuleInWibble | ModuleDeclaration | ModuleInWibble |
|
||||
| modules.rb:1:1:2:3 | Empty | ModuleDeclaration | Empty |
|
||||
| modules.rb:4:1:24:3 | Foo | ModuleDeclaration | Foo |
|
||||
| modules.rb:5:3:14:5 | Bar | ModuleDeclaration | Bar |
|
||||
| modules.rb:26:1:35:3 | Foo | ModuleDeclaration | Foo |
|
||||
| modules.rb:37:1:46:3 | Bar | ModuleDeclaration | Bar |
|
||||
| modules.rb:48:1:57:3 | Bar | ModuleDeclaration | Bar |
|
||||
| modules.rb:60:1:61:3 | MyModuleInGlobalScope | ModuleDeclaration | MyModuleInGlobalScope |
|
||||
| modules.rb:63:1:81:3 | Test | ModuleDeclaration | Test |
|
||||
| modules.rb:65:3:68:5 | Foo1 | ModuleDeclaration | Foo1 |
|
||||
| modules.rb:70:3:74:5 | Foo2 | ModuleDeclaration | Foo2 |
|
||||
| modules.rb:71:5:71:19 | Foo2 | ModuleDeclaration | Foo2 |
|
||||
| modules.rb:76:3:80:5 | Foo3 | ModuleDeclaration | Foo3 |
|
||||
| modules.rb:83:1:86:3 | Other | ModuleDeclaration | Other |
|
||||
| modules.rb:84:3:85:5 | Foo1 | ModuleDeclaration | Foo1 |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | ModuleDeclaration | IncludeTest |
|
||||
| modules.rb:91:3:92:5 | Y | ModuleDeclaration | Y |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | ModuleDeclaration | IncludeTest2 |
|
||||
| modules.rb:97:3:98:5 | Z | ModuleDeclaration | Z |
|
||||
| modules.rb:101:1:105:3 | PrependTest | ModuleDeclaration | PrependTest |
|
||||
| modules.rb:103:3:104:5 | Y | ModuleDeclaration | Y |
|
||||
| modules.rb:107:1:110:3 | MM | ModuleDeclaration | MM |
|
||||
| modules.rb:108:3:109:5 | MM | ModuleDeclaration | MM |
|
||||
| modules.rb:115:1:118:3 | XX | ModuleDeclaration | XX |
|
||||
| modules.rb:120:1:121:3 | Baz | ModuleDeclaration | Baz |
|
||||
modulesWithScopeExprs
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:48:8:48:10 | Foo |
|
||||
| modules.rb:91:3:92:5 | Y | modules.rb:91:10:91:13 | Foo1 |
|
||||
| modules.rb:97:3:98:5 | Z | modules.rb:97:10:97:13 | Foo1 |
|
||||
| modules.rb:103:3:104:5 | Y | modules.rb:103:10:103:13 | Foo2 |
|
||||
| modules.rb:108:3:109:5 | MM | modules.rb:108:10:108:11 | MM |
|
||||
| modules.rb:120:1:121:3 | Baz | modules.rb:120:8:120:22 | Bar |
|
||||
modulesWithGlobalNameScopeExprs
|
||||
| modules.rb:60:1:61:3 | MyModuleInGlobalScope |
|
||||
exprsInModules
|
||||
| modules.rb:4:1:24:3 | Foo | 0 | modules.rb:5:3:14:5 | Bar | ModuleDeclaration |
|
||||
| modules.rb:4:1:24:3 | Foo | 1 | modules.rb:16:3:17:5 | method_in_foo | Method |
|
||||
| modules.rb:4:1:24:3 | Foo | 2 | modules.rb:19:3:20:5 | ClassInFoo | ClassDeclaration |
|
||||
| modules.rb:4:1:24:3 | Foo | 3 | modules.rb:22:3:22:19 | call to puts | MethodCall |
|
||||
| modules.rb:4:1:24:3 | Foo | 4 | modules.rb:23:3:23:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:5:3:14:5 | Bar | 0 | modules.rb:6:5:7:7 | ClassInFooBar | ClassDeclaration |
|
||||
| modules.rb:5:3:14:5 | Bar | 1 | modules.rb:9:5:10:7 | method_in_foo_bar | Method |
|
||||
| modules.rb:5:3:14:5 | Bar | 2 | modules.rb:12:5:12:26 | call to puts | MethodCall |
|
||||
| modules.rb:5:3:14:5 | Bar | 3 | modules.rb:13:5:13:19 | ... = ... | AssignExpr |
|
||||
| modules.rb:26:1:35:3 | Foo | 0 | modules.rb:27:3:28:5 | method_in_another_definition_of_foo | Method |
|
||||
| modules.rb:26:1:35:3 | Foo | 1 | modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo | ClassDeclaration |
|
||||
| modules.rb:26:1:35:3 | Foo | 2 | modules.rb:33:3:33:25 | call to puts | MethodCall |
|
||||
| modules.rb:26:1:35:3 | Foo | 3 | modules.rb:34:3:34:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:37:1:46:3 | Bar | 0 | modules.rb:38:3:39:5 | method_a | Method |
|
||||
| modules.rb:37:1:46:3 | Bar | 1 | modules.rb:41:3:42:5 | method_b | Method |
|
||||
| modules.rb:37:1:46:3 | Bar | 2 | modules.rb:44:3:44:19 | call to puts | MethodCall |
|
||||
| modules.rb:37:1:46:3 | Bar | 3 | modules.rb:45:3:45:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:48:1:57:3 | Bar | 0 | modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | ClassDeclaration |
|
||||
| modules.rb:48:1:57:3 | Bar | 1 | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar | Method |
|
||||
| modules.rb:48:1:57:3 | Bar | 2 | modules.rb:55:3:55:30 | call to puts | MethodCall |
|
||||
| modules.rb:48:1:57:3 | Bar | 3 | modules.rb:56:3:56:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:63:1:81:3 | Test | 0 | modules.rb:65:3:68:5 | Foo1 | ModuleDeclaration |
|
||||
| modules.rb:63:1:81:3 | Test | 1 | modules.rb:70:3:74:5 | Foo2 | ModuleDeclaration |
|
||||
| modules.rb:63:1:81:3 | Test | 2 | modules.rb:76:3:80:5 | Foo3 | ModuleDeclaration |
|
||||
| modules.rb:65:3:68:5 | Foo1 | 0 | modules.rb:66:5:67:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:70:3:74:5 | Foo2 | 0 | modules.rb:71:5:71:19 | Foo2 | ModuleDeclaration |
|
||||
| modules.rb:70:3:74:5 | Foo2 | 1 | modules.rb:72:5:73:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:76:3:80:5 | Foo3 | 0 | modules.rb:77:5:77:17 | ... = ... | AssignExpr |
|
||||
| modules.rb:76:3:80:5 | Foo3 | 1 | modules.rb:78:5:79:7 | Bar | ClassDeclaration |
|
||||
| modules.rb:83:1:86:3 | Other | 0 | modules.rb:84:3:85:5 | Foo1 | ModuleDeclaration |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | 0 | modules.rb:89:3:89:16 | call to include | MethodCall |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | 1 | modules.rb:90:3:90:38 | call to module_eval | MethodCall |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | 2 | modules.rb:91:3:92:5 | Y | ModuleDeclaration |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | 0 | modules.rb:96:3:96:14 | call to include | MethodCall |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | 1 | modules.rb:97:3:98:5 | Z | ModuleDeclaration |
|
||||
| modules.rb:101:1:105:3 | PrependTest | 0 | modules.rb:102:3:102:16 | call to prepend | MethodCall |
|
||||
| modules.rb:101:1:105:3 | PrependTest | 1 | modules.rb:103:3:104:5 | Y | ModuleDeclaration |
|
||||
| modules.rb:107:1:110:3 | MM | 0 | modules.rb:108:3:109:5 | MM | ModuleDeclaration |
|
||||
| modules.rb:115:1:118:3 | XX | 0 | modules.rb:116:7:117:9 | YY | ClassDeclaration |
|
||||
methodsInModules
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:16:3:17:5 | method_in_foo | method_in_foo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:9:5:10:7 | method_in_foo_bar | method_in_foo_bar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:27:3:28:5 | method_in_another_definition_of_foo | method_in_another_definition_of_foo |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:38:3:39:5 | method_a | method_a |
|
||||
| modules.rb:37:1:46:3 | Bar | modules.rb:41:3:42:5 | method_b | method_b |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar | method_in_another_definition_of_foo_bar |
|
||||
classesInModules
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:19:3:20:5 | ClassInFoo | ClassInFoo |
|
||||
| modules.rb:5:3:14:5 | Bar | modules.rb:6:5:7:7 | ClassInFooBar | ClassInFooBar |
|
||||
| modules.rb:26:1:35:3 | Foo | modules.rb:30:3:31:5 | ClassInAnotherDefinitionOfFoo | ClassInAnotherDefinitionOfFoo |
|
||||
| modules.rb:48:1:57:3 | Bar | modules.rb:49:3:50:5 | ClassInAnotherDefinitionOfFooBar | ClassInAnotherDefinitionOfFooBar |
|
||||
| modules.rb:65:3:68:5 | Foo1 | modules.rb:66:5:67:7 | Bar | Bar |
|
||||
| modules.rb:70:3:74:5 | Foo2 | modules.rb:72:5:73:7 | Bar | Bar |
|
||||
| modules.rb:76:3:80:5 | Foo3 | modules.rb:78:5:79:7 | Bar | Bar |
|
||||
| modules.rb:115:1:118:3 | XX | modules.rb:116:7:117:9 | YY | YY |
|
||||
modulesInModules
|
||||
| modules.rb:4:1:24:3 | Foo | modules.rb:5:3:14:5 | Bar | Bar |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:65:3:68:5 | Foo1 | Foo1 |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:70:3:74:5 | Foo2 | Foo2 |
|
||||
| modules.rb:63:1:81:3 | Test | modules.rb:76:3:80:5 | Foo3 | Foo3 |
|
||||
| modules.rb:70:3:74:5 | Foo2 | modules.rb:71:5:71:19 | Foo2 | Foo2 |
|
||||
| modules.rb:83:1:86:3 | Other | modules.rb:84:3:85:5 | Foo1 | Foo1 |
|
||||
| modules.rb:88:1:93:3 | IncludeTest | modules.rb:91:3:92:5 | Y | Y |
|
||||
| modules.rb:95:1:99:3 | IncludeTest2 | modules.rb:97:3:98:5 | Z | Z |
|
||||
| modules.rb:101:1:105:3 | PrependTest | modules.rb:103:3:104:5 | Y | Y |
|
||||
| modules.rb:107:1:110:3 | MM | modules.rb:108:3:109:5 | MM | MM |
|
||||
25
ruby/ql/test/library-tests/ast/modules/modules.ql
Normal file
25
ruby/ql/test/library-tests/ast/modules/modules.ql
Normal file
@@ -0,0 +1,25 @@
|
||||
import ruby
|
||||
|
||||
query predicate modules(ModuleDeclaration m, string pClass, string name) {
|
||||
pClass = m.getAPrimaryQlClass() and name = m.getName()
|
||||
}
|
||||
|
||||
query predicate modulesWithScopeExprs(ModuleDeclaration m, Expr se) { se = m.getScopeExpr() }
|
||||
|
||||
query predicate modulesWithGlobalNameScopeExprs(ModuleDeclaration m) { m.hasGlobalScope() }
|
||||
|
||||
query predicate exprsInModules(ModuleDeclaration m, int i, Expr e, string eClass) {
|
||||
e = m.getStmt(i) and eClass = e.getAPrimaryQlClass()
|
||||
}
|
||||
|
||||
query predicate methodsInModules(ModuleDeclaration mod, Method method, string name) {
|
||||
method = mod.getMethod(name)
|
||||
}
|
||||
|
||||
query predicate classesInModules(ModuleDeclaration mod, ClassDeclaration klass, string name) {
|
||||
klass = mod.getClass(name)
|
||||
}
|
||||
|
||||
query predicate modulesInModules(ModuleDeclaration mod, ModuleDeclaration child, string name) {
|
||||
child = mod.getModule(name)
|
||||
}
|
||||
122
ruby/ql/test/library-tests/ast/modules/modules.rb
Normal file
122
ruby/ql/test/library-tests/ast/modules/modules.rb
Normal file
@@ -0,0 +1,122 @@
|
||||
module Empty
|
||||
end
|
||||
|
||||
module Foo
|
||||
module Bar
|
||||
class ClassInFooBar
|
||||
end
|
||||
|
||||
def method_in_foo_bar
|
||||
end
|
||||
|
||||
puts 'module Foo::Bar'
|
||||
$global_var = 0
|
||||
end
|
||||
|
||||
def method_in_foo
|
||||
end
|
||||
|
||||
class ClassInFoo
|
||||
end
|
||||
|
||||
puts 'module Foo'
|
||||
$global_var = 1
|
||||
end
|
||||
|
||||
module Foo
|
||||
def method_in_another_definition_of_foo
|
||||
end
|
||||
|
||||
class ClassInAnotherDefinitionOfFoo
|
||||
end
|
||||
|
||||
puts 'module Foo again'
|
||||
$global_var = 2
|
||||
end
|
||||
|
||||
module Bar
|
||||
def method_a
|
||||
end
|
||||
|
||||
def method_b
|
||||
end
|
||||
|
||||
puts 'module Bar'
|
||||
$global_var = 3
|
||||
end
|
||||
|
||||
module Foo::Bar
|
||||
class ClassInAnotherDefinitionOfFooBar
|
||||
end
|
||||
|
||||
def method_in_another_definition_of_foo_bar
|
||||
end
|
||||
|
||||
puts 'module Foo::Bar again'
|
||||
$global_var = 4
|
||||
end
|
||||
|
||||
# a module where the name is a scope resolution using the global scope
|
||||
module ::MyModuleInGlobalScope
|
||||
end
|
||||
|
||||
module Test
|
||||
|
||||
module Foo1
|
||||
class Foo1::Bar
|
||||
end
|
||||
end
|
||||
|
||||
module Foo2
|
||||
module Foo2 end
|
||||
class Foo2::Bar
|
||||
end
|
||||
end
|
||||
|
||||
module Foo3
|
||||
Foo3 = Object
|
||||
class Foo3::Bar
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Other
|
||||
module Foo1
|
||||
end
|
||||
end
|
||||
|
||||
module IncludeTest
|
||||
include ::Test
|
||||
Object.module_eval { prepend Other }
|
||||
module Foo1::Y
|
||||
end
|
||||
end
|
||||
|
||||
module IncludeTest2
|
||||
include Test
|
||||
module Foo1::Z
|
||||
end
|
||||
end
|
||||
|
||||
module PrependTest
|
||||
prepend ::Test
|
||||
module Foo2::Y
|
||||
end
|
||||
end
|
||||
|
||||
module MM
|
||||
module MM::MM
|
||||
end
|
||||
end
|
||||
|
||||
class YY
|
||||
end
|
||||
|
||||
module XX
|
||||
class YY < YY
|
||||
end
|
||||
end
|
||||
|
||||
module Test::Foo1::Bar::Baz
|
||||
end
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
singletonClasses
|
||||
| classes.rb:41:1:52:3 | class << ... | SingletonClass | classes.rb:41:10:41:10 | x |
|
||||
exprsInSingletonClasses
|
||||
| classes.rb:41:1:52:3 | class << ... | 0 | classes.rb:42:3:44:5 | length | Method |
|
||||
| classes.rb:41:1:52:3 | class << ... | 1 | classes.rb:46:3:48:5 | wibble | Method |
|
||||
| classes.rb:41:1:52:3 | class << ... | 2 | classes.rb:50:3:50:21 | call to another_method_call | MethodCall |
|
||||
| classes.rb:41:1:52:3 | class << ... | 3 | classes.rb:51:3:51:20 | ... = ... | AssignExpr |
|
||||
methodsInSingletonClasses
|
||||
| classes.rb:41:1:52:3 | class << ... | classes.rb:42:3:44:5 | length |
|
||||
| classes.rb:41:1:52:3 | class << ... | classes.rb:46:3:48:5 | wibble |
|
||||
11
ruby/ql/test/library-tests/ast/modules/singleton_classes.ql
Normal file
11
ruby/ql/test/library-tests/ast/modules/singleton_classes.ql
Normal file
@@ -0,0 +1,11 @@
|
||||
import ruby
|
||||
|
||||
query predicate singletonClasses(SingletonClass sc, string pClass, Expr value) {
|
||||
pClass = sc.getAPrimaryQlClass() and value = sc.getValue()
|
||||
}
|
||||
|
||||
query predicate exprsInSingletonClasses(SingletonClass sc, int i, Expr e, string eClass) {
|
||||
e = sc.getStmt(i) and eClass = e.getAPrimaryQlClass()
|
||||
}
|
||||
|
||||
query predicate methodsInSingletonClasses(SingletonClass sc, Method m) { m = sc.getAMethod() }
|
||||
8
ruby/ql/test/library-tests/ast/modules/toplevel.expected
Normal file
8
ruby/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:122:1 | modules.rb | Toplevel |
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | Toplevel |
|
||||
beginBlocks
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | 0 | toplevel.rb:5:1:5:22 | BEGIN { ... } |
|
||||
endBlocks
|
||||
| toplevel.rb:1:1:5:23 | toplevel.rb | toplevel.rb:3:1:3:18 | END { ... } |
|
||||
9
ruby/ql/test/library-tests/ast/modules/toplevel.ql
Normal file
9
ruby/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
ruby/ql/test/library-tests/ast/modules/toplevel.rb
Normal file
5
ruby/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