@@ -117,3 +117,63 @@ func (ls *INOLanguageServer) ide2ClangVersionedTextDocumentIdentifier(logger jso
117
117
Version : ideVersionedDoc .Version ,
118
118
}, err
119
119
}
120
+
121
+ func (ls * INOLanguageServer ) ide2ClangDiagnosticRelatedInformationArray (logger jsonrpc.FunctionLogger , ideInfos []lsp.DiagnosticRelatedInformation ) ([]lsp.DiagnosticRelatedInformation , error ) {
122
+ clangInfos := []lsp.DiagnosticRelatedInformation {}
123
+ for _ , ideInfo := range ideInfos {
124
+ clangLocation , err := ls .ide2ClangLocation (logger , ideInfo .Location )
125
+ if err != nil {
126
+ return nil , err
127
+ }
128
+ clangInfos = append (clangInfos , lsp.DiagnosticRelatedInformation {
129
+ Message : ideInfo .Message ,
130
+ Location : clangLocation ,
131
+ })
132
+ }
133
+ return clangInfos , nil
134
+ }
135
+
136
+ func (ls * INOLanguageServer ) ide2ClangLocation (logger jsonrpc.FunctionLogger , ideLocation lsp.Location ) (lsp.Location , error ) {
137
+ clangURI , clangRange , err := ls .ide2ClangRange (logger , ideLocation .URI , ideLocation .Range )
138
+ return lsp.Location {
139
+ URI : clangURI ,
140
+ Range : clangRange ,
141
+ }, err
142
+ }
143
+
144
+ func (ls * INOLanguageServer ) ide2ClangDiagnostic (logger jsonrpc.FunctionLogger , ideURI lsp.DocumentURI , ideDiag lsp.Diagnostic ) (lsp.DocumentURI , lsp.Diagnostic , error ) {
145
+ clangURI , clangRange , err := ls .ide2ClangRange (logger , ideURI , ideDiag .Range )
146
+ if err != nil {
147
+ return lsp.DocumentURI {}, lsp.Diagnostic {}, err
148
+ }
149
+ clangDiagRelatedInfo , err := ls .ide2ClangDiagnosticRelatedInformationArray (logger , ideDiag .RelatedInformation )
150
+ if err != nil {
151
+ return lsp.DocumentURI {}, lsp.Diagnostic {}, err
152
+ }
153
+ return clangURI , lsp.Diagnostic {
154
+ Range : clangRange ,
155
+ RelatedInformation : clangDiagRelatedInfo ,
156
+ Severity : ideDiag .Severity ,
157
+ Code : ideDiag .Code ,
158
+ CodeDescription : ideDiag .CodeDescription ,
159
+ Source : ideDiag .Source ,
160
+ Message : ideDiag .Message ,
161
+ Tags : ideDiag .Tags ,
162
+ Data : ideDiag .Data ,
163
+ }, nil
164
+ }
165
+
166
+ func (ls * INOLanguageServer ) ide2ClangCodeActionContext (logger jsonrpc.FunctionLogger , ideURI lsp.DocumentURI , ideContext lsp.CodeActionContext ) (lsp.CodeActionContext , error ) {
167
+ clangDiagnostics := []lsp.Diagnostic {}
168
+ for _ , ideDiag := range ideContext .Diagnostics {
169
+ _ , clangDiag , err := ls .ide2ClangDiagnostic (logger , ideURI , ideDiag )
170
+ if err != nil {
171
+ return lsp.CodeActionContext {}, err
172
+ }
173
+ clangDiagnostics = append (clangDiagnostics , clangDiag )
174
+ }
175
+ return lsp.CodeActionContext {
176
+ Diagnostics : clangDiagnostics ,
177
+ Only : ideContext .Only ,
178
+ }, nil
179
+ }
0 commit comments