mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Add anonymous class declaration stmt
This commit is contained in:
@@ -43,8 +43,6 @@ predicate lateFirstChild(Element e, int i) {
|
||||
and not e instanceof LocalVariableDeclStmt
|
||||
// TODO: Tighten this up:
|
||||
and not e instanceof ForStmt
|
||||
// TODO: This happens for anonymous class instantiations at the moment:
|
||||
and not (e instanceof BlockStmt and i = 1 and e.getFile().getExtension() = "kt")
|
||||
}
|
||||
|
||||
from Element e, int i, string problem
|
||||
|
||||
@@ -585,6 +585,7 @@ case @stmt.kind of
|
||||
| 22 = @catchclause
|
||||
| 23 = @yieldstmt
|
||||
| 24 = @errorstmt
|
||||
| 25 = @anonymousclassdeclstmt
|
||||
;
|
||||
|
||||
#keyset[parent,idx]
|
||||
@@ -1129,3 +1130,8 @@ ktPropertyBackingFields(
|
||||
unique int id: @kt_property ref,
|
||||
int backingField: @field ref
|
||||
)
|
||||
|
||||
ktAnonymousClassDeclarationStmts(
|
||||
unique int id: @anonymousclassdeclstmt ref,
|
||||
int classId: @class ref
|
||||
)
|
||||
|
||||
@@ -911,3 +911,16 @@ class KtBreakStmt extends BreakStmt, KtBreakContinueStmt { }
|
||||
|
||||
/** A Kotlin `continue` statement. */
|
||||
class KtContinueStmt extends ContinueStmt, KtBreakContinueStmt { }
|
||||
|
||||
class KtAnonymousClassDeclarationStmt extends Stmt, @anonymousclassdeclstmt {
|
||||
Class c;
|
||||
|
||||
KtAnonymousClassDeclarationStmt() { ktAnonymousClassDeclarationStmts(this, c) }
|
||||
|
||||
/** Gets the class declaration belonging to this declaration statement. */
|
||||
AnonymousClass getDeclaration() { result = c }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "KtAnonymousClassDeclarationStmt" }
|
||||
|
||||
override string toString() { result = "{ ... }" }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
| classes.kt:66:20:66:54 | new Object(...) { ... } | classes.kt:66:20:66:54 | new (...) | | file://:0:0:0:0 | Object |
|
||||
| classes.kt:68:20:68:74 | new Object(...) { ... } | classes.kt:68:20:68:74 | new (...) | | file://:0:0:0:0 | Object |
|
||||
| classes.kt:72:16:77:10 | new Object(...) { ... } | classes.kt:72:16:77:10 | new (...) | | file://:0:0:0:0 | Object |
|
||||
| classes.kt:75:24:75:33 | new Object(...) { ... } | classes.kt:75:24:75:33 | new (...) | | file://:0:0:0:0 | Object |
|
||||
| classes.kt:81:16:81:38 | new Interface1(...) { ... } | classes.kt:81:16:81:38 | new (...) | | file://:0:0:0:0 | Interface1 |
|
||||
| classes.kt:85:16:85:25 | new Object(...) { ... } | classes.kt:85:16:85:25 | new (...) | | file://:0:0:0:0 | Object |
|
||||
| classes.kt:89:16:89:44 | new Interface3<Integer>(...) { ... } | classes.kt:89:16:89:44 | new (...) | | file://:0:0:0:0 | Interface3<Integer> |
|
||||
| classes.kt:66:20:66:54 | new Object(...) { ... } | classes.kt:66:20:66:54 | new (...) | | file://:0:0:0:0 | Object | classes.kt:66:20:66:54 | { ... } |
|
||||
| classes.kt:68:20:68:74 | new Object(...) { ... } | classes.kt:68:20:68:74 | new (...) | | file://:0:0:0:0 | Object | classes.kt:68:20:68:74 | { ... } |
|
||||
| classes.kt:72:16:77:10 | new Object(...) { ... } | classes.kt:72:16:77:10 | new (...) | | file://:0:0:0:0 | Object | classes.kt:72:16:77:10 | { ... } |
|
||||
| classes.kt:75:24:75:33 | new Object(...) { ... } | classes.kt:75:24:75:33 | new (...) | | file://:0:0:0:0 | Object | classes.kt:75:24:75:33 | { ... } |
|
||||
| classes.kt:81:16:81:38 | new Interface1(...) { ... } | classes.kt:81:16:81:38 | new (...) | | file://:0:0:0:0 | Interface1 | classes.kt:81:16:81:38 | { ... } |
|
||||
| classes.kt:85:16:85:25 | new Object(...) { ... } | classes.kt:85:16:85:25 | new (...) | | file://:0:0:0:0 | Object | classes.kt:85:16:85:25 | { ... } |
|
||||
| classes.kt:89:16:89:44 | new Interface3<Integer>(...) { ... } | classes.kt:89:16:89:44 | new (...) | | file://:0:0:0:0 | Interface3<Integer> | classes.kt:89:16:89:44 | { ... } |
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java
|
||||
|
||||
from AnonymousClass c
|
||||
where c.fromSource()
|
||||
from AnonymousClass c, KtAnonymousClassDeclarationStmt stmt
|
||||
where c.fromSource() and stmt.getDeclaration() = c
|
||||
select c, c.getClassInstanceExpr(),
|
||||
c.getClassInstanceExpr().getConstructor().getDeclaringType().getName(),
|
||||
c.getClassInstanceExpr().getTypeName()
|
||||
c.getClassInstanceExpr().getTypeName(), stmt
|
||||
|
||||
Reference in New Issue
Block a user