errgoengine

package module
v0.0.0-...-22a4c2b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 14 Imported by: 4

README

[!IMPORTANT] What you are seeing here is an in-progress implementation of our thesis paper. This is not usable as of the moment and it remains unanswered if this is effective while no testing has been conducted yet.

ErrgoEngine

A contextualized programming error analysis translation engine.

It is a Go package that analyzes the programming error message in order to build a contextualized data which contains the error type, the data extracted from the error message text and the files from the extracted stack trace data. The data is then used to generate an enhanced form of programming error message which contains an explanation and bug fix suggestions which is local to the said error and at the same time the program's codebase.

Our aim here is to be able to assist novice programmers in enhancing their debugging skills by providing more information that will help them fully understand the programming errors presented to them.

Programming languages supported

ErrgoEngine uses the tree-sitter parser to extract information from the source code from different programming languages in a unified way. This enables us to support a variety of programming languages as long as there is support for it. At the moment, we only support for Java and Python but we will be able to support more programming languages, and in return more types of programming errors, in the near future with improved interface for langauge support.

Dependencies

ErrgoEngine only relies on the third-party go-tree-sitter package for parsing but the rest of the code relies on the Go standard library so it should not be a problem at all when importing this package to your application.

TODO

  • Implementation of error templates
  • Tests

Paper

  • TODO

(c) 2023 by the ErrgoEngine Authors. Code released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FallbackErrorTemplate = &CompiledErrorTemplate{
	ErrorTemplate: ErrorTemplate{
		Name:    "UnknownError",
		Pattern: `.*`,
		OnGenExplainFn: func(cd *ContextData, gen *ExplainGenerator) {
			gen.Add("There are no available error templates for this error.\n")
			gen.Add("```\n")
			gen.Add(cd.Variables["message"])
			gen.Add("\n```")
		},
	},
	Language: &Language{
		AnalyzerFactory: func(cd *ContextData) LanguageAnalyzer {
			return nil
		},
	},
	Pattern:           nil,
	StackTracePattern: nil,
}
View Source
var TestLanguage = &Language{
	Name:              "TestLang",
	FilePatterns:      []string{".test"},
	SitterLanguage:    python.GetLanguage(),
	StackTracePattern: `\sin (?P<symbol>\S+) at (?P<path>\S+):(?P<position>\d+)`,
	AnalyzerFactory: func(cd *ContextData) LanguageAnalyzer {
		return &testAnalyzer{}
	},
	SymbolsToCapture: `
(expression_statement
	(assignment
		left: (identifier) @assignment.name
		right: (identifier) @assignment.content) @assignment)
	`,
}

Functions

func CustomErrorPattern

func CustomErrorPattern(pattern string) string

func ImportExternSymbols

func ImportExternSymbols(externFs fs.ReadFileFS) (map[string]*SymbolTree, error)

func ParseFiles

func ParseFiles(contextData *ContextData, defaultLanguage *Language, files fs.ReadFileFS, fileNames []string) error

func ParseFromStackTrace

func ParseFromStackTrace(contextData *ContextData, defaultLanguage *Language, files fs.ReadFileFS) error

func SetTemplateStackTraceRegex

func SetTemplateStackTraceRegex(lang *Language, pattern *regexp.Regexp)

SetTemplateStackTraceRegex sets the language's regex pattern directly. for testing purposes only

func TemplateKey

func TemplateKey(language, name string) string

func WithSymbolTree

func WithSymbolTree(tree *SymbolTree) context.Context

Types

type AssignmentSymbol

type AssignmentSymbol struct {
	Variable          Symbol
	FallbackName      string
	Location_         Location
	ContentReturnType Symbol
}

func (AssignmentSymbol) Kind

func (sym AssignmentSymbol) Kind() SymbolKind

func (AssignmentSymbol) Location

func (sym AssignmentSymbol) Location() Location

func (AssignmentSymbol) Name

func (sym AssignmentSymbol) Name() string

func (AssignmentSymbol) ReturnType

func (sym AssignmentSymbol) ReturnType() Symbol

