Commit bea5215
committed
gopls/internalanalysis: DeleteStmt deletes comments
DeleteStmt is called with just the AST so it has trouble deciding if
a comment is associated with the statement to be deleted. For instance,
for /*A*/ init()/*B*/;/*C/cond()/*D/;/*E*/post() /*F*/ { /*G*/}
comment B and C are indistinguishable, as are D and E. That is, as the
AST does not say where the semicolons are, B and C could go either
with the init() or the cond(), so cannot be removed safely. The same
is true for D, E, and the post(). (And there are other similar cases.)
But the other comments can be removed as they are unambiguously
associated with the statement being deleted.
The most common case where the new code differs is that it removes
whole lines like
stmt // comment
Change-Id: I2d0652892241aac3a80f1b0a0cafbfeec2e6274f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/710775
Reviewed-by: Alan Donovan <[email protected]>
TryBot-Bypass: Peter Weinberger <[email protected]>1 parent b2d9e77 commit bea5215
File tree
12 files changed
+240
-296
lines changed- gopls/internal
- analysis/unusedvariable/testdata/src
- assign
- decl
- test/marker/testdata/quickfix
- go/analysis/passes
- assign/testdata/src
- a
- typeparams
- modernize/testdata/src
- forvar
- waitgroup
- unreachable/testdata/src/a
- internal/refactor
12 files changed
+240
-296
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 19 | | |
24 | 20 | | |
25 | 21 | | |
26 | 22 | | |
27 | 23 | | |
28 | 24 | | |
29 | | - | |
30 | 25 | | |
31 | 26 | | |
32 | 27 | | |
| |||
44 | 39 | | |
45 | 40 | | |
46 | 41 | | |
47 | | - | |
48 | 42 | | |
49 | 43 | | |
50 | | - | |
51 | 44 | | |
52 | 45 | | |
53 | | - | |
54 | 46 | | |
55 | 47 | | |
56 | 48 | | |
57 | 49 | | |
58 | | - | |
59 | 50 | | |
60 | 51 | | |
61 | 52 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
22 | | - | |
23 | 20 | | |
24 | 21 | | |
25 | 22 | | |
| |||
Lines changed: 0 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | | - | |
11 | 9 | | |
12 | 10 | | |
13 | 11 | | |
14 | | - | |
15 | | - | |
16 | 12 | | |
17 | 13 | | |
18 | 14 | | |
19 | 15 | | |
20 | | - | |
21 | | - | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
26 | | - | |
27 | 20 | | |
28 | 21 | | |
29 | 22 | | |
30 | 23 | | |
31 | | - | |
32 | 24 | | |
33 | 25 | | |
34 | 26 | | |
35 | 27 | | |
36 | | - | |
37 | 28 | | |
38 | 29 | | |
39 | 30 | | |
| |||
Lines changed: 0 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
22 | 19 | | |
23 | 20 | | |
24 | 21 | | |
| |||
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | | - | |
32 | 28 | | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
36 | | - | |
37 | 32 | | |
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
41 | | - | |
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
| |||
48 | 42 | | |
49 | 43 | | |
50 | 44 | | |
51 | | - | |
52 | 45 | | |
53 | 46 | | |
54 | 47 | | |
55 | 48 | | |
56 | 49 | | |
57 | | - | |
58 | 50 | | |
59 | 51 | | |
60 | 52 | | |
61 | 53 | | |
62 | 54 | | |
63 | | - | |
64 | 55 | | |
65 | 56 | | |
66 | 57 | | |
| |||
152 | 143 | | |
153 | 144 | | |
154 | 145 | | |
155 | | - | |
156 | 146 | | |
157 | 147 | | |
158 | 148 | | |
159 | 149 | | |
160 | 150 | | |
161 | | - | |
162 | 151 | | |
163 | 152 | | |
164 | 153 | | |
165 | 154 | | |
166 | 155 | | |
167 | 156 | | |
168 | | - | |
169 | 157 | | |
170 | 158 | | |
171 | 159 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | | - | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
| |||
0 commit comments