Simplify empty import selection evidence

This commit is contained in:
2026-10-27 15:05:22 +00:00
parent 31ae30372e
commit 791cf16136
11 changed files with 58 additions and 87 deletions

View File

@@ -289,7 +289,7 @@ func (s *importTraversal) recordEmptyImportSelection(sourceIndex int, spec impor
// missing-source rollback, unlike a pointer into the source slice.
s.sources[sourceIndex].importSelections = append(s.sources[sourceIndex].importSelections, importSelectionEvidence{
path: spec.path.clone(), location: spec.location,
selector: spec.selector, outcome: importSelectionNone,
selector: spec.selector,
})
}

View File

@@ -43,7 +43,7 @@ func TestBroadEmptyImportSelectionsKeepDeclaringSourceOwnership(t *testing.T) {
}
for selectionIndex, selection := range source.importSelections {
if selection.path.String() != wantPaths[selectionIndex] || selection.location.SourceID != source.ID ||
selection.selector != importSelectorPath || selection.outcome != importSelectionNone {
selection.selector != importSelectorPath {
t.Errorf("source %s selection %d = %#v", source.ID, selectionIndex, selection)
}
}
@@ -90,7 +90,7 @@ func TestOptionalEmptyImportSelectionsRemainSourceLocalAndDetached(t *testing.T)
}
for index, selection := range evidence {
if selection.path.String() != wantPaths[index] || selection.location.SourceID != sources[0].ID ||
selection.selector != wantSelectors[index] || selection.outcome != importSelectionNone {
selection.selector != wantSelectors[index] {
t.Errorf("selection %d = %#v", index, selection)
}
}
@@ -137,7 +137,7 @@ value: main
t.Fatalf("failed-load sources = %#v", sources)
}
selection := sources[0].importSelections[0]
if selection.path.String() != "/configkit/imports/0" || selection.location.SourceID != sources[0].ID || selection.selector != importSelectorGlob || selection.outcome != importSelectionNone {
if selection.path.String() != "/configkit/imports/0" || selection.location.SourceID != sources[0].ID || selection.selector != importSelectorGlob {
t.Fatalf("retained selection = %#v", selection)
}
sources[0].importSelections[0].path.segments[0].key = "changed"

View File

@@ -9,13 +9,6 @@ import (
"strings"
)
type importSelectionOutcome uint8
const (
importSelectionNone importSelectionOutcome = iota
importSelectionHasCandidates
)
type selectedImportCandidate struct {
path string
accessPath string

View File

@@ -206,7 +206,6 @@ type importSelectionEvidence struct {
path Path
location Location
selector importSelector
outcome importSelectionOutcome
}
// ImportSelectionForFacade is a root-converted source-selection transport
@@ -215,7 +214,6 @@ type ImportSelectionForFacade struct {
Path Path // source-local import declaration path
Location Location // authored location and declaring source ID
Selector string // path, dir, or glob
Outcome string // none for a completed empty optional selection
}
// SourceInfoImportSelectionsForFacade returns detached selection records for
@@ -229,7 +227,6 @@ func SourceInfoImportSelectionsForFacade(source SourceInfo) []ImportSelectionFor
result[index] = ImportSelectionForFacade{
Path: selection.path.clone(), Location: selection.location,
Selector: importSelectorString(selection.selector),
Outcome: importSelectionOutcomeString(selection.outcome),
}
}
return result
@@ -250,13 +247,6 @@ func importSelectorString(value importSelector) string {
}
}
func importSelectionOutcomeString(value importSelectionOutcome) string {
if value == importSelectionNone {
return "none"
}
return ""
}
// SourceInfoPlacementModeForFacade converts private placement evidence to its
// root-owned numeric representation.
func SourceInfoPlacementModeForFacade(source SourceInfo) uint8 {