Skip to content

Commit 010bc39

Browse files
authored
Fix tests
I'm not really a fan of `toString`s that don't indicate the type of the object, so I added a reference to `getAPrimaryQlClass`. Hopefully this should result in less noise in the diff.
1 parent 9b0b4df commit 010bc39

3 files changed

Lines changed: 41 additions & 41 deletions

File tree

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class VarDecl extends TVarDecl, VarDef, Declaration {
459459
pred = directMember("getTypeExpr") and result = this.getTypeExpr()
460460
}
461461

462-
override string toString() { result = Declaration.super.toString() }
462+
override string toString() { result = this.getName() }
463463
}
464464

465465
/**
@@ -568,7 +568,7 @@ class Declaration extends TDeclaration, AstNode {
568568
/** Gets the name of this declaration. */
569569
string getName() { none() }
570570

571-
override string toString() { result = this.getName() }
571+
override string toString() { result = this.getAPrimaryQlClass() + " " + this.getName() }
572572

573573
override QLDoc getQLDoc() {
574574
result = any(TopLevel m).getQLDocFor(this)

ql/test/printAst/printAst.expected

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ nodes
33
| Foo.qll:1:1:1:17 | Import | semmle.order | 1 |
44
| Foo.qll:1:1:25:2 | TopLevel | semmle.label | [TopLevel] TopLevel |
55
| Foo.qll:1:1:25:2 | TopLevel | semmle.order | 1 |
6-
| Foo.qll:3:1:7:1 | Foo | semmle.label | [Class] Foo |
7-
| Foo.qll:3:1:7:1 | Foo | semmle.order | 3 |
6+
| Foo.qll:3:1:7:1 | Class Foo | semmle.label | [Class] Class Foo |
7+
| Foo.qll:3:1:7:1 | Class Foo | semmle.order | 3 |
88
| Foo.qll:3:19:3:22 | TypeExpr | semmle.label | [TypeExpr] TypeExpr |
99
| Foo.qll:3:19:3:22 | TypeExpr | semmle.order | 4 |
10-
| Foo.qll:4:3:4:17 | CharPred | semmle.label | [CharPred] CharPred |
11-
| Foo.qll:4:3:4:17 | CharPred | semmle.order | 5 |
10+
| Foo.qll:4:3:4:17 | CharPred Foo | semmle.label | [CharPred] CharPred Foo |
11+
| Foo.qll:4:3:4:17 | CharPred Foo | semmle.order | 5 |
1212
| Foo.qll:4:11:4:11 | Integer | semmle.label | [Integer] Integer |
1313
| Foo.qll:4:11:4:11 | Integer | semmle.order | 6 |
1414
| Foo.qll:4:11:4:15 | ComparisonFormula | semmle.label | [ComparisonFormula] ComparisonFormula |
@@ -19,8 +19,8 @@ nodes
1919
| Foo.qll:4:15:4:15 | Integer | semmle.order | 9 |
2020
| Foo.qll:6:3:6:8 | TypeExpr | semmle.label | [TypeExpr] TypeExpr |
2121
| Foo.qll:6:3:6:8 | TypeExpr | semmle.order | 10 |
22-
| Foo.qll:6:3:6:38 | ClassPredicate | semmle.label | [ClassPredicate] ClassPredicate |
23-
| Foo.qll:6:3:6:38 | ClassPredicate | semmle.order | 10 |
22+
| Foo.qll:6:3:6:38 | ClassPredicate toString | semmle.label | [ClassPredicate] ClassPredicate toString |
23+
| Foo.qll:6:3:6:38 | ClassPredicate toString | semmle.order | 10 |
2424
| Foo.qll:6:23:6:28 | result | semmle.label | [ResultAccess] result |
2525
| Foo.qll:6:23:6:28 | result | semmle.order | 12 |
2626
| Foo.qll:6:23:6:36 | ComparisonFormula | semmle.label | [ComparisonFormula] ComparisonFormula |
@@ -29,8 +29,8 @@ nodes
2929
| Foo.qll:6:30:6:30 | ComparisonOp | semmle.order | 14 |
3030
| Foo.qll:6:32:6:36 | String | semmle.label | [String] String |
3131
| Foo.qll:6:32:6:36 | String | semmle.order | 15 |
32-
| Foo.qll:9:7:11:1 | foo | semmle.label | [ClasslessPredicate] foo |
33-
| Foo.qll:9:7:11:1 | foo | semmle.order | 16 |
32+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | semmle.label | [ClasslessPredicate] ClasslessPredicate foo |
33+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | semmle.order | 16 |
3434
| Foo.qll:9:21:9:23 | TypeExpr | semmle.label | [TypeExpr] TypeExpr |
3535
| Foo.qll:9:21:9:23 | TypeExpr | semmle.order | 17 |
3636
| Foo.qll:9:21:9:25 | f | semmle.label | [VarDecl] f |
@@ -65,8 +65,8 @@ nodes
6565
| Foo.qll:10:69:10:73 | inner | semmle.order | 32 |
6666
| Foo.qll:10:69:10:84 | MemberCall | semmle.label | [MemberCall] MemberCall |
6767
| Foo.qll:10:69:10:84 | MemberCall | semmle.order | 32 |
68-
| Foo.qll:13:1:25:1 | calls | semmle.label | [ClasslessPredicate] calls |
69-
| Foo.qll:13:1:25:1 | calls | semmle.order | 34 |
68+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | semmle.label | [ClasslessPredicate] ClasslessPredicate calls |
69+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | semmle.order | 34 |
7070
| Foo.qll:13:17:13:19 | TypeExpr | semmle.label | [TypeExpr] TypeExpr |
7171
| Foo.qll:13:17:13:19 | TypeExpr | semmle.order | 35 |
7272
| Foo.qll:13:17:13:21 | f | semmle.label | [VarDecl] f |
@@ -164,42 +164,42 @@ nodes
164164
| printAst.ql:1:1:1:29 | TopLevel | semmle.label | [TopLevel] TopLevel |
165165
| printAst.ql:1:1:1:29 | TopLevel | semmle.order | 81 |
166166
edges
167-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:1:1:1:17 | Import | semmle.label | getAMember() |
167+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:1:1:1:17 | Import | semmle.label | getAnImport() |
168168
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:1:1:1:17 | Import | semmle.order | 1 |
169-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:3:1:7:1 | Foo | semmle.label | getAMember() |
170-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:3:1:7:1 | Foo | semmle.order | 3 |
171-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:9:7:11:1 | foo | semmle.label | getAMember() |
172-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:9:7:11:1 | foo | semmle.order | 16 |
173-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:13:1:25:1 | calls | semmle.label | getAMember() |
174-
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:13:1:25:1 | calls | semmle.order | 34 |
175-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:3:19:3:22 | TypeExpr | semmle.label | getASuperType() |
176-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:3:19:3:22 | TypeExpr | semmle.order | 4 |
177-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:4:3:4:17 | CharPred | semmle.label | getCharPred() |
178-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:4:3:4:17 | CharPred | semmle.order | 5 |
179-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:6:3:6:38 | ClassPredicate | semmle.label | getClassPredicate(_) |
180-
| Foo.qll:3:1:7:1 | Foo | Foo.qll:6:3:6:38 | ClassPredicate | semmle.order | 10 |
181-
| Foo.qll:4:3:4:17 | CharPred | Foo.qll:4:11:4:15 | ComparisonFormula | semmle.label | getBody() |
182-
| Foo.qll:4:3:4:17 | CharPred | Foo.qll:4:11:4:15 | ComparisonFormula | semmle.order | 6 |
169+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:3:1:7:1 | Class Foo | semmle.label | getAClass() |
170+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:3:1:7:1 | Class Foo | semmle.order | 3 |
171+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:9:7:11:1 | ClasslessPredicate foo | semmle.label | getAPredicate() |
172+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:9:7:11:1 | ClasslessPredicate foo | semmle.order | 16 |
173+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:13:1:25:1 | ClasslessPredicate calls | semmle.label | getAPredicate() |
174+
| Foo.qll:1:1:25:2 | TopLevel | Foo.qll:13:1:25:1 | ClasslessPredicate calls | semmle.order | 34 |
175+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:3:19:3:22 | TypeExpr | semmle.label | getASuperType() |
176+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:3:19:3:22 | TypeExpr | semmle.order | 4 |
177+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:4:3:4:17 | CharPred Foo | semmle.label | getCharPred() |
178+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:4:3:4:17 | CharPred Foo | semmle.order | 5 |
179+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:6:3:6:38 | ClassPredicate toString | semmle.label | getClassPredicate(_) |
180+
| Foo.qll:3:1:7:1 | Class Foo | Foo.qll:6:3:6:38 | ClassPredicate toString | semmle.order | 10 |
181+
| Foo.qll:4:3:4:17 | CharPred Foo | Foo.qll:4:11:4:15 | ComparisonFormula | semmle.label | getBody() |
182+
| Foo.qll:4:3:4:17 | CharPred Foo | Foo.qll:4:11:4:15 | ComparisonFormula | semmle.order | 6 |
183183
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:11:4:11 | Integer | semmle.label | getLeftOperand() |
184184
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:11:4:11 | Integer | semmle.order | 6 |
185185
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:13:4:13 | ComparisonOp | semmle.label | getOperator() |
186186
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:13:4:13 | ComparisonOp | semmle.order | 8 |
187187
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:15:4:15 | Integer | semmle.label | getRightOperand() |
188188
| Foo.qll:4:11:4:15 | ComparisonFormula | Foo.qll:4:15:4:15 | Integer | semmle.order | 9 |
189-
| Foo.qll:6:3:6:38 | ClassPredicate | Foo.qll:6:3:6:8 | TypeExpr | semmle.label | getReturnTypeExpr() |
190-
| Foo.qll:6:3:6:38 | ClassPredicate | Foo.qll:6:3:6:8 | TypeExpr | semmle.order | 10 |
191-
| Foo.qll:6:3:6:38 | ClassPredicate | Foo.qll:6:23:6:36 | ComparisonFormula | semmle.label | getBody() |
192-
| Foo.qll:6:3:6:38 | ClassPredicate | Foo.qll:6:23:6:36 | ComparisonFormula | semmle.order | 12 |
189+
| Foo.qll:6:3:6:38 | ClassPredicate toString | Foo.qll:6:3:6:8 | TypeExpr | semmle.label | getReturnTypeExpr() |
190+
| Foo.qll:6:3:6:38 | ClassPredicate toString | Foo.qll:6:3:6:8 | TypeExpr | semmle.order | 10 |
191+
| Foo.qll:6:3:6:38 | ClassPredicate toString | Foo.qll:6:23:6:36 | ComparisonFormula | semmle.label | getBody() |
192+
| Foo.qll:6:3:6:38 | ClassPredicate toString | Foo.qll:6:23:6:36 | ComparisonFormula | semmle.order | 12 |
193193
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:23:6:28 | result | semmle.label | getLeftOperand() |
194194
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:23:6:28 | result | semmle.order | 12 |
195195
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:30:6:30 | ComparisonOp | semmle.label | getOperator() |
196196
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:30:6:30 | ComparisonOp | semmle.order | 14 |
197197
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:32:6:36 | String | semmle.label | getRightOperand() |
198198
| Foo.qll:6:23:6:36 | ComparisonFormula | Foo.qll:6:32:6:36 | String | semmle.order | 15 |
199-
| Foo.qll:9:7:11:1 | foo | Foo.qll:9:21:9:25 | f | semmle.label | getParameter(_) |
200-
| Foo.qll:9:7:11:1 | foo | Foo.qll:9:21:9:25 | f | semmle.order | 17 |
201-
| Foo.qll:9:7:11:1 | foo | Foo.qll:10:3:10:85 | ComparisonFormula | semmle.label | getBody() |
202-
| Foo.qll:9:7:11:1 | foo | Foo.qll:10:3:10:85 | ComparisonFormula | semmle.order | 19 |
199+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | Foo.qll:9:21:9:25 | f | semmle.label | getParameter(_) |
200+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | Foo.qll:9:21:9:25 | f | semmle.order | 17 |
201+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | Foo.qll:10:3:10:85 | ComparisonFormula | semmle.label | getBody() |
202+
| Foo.qll:9:7:11:1 | ClasslessPredicate foo | Foo.qll:10:3:10:85 | ComparisonFormula | semmle.order | 19 |
203203
| Foo.qll:9:21:9:25 | f | Foo.qll:9:21:9:23 | TypeExpr | semmle.label | getTypeExpr() |
204204
| Foo.qll:9:21:9:25 | f | Foo.qll:9:21:9:23 | TypeExpr | semmle.order | 17 |
205205
| Foo.qll:10:3:10:85 | ComparisonFormula | Foo.qll:10:3:10:3 | f | semmle.label | getLeftOperand() |
@@ -230,10 +230,10 @@ edges
230230
| Foo.qll:10:27:10:50 | ComparisonFormula | Foo.qll:10:46:10:50 | String | semmle.order | 30 |
231231
| Foo.qll:10:69:10:84 | MemberCall | Foo.qll:10:69:10:73 | inner | semmle.label | getBase() |
232232
| Foo.qll:10:69:10:84 | MemberCall | Foo.qll:10:69:10:73 | inner | semmle.order | 32 |
233-
| Foo.qll:13:1:25:1 | calls | Foo.qll:13:17:13:21 | f | semmle.label | getParameter(_) |
234-
| Foo.qll:13:1:25:1 | calls | Foo.qll:13:17:13:21 | f | semmle.order | 35 |
235-
| Foo.qll:13:1:25:1 | calls | Foo.qll:14:3:24:23 | Disjunction | semmle.label | getBody() |
236-
| Foo.qll:13:1:25:1 | calls | Foo.qll:14:3:24:23 | Disjunction | semmle.order | 37 |
233+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | Foo.qll:13:17:13:21 | f | semmle.label | getParameter(_) |
234+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | Foo.qll:13:17:13:21 | f | semmle.order | 35 |
235+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | Foo.qll:14:3:24:23 | Disjunction | semmle.label | getBody() |
236+
| Foo.qll:13:1:25:1 | ClasslessPredicate calls | Foo.qll:14:3:24:23 | Disjunction | semmle.order | 37 |
237237
| Foo.qll:13:17:13:21 | f | Foo.qll:13:17:13:19 | TypeExpr | semmle.label | getTypeExpr() |
238238
| Foo.qll:13:17:13:21 | f | Foo.qll:13:17:13:19 | TypeExpr | semmle.order | 35 |
239239
| Foo.qll:14:3:14:10 | PredicateCall | Foo.qll:14:9:14:9 | f | semmle.label | getArgument(_) |
@@ -322,7 +322,7 @@ edges
322322
| Foo.qll:24:17:24:21 | AddExpr | Foo.qll:24:17:24:17 | Integer | semmle.order | 78 |
323323
| Foo.qll:24:17:24:21 | AddExpr | Foo.qll:24:21:24:21 | Integer | semmle.label | getRightOperand() |
324324
| Foo.qll:24:17:24:21 | AddExpr | Foo.qll:24:21:24:21 | Integer | semmle.order | 80 |
325-
| printAst.ql:1:1:1:29 | TopLevel | printAst.ql:1:1:1:28 | Import | semmle.label | getAMember() |
325+
| printAst.ql:1:1:1:29 | TopLevel | printAst.ql:1:1:1:28 | Import | semmle.label | getAnImport() |
326326
| printAst.ql:1:1:1:29 | TopLevel | printAst.ql:1:1:1:28 | Import | semmle.order | 81 |
327327
graphProperties
328328
| semmle.graphKind | tree |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| Test.qll:12:3:12:33 | ClassPredicate | Wrong.testoverrides $@ but does not have an override annotation. | Test.qll:4:3:4:40 | ClassPredicate | Super.test |
1+
| Test.qll:12:3:12:33 | ClassPredicate test | Wrong.testoverrides $@ but does not have an override annotation. | Test.qll:4:3:4:40 | ClassPredicate test | Super.test |

0 commit comments

Comments
 (0)