detector

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = NewRegistry()

Default is the process-wide default registry. Detector init() funcs call RegisterDefault to add themselves.

Functions

func RegisterDefault

func RegisterDefault(d Detector)

RegisterDefault registers d with the process-wide Default registry. Panics on duplicate name (programmer error — must be caught at boot, not silently swallowed).

Types

type Context

type Context struct {
	FilePath   string
	Language   string
	Content    string
	Tree       *parser.Tree // nil for languages without a tree-sitter grammar
	ModuleName string
	// ParsedData is the pre-parsed structured payload for YAML/JSON/TOML/INI/
	// properties files. Wrapped in the same envelope shape used by the Java
	// side: a map with keys "type" (e.g. "yaml", "yaml_multi", "json", "toml",
	// "ini", "properties") and "data" / "documents". nil for files that don't
	// participate in structured parsing.
	ParsedData map[string]any
}

Context is the per-file payload threaded through every Detect call. Mirrors Java DetectorContext.

type Detector

type Detector interface {
	Name() string
	SupportedLanguages() []string
	// DefaultConfidence is the floor stamped onto every emission that does not
	// explicitly set Confidence — equivalent to Java's defaultConfidence().
	DefaultConfidence() model.Confidence
	Detect(ctx *Context) *Result
}

Detector is the contract every detector implements. Mirrors Java io.github.randomcodespace.iq.detector.Detector.

Detectors must be stateless — phase 1 invokes each detector from goroutines concurrently. Use method-local state only.

type Registry

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

Registry holds detectors registered at process startup. Lookups by language return deterministic (name-sorted) slices so detector iteration order is stable across runs — determinism is non-negotiable per CLAUDE.md.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) All

func (r *Registry) All() []Detector

All returns every registered detector, sorted by name.

func (*Registry) ByName

func (r *Registry) ByName(name string) Detector

ByName fetches a single detector by its name. Returns nil if absent.

func (*Registry) For

func (r *Registry) For(lang string) []Detector

For returns detectors registered for lang, sorted by name. Returns nil (not empty slice) when no detector matches.

func (*Registry) Register

func (r *Registry) Register(d Detector)

Register adds d to this registry. Panics on duplicate name.

type Result

type Result struct {
	Nodes []*model.CodeNode
	Edges []*model.CodeEdge
}

Result is what a single Detect call returns. Mirrors Java DetectorResult.

func EmptyResult

func EmptyResult() *Result

EmptyResult returns an empty Result. Sentinel for "nothing matched".

func ResultOf

func ResultOf(nodes []*model.CodeNode, edges []*model.CodeEdge) *Result

ResultOf returns a Result with the given slices.

Directories

Path Synopsis
Package auth holds cross-cutting authentication-related detectors.
Package auth holds cross-cutting authentication-related detectors.
Package base frontend.go provides shared helpers for frontend component detectors (Angular, React, Vue).
Package base frontend.go provides shared helpers for frontend component detectors (Angular, React, Vue).
Package csharp holds C#/.NET detectors.
Package csharp holds C#/.NET detectors.
Package golang holds Go-language detectors.
Package golang holds Go-language detectors.
Package iac holds Infrastructure-as-Code detectors (Terraform, Bicep, Dockerfile, ...).
Package iac holds Infrastructure-as-Code detectors (Terraform, Bicep, Dockerfile, ...).
jvm
jvmhelpers
Package jvmhelpers mirrors src/main/java/.../detector/StructuresDetectorHelper.java + AbstractJavaMessagingDetector helpers for JVM-family Go detectors.
Package jvmhelpers mirrors src/main/java/.../detector/StructuresDetectorHelper.java + AbstractJavaMessagingDetector helpers for JVM-family Go detectors.
Package markup holds Markdown / other markup-language detectors.
Package markup holds Markdown / other markup-language detectors.
Package proto holds Protocol Buffer detectors.
Package proto holds Protocol Buffer detectors.
script
shell
Package shell holds Bash and PowerShell detectors.
Package shell holds Bash and PowerShell detectors.
Package sql holds raw-SQL and migration-file detectors.
Package sql holds raw-SQL and migration-file detectors.
systems
cpp
Package cpp holds C/C++ detectors.
Package cpp holds C/C++ detectors.
rust
Package rust holds Rust-language detectors.
Package rust holds Rust-language detectors.
Package typescript ports the Java TypeScript detectors.
Package typescript ports the Java TypeScript detectors.

Jump to

Keyboard shortcuts

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