mirror of
https://github.com/github/codeql.git
synced 2026-02-20 08:53:49 +01:00
AST: add Self class
This commit is contained in:
@@ -12,6 +12,18 @@ class Expr extends Stmt {
|
||||
Expr() { this = range }
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference to the current object. For example:
|
||||
* - `self == other`
|
||||
* - `self.method_name`
|
||||
* - `def self.method_name ... end`
|
||||
*/
|
||||
class Self extends Expr, @token_self {
|
||||
override Self::Range range;
|
||||
|
||||
final override string getAPrimaryQlClass() { result = "Self" }
|
||||
}
|
||||
|
||||
/**
|
||||
* A literal.
|
||||
*
|
||||
|
||||
@@ -47,8 +47,6 @@ module AstNode {
|
||||
or
|
||||
this instanceof Generated::BareString
|
||||
or
|
||||
this instanceof Generated::Self
|
||||
or
|
||||
this instanceof Generated::Float
|
||||
or
|
||||
this instanceof Generated::Superclass
|
||||
|
||||
@@ -6,6 +6,14 @@ module Expr {
|
||||
abstract class Range extends Stmt::Range { }
|
||||
}
|
||||
|
||||
module Self {
|
||||
class Range extends Expr::Range, @token_self {
|
||||
final override Generated::Self generated;
|
||||
|
||||
final override string toString() { result = "self" }
|
||||
}
|
||||
}
|
||||
|
||||
module Literal {
|
||||
abstract class Range extends Expr::Range {
|
||||
abstract string getValueText();
|
||||
|
||||
@@ -74,7 +74,6 @@ callsWithNoReceiverArgumentsOrBlock
|
||||
| calls.rb:286:5:286:9 | call to super | super |
|
||||
| calls.rb:287:5:287:11 | call to super | super |
|
||||
| calls.rb:303:5:303:7 | call to foo | foo |
|
||||
| calls.rb:304:5:304:14 | call to super | super |
|
||||
| calls.rb:305:5:305:9 | call to super | super |
|
||||
callsWithArguments
|
||||
| calls.rb:14:1:14:11 | call to foo | foo | 0 | calls.rb:14:5:14:5 | 0 |
|
||||
@@ -174,6 +173,7 @@ callsWithReceiver
|
||||
| calls.rb:275:7:275:12 | call to bar | calls.rb:275:7:275:7 | X |
|
||||
| calls.rb:279:11:279:16 | call to bar | calls.rb:279:11:279:11 | X |
|
||||
| calls.rb:303:5:303:13 | call to super | calls.rb:303:5:303:7 | call to foo |
|
||||
| calls.rb:304:5:304:14 | call to super | calls.rb:304:5:304:8 | self |
|
||||
| calls.rb:305:5:305:15 | call to super | calls.rb:305:5:305:9 | call to super |
|
||||
callsWithBlock
|
||||
| calls.rb:17:1:17:17 | call to foo | calls.rb:17:5:17:17 | { ... } |
|
||||
|
||||
@@ -301,7 +301,7 @@ end
|
||||
class AnotherClass
|
||||
def another_method
|
||||
foo.super
|
||||
self.super # TODO: this shows up as a call without a receiver, but that should be fixed once we handle `self` expressions
|
||||
self.super
|
||||
super.super # we expect the receiver to be a SuperCall, while the outer call should not (it's just a regular Call)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user