@@ -96,6 +96,54 @@ func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) st
96
96
} else {
97
97
text = fmt .Sprintf ("%s: %s" , diag .Analyzer .Name , diag .Message )
98
98
}
99
+ /// ---
100
+
101
+ issue := result.Issue {
102
+ FromLinter : linterName ,
103
+ Text : text ,
104
+ Pos : diag .Position ,
105
+ Pkg : diag .Pkg ,
106
+ // LineRange: &result.Range{
107
+ // From: diag.SuggestedFixes[0].TextEdits[0].Pos,
108
+ // To: 0,
109
+ // },
110
+ // Replacement: &result.Replacement{
111
+ // NeedOnlyDelete: false,
112
+ // NewLines: nil,
113
+ // Inline: nil,
114
+ // },
115
+ }
116
+
117
+ // FIXME how to handle multiple SuggestedFixes and multiple TextEdits?
118
+
119
+ if len (diag .SuggestedFixes ) > 0 {
120
+ // issue.LineRange = &result.Range{
121
+ // From: diag.Pkg.Fset.Position(diag.SuggestedFixes[0].TextEdits[0].Pos).Line,
122
+ // To: diag.Pkg.Fset.Position(diag.SuggestedFixes[0].TextEdits[0].End).Line,
123
+ // }
124
+
125
+ length := diag .Pkg .Fset .Position (diag .SuggestedFixes [0 ].TextEdits [0 ].End ).Column - diag .Pkg .Fset .Position (diag .SuggestedFixes [0 ].TextEdits [0 ].Pos ).Column
126
+
127
+ if length <= 0 {
128
+ // FIXME it's a problem with the inline system, works with LineRange?
129
+ }
130
+
131
+ println ("GGGGGGG" , length )
132
+
133
+ issue .Replacement = & result.Replacement {
134
+ Inline : & result.InlineFix {
135
+ StartCol : diag .Pkg .Fset .Position (diag .SuggestedFixes [0 ].TextEdits [0 ].Pos ).Column - 1 ,
136
+ Length : length ,
137
+ // NewString: "TEST",
138
+ // Length: len(string(diag.SuggestedFixes[0].TextEdits[0].NewText)),
139
+ NewString : string (diag .SuggestedFixes [0 ].TextEdits [0 ].NewText ),
140
+ },
141
+ }
142
+ }
143
+
144
+ issues = append (issues , issue )
145
+
146
+ /// ---
99
147
100
148
issues = append (issues , result.Issue {
101
149
FromLinter : linterName ,
@@ -104,17 +152,16 @@ func buildIssues(diags []Diagnostic, linterNameBuilder func(diag *Diagnostic) st
104
152
Pkg : diag .Pkg ,
105
153
})
106
154
107
- if len (diag .Related ) > 0 {
108
- for _ , info := range diag .Related {
109
- issues = append (issues , result.Issue {
110
- FromLinter : linterName ,
111
- Text : fmt .Sprintf ("%s(related information): %s" , diag .Analyzer .Name , info .Message ),
112
- Pos : diag .Pkg .Fset .Position (info .Pos ),
113
- Pkg : diag .Pkg ,
114
- })
115
- }
155
+ for _ , info := range diag .Related {
156
+ issues = append (issues , result.Issue {
157
+ FromLinter : linterName ,
158
+ Text : fmt .Sprintf ("%s(related information): %s" , diag .Analyzer .Name , info .Message ),
159
+ Pos : diag .Pkg .Fset .Position (info .Pos ),
160
+ Pkg : diag .Pkg ,
161
+ })
116
162
}
117
163
}
164
+
118
165
return issues
119
166
}
120
167
0 commit comments