@@ -18,6 +18,7 @@ package result
1818import (
1919 "cmp"
2020
21+ f "github.com/arduino/arduino-cli/internal/algorithms"
2122 "github.com/arduino/arduino-cli/internal/orderedmap"
2223 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2324 semver "go.bug.st/relaxed-semver"
@@ -880,6 +881,7 @@ type CompileResponse struct {
880881 BoardPlatform * InstalledPlatformReference `json:"board_platform,omitempty"`
881882 BuildPlatform * InstalledPlatformReference `json:"build_platform,omitempty"`
882883 BuildProperties []string `json:"build_properties,omitempty"`
884+ Diagnostics []* CompileDiagnostic `json:"diagnostics,omitempty"`
883885}
884886
885887func NewCompileResponse (c * rpc.CompileResponse ) * CompileResponse {
@@ -904,6 +906,7 @@ func NewCompileResponse(c *rpc.CompileResponse) *CompileResponse {
904906 BoardPlatform : NewInstalledPlatformReference (c .GetBoardPlatform ()),
905907 BuildPlatform : NewInstalledPlatformReference (c .GetBuildPlatform ()),
906908 BuildProperties : c .GetBuildProperties (),
909+ Diagnostics : NewCompileDiagnostics (c .GetDiagnostics ()),
907910 }
908911}
909912
@@ -959,3 +962,61 @@ func NewBoardListWatchResponse(r *rpc.BoardListWatchResponse) *BoardListWatchRes
959962 Error : r .Error ,
960963 }
961964}
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