type BugFixGenerator

type BugFixGenerator struct {
	Document    *Document
	Suggestions []*BugFixSuggestion
}

func NewBugFixGenerator

func NewBugFixGenerator(doc *Document) *BugFixGenerator

func (*BugFixGenerator) Add

func (gen *BugFixGenerator) Add(title string, makerFn func(s *BugFixSuggestion)) error

type BugFixStep

type BugFixStep struct {
	Doc           *EditableDocument
	StartLine     int
	AfterLine     int
	OrigStartLine int
	OrigAfterLine int
	Content       string
	DiffPosition  Position
	Fixes         []FixSuggestion
	// contains filtered or unexported fields
}

func (*BugFixStep) AddFix

func (step *BugFixStep) AddFix(fix FixSuggestion) *BugFixStep

type BugFixSuggestion

type BugFixSuggestion struct {
	Title string
	Steps []*BugFixStep

	Doc *EditableDocument
	// contains filtered or unexported fields
}

func (*BugFixSuggestion) AddStep

func (gen *BugFixSuggestion) AddStep(content string, d ...any) *BugFixStep

type BuiltinSymbol

type BuiltinSymbol struct {
	Name_ string
}

func (BuiltinSymbol) Kind

func (sym BuiltinSymbol) Kind() SymbolKind

func (BuiltinSymbol) Location

func (sym BuiltinSymbol) Location() Location

func (BuiltinSymbol) Name

func (sym BuiltinSymbol) Name() string

type Changeset

type Changeset struct {
	Id        int
	NewText   string
	StartPos  Position
	EndPos    Position
	IsChanged bool
}

func (Changeset) Add

func (c Changeset) Add(posToAdd Position) Changeset

type CompiledErrorTemplate

type CompiledErrorTemplate struct {
	ErrorTemplate
	Language          *Language
	Pattern           *regexp.Regexp
	StackTracePattern *regexp.Regexp
}

func (*CompiledErrorTemplate) ExtractStackTrace

func (tmp *CompiledErrorTemplate) ExtractStackTrace(cd *ContextData) TraceStack

func (*CompiledErrorTemplate) ExtractVariables

func (tmp *CompiledErrorTemplate) ExtractVariables(msg string) map[string]string

func (*CompiledErrorTemplate) Match

func (tmp *CompiledErrorTemplate) Match(str string) bool

func (*CompiledErrorTemplate) StackTraceRegex

func (tmp *CompiledErrorTemplate) StackTraceRegex() *regexp.Regexp

type ContextData

type ContextData struct {
	*Store
	Analyzer            LanguageAnalyzer
	WorkingPath         string
	CurrentDocumentPath string
	Variables           map[string]string
	TraceStack          TraceStack
	MainError           *MainError
}

func NewContextData

func NewContextData(store *Store, workingPath string) *ContextData

func (*ContextData) AddDocument

func (store *ContextData) AddDocument(doc *Document) *Document

func (*ContextData) AddVariable

func (data *ContextData) AddVariable(name string, value string)

func (*ContextData) AddVariables

func (data *ContextData) AddVariables(vars map[string]string)

func (*ContextData) FindSymbol

func (data *ContextData) FindSymbol(name string, pos int) Symbol

func (*ContextData) MainDocumentPath

func (data *ContextData) MainDocumentPath() string

type DepGraph

type DepGraph map[string]*DepNode

func (DepGraph) Add

func (graph DepGraph) Add(path string, deps map[string]string)

func (DepGraph) Delete

func (graph DepGraph) Delete(path string)

func (DepGraph) Detach

func (graph DepGraph) Detach(path string, dep string) error

func (DepGraph) Has

func (graph DepGraph) Has(path string) bool

type DepNode

type DepNode struct {
	Graph        DepGraph
	Path         string            // path where the module/library/package is located
	Dependencies map[string]string // mapped as map[label]depPath
}

func (*DepNode) DependentPaths

func (node *DepNode) DependentPaths() []string

func (*DepNode) Dependents

func (node *DepNode) Dependents() []*DepNode

