reference

package
v0.0.0-...-8593d01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomRef

func AtomRef(path, symbol string) string

AtomRef builds a path-provider symbol reference: path:./file::symbol

func FileRef

func FileRef(path string) string

FileRef builds a path-provider file reference: path:./file

func JoinProviderPath

func JoinProviderPath(base, name string) string

JoinProviderPath joins slash-separated provider path segments, ignoring empty parts and trimming surrounding slashes from each argument.

func LastPathComponent

func LastPathComponent(s string) string

LastPathComponent returns the final segment of a slash-separated path. A single trailing slash is ignored so "pkg/foo/" and "pkg/foo" agree.

func ParentProviderPath

func ParentProviderPath(path string) string

ParentProviderPath returns the parent slash-separated provider path, or "" at the root (single segment, empty, or ".").

func RegisterProvider

func RegisterProvider(name string, provider Provider)

RegisterProvider registers or overrides a provider name.

func SortScopeChildrenByKindThenPath

func SortScopeChildrenByKindThenPath(children []ScopeChild)

SortScopeChildrenByKindThenPath sorts by Kind, then Ref.Path.

func SortScopeChildrenByPath

func SortScopeChildrenByPath(children []ScopeChild)

SortScopeChildrenByPath sorts children by Ref.Path ascending.

Types

type ImportResolveContext

type ImportResolveContext struct {
	RootDir      string
	ImporterPath string
	KnownFiles   map[string]bool
	KnownDirs    map[string]bool
}

ImportResolveContext carries filesystem and index metadata needed by provider-backed import resolution.

type Provider

type Provider interface {
	Name() string
	Resolve(spec string, ctx ImportResolveContext) (string, bool)
}

Provider resolves import specs into canonical references.

func ProviderForName

func ProviderForName(name string) (Provider, bool)

ProviderForName looks up a provider by name.

type Reference

type Reference struct {
	Provider string // e.g. "path", "go", "python", "node"
	Path     string // e.g. "./main.go", "fmt"
	Name     string // e.g. "main", "Println"; empty for file/package refs
}

Reference is a parsed provider:path::symbol string.

func NormalizePathReference

func NormalizePathReference(ref Reference) Reference

NormalizePathReference normalizes path-provider references so relative paths are consistently prefixed.

func Parse

func Parse(s string) Reference

Parse splits a "provider:path::symbol" string.

func (Reference) String

func (r Reference) String() string

String formats the reference back to its canonical form.

type Resolver

type Resolver struct {
	// RootDir is the project/module working directory used by providers that
	// run tools like `go list` / project .venv python (empty = no project context).
	RootDir string
}

Resolver performs provider-backed scope/symbol resolution in the context of a project root (e.g. serve --dir, browse root). Language/provider specifics are dispatched through registered providers; only this type carries RootDir.

func NewResolver

func NewResolver(rootDir string) *Resolver

NewResolver builds a resolver for the given project root. Non-absolute paths are cleaned; errors are not returned here so callers can always construct one. Non-empty root is also registered as the default python project root so resolution prefers that tree's .venv even when a call site passes workDir "".

func (*Resolver) ResolveScopeChildren

func (r *Resolver) ResolveScopeChildren(ref Reference, includeHidden bool) ([]ScopeChild, bool, error)

ResolveScopeChildren dispatches to the provider named by ref.Provider.

func (*Resolver) ResolveScopeTarget

func (r *Resolver) ResolveScopeTarget(ref Reference) (ScopeTarget, bool, error)

ResolveScopeTarget dispatches to the provider named by ref.Provider.

func (*Resolver) ResolveSymbolTarget

func (r *Resolver) ResolveSymbolTarget(ref Reference) (SymbolTarget, bool, error)

ResolveSymbolTarget dispatches to the provider named by ref.Provider.

type ScopeChild

type ScopeChild struct {
	Ref  Reference
	Kind ScopeChildKind
}

ScopeChild is a provider-backed child scope exposed to browse UIs.

type ScopeChildKind

type ScopeChildKind int
const (
	ScopeChildDir ScopeChildKind = iota
	ScopeChildFile
)

type ScopeChildrenProvider

type ScopeChildrenProvider interface {
	ListScopeChildren(ref Reference, rootDir string, includeHidden bool) ([]ScopeChild, bool, error)
}

ScopeChildrenProvider is an optional provider capability used by browse UIs.

type ScopeTarget

type ScopeTarget struct {
	Dir string
	// CanDescend controls whether provider browse UIs should offer child scope
	// navigation from this target. Nil means unknown/default behavior.
	CanDescend *bool
}

ScopeTarget points to a directory that can be ingested for provider-backed scope operations such as listing.

type ScopeTargetProvider

type ScopeTargetProvider interface {
	ResolveScopeTarget(ref Reference, rootDir string) (ScopeTarget, bool, error)
}

ScopeTargetProvider is an optional provider capability used by listing.

type SymbolTarget

type SymbolTarget struct {
	Dir  string
	Name string
}

SymbolTarget points to a directory that can be ingested for provider-backed symbol lookup.

type SymbolTargetProvider

type SymbolTargetProvider interface {
	ResolveSymbolTarget(ref Reference, rootDir string) (SymbolTarget, bool, error)
}

SymbolTargetProvider is an optional provider capability used by doc lookup. rootDir is injected by Resolver (project/module context for go list, etc.).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL