Validate source versions in recursive imports
This commit is contained in:
@@ -23,6 +23,7 @@ type sourceVersionAncestor struct {
|
||||
}
|
||||
|
||||
type sourceVersionEvidence struct {
|
||||
sourceID string
|
||||
path Path
|
||||
resolvedPath Path
|
||||
destination Path
|
||||
@@ -34,6 +35,35 @@ type sourceVersionEvidence struct {
|
||||
redacted bool
|
||||
}
|
||||
|
||||
type sourceVersionState struct {
|
||||
localRule *VersionRule
|
||||
effectiveRule *VersionRule
|
||||
mode sourceVersionMode
|
||||
mainProcessing *sourceVersionProcessingResult
|
||||
evidence []*sourceVersionEvidence
|
||||
diagnostics []Diagnostic
|
||||
}
|
||||
|
||||
func (state *sourceVersionState) process(root *document.Node, role sourceVersionRole, destination Path, sourceID string) (sourceVersionProcessingResult, []Diagnostic) {
|
||||
if state == nil || state.mode == sourceVersionModeDefault {
|
||||
return sourceVersionProcessingResult{}, nil
|
||||
}
|
||||
result := processSourceVersion(root, state.localRule, role, destination, state.mode)
|
||||
if result.evidence != nil {
|
||||
result.evidence.sourceID = sourceID
|
||||
state.evidence = append(state.evidence, result.evidence)
|
||||
}
|
||||
var failures []Diagnostic
|
||||
for _, diagnostic := range result.diagnostics {
|
||||
if diagnostic.Severity == SeverityWarning {
|
||||
state.diagnostics = append(state.diagnostics, diagnostic)
|
||||
} else if diagnostic.Severity == SeverityError {
|
||||
failures = append(failures, diagnostic)
|
||||
}
|
||||
}
|
||||
return result, failures
|
||||
}
|
||||
|
||||
type sourceVersionProcessingResult struct {
|
||||
payload *document.Node
|
||||
imports []importDeclaration
|
||||
|
||||
Reference in New Issue
Block a user