func (*DepNode) Detach

func (node *DepNode) Detach(path string) error

func (*DepNode) GetDependencies

func (node *DepNode) GetDependencies() []*DepNode

func (*DepNode) HasDependency

func (node *DepNode) HasDependency(path string) bool

type Document

type Document struct {
	Version  int
	Path     string
	Contents string

	Language *Language
	Tree     *sitter.Tree
	// contains filtered or unexported fields
}

func ParseDocument

func ParseDocument(path string, r io.Reader, parser *sitter.Parser, selectLang *Language, existingDoc *Document) (*Document, error)

func (*Document) BytesContentEquals

func (doc *Document) BytesContentEquals(cnt []byte) bool

func (*Document) Editable

func (doc *Document) Editable() *EditableDocument

func (*Document) LineAt

func (doc *Document) LineAt(idx int) string

func (*Document) Lines

func (doc *Document) Lines() []string

func (*Document) LinesAt

func (doc *Document) LinesAt(from int, to int) []string

func (*Document) RootNode

func (doc *Document) RootNode() SyntaxNode

func (*Document) StringContentEquals

func (doc *Document) StringContentEquals(str string) bool

func (*Document) TotalLines

func (doc *Document) TotalLines() int

type EditableDocument

type EditableDocument struct {
	*Document
	// contains filtered or unexported fields
}

func NewEditableDocument

func NewEditableDocument(doc *Document) *EditableDocument

func (*EditableDocument) Apply

func (doc *EditableDocument) Apply(changeset Changeset) Position

func (*EditableDocument) Copy

func (doc *EditableDocument) Copy() *EditableDocument

func (*EditableDocument) FillIndex

func (doc *EditableDocument) FillIndex(pos Position) Position

func (*EditableDocument) ModifiedLineAt

func (doc *EditableDocument) ModifiedLineAt(idx int) string

func (*EditableDocument) ModifiedLinesAt

func (doc *EditableDocument) ModifiedLinesAt(from int, to int) []string

func (*EditableDocument) Reset

func (doc *EditableDocument) Reset()

func (*EditableDocument) String

func (doc *EditableDocument) String() string

type ErrgoEngine

type ErrgoEngine struct {
	SharedStore    *Store
	ErrorTemplates ErrorTemplates
	FS             *MultiReadFileFS
	OutputGen      *OutputGenerator
	IsTesting      bool
}

func New

func New() *ErrgoEngine

func (*ErrgoEngine) Analyze

func (e *ErrgoEngine) Analyze(workingPath, msg string) (*CompiledErrorTemplate, *ContextData, error)

func (*ErrgoEngine) AttachMainFS

func (e *ErrgoEngine) AttachMainFS(instance fs.ReadFileFS)

func (*ErrgoEngine) Translate

func (e *ErrgoEngine) Translate(template *CompiledErrorTemplate, contextData *ContextData) (mainExp string, fullExp string)

type ErrorTemplate

type ErrorTemplate struct {
	Name              string
	Pattern           string
	StackTracePattern string
	OnAnalyzeErrorFn  func(cd *ContextData, m *MainError)
	OnGenExplainFn    func(cd *ContextData, gen *ExplainGenerator)
	OnGenBugFixFn     func(cd *ContextData, gen *BugFixGenerator)
}

type ErrorTemplates

type ErrorTemplates map[string]*CompiledErrorTemplate

func (*ErrorTemplates) Add

func (tmps *ErrorTemplates) Add(language *Language, template ErrorTemplate) (*CompiledErrorTemplate, error)

func (ErrorTemplates) Find

func (tmps ErrorTemplates) Find(language, name string) *CompiledErrorTemplate

func (ErrorTemplates) Match

func (tmps ErrorTemplates) Match(msg string) *CompiledErrorTemplate

func (ErrorTemplates) MustAdd

func (tmps ErrorTemplates) MustAdd(language *Language, template ErrorTemplate) *CompiledErrorTemplate

type ExplainGenerator

type ExplainGenerator struct {
	ErrorName string
	Builder   *strings.Builder
	Sections  map[string]*ExplainGenerator
}

