extract

package
v0.0.0-...-162c42b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAll

func ExtractAll(root string, filePaths []string) (*graph.Extraction, error)

ExtractAll runs the full extraction pipeline: 1. Extract each file in parallel 2. Resolve cross-file imports 3. Merge into single extraction

func ExtractFile

func ExtractFile(filePath string) (*graph.Extraction, error)

ExtractFile extracts nodes and edges from a single code file.

func ExtractFiles

func ExtractFiles(filePaths []string) (map[string]*graph.Extraction, []error)

ExtractFiles extracts from multiple code files in parallel.

func ResolveCrossFileImports

func ResolveCrossFileImports(extractions map[string]*graph.Extraction) []graph.Edge

ResolveCrossFileImports creates edges between nodes across files by resolving import statements to actual class/function definitions.

func SupportedExtensions

func SupportedExtensions() []string

SupportedExtensions returns all supported file extensions.

Types

type ExtraWalkFn

type ExtraWalkFn func(w *Walker, node *sitter.Node, parentClassNID string) bool

ExtraWalkFn handles language-specific node types not covered by the generic walker. Returns true if the node was handled (skip default recursion).

type ImportHandler

type ImportHandler func(node *sitter.Node, source []byte, fileNID, stem string) []RawEdge

ImportHandler extracts import edges from an import AST node.

type LanguageConfig

type LanguageConfig struct {
	Language *sitter.Language

	ClassTypes    []string
	FunctionTypes []string
	ImportTypes   []string
	CallTypes     []string

	NameField              string // default: "name"
	NameFallbackChildTypes []string
	BodyField              string // default: "body"
	BodyFallbackChildTypes []string

	CallFunctionField     string // default: "function"
	CallAccessorNodeTypes []string
	CallAccessorField     string // default: "attribute"

	FunctionBoundaryTypes []string
	FunctionLabelParens   bool // default: true

	ImportHandler ImportHandler
	ExtraWalkFn   ExtraWalkFn
}

LanguageConfig defines how to extract nodes/edges from a specific language's AST.

func GetLanguageConfig

func GetLanguageConfig(filePath string) *LanguageConfig

GetLanguageConfig returns the config for a file extension, or nil.

type RawEdge

type RawEdge struct {
	Source     string
	Target     string
	Relation   string
	Confidence string
	Score      float64
	File       string
	Line       int
}

RawEdge is an edge extracted from AST before final processing.

type RawNode

type RawNode struct {
	ID       string
	Label    string
	FileType string
	File     string
	Line     int
}

RawNode is a node extracted from AST before final processing.

type Walker

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

Walker traverses a tree-sitter AST and extracts nodes and edges.

func NewWalker

func NewWalker(config *LanguageConfig, source []byte, filePath string) *Walker

NewWalker creates a walker for a file with a given language config.

func (*Walker) Extract

func (w *Walker) Extract() (*graph.Extraction, error)

Extract parses and walks the AST, returning an Extraction.

Jump to

Keyboard shortcuts

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