Documentation
¶
Index ¶
- func PrintSyntaxTree(ctx context.Context, tsNode *tree_sitter.Node, content []byte) string
- type CSharpVisitor
- type FileParser
- func (fp *FileParser) CreateTranslator(ctx context.Context, filePath string, fileID int32, langType LanguageType, ...) (*tree_sitter.Tree, *TranslateFromSyntaxTree, error)
- func (fp *FileParser) CreateTranslatorWithContent(ctx context.Context, filePath string, fileID int32, langType LanguageType, ...) (*tree_sitter.Tree, *TranslateFromSyntaxTree, error)
- func (fp *FileParser) DetectLanguage(filePath string) LanguageType
- func (fp *FileParser) GetLanguageParser(langType LanguageType) (*tree_sitter.Language, error)
- func (fp *FileParser) GetLanguageVisitor(langType LanguageType, ts *TranslateFromSyntaxTree) (SyntaxTreeVisitor, error)
- func (fp *FileParser) ParseAndTraverseWithContent(ctx context.Context, repo *config.Repository, info os.FileInfo, ...) error
- func (fp *FileParser) ReadFile(filePath string) ([]byte, error)
- func (fp *FileParser) ShouldSkipFile(ctx context.Context, repo *config.Repository, info os.FileInfo, ...) bool
- type GoVisitor
- type JavaScriptVisitor
- type JavaVisitor
- type LanguageType
- type PrintVisitor
- func (pv *PrintVisitor) GetName(tsNode *tree_sitter.Node) string
- func (pv *PrintVisitor) HasSpecialName(kind string) bool
- func (pv *PrintVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (pv *PrintVisitor) WriteToFile(filePath string, prefix string) error
- type PythonVisitor
- type Scope
- func (s *Scope) AddNotContainedNode(nodeID ast.NodeID)
- func (s *Scope) AddRhsVar(nodeID ast.NodeID)
- func (s *Scope) AddSymbol(sym *Symbol) error
- func (s *Scope) GetAllNotContainedNodes() []ast.NodeID
- func (s *Scope) GetRhsVars() []ast.NodeID
- func (s *Scope) GetSymbol(name string) *Symbol
- func (s *Scope) IsNotContainedNode(nodeID ast.NodeID) bool
- func (s *Scope) IsRhs() bool
- func (s *Scope) RemoveNotContainedNode(nodeID ast.NodeID)
- func (s *Scope) Resolve(name string) *Symbol
- type Symbol
- type SyntaxTreeVisitor
- type TranslateFromSyntaxTree
- func (t *TranslateFromSyntaxTree) Chindren(node *tree_sitter.Node) []*tree_sitter.Node
- func (t *TranslateFromSyntaxTree) CreateContainsRelation(ctx context.Context, parentID ast.NodeID, childID ast.NodeID, fileID int32)
- func (t *TranslateFromSyntaxTree) CreateContainsRelations(ctx context.Context, parentID ast.NodeID, childIDs []ast.NodeID)
- func (t *TranslateFromSyntaxTree) CreateFakeVariable(ctx context.Context, scopeID ast.NodeID, prefix string, rng base.Range, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) CreateFunction(ctx context.Context, scopeID ast.NodeID, fn *tree_sitter.Node, fnName string, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) CreateFunctionWithMetadata(ctx context.Context, scopeID ast.NodeID, fn *tree_sitter.Node, fnName string, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) GetAstNodeText(node *ast.Node) string
- func (t *TranslateFromSyntaxTree) GetTreeNodeName(node *tree_sitter.Node) string
- func (t *TranslateFromSyntaxTree) HandleAssignment(ctx context.Context, assignNode *tree_sitter.Node, lhs *tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleBlock(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleCall(ctx context.Context, nameID ast.NodeID, args []*tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleCallWithMetadata(ctx context.Context, nameID ast.NodeID, args []*tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleClass(ctx context.Context, scopeID ast.NodeID, cls *tree_sitter.Node, name string, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleClassWithMetadata(ctx context.Context, scopeID ast.NodeID, cls *tree_sitter.Node, name string, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleConditional(ctx context.Context, conditionalNode *tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleIdentifier(ctx context.Context, idNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleLoop(ctx context.Context, loopNode *tree_sitter.Node, initID ast.NodeID, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleReturn(ctx context.Context, rhs *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleRhs(ctx context.Context, rhs *tree_sitter.Node, scopeID ast.NodeID) ([]ast.NodeID, ast.NodeID)
- func (t *TranslateFromSyntaxTree) HandleRhsExprsWithFakeVariable(ctx context.Context, lhsPrefix string, rhsExprs []*tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleRhsWithFakeVariable(ctx context.Context, lhsPrefix string, rhs *tree_sitter.Node, ...) ast.NodeID
- func (t *TranslateFromSyntaxTree) HandleVariable(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (t *TranslateFromSyntaxTree) NamedChildren(node *tree_sitter.Node) []*tree_sitter.Node
- func (t *TranslateFromSyntaxTree) NewNode(nodeType ast.NodeType, name string, rng base.Range, parentID ast.NodeID) *ast.Node
- func (t *TranslateFromSyntaxTree) NextNodeID() ast.NodeID
- func (t *TranslateFromSyntaxTree) PopScope(ctx context.Context, closingScopeId ast.NodeID)
- func (t *TranslateFromSyntaxTree) PushScope(rhs bool)
- func (t *TranslateFromSyntaxTree) ResolveNameChain(ctx context.Context, nameChain []*tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
- func (t *TranslateFromSyntaxTree) String(node *tree_sitter.Node) string
- func (t *TranslateFromSyntaxTree) SubtreeNodeByKind(node *tree_sitter.Node, kind string) *tree_sitter.Node
- func (t *TranslateFromSyntaxTree) ToRange(node *tree_sitter.Node) base.Range
- func (t *TranslateFromSyntaxTree) TraverseChildren(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) []ast.NodeID
- func (t *TranslateFromSyntaxTree) TreeChildByFieldName(node *tree_sitter.Node, fieldName string) *tree_sitter.Node
- func (t *TranslateFromSyntaxTree) TreeChildByKind(node *tree_sitter.Node, kind string) *tree_sitter.Node
- func (t *TranslateFromSyntaxTree) TreeChildrenByKind(node *tree_sitter.Node, kind string) []*tree_sitter.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintSyntaxTree ¶
Types ¶
type CSharpVisitor ¶
type CSharpVisitor struct {
// contains filtered or unexported fields
}
CSharpVisitor handles traversal of C# syntax trees
func NewCSharpVisitor ¶
func NewCSharpVisitor(logger *zap.Logger, ts *TranslateFromSyntaxTree) *CSharpVisitor
NewCSharpVisitor creates a new C# visitor instance
func (*CSharpVisitor) GetName ¶
func (cv *CSharpVisitor) GetName(tsNode *tree_sitter.Node) string
GetName extracts the proper name from a C# node considering special naming conventions
func (*CSharpVisitor) HasSpecialName ¶
func (cv *CSharpVisitor) HasSpecialName(kind string) bool
HasSpecialName returns true for C# node kinds that have special naming conventions
func (*CSharpVisitor) TraverseNode ¶
func (cv *CSharpVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
TraverseNode traverses a C# syntax tree node and returns the created AST node ID
type FileParser ¶
type FileParser struct {
CodeGraph *codegraph.CodeGraph
Config *config.Config
// contains filtered or unexported fields
}
func NewFileParser ¶
func (*FileParser) CreateTranslator ¶
func (fp *FileParser) CreateTranslator(ctx context.Context, filePath string, fileID int32, langType LanguageType, version int32) (*tree_sitter.Tree, *TranslateFromSyntaxTree, error)
func (*FileParser) CreateTranslatorWithContent ¶
func (fp *FileParser) CreateTranslatorWithContent(ctx context.Context, filePath string, fileID int32, langType LanguageType, version int32, content []byte) (*tree_sitter.Tree, *TranslateFromSyntaxTree, error)
func (*FileParser) DetectLanguage ¶
func (fp *FileParser) DetectLanguage(filePath string) LanguageType
func (*FileParser) GetLanguageParser ¶
func (fp *FileParser) GetLanguageParser(langType LanguageType) (*tree_sitter.Language, error)
func (*FileParser) GetLanguageVisitor ¶
func (fp *FileParser) GetLanguageVisitor(langType LanguageType, ts *TranslateFromSyntaxTree) (SyntaxTreeVisitor, error)
func (*FileParser) ParseAndTraverseWithContent ¶
func (*FileParser) ShouldSkipFile ¶
func (fp *FileParser) ShouldSkipFile(ctx context.Context, repo *config.Repository, info os.FileInfo, filePath string) bool
type GoVisitor ¶
type GoVisitor struct {
// contains filtered or unexported fields
}
func NewGoVisitor ¶
func NewGoVisitor(logger *zap.Logger, ts *TranslateFromSyntaxTree) *GoVisitor
func (*GoVisitor) GetName ¶
func (gv *GoVisitor) GetName(tsNode *tree_sitter.Node) string
GetName is not implemented for Go visitor
func (*GoVisitor) HasSpecialName ¶
HasSpecialName returns false for Go - no special naming conventions
type JavaScriptVisitor ¶
type JavaScriptVisitor struct {
// contains filtered or unexported fields
}
func NewJavaScriptVisitor ¶
func NewJavaScriptVisitor(logger *zap.Logger, ts *TranslateFromSyntaxTree) *JavaScriptVisitor
func (*JavaScriptVisitor) GetName ¶
func (jsv *JavaScriptVisitor) GetName(tsNode *tree_sitter.Node) string
GetName is not implemented for JavaScript visitor
func (*JavaScriptVisitor) HasSpecialName ¶
func (jsv *JavaScriptVisitor) HasSpecialName(kind string) bool
HasSpecialName returns false for JavaScript - no special naming conventions
func (*JavaScriptVisitor) TraverseNode ¶
func (jsv *JavaScriptVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
type JavaVisitor ¶
type JavaVisitor struct {
// contains filtered or unexported fields
}
func NewJavaVisitor ¶
func NewJavaVisitor(logger *zap.Logger, ts *TranslateFromSyntaxTree) *JavaVisitor
func (*JavaVisitor) GetName ¶
func (jv *JavaVisitor) GetName(tsNode *tree_sitter.Node) string
GetName is not implemented for Java visitor
func (*JavaVisitor) HasSpecialName ¶
func (jv *JavaVisitor) HasSpecialName(kind string) bool
HasSpecialName returns false for Java - no special naming conventions like C#
func (*JavaVisitor) TraverseNode ¶
func (jv *JavaVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
type LanguageType ¶
type LanguageType int
const ( Go LanguageType = iota JavaScript TypeScript Python Java CSharp Unknown )
func NewLanguageTypeFromString ¶
func NewLanguageTypeFromString(lang string) LanguageType
func (LanguageType) String ¶
func (lt LanguageType) String() string
type PrintVisitor ¶
type PrintVisitor struct {
// contains filtered or unexported fields
}
func NewPrintVisitor ¶
func NewPrintVisitor(ts *TranslateFromSyntaxTree) *PrintVisitor
func (*PrintVisitor) GetName ¶
func (pv *PrintVisitor) GetName(tsNode *tree_sitter.Node) string
GetName is not implemented for PrintVisitor
func (*PrintVisitor) HasSpecialName ¶
func (pv *PrintVisitor) HasSpecialName(kind string) bool
HasSpecialName returns false for PrintVisitor - no special naming conventions
func (*PrintVisitor) TraverseNode ¶
func (pv *PrintVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*PrintVisitor) WriteToFile ¶
func (pv *PrintVisitor) WriteToFile(filePath string, prefix string) error
type PythonVisitor ¶
type PythonVisitor struct {
// contains filtered or unexported fields
}
func NewPythonVisitor ¶
func NewPythonVisitor(logger *zap.Logger, ts *TranslateFromSyntaxTree) *PythonVisitor
func (*PythonVisitor) GetName ¶
func (pv *PythonVisitor) GetName(tsNode *tree_sitter.Node) string
GetName is not implemented for Python visitor
func (*PythonVisitor) HasSpecialName ¶
func (pv *PythonVisitor) HasSpecialName(kind string) bool
HasSpecialName returns false for Python - no special naming conventions
func (*PythonVisitor) TraverseNode ¶
func (pv *PythonVisitor) TraverseNode(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
type Scope ¶
type Scope struct {
Parent *Scope
// contains filtered or unexported fields
}
func (*Scope) AddNotContainedNode ¶
func (*Scope) GetAllNotContainedNodes ¶
func (*Scope) GetRhsVars ¶
func (*Scope) RemoveNotContainedNode ¶
type SyntaxTreeVisitor ¶
type TranslateFromSyntaxTree ¶
type TranslateFromSyntaxTree struct {
ScopeStack []*Scope
CurrentScope *Scope
FileID int32
Version int32
NodeIDSeq uint32
CodeGraph *codegraph.CodeGraph
FileContent []byte
Visitor SyntaxTreeVisitor
Logger *zap.Logger
Nodes map[ast.NodeID]*ast.Node
// Batch writing support
EnableBatchWrites bool
BatchSize int
// contains filtered or unexported fields
}
func (*TranslateFromSyntaxTree) Chindren ¶
func (t *TranslateFromSyntaxTree) Chindren(node *tree_sitter.Node) []*tree_sitter.Node
func (*TranslateFromSyntaxTree) CreateContainsRelation ¶
func (*TranslateFromSyntaxTree) CreateContainsRelations ¶
func (*TranslateFromSyntaxTree) CreateFakeVariable ¶
func (*TranslateFromSyntaxTree) CreateFunction ¶
func (t *TranslateFromSyntaxTree) CreateFunction(ctx context.Context, scopeID ast.NodeID, fn *tree_sitter.Node, fnName string, params []*tree_sitter.Node, body *tree_sitter.Node) ast.NodeID
func (*TranslateFromSyntaxTree) CreateFunctionWithMetadata ¶
func (t *TranslateFromSyntaxTree) CreateFunctionWithMetadata(ctx context.Context, scopeID ast.NodeID, fn *tree_sitter.Node, fnName string, params []*tree_sitter.Node, body *tree_sitter.Node, metadata map[string]any) ast.NodeID
func (*TranslateFromSyntaxTree) GetAstNodeText ¶
func (t *TranslateFromSyntaxTree) GetAstNodeText(node *ast.Node) string
func (*TranslateFromSyntaxTree) GetTreeNodeName ¶
func (t *TranslateFromSyntaxTree) GetTreeNodeName(node *tree_sitter.Node) string
func (*TranslateFromSyntaxTree) HandleAssignment ¶
func (t *TranslateFromSyntaxTree) HandleAssignment(ctx context.Context, assignNode *tree_sitter.Node, lhs *tree_sitter.Node, rhs *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleBlock ¶
func (t *TranslateFromSyntaxTree) HandleBlock(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleCall ¶
func (*TranslateFromSyntaxTree) HandleCallWithMetadata ¶
func (t *TranslateFromSyntaxTree) HandleCallWithMetadata(ctx context.Context, nameID ast.NodeID, args []*tree_sitter.Node, scopeID ast.NodeID, rng base.Range, extraMetadata map[string]any) ast.NodeID
HandleCallWithMetadata creates a function call node with additional metadata. This is useful for annotating special call types like constructor calls.
func (*TranslateFromSyntaxTree) HandleClass ¶
func (t *TranslateFromSyntaxTree) HandleClass(ctx context.Context, scopeID ast.NodeID, cls *tree_sitter.Node, name string, methods []*tree_sitter.Node, fields []*tree_sitter.Node) ast.NodeID
func (*TranslateFromSyntaxTree) HandleClassWithMetadata ¶
func (t *TranslateFromSyntaxTree) HandleClassWithMetadata(ctx context.Context, scopeID ast.NodeID, cls *tree_sitter.Node, name string, methods []*tree_sitter.Node, fields []*tree_sitter.Node, metadata map[string]any) ast.NodeID
func (*TranslateFromSyntaxTree) HandleConditional ¶
func (t *TranslateFromSyntaxTree) HandleConditional(ctx context.Context, conditionalNode *tree_sitter.Node, conditions []*tree_sitter.Node, branches []*tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleIdentifier ¶
func (t *TranslateFromSyntaxTree) HandleIdentifier(ctx context.Context, idNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleLoop ¶
func (t *TranslateFromSyntaxTree) HandleLoop(ctx context.Context, loopNode *tree_sitter.Node, initID ast.NodeID, conditionID ast.NodeID, body *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleReturn ¶
func (t *TranslateFromSyntaxTree) HandleReturn(ctx context.Context, rhs *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) HandleRhsExprsWithFakeVariable ¶
func (*TranslateFromSyntaxTree) HandleRhsWithFakeVariable ¶
func (*TranslateFromSyntaxTree) HandleVariable ¶
func (t *TranslateFromSyntaxTree) HandleVariable(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) NamedChildren ¶
func (t *TranslateFromSyntaxTree) NamedChildren(node *tree_sitter.Node) []*tree_sitter.Node
func (*TranslateFromSyntaxTree) NextNodeID ¶
func (t *TranslateFromSyntaxTree) NextNodeID() ast.NodeID
func (*TranslateFromSyntaxTree) PopScope ¶
func (t *TranslateFromSyntaxTree) PopScope(ctx context.Context, closingScopeId ast.NodeID)
func (*TranslateFromSyntaxTree) PushScope ¶
func (t *TranslateFromSyntaxTree) PushScope(rhs bool)
func (*TranslateFromSyntaxTree) ResolveNameChain ¶
func (t *TranslateFromSyntaxTree) ResolveNameChain(ctx context.Context, nameChain []*tree_sitter.Node, scopeID ast.NodeID) ast.NodeID
func (*TranslateFromSyntaxTree) String ¶
func (t *TranslateFromSyntaxTree) String(node *tree_sitter.Node) string
func (*TranslateFromSyntaxTree) SubtreeNodeByKind ¶
func (t *TranslateFromSyntaxTree) SubtreeNodeByKind(node *tree_sitter.Node, kind string) *tree_sitter.Node
func (*TranslateFromSyntaxTree) ToRange ¶
func (t *TranslateFromSyntaxTree) ToRange(node *tree_sitter.Node) base.Range
func (*TranslateFromSyntaxTree) TraverseChildren ¶
func (t *TranslateFromSyntaxTree) TraverseChildren(ctx context.Context, tsNode *tree_sitter.Node, scopeID ast.NodeID) []ast.NodeID
func (*TranslateFromSyntaxTree) TreeChildByFieldName ¶
func (t *TranslateFromSyntaxTree) TreeChildByFieldName(node *tree_sitter.Node, fieldName string) *tree_sitter.Node
func (*TranslateFromSyntaxTree) TreeChildByKind ¶
func (t *TranslateFromSyntaxTree) TreeChildByKind(node *tree_sitter.Node, kind string) *tree_sitter.Node
func (*TranslateFromSyntaxTree) TreeChildrenByKind ¶
func (t *TranslateFromSyntaxTree) TreeChildrenByKind(node *tree_sitter.Node, kind string) []*tree_sitter.Node