Skip to content

Commit 06ee3bd

Browse files
rename diagnostic manager in Store
1 parent e6c58c4 commit 06ee3bd

File tree

6 files changed

+49
-53
lines changed

6 files changed

+49
-53
lines changed

Diff for: internal/arduino/builder/builder.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/compilation"
2727
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/detector"
28-
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnosticmanager"
2928
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnostics"
3029
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/logger"
3130
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/progress"
@@ -94,7 +93,7 @@ type Builder struct {
9493

9594
toolEnv []string
9695

97-
diagnosticsManager *diagnosticmanager.Manager
96+
diagnosticStore *diagnostics.Store
9897
}
9998

10099
// buildArtifacts contains the result of various build
@@ -195,7 +194,7 @@ func NewBuilder(
195194
logger.Warn(string(verboseOut))
196195
}
197196

198-
diagnosticmanager := diagnosticmanager.New()
197+
diagnosticStore := diagnostics.NewStore()
199198
b := &Builder{
200199
sketch: sk,
201200
buildProperties: buildProperties,
@@ -228,13 +227,13 @@ func NewBuilder(
228227
buildProperties.GetPath("runtime.platform.path"),
229228
buildProperties.GetPath("build.core.path"), // TODO can we buildCorePath ?
230229
),
231-
diagnosticsManager: diagnosticmanager,
230+
diagnosticStore: diagnosticStore,
232231
libsDetector: detector.NewSketchLibrariesDetector(
233232
libsManager, libsResolver,
234233
useCachedLibrariesResolution,
235234
onlyUpdateCompilationDatabase,
236235
logger,
237-
diagnosticmanager,
236+
diagnosticStore,
238237
),
239238
}
240239
return b, nil
@@ -262,7 +261,7 @@ func (b *Builder) ImportedLibraries() libraries.List {
262261

263262
// CompilerDiagnostics returns the parsed compiler diagnostics
264263
func (b *Builder) CompilerDiagnostics() diagnostics.Diagnostics {
265-
return b.diagnosticsManager.CompilerDiagnostics()
264+
return b.diagnosticStore.Diagnostics()
266265
}
267266

268267
// Preprocess fixdoc

Diff for: internal/arduino/builder/compilation.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ func (b *Builder) compileFileWithRecipe(
166166
b.logger.WriteStderr(commandStderr.Bytes())
167167

168168
// Parse the output of the compiler to gather errors and warnings...
169-
if b.diagnosticsManager != nil {
170-
b.diagnosticsManager.Parse(command.GetArgs(), commandStdout.Bytes())
171-
b.diagnosticsManager.Parse(command.GetArgs(), commandStderr.Bytes())
169+
if b.diagnosticStore != nil {
170+
b.diagnosticStore.Parse(command.GetArgs(), commandStdout.Bytes())
171+
b.diagnosticStore.Parse(command.GetArgs(), commandStderr.Bytes())
172172
}
173173

174174
// ...and then return the error

Diff for: internal/arduino/builder/internal/detector/detector.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"strings"
2727
"time"
2828

29-
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnosticmanager"
29+
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/diagnostics"
3030
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/logger"
3131
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/preprocessor"
3232
"github.com/arduino/arduino-cli/internal/arduino/builder/internal/utils"
@@ -58,7 +58,7 @@ type SketchLibrariesDetector struct {
5858
librariesResolutionResults map[string]libraryResolutionResult
5959
includeFolders paths.PathList
6060
logger *logger.BuilderLogger
61-
diagnosticManager *diagnosticmanager.Manager
61+
diagnosticStore *diagnostics.Store
6262
}
6363

6464
// NewSketchLibrariesDetector todo
@@ -68,7 +68,7 @@ func NewSketchLibrariesDetector(
6868
useCachedLibrariesResolution bool,
6969
onlyUpdateCompilationDatabase bool,
7070
logger *logger.BuilderLogger,
71-
diagnosticManager *diagnosticmanager.Manager,
71+
diagnosticStore *diagnostics.Store,
7272
) *SketchLibrariesDetector {
7373
return &SketchLibrariesDetector{
7474
librariesManager: lm,
@@ -79,7 +79,7 @@ func NewSketchLibrariesDetector(
7979
includeFolders: paths.PathList{},
8080
onlyUpdateCompilationDatabase: onlyUpdateCompilationDatabase,
8181
logger: logger,
82-
diagnosticManager: diagnosticManager,
82+
diagnosticStore: diagnosticStore,
8383
}
8484
}
8585

@@ -392,11 +392,11 @@ func (l *SketchLibrariesDetector) findIncludesUntilDone(
392392
// deleted, so hopefully the next compilation will succeed.
393393
return errors.New(tr("Internal error in cache"))
394394
}
395-
l.diagnosticManager.Parse(result.Args(), result.Stderr())
395+
l.diagnosticStore.Parse(result.Args(), result.Stderr())
396396
l.logger.WriteStderr(result.Stderr())
397397
return err
398398
}
399-
l.diagnosticManager.Parse(preprocFirstResult.Args(), preprocFirstResult.Stderr())
399+
l.diagnosticStore.Parse(preprocFirstResult.Args(), preprocFirstResult.Stderr())
400400
l.logger.WriteStderr(preprocFirstResult.Stderr())
401401
return preprocErr
402402
}

Diff for: internal/arduino/builder/internal/diagnosticmanager/diagnosticmanager.go

-37
This file was deleted.
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package diagnostics
2+
3+
import (
4+
"github.com/sirupsen/logrus"
5+
)
6+
7+
type Store struct {
8+
results Diagnostics
9+
}
10+
11+
func NewStore() *Store {
12+
return &Store{}
13+
}
14+
15+
func (m *Store) Parse(cmdline []string, out []byte) {
16+
compiler := DetectCompilerFromCommandLine(
17+
cmdline,
18+
false, // at the moment compiler-probing is not required
19+
)
20+
if compiler == nil {
21+
logrus.Warnf("Could not detect compiler from: %s", cmdline)
22+
return
23+
}
24+
diags, err := ParseCompilerOutput(compiler, out)
25+
if err != nil {
26+
logrus.Warnf("Error parsing compiler output: %s", err)
27+
return
28+
}
29+
m.results = append(m.results, diags...)
30+
}
31+
32+
func (m *Store) Diagnostics() Diagnostics {
33+
return m.results
34+
}

Diff for: internal/arduino/builder/preprocess_sketch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (b *Builder) preprocessSketch(includes paths.PathList) error {
3232
} else {
3333
b.logger.WriteStdout(result.Stderr())
3434
}
35-
b.diagnosticsManager.Parse(result.Args(), result.Stderr())
35+
b.diagnosticStore.Parse(result.Args(), result.Stderr())
3636

3737
return err
3838
}

0 commit comments

Comments
 (0)