func NewExplainGeneratorForError

func NewExplainGeneratorForError(name string) *ExplainGenerator

func (*ExplainGenerator) Add

func (gen *ExplainGenerator) Add(text string, data ...any)

func (*ExplainGenerator) CreateSection

func (gen *ExplainGenerator) CreateSection(name string) *ExplainGenerator

type ExternFile

type ExternFile struct {
	Name         string         `json:"name"`
	Package      string         `json:"package"`
	Constructors []ExternSymbol `json:"constructors"`
	Methods      []ExternSymbol `json:"methods"`
}

type ExternSymbol

type ExternSymbol struct {
	Name       string         `json:"name"`
	Type       string         `json:"type"`
	ReturnType string         `json:"returnType"`
	Paremeters []ExternSymbol `json:"parameters"`
}

type FixSuggestion

type FixSuggestion struct {
	StartPosition Position
	EndPosition   Position
	NewText       string
	Description   string
}

type IChildrenSymbol

type IChildrenSymbol interface {
	Symbol
	Children() *SymbolTree
}

func CastChildrenSymbol

func CastChildrenSymbol(sym Symbol) IChildrenSymbol

type ICollectionTypeSymbol

type ICollectionTypeSymbol interface {
	IsFixed() bool
}

Collection types

type IReturnableSymbol

type IReturnableSymbol interface {
	Symbol
	ReturnType() Symbol
}

func CastSymbolReturnable

func CastSymbolReturnable(sym Symbol) IReturnableSymbol

type ImportParams

type ImportParams struct {
	Node       SyntaxNode
	CurrentDir string
}

type ImportSymbol

type ImportSymbol struct {
	Alias           string
	Node            *DepNode
	ImportedSymbols []string
}

func (ImportSymbol) Kind

func (sym ImportSymbol) Kind() SymbolKind

func (ImportSymbol) Location

func (sym ImportSymbol) Location() Location

func (ImportSymbol) Name

func (sym ImportSymbol) Name() string

type Language

type Language struct {
	Name              string
	FilePatterns      []string
	SitterLanguage    *sitter.Language
	StackTracePattern string
	ErrorPattern      string
	SymbolsToCapture  string
	LocationConverter func(ctx LocationConverterContext) Location
	AnalyzerFactory   func(cd *ContextData) LanguageAnalyzer
	ExternFS          fs.ReadFileFS
	// contains filtered or unexported fields
}

func (*Language) Compile

func (lang *Language) Compile()

func (*Language) MatchPath

func (lang *Language) MatchPath(path string) bool

type LanguageAnalyzer

type LanguageAnalyzer interface {
	FallbackSymbol() Symbol
	FindSymbol(name string) Symbol
	AnalyzeNode(context.Context, SyntaxNode) Symbol
	AnalyzeImport(ImportParams) ResolvedImport
}

type Location

type Location struct {
	DocumentPath string
	// Position
	StartPos Position
	EndPos   Position
}

func DefaultLocationConverter

func DefaultLocationConverter(ctx LocationConverterContext) Location

func (Location) IsWithin

func (loc Location) IsWithin(other Location) bool

func (Location) Point

func (loc Location) Point() sitter.Point

func (Location) Range

func (loc Location) Range() sitter.Range

type LocationConverterContext

type LocationConverterContext struct {
	Path        string
	Pos         string
	ContextData *ContextData
}

type LocationConverterFunc

type LocationConverterFunc func(ctx LocationConverterContext) Position

type MainError

type MainError struct {
	ErrorNode *StackTraceEntry
	Document  *Document
	Nearest   SyntaxNode
	Context   any
}

func (*MainError) DocumentPath

func (err *MainError) DocumentPath() string

type MultiReadFileFS

type MultiReadFileFS struct {
	FSs []fs.ReadFileFS
}

func (*MultiReadFileFS) Attach

func (mfs *MultiReadFileFS) Attach(instance fs.ReadFileFS, idx int)

func (*MultiReadFileFS) AttachOrReplace

