Skip to content

Commit a121bf2

Browse files
Denys Smirnovdennwc
authored andcommitted
remove SkippedToken trivias
Signed-off-by: Denys Smirnov <denys@sourced.tech>
1 parent 56e5d4e commit a121bf2

10 files changed

Lines changed: 18 additions & 266 deletions

driver/normalizer/normalizer.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,15 @@ var useFullSpan = []nodes.Value{
198198

199199
// Preprocessors is a block of AST preprocessing rules rules.
200200
var Preprocessors = []Mapping{
201-
// Erase Whitespace and EndOfLine trivias.
201+
// Erase Whitespace, EndOfLine and SkippedToken trivias.
202202
Map(
203203
Obj{
204204
uast.KeyType: Check(
205-
In(nodes.String("WhitespaceTrivia"), nodes.String("EndOfLineTrivia")),
205+
In(
206+
nodes.String("WhitespaceTrivia"),
207+
nodes.String("EndOfLineTrivia"),
208+
nodes.String("SkippedTokensTrivia"),
209+
),
206210
Any(),
207211
),
208212
"FullSpan": Any(),

fixtures/conditional_ops.cs.sem.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -826,24 +826,7 @@
826826
IsMissing: true,
827827
LeadingTrivia: [],
828828
Text: "",
829-
TrailingTrivia: [
830-
{ '@type': "csharp:SkippedTokensTrivia",
831-
'@role': [Incomplete],
832-
'@pos': { '@type': "uast:Positions",
833-
start: { '@type': "uast:Position",
834-
offset: 139,
835-
line: 8,
836-
col: 15,
837-
},
838-
end: { '@type': "uast:Position",
839-
offset: 140,
840-
line: 8,
841-
col: 16,
842-
},
843-
},
844-
IsDirective: false,
845-
},
846-
],
829+
TrailingTrivia: [],
847830
Value: ~,
848831
ValueText: "",
849832
},

fixtures/conditional_ops.cs.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,24 +1068,7 @@
10681068
IsMissing: true,
10691069
LeadingTrivia: [],
10701070
Text: "",
1071-
TrailingTrivia: [
1072-
{ '@type': "SkippedTokensTrivia",
1073-
'@role': [Incomplete],
1074-
'@pos': { '@type': "uast:Positions",
1075-
start: { '@type': "uast:Position",
1076-
offset: 139,
1077-
line: 8,
1078-
col: 15,
1079-
},
1080-
end: { '@type': "uast:Position",
1081-
offset: 140,
1082-
line: 8,
1083-
col: 16,
1084-
},
1085-
},
1086-
IsDirective: false,
1087-
},
1088-
],
1071+
TrailingTrivia: [],
10891072
Value: ~,
10901073
ValueText: "",
10911074
},

fixtures/foreach.cs.sem.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,24 +1944,7 @@
19441944
IsMissing: true,
19451945
LeadingTrivia: [],
19461946
Text: "",
1947-
TrailingTrivia: [
1948-
{ '@type': "csharp:SkippedTokensTrivia",
1949-
'@role': [Incomplete],
1950-
'@pos': { '@type': "uast:Positions",
1951-
start: { '@type': "uast:Position",
1952-
offset: 335,
1953-
line: 13,
1954-
col: 45,
1955-
},
1956-
end: { '@type': "uast:Position",
1957-
offset: 336,
1958-
line: 13,
1959-
col: 46,
1960-
},
1961-
},
1962-
IsDirective: false,
1963-
},
1964-
],
1947+
TrailingTrivia: [],
19651948
Value: ~,
19661949
ValueText: "",
19671950
},

fixtures/foreach.cs.uast

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,24 +2275,7 @@
22752275
},
22762276
IsMissing: true,
22772277
LeadingTrivia: [],
2278-
TrailingTrivia: [
2279-
{ '@type': "SkippedTokensTrivia",
2280-
'@role': [Incomplete],
2281-
'@pos': { '@type': "uast:Positions",
2282-
start: { '@type': "uast:Position",
2283-
offset: 322,
2284-
line: 13,
2285-
col: 32,
2286-
},
2287-
end: { '@type': "uast:Position",
2288-
offset: 324,
2289-
line: 13,
2290-
col: 34,
2291-
},
2292-
},
2293-
IsDirective: false,
2294-
},
2295-
],
2278+
TrailingTrivia: [],
22962279
Value: "",
22972280
ValueText: "",
22982281
},
@@ -2445,24 +2428,7 @@
24452428
IsMissing: true,
24462429
LeadingTrivia: [],
24472430
Text: "",
2448-
TrailingTrivia: [
2449-
{ '@type': "SkippedTokensTrivia",
2450-
'@role': [Incomplete],
2451-
'@pos': { '@type': "uast:Positions",
2452-
start: { '@type': "uast:Position",
2453-
offset: 335,
2454-
line: 13,
2455-
col: 45,
2456-
},
2457-
end: { '@type': "uast:Position",
2458-
offset: 336,
2459-
line: 13,
2460-
col: 46,
2461-
},
2462-
},
2463-
IsDirective: false,
2464-
},
2465-
],
2431+
TrailingTrivia: [],
24662432
Value: ~,
24672433
ValueText: "",
24682434
},

