mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Create ExtensionMethodAccess class
This commit is contained in:
committed by
Ian Lynagh
parent
270beecef5
commit
fcb334180d
@@ -550,12 +550,23 @@ private module ControlFlowGraphImpl {
|
||||
or
|
||||
index = 0 and result = this.(RValue).getQualifier() and not result instanceof TypeAccess
|
||||
or
|
||||
exists(Call e | e = this |
|
||||
exists(Call e | e = this and not e instanceof ExtensionMethodAccess |
|
||||
index = -1 and result = e.getQualifier() and not result instanceof TypeAccess
|
||||
or
|
||||
result = e.getArgument(index)
|
||||
)
|
||||
or
|
||||
exists(ExtensionMethodAccess e | e = this |
|
||||
// the actual qualifier of the expression method access
|
||||
index = -1 and result.(Expr).isNthChildOf(this, index)
|
||||
or
|
||||
// the extension receiver
|
||||
index = 0 and result = e.getQualifier()
|
||||
or
|
||||
// the arguments
|
||||
result = e.getArgument(index)
|
||||
)
|
||||
or
|
||||
exists(StringTemplateExpr e | e = this | result = e.getComponent(index))
|
||||
or
|
||||
index = 0 and result = this.(ClassExpr).getExpr()
|
||||
|
||||
@@ -1957,6 +1957,22 @@ class MethodAccess extends Expr, Call, @methodaccess {
|
||||
override string getAPrimaryQlClass() { result = "MethodAccess" }
|
||||
}
|
||||
|
||||
/**
|
||||
* An invocation of a Kotlin `ExtensionMethod`.
|
||||
*
|
||||
* The syntactical qualifier of an extension method is its receiver (arg 0),
|
||||
* whereas the actual arguments begin at index 1.
|
||||
*/
|
||||
class ExtensionMethodAccess extends MethodAccess {
|
||||
ExtensionMethodAccess() { this.getMethod() instanceof ExtensionMethod }
|
||||
|
||||
override Expr getQualifier() { result.isNthChildOf(this, 0) }
|
||||
|
||||
override Expr getAnArgument() { result.getIndex() >= 1 and result.getParent() = this }
|
||||
|
||||
override Expr getArgument(int index) { result = super.getArgument(index + 1) }
|
||||
}
|
||||
|
||||
/** A type access is a (possibly qualified) reference to a type. */
|
||||
class TypeAccess extends Expr, Annotatable, @typeaccess {
|
||||
/** Gets the qualifier of this type access, if any. */
|
||||
|
||||
Reference in New Issue
Block a user