detection

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DetectionSource added in v1.2.0

type DetectionSource string

DetectionSource indicates how the framework was detected.

const (
	// SourceImport indicates detection via explicit import statement (highest confidence).
	SourceImport DetectionSource = "import"

	// SourceConfigScope indicates detection via config file scope.
	SourceConfigScope DetectionSource = "config-scope"

	// SourceContentPattern indicates detection via content pattern matching.
	SourceContentPattern DetectionSource = "content-pattern"

	// SourceUnknown indicates no framework was detected.
	SourceUnknown DetectionSource = "unknown"
)

type Detector

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

Detector performs framework detection using early-return approach. Detection priority (highest to lowest): 1. Import statements - explicit developer intent (immediate return) 2. Config scope - project-level configuration 3. Content patterns - framework-specific code patterns

The first successful match at any level immediately returns.

func NewDetector

func NewDetector(registry *framework.Registry) *Detector

NewDetector creates a new detector.

func (*Detector) Detect

func (d *Detector) Detect(ctx context.Context, filePath string, content []byte) Result

Detect performs framework detection on a test file. Uses early-return: first match wins based on priority.

func (*Detector) SetProjectScope added in v1.2.0

func (d *Detector) SetProjectScope(scope *framework.AggregatedProjectScope)

SetProjectScope configures the detector with project-wide configuration context.

type Result

type Result struct {
	// Framework is the detected framework name (e.g., "jest", "vitest").
	// Empty string if no framework detected.
	Framework string

	// Source indicates how the framework was detected.
	Source DetectionSource

	// Scope is the config scope that applies to this file (if scope-based detection succeeded).
	// May be nil if no config scope applies.
	Scope interface{} // framework.ConfigScope, but avoid import cycle
}

Result represents the outcome of framework detection for a test file.

func Confirmed added in v1.2.0

func Confirmed(framework string, source DetectionSource) Result

Confirmed returns a Result indicating a framework was definitively detected.

func ConfirmedWithScope added in v1.2.0

func ConfirmedWithScope(framework string, scope interface{}) Result

ConfirmedWithScope returns a Result with config scope information.

func Unknown

func Unknown() Result

Unknown returns a Result indicating no framework was detected.

func (Result) IsDetected added in v1.2.0

func (r Result) IsDetected() bool

IsDetected returns true if a framework was detected.

func (Result) String added in v1.2.0

func (r Result) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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