fixtures/modifiers.cs.uast

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,72 +2634,7 @@
26342634
IsMissing: false,
26352635
LeadingTrivia: [],
26362636
Text: ";",
2637-
TrailingTrivia: [
2638-
{ '@type': "SkippedTokensTrivia",
2639-
'@role': [Incomplete],
2640-
'@pos': { '@type': "uast:Positions",
2641-
start: { '@type': "uast:Position",
2642-
offset: 329,
2643-
line: 20,
2644-
col: 1,
2645-
},
2646-
end: { '@type': "uast:Position",
2647-
offset: 335,
2648-
line: 20,
2649-
col: 7,
2650-
},
2651-
},
2652-
IsDirective: false,
2653-
},
2654-
{ '@type': "SkippedTokensTrivia",
2655-
'@role': [Incomplete],
2656-
'@pos': { '@type': "uast:Positions",
2657-
start: { '@type': "uast:Position",
2658-
offset: 336,
2659-
line: 20,
2660-
col: 8,
2661-
},
2662-
end: { '@type': "uast:Position",
2663-
offset: 341,
2664-
line: 20,
2665-
col: 13,
2666-
},
2667-
},
2668-
IsDirective: false,
2669-
},
2670-
{ '@type': "SkippedTokensTrivia",
2671-
'@role': [Incomplete],
2672-
'@pos': { '@type': "uast:Positions",
2673-
start: { '@type': "uast:Position",
2674-
offset: 342,
2675-
line: 20,
2676-
col: 14,
2677-
},
2678-
end: { '@type': "uast:Position",
2679-
offset: 346,
2680-
line: 20,
2681-
col: 18,
2682-
},
2683-
},
2684-
IsDirective: false,
2685-
},
2686-
{ '@type': "SkippedTokensTrivia",
2687-
'@role': [Incomplete],
2688-
'@pos': { '@type': "uast:Positions",
2689-
start: { '@type': "uast:Position",
2690-
offset: 346,
2691-
line: 20,
2692-
col: 18,
2693-
},
2694-
end: { '@type': "uast:Position",
2695-
offset: 347,
2696-
line: 20,
2697-
col: 19,
2698-
},
2699-
},
2700-
IsDirective: false,
2701-
},
2702-
],
2637+
TrailingTrivia: [],
27032638
Value: ";",
27042639
ValueText: ";",
27052640
},

fixtures/object_initializer.cs.sem.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,7 @@
7272
IsMissing: false,
7373
LeadingTrivia: [],
7474
Text: "}",
75-
TrailingTrivia: [
76-
{ '@type': "csharp:SkippedTokensTrivia",
77-
'@role': [Incomplete],
78-
'@pos': { '@type': "uast:Positions",
79-
start: { '@type': "uast:Position",
80-
offset: 180,
81-
line: 8,
82-
col: 1,
83-
},
84-
end: { '@type': "uast:Position",
85-
offset: 181,
86-
line: 8,
87-
col: 2,
88-
},
89-
},
90-
IsDirective: false,
91-
},
92-
],
75+
TrailingTrivia: [],
9376
Value: "}",
9477
ValueText: "}",
9578
},