func (mfs *MultiReadFileFS) AttachOrReplace(fs fs.ReadFileFS, idx int)

func (*MultiReadFileFS) LastAttachedIdx

func (mfs *MultiReadFileFS) LastAttachedIdx() int

func (*MultiReadFileFS) Open

func (mfs *MultiReadFileFS) Open(name string) (fs.File, error)

func (*MultiReadFileFS) ReadFile

func (mfs *MultiReadFileFS) ReadFile(name string) ([]byte, error)

type NodeValueAnalyzer

type NodeValueAnalyzer interface {
	FindSymbol(name string, pos int) Symbol
	AnalyzeValue(n SyntaxNode) Symbol
}

type OutputGenerator

type OutputGenerator struct {
	GenAfterExplain func(*OutputGenerator)
	Builder         *strings.Builder
}

func (*OutputGenerator) Break

func (gen *OutputGenerator) Break()

func (*OutputGenerator) FromExplanation

func (gen *OutputGenerator) FromExplanation(level int, explain *ExplainGenerator)

func (*OutputGenerator) Generate

func (gen *OutputGenerator) Generate(explain *ExplainGenerator, bugFix *BugFixGenerator) string

func (*OutputGenerator) Heading

func (gen *OutputGenerator) Heading(level int, text string)

func (*OutputGenerator) Reset

func (gen *OutputGenerator) Reset()

func (*OutputGenerator) Write

func (gen *OutputGenerator) Write(str string, d ...any)

func (*OutputGenerator) WriteLines

func (gen *OutputGenerator) WriteLines(lines ...string)

func (*OutputGenerator) Writeln

func (gen *OutputGenerator) Writeln(str string, d ...any)

type Position

type Position struct {
	Line   int
	Column int
	Index  int
}

func (Position) Add

func (pos Position) Add(pos2 Position) Position

func (Position) AddUnsafe

func (pos Position) AddUnsafe(pos2 Position) Position

func (Position) Eq

func (a Position) Eq(b Position) bool

func (Position) Eq2

func (a Position) Eq2(b Position) bool

func (Position) IsInBetween

func (pos Position) IsInBetween(loc Location) bool

func (Position) Point

func (pos Position) Point() sitter.Point

func (Position) String

func (pos Position) String() string

type QueryMatchIterator

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

func (*QueryMatchIterator) Captures

func (it *QueryMatchIterator) Captures() []sitter.QueryCapture

func (*QueryMatchIterator) Current

func (it *QueryMatchIterator) Current() sitter.QueryCapture

func (*QueryMatchIterator) Next

func (it *QueryMatchIterator) Next() bool

func (*QueryMatchIterator) ReachedEnd

func (it *QueryMatchIterator) ReachedEnd() bool

type QueryNodeCtx

type QueryNodeCtx struct {
	Query  *sitter.Query
	Cursor *sitter.QueryCursor
}

type QueryNodeCursor

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

func (*QueryNodeCursor) CurrentNode

func (c *QueryNodeCursor) CurrentNode() SyntaxNode

func (*QueryNodeCursor) CurrentTagName

func (c *QueryNodeCursor) CurrentTagName() string

func (*QueryNodeCursor) Len

func (c *QueryNodeCursor) Len() int

func (*QueryNodeCursor) Match

func (c *QueryNodeCursor) Match() *QueryMatchIterator

func (*QueryNodeCursor) Next

func (c *QueryNodeCursor) Next() bool

func (*QueryNodeCursor) NextMatch

func (c *QueryNodeCursor) NextMatch() bool

func (*QueryNodeCursor) Query

func (c *QueryNodeCursor) Query() *sitter.Query

type RawFS

type RawFS struct{}

func (*RawFS) Open

func (*RawFS) Open(name string) (fs.File, error)

func (*RawFS) ReadFile

func (rfs *RawFS) ReadFile(name string) ([]byte, error)

type ResolvedImport

type ResolvedImport struct {
	Path    string
	Name    string
	Symbols []string
}

type StackTraceEntry

