@@ -21,11 +21,11 @@ import (
21
21
"io"
22
22
"os"
23
23
"path/filepath"
24
- "slices"
25
24
"strings"
26
25
27
26
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/compilation"
28
27
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/detector"
28
+ "github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnosticmanager"
29
29
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnostics"
30
30
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/logger"
31
31
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/progress"
@@ -37,7 +37,6 @@ import (
37
37
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
38
38
"github.com/arduino/go-paths-helper"
39
39
"github.com/arduino/go-properties-orderedmap"
40
- "github.com/sirupsen/logrus"
41
40
)
42
41
43
42
// ErrSketchCannotBeLocatedInBuildPath fixdoc
@@ -95,11 +94,7 @@ type Builder struct {
95
94
96
95
toolEnv []string
97
96
98
- // This is a function used to parse the output of the compiler
99
- // It is used to extract errors and warnings
100
- compilerOutputParser diagnostics.CompilerOutputParserCB
101
- // and here are the diagnostics parsed from the compiler
102
- compilerDiagnostics diagnostics.Diagnostics
97
+ diagnosticsManager * diagnosticmanager.Manager
103
98
}
104
99
105
100
// buildArtifacts contains the result of various build
@@ -200,6 +195,7 @@ func NewBuilder(
200
195
logger .Warn (string (verboseOut ))
201
196
}
202
197
198
+ diagnosticmanager := diagnosticmanager .New ()
203
199
b := & Builder {
204
200
sketch : sk ,
205
201
buildProperties : buildProperties ,
@@ -232,33 +228,15 @@ func NewBuilder(
232
228
buildProperties .GetPath ("runtime.platform.path" ),
233
229
buildProperties .GetPath ("build.core.path" ), // TODO can we buildCorePath ?
234
230
),
231
+ diagnosticsManager : diagnosticmanager ,
232
+ libsDetector : detector .NewSketchLibrariesDetector (
233
+ libsManager , libsResolver ,
234
+ useCachedLibrariesResolution ,
235
+ onlyUpdateCompilationDatabase ,
236
+ logger ,
237
+ diagnosticmanager ,
238
+ ),
235
239
}
236
-
237
- b .compilerOutputParser = func (cmdline []string , out []byte ) {
238
- compiler := diagnostics .DetectCompilerFromCommandLine (
239
- cmdline ,
240
- false , // at the moment compiler-probing is not required
241
- )
242
- if compiler == nil {
243
- logrus .Warnf ("Could not detect compiler from: %s" , cmdline )
244
- return
245
- }
246
- diags , err := diagnostics .ParseCompilerOutput (compiler , out )
247
- if err != nil {
248
- logrus .Warnf ("Error parsing compiler output: %s" , err )
249
- return
250
- }
251
- b .compilerDiagnostics = append (b .compilerDiagnostics , diags ... )
252
- }
253
-
254
- b .libsDetector = detector .NewSketchLibrariesDetector (
255
- libsManager , libsResolver ,
256
- useCachedLibrariesResolution ,
257
- onlyUpdateCompilationDatabase ,
258
- logger ,
259
- b .compilerOutputParser ,
260
- )
261
-
262
240
return b , nil
263
241
}
264
242
@@ -284,18 +262,7 @@ func (b *Builder) ImportedLibraries() libraries.List {
284
262
285
263
// CompilerDiagnostics returns the parsed compiler diagnostics
286
264
func (b * Builder ) CompilerDiagnostics () diagnostics.Diagnostics {
287
- // When producing the preprocessing diagnostics, we might have duplicates
288
- // caused by the run of the libraries detector and the sketch preprocessing.
289
- return slices .CompactFunc (b .compilerDiagnostics , func (d1 , d2 * diagnostics.Diagnostic ) bool {
290
- if d1 == nil || d2 == nil {
291
- return false
292
- }
293
- return d1 .Column == d2 .Column &&
294
- d1 .File == d2 .File &&
295
- d1 .Line == d2 .Line &&
296
- d1 .Message == d2 .Message &&
297
- d1 .Severity == d2 .Severity
298
- })
265
+ return b .diagnosticsManager .CompilerDiagnostics ()
299
266
}
300
267
301
268
// Preprocess fixdoc
0 commit comments