Documentation
¶
Overview ¶
Package resolver handles reference resolution.
Index ¶
- type AliasCollision
- type IDCollision
- type Options
- type ResolveResult
- type Resolver
- func (r *Resolver) AllObjectIDs() []string
- func (r *Resolver) Exists(id string) bool
- func (r *Resolver) FindAliasCollisions() []AliasCollision
- func (r *Resolver) FindCollisions() []IDCollision
- func (r *Resolver) Resolve(ref string) ResolveResult
- func (r *Resolver) ResolveAll(refs []string) map[string]ResolveResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AliasCollision ¶
type AliasCollision struct {
Alias string // The alias that collides
ObjectIDs []string // Object IDs that share this alias (if multiple objects use same alias)
ConflictsWith string // What it conflicts with: "alias", "short_name", or "object_id"
}
AliasCollision represents a collision where an alias conflicts with something else.
type IDCollision ¶
type IDCollision struct {
ShortName string // The short name that collides (e.g., "freya")
ObjectIDs []string // The full object IDs that share this short name
}
IDCollision represents a collision between object IDs with the same short name.
type Options ¶
type Options struct {
// DailyDirectory is the directory for daily notes (default: "daily").
DailyDirectory string
// Aliases maps alias strings to their target object IDs.
// For example: {"The Queen": "people/freya"}
Aliases map[string]string
// NameFieldMap maps name_field values to object IDs for semantic resolution.
// Values are multi-mapped to preserve ambiguity when multiple objects share
// the same display name.
// For example: {"The Prose Edda": {"books/the-prose-edda"}}
NameFieldMap map[string][]string
}
Options configures the resolver.
type ResolveResult ¶
type ResolveResult struct {
// TargetID is the resolved target object ID (empty if unresolved).
TargetID string
// Ambiguous is true if the reference matches multiple objects.
Ambiguous bool
// Matches contains all matching IDs (for ambiguous refs).
Matches []string
// MatchSources maps matched IDs to their match source.
MatchSources map[string]string
// Error message if resolution failed.
Error string
}
ResolveResult represents the result of a reference resolution.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves short references to full object IDs.
func (*Resolver) AllObjectIDs ¶
AllObjectIDs returns a slice of all known object IDs.
func (*Resolver) FindAliasCollisions ¶
func (r *Resolver) FindAliasCollisions() []AliasCollision
FindAliasCollisions finds alias conflicts: 1. Multiple objects using the same alias 2. An alias that matches an existing object's short name 3. An alias that matches an existing object ID
func (*Resolver) FindCollisions ¶
func (r *Resolver) FindCollisions() []IDCollision
FindCollisions finds object IDs that share the same short name. This is useful for `rvn check` to warn about potential reference ambiguity.
Note: Collisions between a file and sections within that same file are NOT reported, since these resolve unambiguously (the file takes precedence). For example, `people/freya` and `people/freya#freya` sharing short name "freya" is fine - [[freya]] resolves to the file.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(ref string) ResolveResult
Resolve resolves a reference to its target object ID. If a reference matches multiple things (alias + object, alias + short name, etc.), it is treated as ambiguous and returns an error.
Resolution priority:
- Aliases (exact match)
- Name field values (semantic match by display name)
- Date references (YYYY-MM-DD)
- Object IDs (exact path match)
- Short names (filename match)
func (*Resolver) ResolveAll ¶
func (r *Resolver) ResolveAll(refs []string) map[string]ResolveResult
ResolveAll resolves all references and returns a map from raw ref to result.