Add detached source lookup to results and errors

This commit is contained in:
2026-10-27 15:26:19 +00:00
parent 24ab623cb2
commit c96197c417
8 changed files with 302 additions and 3 deletions

View File

@@ -214,6 +214,20 @@ func (r *Result[T]) Sources() []SourceInfo {
return result
}
// Source returns a detached record for an acquired source in this load. IDs are
// local to the load; the lookup does not reacquire the source or access the
// filesystem. Empty or unknown IDs return false.
func (r *Result[T]) Source(id string) (SourceInfo, bool) {
if r == nil || r.inspection == nil {
return SourceInfo{}, false
}
value, ok := r.inspection.Source(id)
if !ok {
return SourceInfo{}, false
}
return fromEngineSourceInfo(value), true
}
// Diagnostics returns detached nonfatal diagnostics from the load.
func (r *Result[T]) Diagnostics() []Diagnostic {
if r == nil || r.inspection == nil {