resolver

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker added in v0.2.0

type Checker interface {
	Exists(ctx context.Context, path string) bool
}

Checker tests file existence by absolute or relative path. It keeps the resolver pure string paths: the cache boundary translates uri.URI to OS paths before calling Exists.

type Option added in v0.2.0

type Option func(*Resolver)

Option configures a Resolver.

func WithChecker added in v0.2.0

func WithChecker(checker Checker) Option

WithChecker checks existence through checker.

func WithExistsFunc added in v0.2.0

func WithExistsFunc(exists func(ctx context.Context, path string) bool) Option

WithExistsFunc checks existence through exists.

func WithFS added in v0.2.0

func WithFS(fsys fs.FS) Option

WithFS checks file existence through fsys. Paths are looked up as given; when an absolute path misses, it is retried without the leading slash, so os.DirFS("/") and other relative-keyed trees behave like the real filesystem. resolvertest.Map and fstest.MapFS make tests hermetic.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver resolves include paths for Thrift files. It provides a centralized, pure implementation that can be used by both CLI and LSP components.

func New

func New(includePaths []string, opts ...Option) *Resolver

New creates a Resolver over the real filesystem, unless an Option overrides existence checks.

func (*Resolver) Candidates added in v0.1.8

func (r *Resolver) Candidates(ctx context.Context, currentFile, includePath string) []string

Candidates lists the existing locations of includePath for currentFile, nearest first: the file's directory, then include paths ordered by shared directory prefix with the file's directory, config order breaking ties. More than one location means the include path is shadowed by another include path.

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, currentFile, includePath string) string

Resolve returns the nearest location of includePath for currentFile: the file's directory first, then include paths by proximity (see Candidates). When the include resolves nowhere, it returns the file-relative candidate.

Directories

Path Synopsis
Package resolvertest provides an in-memory file tree for include resolution tests, so tests never touch disk.
Package resolvertest provides an in-memory file tree for include resolution tests, so tests never touch disk.

Jump to

Keyboard shortcuts

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