mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Ensure that initializers are only printed once in a PrintAst run
Otherwise the output becomes a DAG not a tree. Java achieves the same by omitting all PrintAst of `<obinit>` routines.
This commit is contained in:
committed by
Ian Lynagh
parent
13cd145a76
commit
dc64b536b3
@@ -244,6 +244,21 @@ class ExprStmtNode extends ElementNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A node representing a `KtInitializerAssignExpr`.
|
||||
*/
|
||||
class KtInitializerNode extends ExprStmtNode {
|
||||
KtInitializerNode() { element instanceof KtInitializerAssignExpr }
|
||||
|
||||
override PrintAstNode getChild(int childIndex) {
|
||||
// Remove the RHS of the initializer, because otherwise
|
||||
// it appears as both the initializer's child and the
|
||||
// initialize of the related field, producing a DAG not
|
||||
// a tree and consequently unreadable output.
|
||||
result = super.getChild(childIndex) and childIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the given expression is part of an annotation.
|
||||
*/
|
||||
|
||||
@@ -86,9 +86,8 @@ generics.kt:
|
||||
# 13| 0: [SuperConstructorInvocationStmt] super(...)
|
||||
# 13| 1: [BlockStmt] { ... }
|
||||
# 13| 0: [ExprStmt] <Expr>;
|
||||
# 13| 0: [AssignExpr] ...=...
|
||||
# 13| 0: [KtInitializerAssignExpr] ...=...
|
||||
# 13| 0: [VarAccess] t
|
||||
# 13| 1: [VarAccess] t
|
||||
# 13| 2: [Method] getT
|
||||
# 13| 5: [BlockStmt] { ... }
|
||||
# 13| 0: [ReturnStmt] return ...
|
||||
@@ -96,6 +95,7 @@ generics.kt:
|
||||
# 13| -1: [ThisAccess] this
|
||||
# 13| 2: [FieldDeclaration] T t;
|
||||
# 13| -1: [TypeAccess] T
|
||||
# 13| 0: [VarAccess] t
|
||||
# 14| 4: [Method] f1
|
||||
#-----| 4: (Parameters)
|
||||
# 14| 0: [Parameter] t
|
||||
|
||||
Reference in New Issue
Block a user