core

package
v0.0.0-...-3200512 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	// The name of the file in the file system.
	// This is the path relative to the root of the file system
	// source defined by the file system.
	Name() string

	// Open the file for reading.
	Reader() (io.ReadCloser, error)

	// Flag to identify if the file is an application source file
	IsApp() bool

	// Flag to identify if the file is an import source file
	IsImport() bool
}

type FilePlugin

type FilePlugin interface {
	Plugin

	AnalyzeSource(context.Context, File) error
}

FilePlugin is the contract for a plugin that can analyze a source file

type FileSystem

type FileSystem interface {
	// Enumerate the contents of the file system
	Enumerate(context.Context, func(File) error) error

	// Find a file by name in the file system
	// The name is a relative path to the root of the file system
	Find(context.Context, string) (File, error)
}

type ImportAwareFileSystem

type ImportAwareFileSystem interface {
	// Base file system
	FileSystem

	// Enumerate application source files in the file system
	EnumerateApp(context.Context, func(File) error) error

	// Enumerate import source files in the file system
	EnumerateImports(context.Context, func(File) error) error
}

ImportAwareFileSystem is a contract for implementing file systems that maintain a distinction between application source files and imported source files by the application. This is a first class concept in our system because we need the ability to distinguish between the two.

type Language

type Language interface {
	// Name returns the name of the language
	Meta() LanguageMeta

	// Tree Sitter Language
	Language() *sitter.Language

	// Get language specific resolvers
	Resolvers() LanguageResolvers
}

Language is the contract for implementing a language supported in the framework. It should be minimal and contain core language specific operations such as parsing.

type LanguageCode

type LanguageCode string
const (
	LanguageCodePython     LanguageCode = "python"
	LanguageCodeJavascript LanguageCode = "javascript"
	LanguageCodeJava       LanguageCode = "java"
	LanguageCodeGo         LanguageCode = "go"
	LanguageCodeTypescript LanguageCode = "typescript"
)

type LanguageMeta

type LanguageMeta struct {
	// Name of the language
	Name string

	// Code of the language, used for internal comparisons
	Code LanguageCode

	// Flag to indicate if the language is object oriented
	ObjectOriented bool

	// Supported file extensions
	SourceFileExtensions []string
}

LanguageMeta is exposes metadata about a language implementation for the framework

type LanguageResolvers

type LanguageResolvers interface {
	// ResolveImports returns a list of import statements
	// identified from the parse tree
	ResolveImports(tree ParseTree) ([]*ast.ImportNode, error)

	// ResolveFunctions returns a list of function declarations
	// identified from the parse tree
	ResolveFunctions(tree ParseTree) ([]*ast.FunctionDeclarationNode, error)
}

LanguageResolvers define the minimum contract for a language implementation to resolve language specific concerns such as imports, functions, etc.

type ObjectOrientedLanguageResolvers

type ObjectOrientedLanguageResolvers interface {

	// ResolveClasses returns a list of class declarations
	// identified from the parse tree
	ResolveClasses(tree ParseTree) ([]*ast.ClassDeclarationNode, error)

	// ResolveInheritance returns the inheritance graph
	// constructed from class definitions in the parse tree
	ResolveInheritance(tree ParseTree) (*ast.InheritanceGraph, error)
}

ObjectOrientedLanguageResolvers define the additional contract for a language implementation to resolve object oriented language specific concerns such as classes, methods, etc.

type ParseTree

type ParseTree interface {
	// Tree returns the underlying TreeSitter tree
	Tree() *sitter.Tree

	// Data returns the raw data of the source file
	// from which the tree was created.
	Data() (*[]byte, error)

	// The file from which the tree was created
	File() (File, error)

	// The language used to parse the tree
	Language() (Language, error)
}

type Parser

type Parser interface {
	Parse(context.Context, File) (ParseTree, error)
}

type Plugin

type Plugin interface {
	Name() string

	SupportedLanguages() []LanguageCode
}

Plugin is the contract for a base plugin

type PluginCallback

type PluginCallback[T any] func(context.Context, T) error

PluginCallback is the contract for a callback function provided by any plugin

type SourceVisitor

type SourceVisitor interface {
	VisitFile(File) error
}

type SourceWalker

type SourceWalker interface {
	Walk(context.Context, ImportAwareFileSystem, SourceVisitor) error
}

type TreePlugin

type TreePlugin interface {
	Plugin

	AnalyzeTree(context.Context, ParseTree) error
}

TreePlugin is the contract for a plugin that can analyze a a parse tree (CST in Tree Sitter)

type TreeVisitor

type TreeVisitor interface {
	VisitTree(ParseTree) error
}

type TreeWalker

type TreeWalker interface {
	Walk(context.Context, ImportAwareFileSystem, TreeVisitor) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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