@@ -18,6 +18,7 @@ package result
18
18
import (
19
19
"cmp"
20
20
21
+ f "github.com/arduino/arduino-cli/internal/algorithms"
21
22
"github.com/arduino/arduino-cli/internal/orderedmap"
22
23
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
23
24
semver "go.bug.st/relaxed-semver"
@@ -880,6 +881,7 @@ type CompileResponse struct {
880
881
BoardPlatform *InstalledPlatformReference `json:"board_platform,omitempty"`
881
882
BuildPlatform *InstalledPlatformReference `json:"build_platform,omitempty"`
882
883
BuildProperties []string `json:"build_properties,omitempty"`
884
+ Diagnostics []*CompileDiagnostic `json:"diagnostics,omitempty"`
883
885
}
884
886
885
887
func NewCompileResponse(c *rpc.CompileResponse) *CompileResponse {
@@ -904,6 +906,7 @@ func NewCompileResponse(c *rpc.CompileResponse) *CompileResponse {
904
906
BoardPlatform: NewInstalledPlatformReference(c.GetBoardPlatform()),
905
907
BuildPlatform: NewInstalledPlatformReference(c.GetBuildPlatform()),
906
908
BuildProperties: c.GetBuildProperties(),
909
+ Diagnostics: NewCompileDiagnostics(c.GetDiagnostics()),
907
910
}
908
911
}
909
912
@@ -959,3 +962,61 @@ func NewBoardListWatchResponse(r *rpc.BoardListWatchResponse) *BoardListWatchRes
959
962
Error: r.Error,
960
963
}
961
964
}
965
+
966
+ type CompileDiagnostic struct {
967
+ Severity string `json:"severity,omitempty"`
968
+ Message string `json:"message,omitempty"`
969
+ File string `json:"file,omitempty"`
970
+ Line int64 `json:"line,omitempty"`
971
+ Column int64 `json:"column,omitempty"`
972
+ Context []*CompileDiagnosticContext `json:"context,omitempty"`
973
+ Notes []*CompileDiagnosticNote `json:"notes,omitempty"`
974
+ }
975
+
976
+ func NewCompileDiagnostics(cd []*rpc.CompileDiagnostic) []*CompileDiagnostic {
977
+ return f.Map(cd, NewCompileDiagnostic)
978
+ }
979
+
980
+ func NewCompileDiagnostic(cd *rpc.CompileDiagnostic) *CompileDiagnostic {
981
+ return &CompileDiagnostic{
982
+ Severity: cd.GetSeverity(),
983
+ Message: cd.GetMessage(),
984
+ File: cd.GetFile(),
985
+ Line: cd.GetLine(),
986
+ Column: cd.GetColumn(),
987
+ Context: f.Map(cd.GetContext(), NewCompileDiagnosticContext),
988
+ Notes: f.Map(cd.GetNotes(), NewCompileDiagnosticNote),
989
+ }
990
+ }
991
+
992
+ type CompileDiagnosticContext struct {
993
+ Message string `json:"message,omitempty"`
994
+ File string `json:"file,omitempty"`
995
+ Line int64 `json:"line,omitempty"`
996
+ Column int64 `json:"column,omitempty"`
997
+ }
998
+
999
+ func NewCompileDiagnosticContext(cdc *rpc.CompileDiagnosticContext) *CompileDiagnosticContext {
1000
+ return &CompileDiagnosticContext{
1001
+ Message: cdc.GetMessage(),
1002
+ File: cdc.GetFile(),
1003
+ Line: cdc.GetLine(),
1004
+ Column: cdc.GetColumn(),
1005
+ }
1006
+ }
1007
+
1008
+ type CompileDiagnosticNote struct {
1009
+ Message string `json:"message,omitempty"`
1010
+ File string `json:"file,omitempty"`
1011
+ Line int64 `json:"line,omitempty"`
1012
+ Column int64 `json:"column,omitempty"`
1013
+ }
1014
+
1015
+ func NewCompileDiagnosticNote(cdn *rpc.CompileDiagnosticNote) *CompileDiagnosticNote {
1016
+ return &CompileDiagnosticNote{
1017
+ Message: cdn.GetMessage(),
1018
+ File: cdn.GetFile(),
1019
+ Line: cdn.GetLine(),
1020
+ Column: cdn.GetColumn(),
1021
+ }
1022
+ }
0 commit comments