Finalize structured diagnostic aggregation
This commit is contained in:
@@ -259,7 +259,7 @@ type rejectedFile struct {
|
||||
}
|
||||
|
||||
type warningsFile struct {
|
||||
Warnings []contracts.Warning `json:"warnings"`
|
||||
Groups []contracts.DiagnosticGroup `json:"groups"`
|
||||
}
|
||||
|
||||
func logicalFiles(req contracts.OutputRequest, options Options) ([]contracts.OutputFile, error) {
|
||||
@@ -332,7 +332,7 @@ func logicalFiles(req contracts.OutputRequest, options Options) ([]contracts.Out
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
warningsOutput, err := jsonFile("warnings.json", warningsFile{Warnings: cloneWarnings(req.Warnings)})
|
||||
warningsOutput, err := jsonFile("warnings.json", warningsFile{Groups: warningGroups(req.Diagnostics)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -487,11 +487,14 @@ func cloneRejected(rejected []contracts.RejectedOutput) []contracts.RejectedOutp
|
||||
return append([]contracts.RejectedOutput(nil), rejected...)
|
||||
}
|
||||
|
||||
func cloneWarnings(warnings []contracts.Warning) []contracts.Warning {
|
||||
if len(warnings) == 0 {
|
||||
return []contracts.Warning{}
|
||||
func warningGroups(collection contracts.DiagnosticCollection) []contracts.DiagnosticGroup {
|
||||
groups := make([]contracts.DiagnosticGroup, 0)
|
||||
for _, group := range collection.Groups {
|
||||
if group.Disposition == contracts.DiagnosticDispositionWarning {
|
||||
groups = append(groups, group)
|
||||
}
|
||||
}
|
||||
return append([]contracts.Warning(nil), warnings...)
|
||||
return contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: groups}).Groups
|
||||
}
|
||||
|
||||
func encoderErrorf(format string, args ...any) error {
|
||||
|
||||
Reference in New Issue
Block a user