infer

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package infer bridges auto-detection and the provider registry: it decides whether a line Clover recognizes would actually resolve, offline. The one gate is shared by annotate, which writes a directive above each passing line, and by run --infer, which synthesizes a marker for it without writing anything - so the two features can never disagree about what is trackable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Directive

func Directive(inf match.Inference) directive.Directive

Directive builds the directive a provider=auto marker binds for inf: the inferred provider plus every parameter read from the line. It is what the gate validates the provider resource against.

func Recognizable

func Recognizable(path string, lines []string, i int) bool

Recognizable is the one-shot form of Recognizer.Recognizable.

func Recognize

func Recognize(path string, lines []string, i int) (match.Inference, string, bool)

Recognize is the one-shot form of Recognizer.Recognize, for a caller gating a single line.

func Unresolved

func Unresolved(
	providerName string,
	d directive.Directive,
	line string,
	rewriter func() (match.Rewriter, error),
) string

Unresolved runs the offline checks lint and run perform against a candidate annotation: the provider must exist, build a valid resource from d, and the rewriter must locate a trackable version on line. An empty reason means the candidate is safe to emit.

Types

type Recognizer added in v0.3.8

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

Recognizer is the gate scoped to one file: it holds the file's dispatch table so a loop over the file's lines never re-matches path globs.

func NewRecognizer added in v0.3.8

func NewRecognizer(path string) Recognizer

NewRecognizer returns the recognition gate for the file at path.

func (Recognizer) Recognizable added in v0.3.8

func (r Recognizer) Recognizable(lines []string, i int) bool

Recognizable reports whether lines[i] names a complete reference, stopping before the heavier offline resolution gate. It backs opt-out diagnostics, which only need to know a line would otherwise have been a candidate.

func (Recognizer) Recognize added in v0.3.8

func (r Recognizer) Recognize(lines []string, i int) (match.Inference, string, bool)

Recognize reports the inference for lines[i] and whether its line would resolve: ok is false when no auto route matches at all, and reason carries why a matched line still cannot resolve (an incomplete reference, a provider resource that does not build, a version the rewriter cannot locate). A matched line with an empty reason is safe to annotate or update.

Jump to

Keyboard shortcuts

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