@@ -13,11 +13,7 @@ import (
13
13
"golang.org/x/tools/gopls/internal/util/safetoken"
14
14
)
15
15
16
- func CanSplitLines (
17
- file * ast.File ,
18
- fset * token.FileSet ,
19
- start , end token.Pos ,
20
- ) (string , bool , error ) {
16
+ func CanSplitLines (file * ast.File , fset * token.FileSet , start , end token.Pos ) (string , bool , error ) {
21
17
msg , lines , numElts , target := findSplitGroupTarget (file , fset , start , end )
22
18
if target == nil {
23
19
return "" , false , nil
@@ -79,9 +75,12 @@ func groupLines(
79
75
return fset , processLines (fset , target , src , file , ", " , "" , "" , "" ), nil
80
76
}
81
77
82
- func processLines (fset * token.FileSet , target ast.Node , src []byte , file * ast.File , sep ,
83
- prefix ,
84
- suffix , indent string ,
78
+ func processLines (
79
+ fset * token.FileSet ,
80
+ target ast.Node ,
81
+ src []byte ,
82
+ file * ast.File ,
83
+ sep , prefix , suffix , indent string ,
85
84
) * analysis.SuggestedFix {
86
85
var replPos , replEnd token.Pos
87
86
var lines []string
@@ -131,9 +130,7 @@ func findSplitGroupTarget(
131
130
// current cursor is inside the parens/bracket
132
131
isInside := opening < start && end < closing
133
132
134
- // todo: retain /*-style comments.
135
- // it doesnt have //-style comment in between
136
- // we prefer not to do anything here because it will break the code once it got grouped.
133
+ // todo: retain /*-style comments instead of rejecting them.
137
134
for _ , comment := range file .Comments {
138
135
if comment .End () < start {
139
136
continue
@@ -143,11 +140,7 @@ func findSplitGroupTarget(
143
140
break
144
141
}
145
142
146
- for _ , c := range comment .List {
147
- if strings .HasPrefix (c .Text , "//" ) {
148
- return false
149
- }
150
- }
143
+ return false
151
144
}
152
145
153
146
// and it has more than 1 element
0 commit comments