type StackTraceEntry struct {
	Location
	SymbolName string
}

type Store

type Store struct {
	DepGraph  DepGraph
	Documents map[string]*Document
	Symbols   map[string]*SymbolTree
	FS        fs.ReadFileFS
}

func NewEmptyStore

func NewEmptyStore() *Store

func (*Store) FindSymbol

func (store *Store) FindSymbol(docPath string, name string, pos int) Symbol

func (*Store) InitOrGetSymbolTree

func (store *Store) InitOrGetSymbolTree(docPath string) *SymbolTree

type Symbol

type Symbol interface {
	Name() string
	Kind() SymbolKind
	Location() Location
}
var UnresolvedSymbol Symbol = unresolvedSymbol{}

func Builtin

func Builtin(name string) Symbol

func GetFromSymbol

func GetFromSymbol(sym IChildrenSymbol, field string) Symbol

func UnwrapActualReturnType

func UnwrapActualReturnType(sym Symbol) Symbol

func UnwrapReturnType

func UnwrapReturnType(sym Symbol) Symbol

type SymbolAnalyzer

type SymbolAnalyzer struct {
	ContextData *ContextData
	// contains filtered or unexported fields
}

func (*SymbolAnalyzer) Analyze

func (an *SymbolAnalyzer) Analyze(doc *Document)

type SymbolKind

type SymbolKind int
const (
	SymbolKindUnknown    SymbolKind = 0
	SymbolKindUnresolved SymbolKind = iota
	SymbolKindBuiltin    SymbolKind = iota
	SymbolKindClass      SymbolKind = iota
	SymbolKindFunction   SymbolKind = iota
	SymbolKindVariable   SymbolKind = iota
	SymbolKindAssignment SymbolKind = iota
	SymbolKindType       SymbolKind = iota
	SymbolKindImport     SymbolKind = iota
)

func NewSymbolKindFromString

func NewSymbolKindFromString(str string) SymbolKind

func (SymbolKind) String

func (kind SymbolKind) String() string

type SymbolTree

type SymbolTree struct {
	Parent   *SymbolTree
	StartPos Position
	EndPos   Position
	Symbols  map[string]Symbol
	Scopes   []*SymbolTree
}

func GetSymbolTreeCtx

func GetSymbolTreeCtx(ctx context.Context) *SymbolTree

func (*SymbolTree) Add

func (tree *SymbolTree) Add(sym Symbol)

func (*SymbolTree) CreateChildFromNode

func (tree *SymbolTree) CreateChildFromNode(n SyntaxNode) *SymbolTree

func (*SymbolTree) Find

func (tree *SymbolTree) Find(name string) Symbol

func (*SymbolTree) FindSymbolsByClause

func (tree *SymbolTree) FindSymbolsByClause(findFn func(sym Symbol) bool) []Symbol

func (*SymbolTree) GetNearestScopedTree

func (tree *SymbolTree) GetNearestScopedTree(index int) *SymbolTree

func (*SymbolTree) GetSymbolByNode

func (tree *SymbolTree) GetSymbolByNode(node SyntaxNode) Symbol

type SyntaxNode

type SyntaxNode struct {
	*sitter.Node

	Doc *Document
	// contains filtered or unexported fields
}

func WrapNode

func WrapNode(doc *Document, n *sitter.Node) SyntaxNode

func (SyntaxNode) Child

func (n SyntaxNode) Child(idx int) SyntaxNode

func (SyntaxNode) ChildByFieldName

func (n SyntaxNode) ChildByFieldName(field string) SyntaxNode

func (SyntaxNode) Debug

func (n SyntaxNode) Debug()

func (SyntaxNode) EndPosition

func (n SyntaxNode) EndPosition() Position

func (SyntaxNode) FirstNamedChild

func (n SyntaxNode) FirstNamedChild() SyntaxNode

func (SyntaxNode) IsNull

func (n SyntaxNode) IsNull() bool

func (SyntaxNode) LastNamedChild

func (n SyntaxNode) LastNamedChild() SyntaxNode

func (SyntaxNode) Location

