Documentation
¶
Index ¶
- type File
- type FilePlugin
- type FileSystem
- type ImportAwareFileSystem
- type Language
- type LanguageCode
- type LanguageMeta
- type LanguageResolvers
- type ObjectOrientedLanguageResolvers
- type ParseTree
- type Parser
- type Plugin
- type PluginCallback
- type SourceVisitor
- type SourceWalker
- type TreePlugin
- type TreeVisitor
- type TreeWalker
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 ¶
FilePlugin is the contract for a plugin that can analyze a source file
type FileSystem ¶
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 Plugin ¶
type Plugin interface {
Name() string
SupportedLanguages() []LanguageCode
}
Plugin is the contract for a base plugin
type PluginCallback ¶
PluginCallback is the contract for a callback function provided by any plugin
type SourceVisitor ¶
type SourceWalker ¶
type SourceWalker interface {
Walk(context.Context, ImportAwareFileSystem, SourceVisitor) error
}
type TreePlugin ¶
TreePlugin is the contract for a plugin that can analyze a a parse tree (CST in Tree Sitter)
type TreeVisitor ¶
type TreeWalker ¶
type TreeWalker interface {
Walk(context.Context, ImportAwareFileSystem, TreeVisitor) error
}