extractor

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package extractor defines the interface for language-specific import extraction.

Index

Constants

View Source
const MaxSignatureLength = 120

MaxSignatureLength is the maximum length for a signature string before truncation.

Variables

This section is empty.

Functions

func BuildNameSet

func BuildNameSet(symbolNames []string) map[string]bool

BuildNameSet creates a lookup set from a list of symbol names. Returns nil if symbolNames is empty.

func TrimBodyOpener

func TrimBodyOpener(sig string) string

TrimBodyOpener removes the opening brace " {" from the end of a signature line. Uses substring matching (not character set) to avoid stripping valid trailing characters.

func TruncateSig

func TruncateSig(sig string, maxLen int) string

TruncateSig truncates a signature string to maxLen, appending "..." if truncated.

Types

type DefinitionExtractor

type DefinitionExtractor interface {
	// ExtractDefinitions returns signature strings for the given symbol names
	// found in the file content. Only the signature line is returned (not the body).
	ExtractDefinitions(content []byte, symbolNames []string) []string
}

DefinitionExtractor extracts code signatures (function/class/type definitions) for named symbols. Extractors that also implement this interface can provide symbol definitions for the --signatures feature.

type Extractor

type Extractor interface {
	// Language returns the language this extractor handles (e.g., "python").
	Language() string
	// Extensions returns file extensions this extractor handles (e.g., [".py"]).
	Extensions() []string
	// Extract parses a file and returns all import facts.
	Extract(filePath string, content []byte) ([]model.ImportFact, error)
	// Clone returns a new independent instance for concurrent use.
	Clone() Extractor
}

Extractor extracts import facts from a source file.

Directories

Path Synopsis
Package golang implements import extraction for Go source files.
Package golang implements import extraction for Go source files.
Package java implements import extraction for Java source files.
Package java implements import extraction for Java source files.
Package python implements import extraction for Python source files.
Package python implements import extraction for Python source files.
Package rust implements import extraction for Rust source files.
Package rust implements import extraction for Rust source files.
Package typescript implements import extraction for TypeScript and JavaScript source files.
Package typescript implements import extraction for TypeScript and JavaScript source files.

Jump to

Keyboard shortcuts

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