func (n SyntaxNode) Location() Location

func (SyntaxNode) NamedChild

func (n SyntaxNode) NamedChild(idx int) SyntaxNode

func (SyntaxNode) NamedDescendantForPointRange

func (n SyntaxNode) NamedDescendantForPointRange(posRange Location) SyntaxNode

func (SyntaxNode) NextSibling

func (n SyntaxNode) NextSibling() SyntaxNode

func (SyntaxNode) Parent

func (n SyntaxNode) Parent() SyntaxNode

func (SyntaxNode) PrevNamedSibling

func (n SyntaxNode) PrevNamedSibling() SyntaxNode

func (SyntaxNode) PrevSibling

func (n SyntaxNode) PrevSibling() SyntaxNode

func (SyntaxNode) Query

func (n SyntaxNode) Query(q string, d ...any) *QueryNodeCursor

func (SyntaxNode) RawNode

func (n SyntaxNode) RawNode() *sitter.Node

func (SyntaxNode) StartPosition

func (n SyntaxNode) StartPosition() Position

func (SyntaxNode) Text

func (n SyntaxNode) Text() string

func (SyntaxNode) TreeCursor

func (n SyntaxNode) TreeCursor() *sitter.TreeCursor

type TopLevelSymbol

type TopLevelSymbol struct {
	Name_       string      `json:"name"`
	Kind_       SymbolKind  `json:"kind"`
	Location_   Location    `json:"location"`
	Children_   *SymbolTree `json:"children"`
	ReturnType_ Symbol      `json:"returnType"`
}

func (TopLevelSymbol) Children

func (sym TopLevelSymbol) Children() *SymbolTree

func (TopLevelSymbol) Kind

func (sym TopLevelSymbol) Kind() SymbolKind

func (TopLevelSymbol) Location

func (sym TopLevelSymbol) Location() Location

func (TopLevelSymbol) Name

func (sym TopLevelSymbol) Name() string

func (TopLevelSymbol) ReturnType

func (sym TopLevelSymbol) ReturnType() Symbol

type TraceStack

type TraceStack []StackTraceEntry

func (*TraceStack) Add

func (st *TraceStack) Add(symbolName string, loc Location)

func (TraceStack) NearestTo

func (st TraceStack) NearestTo(path string) StackTraceEntry

func (TraceStack) Top

func (st TraceStack) Top() StackTraceEntry

type VariableSymbol

type VariableSymbol struct {
	Name_       string
	Location_   Location
	ReturnType_ Symbol
	// contains filtered or unexported fields
}

func (VariableSymbol) ContentReturnType

func (sym VariableSymbol) ContentReturnType() Symbol

func (VariableSymbol) IsParam

func (sym VariableSymbol) IsParam() bool

func (VariableSymbol) Kind

func (sym VariableSymbol) Kind() SymbolKind

func (VariableSymbol) Location

func (sym VariableSymbol) Location() Location

func (VariableSymbol) Name

func (sym VariableSymbol) Name() string

func (VariableSymbol) ReturnType

func (sym VariableSymbol) ReturnType() Symbol

type VirtualFS

type VirtualFS struct {
	Files []VirtualFile
}

func (*VirtualFS) Open

func (vfs *VirtualFS) Open(name string) (fs.File, error)

func (*VirtualFS) ReadFile

func (vfs *VirtualFS) ReadFile(name string) ([]byte, error)

func (*VirtualFS) StubFile

func (vfs *VirtualFS) StubFile(name string) VirtualFile

type VirtualFile

type VirtualFile struct {
	Name string
}

func (VirtualFile) Close

func (VirtualFile) Close() error

func (VirtualFile) Read

func (VirtualFile) Read(bt []byte) (int, error)

func (VirtualFile) Stat

func (vf VirtualFile) Stat() (fs.FileInfo, error)

Directories

Path Synopsis
utils
levenshtein
Package levenshtein is a Go implementation to calculate Levenshtein Distance.
Package levenshtein is a Go implementation to calculate Levenshtein Distance.

Jump to

Keyboard shortcuts

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