From d361ef37afacb2acbd96da2df017c932bae16d4e Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Fri, 9 Apr 2021 18:34:09 +0200 Subject: [PATCH] Rename Method -> MethodDeclaration --- ql/src/codeql_ruby/ast/Expr.qll | 2 +- ql/src/codeql_ruby/ast/Method.qll | 6 +- ql/src/codeql_ruby/ast/internal/AST.qll | 9 +-- .../internal/ControlFlowGraphImpl.qll | 2 +- .../dataflow/internal/DataFlowPrivate.qll | 6 +- ql/test/library-tests/ast/Ast.expected | 56 +++++++++---------- .../ast/modules/classes.expected | 4 +- ql/test/library-tests/ast/modules/classes.ql | 2 +- .../library-tests/ast/modules/module_base.ql | 2 +- .../ast/modules/modules.expected | 12 ++-- ql/test/library-tests/ast/modules/modules.ql | 2 +- .../ast/modules/singleton_classes.expected | 4 +- .../ast/modules/singleton_classes.ql | 4 +- ql/test/library-tests/ast/params/params.ql | 2 +- 14 files changed, 60 insertions(+), 53 deletions(-) diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index 4e44bc98a25..04fc3023d93 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -123,7 +123,7 @@ private class Ensure extends StmtSequence, TEnsure { class BodyStmt extends StmtSequence, TBodyStmt { // Not defined by dispatch, as it should not be exposed private Generated::AstNode getChild(int i) { - result = any(Generated::Method g | this = TMethod(g)).getChild(i) + result = any(Generated::Method g | this = TMethodDeclaration(g)).getChild(i) or result = any(Generated::SingletonMethod g | this = TSingletonMethod(g)).getChild(i) or diff --git a/ql/src/codeql_ruby/ast/Method.qll b/ql/src/codeql_ruby/ast/Method.qll index 648392b28f0..f01eba6c323 100644 --- a/ql/src/codeql_ruby/ast/Method.qll +++ b/ql/src/codeql_ruby/ast/Method.qll @@ -32,12 +32,12 @@ class MethodBase extends Callable, BodyStmt, Scope, TMethodBase { } /** A normal method. */ -class Method extends MethodBase, TMethod { +class MethodDeclaration extends MethodBase, TMethodDeclaration { private Generated::Method g; - Method() { this = TMethod(g) } + MethodDeclaration() { this = TMethodDeclaration(g) } - final override string getAPrimaryQlClass() { result = "Method" } + final override string getAPrimaryQlClass() { result = "MethodDeclaration" } final override string getName() { result = g.getName().(Generated::Token).getValue() or diff --git a/ql/src/codeql_ruby/ast/internal/AST.qll b/ql/src/codeql_ruby/ast/internal/AST.qll index 26e2e6149c3..b78c6c19bf0 100644 --- a/ql/src/codeql_ruby/ast/internal/AST.qll +++ b/ql/src/codeql_ruby/ast/internal/AST.qll @@ -138,7 +138,7 @@ private module Cached { g instanceof @binary_and or g instanceof @binary_ampersandampersand } or TLogicalOrExpr(Generated::Binary g) { g instanceof @binary_or or g instanceof @binary_pipepipe } or - TMethod(Generated::Method g) or + TMethodDeclaration(Generated::Method g) or TModuleDeclaration(Generated::Module g) or TModuloExpr(Generated::Binary g) { g instanceof @binary_percent } or TMulExpr(Generated::Binary g) { g instanceof @binary_star } or @@ -301,7 +301,7 @@ private module Cached { n = TLocalVariableAccess(result, _) or n = TLogicalAndExpr(result) or n = TLogicalOrExpr(result) or - n = TMethod(result) or + n = TMethodDeclaration(result) or n = TModuleDeclaration(result) or n = TModuloExpr(result) or n = TMulExpr(result) or @@ -402,7 +402,8 @@ class TStmtSequence = TBeginBlock or TEndBlock or TThen or TElse or TDo or TEnsure or TStringInterpolationComponent or TBlock or TBodyStmt or TParenthesizedExpr; -class TBodyStmt = TBeginExpr or TModuleBase or TMethod or TLambda or TDoBlock or TSingletonMethod; +class TBodyStmt = + TBeginExpr or TModuleBase or TMethodDeclaration or TLambda or TDoBlock or TSingletonMethod; class TLiteral = TNumericLiteral or TNilLiteral or TBooleanLiteral or TStringlikeLiteral or TCharacterLiteral or @@ -428,7 +429,7 @@ class TArrayLiteral = TRegularArrayLiteral or TStringArrayLiteral or TSymbolArra class TCallable = TMethodBase or TLambda or TBlock; -class TMethodBase = TMethod or TSingletonMethod; +class TMethodBase = TMethodDeclaration or TSingletonMethod; class TBlock = TDoBlock or TBraceBlock; diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index a648a2c1b71..45ca798d99d 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -925,7 +925,7 @@ module Trees { private class MethodNameTree extends LeafTree, MethodName, ASTInternal::TTokenMethodName { } - private class MethodTree extends BodyStmtPostOrderTree, Method { + private class MethodDeclarationTree extends BodyStmtPostOrderTree, MethodDeclaration { /** Gets the `i`th child in the body of this block. */ final override AstNode getBodyChild(int i, boolean rescuable) { result = this.getParameter(i) and rescuable = false diff --git a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll index 09c84fda825..f21a08a9cf3 100644 --- a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll +++ b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll @@ -269,7 +269,11 @@ private module ReturnNodes { scope = node.getScope() | stmt instanceof ReturnStmt and - (scope instanceof Method or scope instanceof SingletonMethod or scope instanceof Lambda) + ( + scope instanceof MethodDeclaration or + scope instanceof SingletonMethod or + scope instanceof Lambda + ) or stmt instanceof NextStmt and (scope instanceof Block or scope instanceof Lambda) diff --git a/ql/test/library-tests/ast/Ast.expected b/ql/test/library-tests/ast/Ast.expected index 7078ea3c675..26e31fac3f5 100644 --- a/ql/test/library-tests/ast/Ast.expected +++ b/ql/test/library-tests/ast/Ast.expected @@ -34,9 +34,9 @@ calls/calls.rb: # 26| getStmt: [AddExpr] ... + ... # 26| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 26| getAnOperand/getRightOperand: [IntegerLiteral] 1 -# 30| getStmt: [Method] method_that_yields +# 30| getStmt: [MethodDeclaration] method_that_yields # 31| getStmt: [YieldCall] yield ... -# 35| getStmt: [Method] another_method_that_yields +# 35| getStmt: [MethodDeclaration] another_method_that_yields # 36| getStmt: [YieldCall] yield ... # 36| getArgument: [IntegerLiteral] 100 # 36| getArgument: [IntegerLiteral] 200 @@ -145,7 +145,7 @@ calls/calls.rb: # 131| getReceiver: [ConstantReadAccess] X # 132| getStmt: [MethodCall] call to bar # 132| getReceiver: [ConstantReadAccess] X -# 136| getStmt: [Method] some_method +# 136| getStmt: [MethodDeclaration] some_method # 137| getStmt: [MethodCall] call to foo # 138| getStmt: [MethodCall] call to bar # 138| getReceiver: [ConstantReadAccess] X @@ -154,20 +154,20 @@ calls/calls.rb: # 143| getStmt: [MethodCall] call to bar # 144| getStmt: [MethodCall] call to baz # 144| getReceiver: [ConstantReadAccess] X -# 148| getStmt: [Method] method_with_keyword_param +# 148| getStmt: [MethodDeclaration] method_with_keyword_param # 148| getParameter: [KeywordParameter] keyword # 148| getDefiningAccess: [LocalVariableAccess] keyword # 148| getDefaultValue: [MethodCall] call to foo -# 150| getStmt: [Method] method_with_keyword_param2 +# 150| getStmt: [MethodDeclaration] method_with_keyword_param2 # 150| getParameter: [KeywordParameter] keyword # 150| getDefiningAccess: [LocalVariableAccess] keyword # 150| getDefaultValue: [MethodCall] call to foo # 150| getReceiver: [ConstantReadAccess] X -# 154| getStmt: [Method] method_with_optional_param +# 154| getStmt: [MethodDeclaration] method_with_optional_param # 154| getParameter: [OptionalParameter] param # 154| getDefiningAccess: [LocalVariableAccess] param # 154| getDefaultValue: [MethodCall] call to foo -# 156| getStmt: [Method] method_with_optional_param2 +# 156| getStmt: [MethodDeclaration] method_with_optional_param2 # 156| getParameter: [OptionalParameter] param # 156| getDefiningAccess: [LocalVariableAccess] param # 156| getDefaultValue: [MethodCall] call to foo @@ -377,7 +377,7 @@ calls/calls.rb: # 279| getValue: [MethodCall] call to bar # 279| getReceiver: [ConstantReadAccess] X # 284| getStmt: [ClassDeclaration] MyClass -# 285| getStmt: [Method] my_method +# 285| getStmt: [MethodDeclaration] my_method # 286| getStmt: [SuperCall] call to super # 287| getStmt: [SuperCall] call to super # 288| getStmt: [SuperCall] call to super @@ -420,7 +420,7 @@ calls/calls.rb: # 293| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 293| getAnOperand/getRightOperand: [IntegerLiteral] 200 # 301| getStmt: [ClassDeclaration] AnotherClass -# 302| getStmt: [Method] another_method +# 302| getStmt: [MethodDeclaration] another_method # 303| getStmt: [MethodCall] call to super # 303| getReceiver: [MethodCall] call to foo # 304| getStmt: [MethodCall] call to super @@ -532,11 +532,11 @@ modules/classes.rb: # 16| getStmt: [ClassDeclaration] MyClass # 16| getScopeExpr: [ConstantReadAccess] MyModule # 20| getStmt: [ClassDeclaration] Wibble -# 21| getStmt: [Method] method_a +# 21| getStmt: [MethodDeclaration] method_a # 22| getStmt: [MethodCall] call to puts # 22| getArgument: [StringLiteral] "a" # 22| getComponent: [StringTextComponent] a -# 25| getStmt: [Method] method_b +# 25| getStmt: [MethodDeclaration] method_b # 26| getStmt: [MethodCall] call to puts # 26| getArgument: [StringLiteral] "b" # 26| getComponent: [StringTextComponent] b @@ -552,11 +552,11 @@ modules/classes.rb: # 40| getComponent: [StringTextComponent] hello # 41| getStmt: [ClassDeclaration] class << ... # 41| getValue: [LocalVariableAccess] x -# 42| getStmt: [Method] length +# 42| getStmt: [MethodDeclaration] length # 43| getStmt: [MulExpr] ... * ... # 43| getAnOperand/getLeftOperand: [IntegerLiteral] 100 # 43| getAnOperand/getRightOperand: [SuperCall] call to super -# 46| getStmt: [Method] wibble +# 46| getStmt: [MethodDeclaration] wibble # 47| getStmt: [MethodCall] call to puts # 47| getArgument: [StringLiteral] "wibble" # 47| getComponent: [StringTextComponent] wibble @@ -700,7 +700,7 @@ constants/constants.rb: # 14| getAnOperand/getLeftOperand: [ConstantAssignment] GREETING # 14| getAnOperand/getRightOperand: [StringLiteral] "Hello" # 14| getComponent: [StringTextComponent] Hello -# 16| getStmt: [Method] foo +# 16| getStmt: [MethodDeclaration] foo # 17| getStmt: [AssignExpr] ... = ... # 17| getAnOperand/getLeftOperand: [ConstantAssignment] Names # 17| getAnOperand/getRightOperand: [ArrayLiteral] [...] @@ -1096,7 +1096,7 @@ literals/literals.rb: # 154| getStmt: [MethodCall] call to name # 154| getComponent: [StringTextComponent] # 154| -# 157| getStmt: [Method] m +# 157| getStmt: [MethodDeclaration] m # 158| getStmt: [AssignExpr] ... = ... # 158| getAnOperand/getLeftOperand: [LocalVariableAccess] query # 158| getAnOperand/getRightOperand: [HereDoc] <<-BLA @@ -1326,14 +1326,14 @@ modules/modules.rb: # 4| getStmt: [ModuleDeclaration] Foo # 5| getStmt: [ModuleDeclaration] Bar # 6| getStmt: [ClassDeclaration] ClassInFooBar -# 9| getStmt: [Method] method_in_foo_bar +# 9| getStmt: [MethodDeclaration] method_in_foo_bar # 12| getStmt: [MethodCall] call to puts # 12| getArgument: [StringLiteral] "module Foo::Bar" # 12| getComponent: [StringTextComponent] module Foo::Bar # 13| getStmt: [AssignExpr] ... = ... # 13| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var # 13| getAnOperand/getRightOperand: [IntegerLiteral] 0 -# 16| getStmt: [Method] method_in_foo +# 16| getStmt: [MethodDeclaration] method_in_foo # 19| getStmt: [ClassDeclaration] ClassInFoo # 22| getStmt: [MethodCall] call to puts # 22| getArgument: [StringLiteral] "module Foo" @@ -1342,7 +1342,7 @@ modules/modules.rb: # 23| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var # 23| getAnOperand/getRightOperand: [IntegerLiteral] 1 # 26| getStmt: [ModuleDeclaration] Foo -# 27| getStmt: [Method] method_in_another_definition_of_foo +# 27| getStmt: [MethodDeclaration] method_in_another_definition_of_foo # 30| getStmt: [ClassDeclaration] ClassInAnotherDefinitionOfFoo # 33| getStmt: [MethodCall] call to puts # 33| getArgument: [StringLiteral] "module Foo again" @@ -1351,8 +1351,8 @@ modules/modules.rb: # 34| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var # 34| getAnOperand/getRightOperand: [IntegerLiteral] 2 # 37| getStmt: [ModuleDeclaration] Bar -# 38| getStmt: [Method] method_a -# 41| getStmt: [Method] method_b +# 38| getStmt: [MethodDeclaration] method_a +# 41| getStmt: [MethodDeclaration] method_b # 44| getStmt: [MethodCall] call to puts # 44| getArgument: [StringLiteral] "module Bar" # 44| getComponent: [StringTextComponent] module Bar @@ -1362,7 +1362,7 @@ modules/modules.rb: # 48| getStmt: [ModuleDeclaration] Bar # 48| getScopeExpr: [ConstantReadAccess] Foo # 49| getStmt: [ClassDeclaration] ClassInAnotherDefinitionOfFooBar -# 52| getStmt: [Method] method_in_another_definition_of_foo_bar +# 52| getStmt: [MethodDeclaration] method_in_another_definition_of_foo_bar # 55| getStmt: [MethodCall] call to puts # 55| getArgument: [StringLiteral] "module Foo::Bar again" # 55| getComponent: [StringTextComponent] module Foo::Bar again @@ -1603,7 +1603,7 @@ operations/operations.rb: # 84| getAnOperand/getRightOperand: [LocalVariableAccess] qux params/params.rb: # 1| [Toplevel] params.rb -# 4| getStmt: [Method] identifier_method_params +# 4| getStmt: [MethodDeclaration] identifier_method_params # 4| getParameter: [SimpleParameter] foo # 4| getDefiningAccess: [LocalVariableAccess] foo # 4| getParameter: [SimpleParameter] bar @@ -1637,7 +1637,7 @@ params/params.rb: # 14| getStmt: [AddExpr] ... + ... # 14| getAnOperand/getLeftOperand: [LocalVariableAccess] foo # 14| getAnOperand/getRightOperand: [LocalVariableAccess] bar -# 17| getStmt: [Method] destructured_method_param +# 17| getStmt: [MethodDeclaration] destructured_method_param # 17| getParameter: [TuplePatternParameter] (..., ...) # 17| getElement: [LocalVariableAccess] a # 17| getElement: [LocalVariableAccess] b @@ -1671,7 +1671,7 @@ params/params.rb: # 26| getAnOperand/getRightOperand: [LocalVariableAccess] second # 26| getAnOperand/getRightOperand: [LocalVariableAccess] third # 26| getAnOperand/getRightOperand: [LocalVariableAccess] fourth -# 30| getStmt: [Method] method_with_splat +# 30| getStmt: [MethodDeclaration] method_with_splat # 30| getParameter: [SimpleParameter] wibble # 30| getDefiningAccess: [LocalVariableAccess] wibble # 30| getParameter: [SplatParameter] *splat @@ -1696,7 +1696,7 @@ params/params.rb: # 38| getDefiningAccess: [LocalVariableAccess] blah # 38| getParameter: [HashSplatParameter] **wibble # 38| getDefiningAccess: [LocalVariableAccess] wibble -# 41| getStmt: [Method] method_with_keyword_params +# 41| getStmt: [MethodDeclaration] method_with_keyword_params # 41| getParameter: [SimpleParameter] x # 41| getDefiningAccess: [LocalVariableAccess] x # 41| getParameter: [KeywordParameter] foo @@ -1709,7 +1709,7 @@ params/params.rb: # 42| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 42| getAnOperand/getRightOperand: [LocalVariableAccess] foo # 42| getAnOperand/getRightOperand: [LocalVariableAccess] bar -# 46| getStmt: [Method] use_block_with_keyword +# 46| getStmt: [MethodDeclaration] use_block_with_keyword # 46| getParameter: [BlockParameter] &block # 46| getDefiningAccess: [LocalVariableAccess] block # 47| getStmt: [MethodCall] call to puts @@ -1746,7 +1746,7 @@ params/params.rb: # 54| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 54| getAnOperand/getRightOperand: [LocalVariableAccess] y # 54| getAnOperand/getRightOperand: [LocalVariableAccess] z -# 58| getStmt: [Method] method_with_optional_params +# 58| getStmt: [MethodDeclaration] method_with_optional_params # 58| getParameter: [SimpleParameter] val1 # 58| getDefiningAccess: [LocalVariableAccess] val1 # 58| getParameter: [OptionalParameter] val2 @@ -1755,7 +1755,7 @@ params/params.rb: # 58| getParameter: [OptionalParameter] val3 # 58| getDefiningAccess: [LocalVariableAccess] val3 # 58| getDefaultValue: [IntegerLiteral] 100 -# 62| getStmt: [Method] use_block_with_optional +# 62| getStmt: [MethodDeclaration] use_block_with_optional # 62| getParameter: [BlockParameter] &block # 62| getDefiningAccess: [LocalVariableAccess] block # 63| getStmt: [MethodCall] call to call diff --git a/ql/test/library-tests/ast/modules/classes.expected b/ql/test/library-tests/ast/modules/classes.expected index e81722ecfa2..08543bb9fb0 100644 --- a/ql/test/library-tests/ast/modules/classes.expected +++ b/ql/test/library-tests/ast/modules/classes.expected @@ -23,8 +23,8 @@ classesWithNameScopeExprs 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 | 0 | classes.rb:21:3:23:5 | method_a | MethodDeclaration | +| classes.rb:20:1:37:3 | Wibble | 1 | classes.rb:25:3:27:5 | method_b | MethodDeclaration | | 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 | diff --git a/ql/test/library-tests/ast/modules/classes.ql b/ql/test/library-tests/ast/modules/classes.ql index a4b392a32cb..ed6b8ad45b1 100644 --- a/ql/test/library-tests/ast/modules/classes.ql +++ b/ql/test/library-tests/ast/modules/classes.ql @@ -12,7 +12,7 @@ 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) { +query predicate methodsInClasses(ClassDeclaration c, MethodDeclaration m, string name) { m = c.getMethod(name) } diff --git a/ql/test/library-tests/ast/modules/module_base.ql b/ql/test/library-tests/ast/modules/module_base.ql index e95faa62969..859fe2d8bc7 100644 --- a/ql/test/library-tests/ast/modules/module_base.ql +++ b/ql/test/library-tests/ast/modules/module_base.ql @@ -4,6 +4,6 @@ query predicate moduleBases(ModuleBase mb, string pClass) { pClass = mb.getAPrim query predicate moduleBaseClasses(ModuleBase mb, ClassDeclaration c) { c = mb.getAClass() } -query predicate moduleBaseMethods(ModuleBase mb, Method m) { m = mb.getAMethod() } +query predicate moduleBaseMethods(ModuleBase mb, MethodDeclaration m) { m = mb.getAMethod() } query predicate moduleBaseModules(ModuleBase mb, ModuleDeclaration m) { m = mb.getAModule() } diff --git a/ql/test/library-tests/ast/modules/modules.expected b/ql/test/library-tests/ast/modules/modules.expected index f7f52051674..4226cddf806 100644 --- a/ql/test/library-tests/ast/modules/modules.expected +++ b/ql/test/library-tests/ast/modules/modules.expected @@ -36,24 +36,24 @@ 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 | 1 | modules.rb:16:3:17:5 | method_in_foo | MethodDeclaration | | 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 | 1 | modules.rb:9:5:10:7 | method_in_foo_bar | MethodDeclaration | | 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 | 0 | modules.rb:27:3:28:5 | method_in_another_definition_of_foo | MethodDeclaration | | 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 | 0 | modules.rb:38:3:39:5 | method_a | MethodDeclaration | +| modules.rb:37:1:46:3 | Bar | 1 | modules.rb:41:3:42:5 | method_b | MethodDeclaration | | 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 | 1 | modules.rb:52:3:53:5 | method_in_another_definition_of_foo_bar | MethodDeclaration | | 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 | diff --git a/ql/test/library-tests/ast/modules/modules.ql b/ql/test/library-tests/ast/modules/modules.ql index 21adb23e633..b10b99c55a5 100644 --- a/ql/test/library-tests/ast/modules/modules.ql +++ b/ql/test/library-tests/ast/modules/modules.ql @@ -12,7 +12,7 @@ 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) { +query predicate methodsInModules(ModuleDeclaration mod, MethodDeclaration method, string name) { method = mod.getMethod(name) } diff --git a/ql/test/library-tests/ast/modules/singleton_classes.expected b/ql/test/library-tests/ast/modules/singleton_classes.expected index f1c13b476d6..2b11f88cfe1 100644 --- a/ql/test/library-tests/ast/modules/singleton_classes.expected +++ b/ql/test/library-tests/ast/modules/singleton_classes.expected @@ -1,8 +1,8 @@ singletonClasses | classes.rb:41:1:52:3 | class << ... | ClassDeclaration | 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 << ... | 0 | classes.rb:42:3:44:5 | length | MethodDeclaration | +| classes.rb:41:1:52:3 | class << ... | 1 | classes.rb:46:3:48:5 | wibble | MethodDeclaration | | 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 diff --git a/ql/test/library-tests/ast/modules/singleton_classes.ql b/ql/test/library-tests/ast/modules/singleton_classes.ql index d02dd8cb68c..850007c0071 100644 --- a/ql/test/library-tests/ast/modules/singleton_classes.ql +++ b/ql/test/library-tests/ast/modules/singleton_classes.ql @@ -8,4 +8,6 @@ query predicate exprsInSingletonClasses(SingletonClass sc, int i, Expr e, string e = sc.getStmt(i) and eClass = e.getAPrimaryQlClass() } -query predicate methodsInSingletonClasses(SingletonClass sc, Method m) { m = sc.getAMethod() } +query predicate methodsInSingletonClasses(SingletonClass sc, MethodDeclaration m) { + m = sc.getAMethod() +} diff --git a/ql/test/library-tests/ast/params/params.ql b/ql/test/library-tests/ast/params/params.ql index eb77ac0e418..28913458b9b 100644 --- a/ql/test/library-tests/ast/params/params.ql +++ b/ql/test/library-tests/ast/params/params.ql @@ -28,7 +28,7 @@ query predicate optionalParams(OptionalParameter op, string name, AstNode defaul //////////////////////////////////////////////////////////////////////////////// // Query predicates for various contexts of parameters -query predicate paramsInMethods(Method m, int i, Parameter p, string pClass) { +query predicate paramsInMethods(MethodDeclaration m, int i, Parameter p, string pClass) { p = m.getParameter(i) and pClass = p.getAPrimaryQlClass() }