resolver

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

type Resolver struct {
	SearchPaths    []string
	Registry       *TypeRegistry
	Resolved       map[string]bool
	SkipUnresolved bool
}

Resolver resolves AIDL imports and builds a TypeRegistry.

Resolver is NOT safe for concurrent use. While the underlying TypeRegistry is mutex-protected, the Resolver's own resolved map has no synchronization. Callers must ensure that only one goroutine calls Resolver methods at a time.

func New

func New(
	searchPaths []string,
) *Resolver

New creates a Resolver that searches the given paths for AIDL files.

func (*Resolver) ResolveDocument

func (r *Resolver) ResolveDocument(
	doc *parser.Document,
	filename string,
) (_err error)

ResolveDocument registers definitions from an already-parsed document and transitively resolves all its imports.

func (*Resolver) ResolveFile

func (r *Resolver) ResolveFile(
	filename string,
) (_err error)

ResolveFile parses an AIDL file and transitively resolves all its imports.

func (*Resolver) SetSkipUnresolved

func (r *Resolver) SetSkipUnresolved(
	skip bool,
)

SetSkipUnresolved configures whether the resolver silently skips imports that cannot be found in any search path. When true, missing imports are ignored instead of causing an error.

type TypeRegistry

type TypeRegistry struct {
	Defs map[string]parser.Definition
	// contains filtered or unexported fields
}

TypeRegistry maps fully qualified AIDL names to their parsed definitions.

func NewTypeRegistry

func NewTypeRegistry() *TypeRegistry

NewTypeRegistry creates a new empty TypeRegistry.

func (*TypeRegistry) All

func (r *TypeRegistry) All() map[string]parser.Definition

All returns a copy of all registered definitions.

func (*TypeRegistry) Lookup

func (r *TypeRegistry) Lookup(
	qualifiedName string,
) (parser.Definition, bool)

Lookup returns the definition for the given qualified name, or false if not found.

func (*TypeRegistry) LookupAllByShortName

func (r *TypeRegistry) LookupAllByShortName(
	shortName string,
) []struct {
	QualifiedName string
	Def           parser.Definition
}

LookupAllByShortName returns all fully qualified names and definitions whose short name matches the given name.

func (*TypeRegistry) LookupByShortName

func (r *TypeRegistry) LookupByShortName(
	shortName string,
) (parser.Definition, bool)

LookupByShortName returns the definition whose short name (last segment after the final dot) matches the given name. If multiple definitions share the same short name, the first match is returned. This is useful for resolving unqualified type references within a package.

func (*TypeRegistry) LookupQualifiedByShortName

func (r *TypeRegistry) LookupQualifiedByShortName(
	shortName string,
) (string, parser.Definition, bool)

LookupQualifiedByShortName returns the fully qualified name and definition whose short name (last segment after the final dot) matches the given name. If multiple definitions share the same short name, the first match is returned.

func (*TypeRegistry) Register

func (r *TypeRegistry) Register(
	qualifiedName string,
	def parser.Definition,
)

Register adds a definition to the registry under the given qualified name.

Jump to

Keyboard shortcuts

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