fixtures/object_initializer.cs.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,7 @@
7272
IsMissing: false,
7373
LeadingTrivia: [],
7474
Text: "}",
75-
TrailingTrivia: [
76-
{ '@type': "SkippedTokensTrivia",
77-
'@role': [Incomplete],
78-
'@pos': { '@type': "uast:Positions",
79-
start: { '@type': "uast:Position",
80-
offset: 180,
81-
line: 8,
82-
col: 1,
83-
},
84-
end: { '@type': "uast:Position",
85-
offset: 181,
86-
line: 8,
87-
col: 2,
88-
},
89-
},
90-
IsDirective: false,
91-
},
92-
],
75+
TrailingTrivia: [],
9376
Value: "}",
9477
ValueText: "}",
9578
},

fixtures/u2_func_generic.cs.sem.uast

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,24 +353,7 @@
353353
IsMissing: false,
354354
LeadingTrivia: [],
355355
Text: "{",
356-
TrailingTrivia: [
357-
{ '@type': "csharp:SkippedTokensTrivia",
358-
'@role': [Incomplete],
359-
'@pos': { '@type': "uast:Positions",
360-
start: { '@type': "uast:Position",
361-
offset: 21,
362-
line: 2,
363-
col: 5,
364-
},
365-
end: { '@type': "uast:Position",
366-
offset: 22,
367-
line: 2,
368-
col: 6,
369-
},
370-
},
371-
IsDirective: false,
372-
},
373-
],
356+
TrailingTrivia: [],
374357
Value: "{",
375358
ValueText: "{",
376359
},

fixtures/u2_func_generic.cs.uast

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,7 @@
172172
},
173173
IsMissing: false,
174174
LeadingTrivia: [],
175-
TrailingTrivia: [
176-
{ '@type': "SkippedTokensTrivia",
177-
'@role': [Incomplete],
178-
'@pos': { '@type': "uast:Positions",
179-
start: { '@type': "uast:Position",
180-
offset: 24,
181-
line: 2,
182-
col: 8,
183-
},
184-
end: { '@type': "uast:Position",
185-
offset: 25,
186-
line: 2,
187-
col: 9,
188-
},
189-
},
190-
IsDirective: false,
191-
},
192-
],
175+
TrailingTrivia: [],
193176
Value: "T1",
194177
ValueText: "T1",
195178
},
@@ -249,24 +232,7 @@
249232
},
250233
IsMissing: false,
251234
LeadingTrivia: [],
252-
TrailingTrivia: [
253-
{ '@type': "SkippedTokensTrivia",
254-
'@role': [Incomplete],
255-
'@pos': { '@type': "uast:Positions",
256-
start: { '@type': "uast:Position",
257-
offset: 28,
258-
line: 2,
259-
col: 12,
260-
},
261-
end: { '@type': "uast:Position",
262-
offset: 29,
263-
line: 2,
264-
col: 13,
265-
},
266-
},
267-
IsDirective: false,
268-
},
269-
],
235+
TrailingTrivia: [],
270236
Value: "T2",
271237
ValueText: "T2",
272238
},
@@ -644,24 +610,7 @@
644610
IsMissing: false,
645611
LeadingTrivia: [],
646612
Text: "{",
647-
TrailingTrivia: [
648-
{ '@type': "SkippedTokensTrivia",
649-
'@role': [Incomplete],
650-
'@pos': { '@type': "uast:Positions",
651-
start: { '@type': "uast:Position",
652-
offset: 21,
653-
line: 2,
654-
col: 5,
655-
},
656-
end: { '@type': "uast:Position",
657-
offset: 22,
658-
line: 2,
659-
col: 6,
660-
},
661-
},
662-
IsDirective: false,
663-
},
664-
],
613+
TrailingTrivia: [],
665614
Value: "{",
666615
ValueText: "{",
667616
},

0 commit comments

Comments
 (0)