Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dad5166

Browse files
committed
C#: Print full name of type mentions in AST
1 parent 7929d8a commit dad5166

34 files changed

Lines changed: 1101 additions & 1071 deletions

File tree

csharp/ql/src/semmle/code/csharp/PrintAst.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ abstract class ElementNode extends PrintAstNode, TElementNode {
249249
abstract class TypeMentionNode extends PrintAstNode {
250250
TypeMention typeMention;
251251

252-
override string toString() { result = "[TypeMention] " + typeMention.getType().toString() }
252+
override string toString() {
253+
result = "[TypeMention] " + typeMention.getType().toStringWithTypes()
254+
}
253255

254256
override Location getLocation() { result = typeMention.getLocation() }
255257

csharp/ql/test/experimental/ir/ir/PrintAst.expected

Lines changed: 107 additions & 107 deletions
Large diffs are not rendered by default.

csharp/ql/test/library-tests/arguments/PrintAst.expected

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ arguments.cs:
33
# 5| 4: [InstanceConstructor] ArgumentsTest
44
#-----| 2: (Parameters)
55
# 5| 0: [Parameter] x
6-
# 5| -1: [TypeMention] Int32
6+
# 5| -1: [TypeMention] int
77
# 5| 1: [IntLiteral] 0
88
# 5| 1: [Parameter] y
9-
# 5| -1: [TypeMention] Int32
9+
# 5| -1: [TypeMention] int
1010
# 5| 1: [IntLiteral] 0
1111
# 6| 4: [BlockStmt] {...}
1212
# 9| 5: [InstanceConstructor] ArgumentsTest
1313
#-----| 2: (Parameters)
1414
# 9| 0: [Parameter] x
15-
# 9| -1: [TypeMention] Int32
15+
# 9| -1: [TypeMention] int
1616
# 9| 1: [Parameter] y
17-
# 9| -1: [TypeMention] Int32
17+
# 9| -1: [TypeMention] int
1818
# 9| 2: [Parameter] z
19-
# 9| -1: [TypeMention] Int32
19+
# 9| -1: [TypeMention] int
2020
# 10| 4: [BlockStmt] {...}
2121
# 11| 0: [ExprStmt] ...;
2222
# 11| 0: [AssignExpr] ... = ...
@@ -26,21 +26,21 @@ arguments.cs:
2626
# 14| -1: [TypeMention] Void
2727
#-----| 2: (Parameters)
2828
# 14| 0: [Parameter] x
29-
# 14| -1: [TypeMention] Int32
29+
# 14| -1: [TypeMention] int
3030
# 14| 1: [IntLiteral] 1
3131
# 14| 1: [Parameter] y
32-
# 14| -1: [TypeMention] Int32
32+
# 14| -1: [TypeMention] int
3333
# 14| 1: [IntLiteral] 2
3434
# 15| 4: [BlockStmt] {...}
3535
# 18| 7: [Method] f2
3636
# 18| -1: [TypeMention] Void
3737
#-----| 2: (Parameters)
3838
# 18| 0: [Parameter] x
39-
# 18| -1: [TypeMention] Int32
39+
# 18| -1: [TypeMention] int
4040
# 18| 1: [Parameter] y
41-
# 18| -1: [TypeMention] Int32
41+
# 18| -1: [TypeMention] int
4242
# 18| 2: [Parameter] z
43-
# 18| -1: [TypeMention] Int32
43+
# 18| -1: [TypeMention] int
4444
# 19| 4: [BlockStmt] {...}
4545
# 20| 0: [ExprStmt] ...;
4646
# 20| 0: [AssignExpr] ... = ...
@@ -51,7 +51,7 @@ arguments.cs:
5151
# 24| 4: [BlockStmt] {...}
5252
# 25| 0: [LocalVariableDeclStmt] ... ...;
5353
# 25| 0: [LocalVariableDeclAndInitExpr] Int32 x = ...
54-
# 25| -1: [TypeMention] Int32
54+
# 25| -1: [TypeMention] int
5555
# 25| 0: [LocalVariableAccess] access to local variable x
5656
# 25| 1: [IntLiteral] 1
5757
# 27| 1: [ExprStmt] ...;
@@ -77,10 +77,10 @@ arguments.cs:
7777
# 33| -1: [TypeMention] Void
7878
#-----| 2: (Parameters)
7979
# 33| 0: [Parameter] o
80-
# 33| -1: [TypeMention] Int32
80+
# 33| -1: [TypeMention] int
8181
# 33| 1: [Parameter] args
8282
# 33| -1: [TypeMention] Int32[]
83-
# 33| 1: [TypeMention] Int32
83+
# 33| 1: [TypeMention] int
8484
# 34| 4: [BlockStmt] {...}
8585
# 35| 0: [ExprStmt] ...;
8686
# 35| 0: [MethodCall] call to method f3
@@ -92,7 +92,7 @@ arguments.cs:
9292
# 36| 0: [IntLiteral] 0
9393
# 36| 1: [ArrayCreation] array creation of type Int32[]
9494
# 36| -2: [TypeMention] Int32[]
95-
# 36| 1: [TypeMention] Int32
95+
# 36| 1: [TypeMention] int
9696
# 36| -1: [ArrayInitializer] { ..., ... }
9797
# 36| 0: [IntLiteral] 1
9898
# 36| 1: [IntLiteral] 2
@@ -112,7 +112,7 @@ arguments.cs:
112112
# 40| 0: [MethodCall] call to method f3
113113
# 40| 0: [ArrayCreation] array creation of type Int32[]
114114
# 40| -2: [TypeMention] Int32[]
115-
# 40| 1: [TypeMention] Int32
115+
# 40| 1: [TypeMention] int
116116
# 40| -1: [ArrayInitializer] { ..., ... }
117117
# 40| 0: [IntLiteral] 1
118118
# 40| 1: [IntLiteral] 2
@@ -122,29 +122,29 @@ arguments.cs:
122122
#-----| 2: (Parameters)
123123
# 43| 0: [Parameter] args
124124
# 43| -1: [TypeMention] Object[]
125-
# 43| 1: [TypeMention] Object
125+
# 43| 1: [TypeMention] object
126126
# 44| 4: [BlockStmt] {...}
127127
# 45| 0: [ExprStmt] ...;
128128
# 45| 0: [MethodCall] call to method f4
129129
# 45| 0: [ArrayCreation] array creation of type Object[]
130130
# 45| -2: [TypeMention] Object[]
131-
# 45| 1: [TypeMention] Object
131+
# 45| 1: [TypeMention] object
132132
# 45| -1: [ArrayInitializer] { ..., ... }
133133
# 45| 0: [NullLiteral] null
134134
# 45| 1: [NullLiteral] null
135135
# 48| 11: [Property] Prop
136-
# 48| -1: [TypeMention] Int32
136+
# 48| -1: [TypeMention] int
137137
# 48| 3: [Getter] get_Prop
138138
# 48| 4: [Setter] set_Prop
139139
#-----| 2: (Parameters)
140140
# 48| 0: [Parameter] value
141141
# 50| 12: [Indexer] Item
142-
# 50| -1: [TypeMention] Int32
142+
# 50| -1: [TypeMention] int
143143
#-----| 1: (Parameters)
144144
# 50| 0: [Parameter] a
145-
# 50| -1: [TypeMention] Int32
145+
# 50| -1: [TypeMention] int
146146
# 50| 1: [Parameter] b
147-
# 50| -1: [TypeMention] Int32
147+
# 50| -1: [TypeMention] int
148148
# 50| 3: [Getter] get_Item
149149
#-----| 2: (Parameters)
150150
# 50| 0: [Parameter] a
@@ -205,7 +205,7 @@ arguments.cs:
205205
# 60| 1: [IntLiteral] 12
206206
# 61| 7: [LocalVariableDeclStmt] ... ...;
207207
# 61| 0: [LocalVariableDeclAndInitExpr] (Int32,Int32) tuple = ...
208-
# 61| -1: [TypeMention] (Int32,Int32)
208+
# 61| -1: [TypeMention] (int, int)
209209
# 61| 0: [LocalVariableAccess] access to local variable tuple
210210
# 61| 1: [TupleExpr] (..., ...)
211211
# 61| 0: [IntLiteral] 13
@@ -239,15 +239,15 @@ arguments.cs:
239239
#-----| 3: (Base types)
240240
# 72| 0: [TypeMention] Attribute
241241
# 74| 4: [Field] x
242-
# 74| -1: [TypeMention] Int32
242+
# 74| -1: [TypeMention] int
243243
# 75| 5: [IndexerProperty] y
244-
# 75| -1: [TypeMention] String
244+
# 75| -1: [TypeMention] string
245245
# 75| 3: [Getter] get_y
246246
# 75| 4: [Setter] set_y
247247
#-----| 2: (Parameters)
248248
# 75| 0: [Parameter] value
249249
# 76| 6: [InstanceConstructor] MyAttribute
250250
#-----| 2: (Parameters)
251251
# 76| 0: [Parameter] b
252-
# 76| -1: [TypeMention] Boolean
252+
# 76| -1: [TypeMention] bool
253253
# 76| 4: [BlockStmt] {...}

csharp/ql/test/library-tests/assignments/PrintAst.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Assignments.cs:
55
# 4| 4: [BlockStmt] {...}
66
# 5| 0: [LocalVariableDeclStmt] ... ...;
77
# 5| 0: [LocalVariableDeclAndInitExpr] Int32 x = ...
8-
# 5| -1: [TypeMention] Int32
8+
# 5| -1: [TypeMention] int
99
# 5| 0: [LocalVariableAccess] access to local variable x
1010
# 5| 1: [IntLiteral] 0
1111
# 6| 1: [ExprStmt] ...;
@@ -53,9 +53,9 @@ Assignments.cs:
5353
# 22| 7: [DelegateType] EventHandler
5454
#-----| 2: (Parameters)
5555
# 22| 0: [Parameter] sender
56-
# 22| -1: [TypeMention] Object
56+
# 22| -1: [TypeMention] object
5757
# 22| 1: [Parameter] e
58-
# 22| -1: [TypeMention] Object
58+
# 22| -1: [TypeMention] object
5959
# 23| 8: [Event] Event
6060
# 23| -1: [TypeMention] EventHandler
6161
# 23| 3: [AddEventAccessor] add_Event

csharp/ql/test/library-tests/attributes/PrintAst.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ attributes.cs:
5353
# 44| 4: [BlockStmt] {...}
5454
# 47| [Class] Bar
5555
# 49| 5: [Method] inc
56-
# 49| -1: [TypeMention] Int32
56+
# 49| -1: [TypeMention] int
5757
#-----| 2: (Parameters)
5858
# 49| 0: [Parameter] x
59-
# 49| -1: [TypeMention] Int32
59+
# 49| -1: [TypeMention] int
6060
#-----| 0: (Attributes)
6161
# 49| 1: [Attribute] [Foo(...)]
6262
# 49| 0: [TypeMention] Foo
@@ -85,15 +85,15 @@ attributes.cs:
8585
#-----| 3: (Base types)
8686
# 58| 0: [TypeMention] Attribute
8787
# 60| 4: [Field] x
88-
# 60| -1: [TypeMention] Int32
88+
# 60| -1: [TypeMention] int
8989
# 61| 5: [IndexerProperty] y
90-
# 61| -1: [TypeMention] String
90+
# 61| -1: [TypeMention] string
9191
# 61| 3: [Getter] get_y
9292
# 61| 4: [Setter] set_y
9393
#-----| 2: (Parameters)
9494
# 61| 0: [Parameter] value
9595
# 62| 6: [InstanceConstructor] MyAttribute
9696
#-----| 2: (Parameters)
9797
# 62| 0: [Parameter] b
98-
# 62| -1: [TypeMention] Boolean
98+
# 62| -1: [TypeMention] bool
9999
# 62| 4: [BlockStmt] {...}

csharp/ql/test/library-tests/constructors/PrintAst.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ constructors.cs:
66
# 8| 5: [InstanceConstructor] Class
77
#-----| 2: (Parameters)
88
# 8| 0: [Parameter] i
9-
# 8| -1: [TypeMention] Int32
9+
# 8| -1: [TypeMention] int
1010
# 9| 4: [BlockStmt] {...}
1111
# 11| 6: [StaticConstructor] Class
1212
# 12| 4: [BlockStmt] {...}
1313
# 14| 7: [Destructor] ~Class
1414
# 15| 4: [BlockStmt] {...}
1515
# 16| 0: [LocalVariableDeclStmt] ... ...;
1616
# 16| 0: [LocalVariableDeclAndInitExpr] Int32 i = ...
17-
# 16| -1: [TypeMention] Int32
17+
# 16| -1: [TypeMention] int
1818
# 16| 0: [LocalVariableAccess] access to local variable i
1919
# 16| 1: [IntLiteral] 0

csharp/ql/test/library-tests/conversion/operator/PrintAst.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Operator.cs:
44
# 5| -1: [TypeMention] C
55
#-----| 2: (Parameters)
66
# 5| 0: [Parameter] i
7-
# 5| -1: [TypeMention] Int32
7+
# 5| -1: [TypeMention] int
88
# 5| 4: [BlockStmt] {...}
99
# 5| 0: [ReturnStmt] return ...;
1010
# 5| 0: [NullLiteral] null
1111
# 7| 6: [Field] x1
12-
# 7| -1: [TypeMention] Int32
12+
# 7| -1: [TypeMention] int
1313
# 8| 7: [Field] x2
1414
# 8| -1: [TypeMention] C
1515
# 11| 8: [Method] M

0 commit comments

Comments
 (0)