Skip to content

Commit 570e418

Browse files
committed
Fix ordering PrintAst nodes
1 parent ec95cba commit 570e418

File tree

8 files changed

+805
-805
lines changed

8 files changed

+805
-805
lines changed

java/ql/lib/semmle/code/java/PrintAst.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ final class ClassInterfaceNode extends ElementNode {
537537
rank[childIndex](Element e, string file, int line, int column, string childStr |
538538
e = this.getADeclaration() and
539539
locationSortKeys(e, file, line, column) and
540-
childStr = result.toString()
540+
childStr = e.toString()
541541
|
542542
e order by file, line, column, childStr
543543
)

java/ql/test/kotlin/library-tests/classes/PrintAst.expected

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ classes.kt:
3232
# 4| 0: [ReturnStmt] return ...
3333
# 4| 0: [VarAccess] this.arg
3434
# 4| -1: [ThisAccess] this
35-
# 4| 2: [FieldDeclaration] int arg;
35+
# 4| 3: [FieldDeclaration] int arg;
3636
# 4| -1: [TypeAccess] int
3737
# 4| 0: [VarAccess] arg
3838
# 5| 4: [Method] getX
@@ -41,7 +41,7 @@ classes.kt:
4141
# 5| 0: [ReturnStmt] return ...
4242
# 5| 0: [VarAccess] this.x
4343
# 5| -1: [ThisAccess] this
44-
# 5| 4: [FieldDeclaration] int x;
44+
# 5| 5: [FieldDeclaration] int x;
4545
# 5| -1: [TypeAccess] int
4646
# 5| 0: [IntegerLiteral] 3
4747
# 8| 4: [Class] ClassThree
@@ -118,18 +118,18 @@ classes.kt:
118118
# 42| 0: [ReturnStmt] return ...
119119
# 42| 0: [VarAccess] this.x
120120
# 42| -1: [ThisAccess] this
121-
# 42| 2: [FieldDeclaration] int x;
121+
# 42| 3: [FieldDeclaration] int x;
122122
# 42| -1: [TypeAccess] int
123123
# 42| 0: [IntegerLiteral] 3
124124
# 49| 11: [Class] Direction
125-
# 0| 1: [Method] values
126-
# 0| 3: [TypeAccess] Direction[]
127-
# 0| 0: [TypeAccess] Direction
128-
# 0| 1: [Method] valueOf
125+
# 0| 2: [Method] valueOf
129126
# 0| 3: [TypeAccess] Direction
130127
#-----| 4: (Parameters)
131128
# 0| 0: [Parameter] value
132129
# 0| 0: [TypeAccess] String
130+
# 0| 3: [Method] values
131+
# 0| 3: [TypeAccess] Direction[]
132+
# 0| 0: [TypeAccess] Direction
133133
# 49| 4: [Constructor] Direction
134134
# 49| 5: [BlockStmt] { ... }
135135
# 49| 0: [ExprStmt] <Expr>;
@@ -154,14 +154,14 @@ classes.kt:
154154
# 50| 0: [ClassInstanceExpr] new Direction(...)
155155
# 50| -3: [TypeAccess] Direction
156156
# 53| 12: [Class] Color
157-
# 0| 1: [Method] values
158-
# 0| 3: [TypeAccess] Color[]
159-
# 0| 0: [TypeAccess] Color
160-
# 0| 1: [Method] valueOf
157+
# 0| 2: [Method] valueOf
161158
# 0| 3: [TypeAccess] Color
162159
#-----| 4: (Parameters)
163160
# 0| 0: [Parameter] value
164161
# 0| 0: [TypeAccess] String
162+
# 0| 3: [Method] values
163+
# 0| 3: [TypeAccess] Color[]
164+
# 0| 0: [TypeAccess] Color
165165
# 53| 4: [Constructor] Color
166166
#-----| 4: (Parameters)
167167
# 53| 0: [Parameter] rgb
@@ -181,7 +181,7 @@ classes.kt:
181181
# 53| 0: [ReturnStmt] return ...
182182
# 53| 0: [VarAccess] this.rgb
183183
# 53| -1: [ThisAccess] this
184-
# 53| 5: [FieldDeclaration] int rgb;
184+
# 53| 6: [FieldDeclaration] int rgb;
185185
# 53| -1: [TypeAccess] int
186186
# 53| 0: [VarAccess] rgb
187187
# 54| 7: [FieldDeclaration] Color RED;
@@ -266,7 +266,7 @@ classes.kt:
266266
# 73| 0: [ReturnStmt] return ...
267267
# 73| 0: [VarAccess] this.x
268268
# 73| -1: [ThisAccess] this
269-
# 73| 2: [FieldDeclaration] int x;
269+
# 73| 3: [FieldDeclaration] int x;
270270
# 73| -1: [TypeAccess] int
271271
# 73| 0: [IntegerLiteral] 1
272272
# 74| 4: [Method] foo
@@ -434,7 +434,7 @@ classes.kt:
434434
# 118| 1: [Constructor]
435435
# 118| 5: [BlockStmt] { ... }
436436
# 118| 0: [SuperConstructorInvocationStmt] super(...)
437-
# 118| 1: [Method] localFn
437+
# 118| 2: [Method] localFn
438438
# 118| 3: [TypeAccess] Unit
439439
# 118| 5: [BlockStmt] { ... }
440440
# 119| 0: [LocalTypeDeclStmt] class ...
@@ -541,15 +541,15 @@ generic_anonymous.kt:
541541
# 3| 1: [ExprStmt] <Expr>;
542542
# 3| 0: [KtInitializerAssignExpr] ...=...
543543
# 3| 0: [VarAccess] x
544-
# 1| 2: [Method] getT
544+
# 1| 2: [FieldDeclaration] T t;
545+
# 1| -1: [TypeAccess] T
546+
# 1| 0: [VarAccess] t
547+
# 1| 3: [Method] getT
545548
# 1| 3: [TypeAccess] T
546549
# 1| 5: [BlockStmt] { ... }
547550
# 1| 0: [ReturnStmt] return ...
548551
# 1| 0: [VarAccess] this.t
549552
# 1| -1: [ThisAccess] this
550-
# 1| 2: [FieldDeclaration] T t;
551-
# 1| -1: [TypeAccess] T
552-
# 1| 0: [VarAccess] t
553553
# 3| 4: [FieldDeclaration] new Object(...) { ... } x;
554554
# 3| -1: [TypeAccess] new Object(...) { ... }
555555
# 3| 0: [TypeAccess] T
@@ -564,17 +564,17 @@ generic_anonymous.kt:
564564
# 4| 0: [ExprStmt] <Expr>;
565565
# 4| 0: [KtInitializerAssignExpr] ...=...
566566
# 4| 0: [VarAccess] member
567-
# 4| 2: [Method] getMember
568-
# 4| 3: [TypeAccess] T
569-
# 4| 5: [BlockStmt] { ... }
570-
# 4| 0: [ReturnStmt] return ...
571-
# 4| 0: [VarAccess] this.member
572-
# 4| -1: [ThisAccess] this
573567
# 4| 2: [FieldDeclaration] T member;
574568
# 4| -1: [TypeAccess] T
575569
# 4| 0: [MethodAccess] getT(...)
576570
# 4| -1: [ThisAccess] Generic.this
577571
# 4| 0: [TypeAccess] Generic
572+
# 4| 3: [Method] getMember
573+
# 4| 3: [TypeAccess] T
574+
# 4| 5: [BlockStmt] { ... }
575+
# 4| 0: [ReturnStmt] return ...
576+
# 4| 0: [VarAccess] this.member
577+
# 4| -1: [ThisAccess] this
578578
# 3| 1: [ExprStmt] <Expr>;
579579
# 3| 0: [ClassInstanceExpr] new (...)
580580
# 3| -3: [TypeAccess] Object
@@ -605,12 +605,6 @@ localClassField.kt:
605605
# 7| 1: [ExprStmt] <Expr>;
606606
# 7| 0: [KtInitializerAssignExpr] ...=...
607607
# 7| 0: [VarAccess] y
608-
# 2| 2: [Method] getX
609-
# 2| 3: [TypeAccess] Object
610-
# 2| 5: [BlockStmt] { ... }
611-
# 2| 0: [ReturnStmt] return ...
612-
# 2| 0: [VarAccess] this.x
613-
# 2| -1: [ThisAccess] this
614608
# 2| 2: [FieldDeclaration] Object x;
615609
# 2| -1: [TypeAccess] Object
616610
# 2| 0: [WhenExpr] when ...
@@ -629,12 +623,12 @@ localClassField.kt:
629623
# 2| 1: [WhenBranch] ... -> ...
630624
# 2| 0: [BooleanLiteral] true
631625
# 5| 1: [BlockStmt] { ... }
632-
# 7| 4: [Method] getY
633-
# 7| 3: [TypeAccess] Object
634-
# 7| 5: [BlockStmt] { ... }
635-
# 7| 0: [ReturnStmt] return ...
636-
# 7| 0: [VarAccess] this.y
637-
# 7| -1: [ThisAccess] this
626+
# 2| 3: [Method] getX
627+
# 2| 3: [TypeAccess] Object
628+
# 2| 5: [BlockStmt] { ... }
629+
# 2| 0: [ReturnStmt] return ...
630+
# 2| 0: [VarAccess] this.x
631+
# 2| -1: [ThisAccess] this
638632
# 7| 4: [FieldDeclaration] Object y;
639633
# 7| -1: [TypeAccess] Object
640634
# 7| 0: [WhenExpr] when ...
@@ -653,6 +647,12 @@ localClassField.kt:
653647
# 7| 1: [WhenBranch] ... -> ...
654648
# 7| 0: [BooleanLiteral] true
655649
# 10| 1: [BlockStmt] { ... }
650+
# 7| 5: [Method] getY
651+
# 7| 3: [TypeAccess] Object
652+
# 7| 5: [BlockStmt] { ... }
653+
# 7| 0: [ReturnStmt] return ...
654+
# 7| 0: [VarAccess] this.y
655+
# 7| -1: [ThisAccess] this
656656
local_anonymous.kt:
657657
# 0| [CompilationUnit] local_anonymous
658658
# 3| 1: [Class] Class1
@@ -686,7 +686,7 @@ local_anonymous.kt:
686686
# 11| 1: [Constructor]
687687
# 11| 5: [BlockStmt] { ... }
688688
# 11| 0: [SuperConstructorInvocationStmt] super(...)
689-
# 11| 1: [Method] fnLocal
689+
# 11| 2: [Method] fnLocal
690690
# 11| 3: [TypeAccess] Unit
691691
# 11| 5: [BlockStmt] { ... }
692692
# 12| 1: [ExprStmt] <Expr>;
@@ -703,7 +703,7 @@ local_anonymous.kt:
703703
# 16| 1: [Constructor]
704704
# 16| 5: [BlockStmt] { ... }
705705
# 16| 0: [SuperConstructorInvocationStmt] super(...)
706-
# 16| 1: [Method] invoke
706+
# 16| 2: [Method] invoke
707707
# 16| 3: [TypeAccess] int
708708
#-----| 4: (Parameters)
709709
# 16| 0: [Parameter] a
@@ -726,7 +726,7 @@ local_anonymous.kt:
726726
# 17| 1: [Constructor]
727727
# 17| 5: [BlockStmt] { ... }
728728
# 17| 0: [SuperConstructorInvocationStmt] super(...)
729-
# 17| 1: [Method] invoke
729+
# 17| 2: [Method] invoke
730730
# 17| 3: [TypeAccess] int
731731
#-----| 4: (Parameters)
732732
# 17| 0: [Parameter] a
@@ -752,7 +752,7 @@ local_anonymous.kt:
752752
# 21| 1: [Constructor]
753753
# 21| 5: [BlockStmt] { ... }
754754
# 21| 0: [SuperConstructorInvocationStmt] super(...)
755-
# 21| 1: [Method] invoke
755+
# 21| 2: [Method] invoke
756756
#-----| 4: (Parameters)
757757
# 21| 0: [Parameter] a0
758758
# 21| 5: [BlockStmt] { ... }
@@ -797,7 +797,10 @@ local_anonymous.kt:
797797
# 30| 0: [ReturnStmt] return ...
798798
# 30| 0: [VarAccess] this.x
799799
# 30| -1: [ThisAccess] this
800-
# 30| 2: [Method] setX
800+
# 30| 3: [FieldDeclaration] int x;
801+
# 30| -1: [TypeAccess] int
802+
# 30| 0: [IntegerLiteral] 1
803+
# 30| 4: [Method] setX
801804
# 30| 3: [TypeAccess] Unit
802805
#-----| 4: (Parameters)
803806
# 30| 0: [Parameter] <set-?>
@@ -808,9 +811,6 @@ local_anonymous.kt:
808811
# 30| 0: [VarAccess] this.x
809812
# 30| -1: [ThisAccess] this
810813
# 30| 1: [VarAccess] <set-?>
811-
# 30| 2: [FieldDeclaration] int x;
812-
# 30| -1: [TypeAccess] int
813-
# 30| 0: [IntegerLiteral] 1
814814
# 32| 5: [Method] member
815815
# 32| 3: [TypeAccess] Unit
816816
# 32| 5: [BlockStmt] { ... }
@@ -840,23 +840,6 @@ local_anonymous.kt:
840840
# 40| 0: [ExprStmt] <Expr>;
841841
# 40| 0: [KtInitializerAssignExpr] ...=...
842842
# 40| 0: [VarAccess] i
843-
# 40| 2: [Method] getI
844-
# 40| 3: [TypeAccess] Interface2
845-
# 40| 5: [BlockStmt] { ... }
846-
# 40| 0: [ReturnStmt] return ...
847-
# 40| 0: [VarAccess] this.i
848-
# 40| -1: [ThisAccess] this
849-
# 40| 2: [Method] setI
850-
# 40| 3: [TypeAccess] Unit
851-
#-----| 4: (Parameters)
852-
# 40| 0: [Parameter] <set-?>
853-
# 40| 0: [TypeAccess] Interface2
854-
# 40| 5: [BlockStmt] { ... }
855-
# 40| 0: [ExprStmt] <Expr>;
856-
# 40| 0: [AssignExpr] ...=...
857-
# 40| 0: [VarAccess] this.i
858-
# 40| -1: [ThisAccess] this
859-
# 40| 1: [VarAccess] <set-?>
860843
# 40| 2: [FieldDeclaration] Interface2 i;
861844
# 40| -1: [TypeAccess] Interface2
862845
# 40| 0: [StmtExpr] <Stmt>
@@ -873,6 +856,23 @@ local_anonymous.kt:
873856
# 40| 1: [ExprStmt] <Expr>;
874857
# 40| 0: [ClassInstanceExpr] new (...)
875858
# 40| -3: [TypeAccess] Interface2
859+
# 40| 3: [Method] getI
860+
# 40| 3: [TypeAccess] Interface2
861+
# 40| 5: [BlockStmt] { ... }
862+
# 40| 0: [ReturnStmt] return ...
863+
# 40| 0: [VarAccess] this.i
864+
# 40| -1: [ThisAccess] this
865+
# 40| 4: [Method] setI
866+
# 40| 3: [TypeAccess] Unit
867+
#-----| 4: (Parameters)
868+
# 40| 0: [Parameter] <set-?>
869+
# 40| 0: [TypeAccess] Interface2
870+
# 40| 5: [BlockStmt] { ... }
871+
# 40| 0: [ExprStmt] <Expr>;
872+
# 40| 0: [AssignExpr] ...=...
873+
# 40| 0: [VarAccess] this.i
874+
# 40| -1: [ThisAccess] this
875+
# 40| 1: [VarAccess] <set-?>
876876
superChain.kt:
877877
# 0| [CompilationUnit] superChain
878878
# 1| 1: [Class,GenericType,ParameterizedType] SuperChain1

0 commit comments

Comments
 (0)