mirror of
https://github.com/safedep/vet.git
synced 2025-12-11 00:02:56 -06:00
feat: Building code graph Refactor to support import processing Handle relative import name fixup Add docs for code analysis framework Update docs to include additional examples feat: Function call graph Update code graph to link function decl and calls Include call node in function calls feat: Flatten vulnerabilities in CSV reporter refactor: Maintain separation of concerns for code analysis framework refactor: Separate storage entities in its own package feat: Add callback support in code graph builder docs: Fix code analysis framework docs Signed-off-by: abhisek <abhisek.datta@gmail.com>
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package nodes
|
|
|
|
import sitter "github.com/smacker/go-tree-sitter"
|
|
|
|
type CSTImportNode struct {
|
|
cst *CST
|
|
moduleNameNode *sitter.Node
|
|
moduleItemNode *sitter.Node
|
|
moduleAliasNode *sitter.Node
|
|
}
|
|
|
|
func NewCSTImportNode(cst *CST) *CSTImportNode {
|
|
return &CSTImportNode{cst: cst}
|
|
}
|
|
|
|
func (n *CSTImportNode) WithModuleName(moduleName *sitter.Node) *CSTImportNode {
|
|
n.moduleNameNode = moduleName
|
|
return n
|
|
}
|
|
|
|
func (n *CSTImportNode) WithModuleItem(moduleItem *sitter.Node) *CSTImportNode {
|
|
n.moduleItemNode = moduleItem
|
|
return n
|
|
}
|
|
|
|
func (n *CSTImportNode) WithModuleAlias(moduleAlias *sitter.Node) *CSTImportNode {
|
|
n.moduleAliasNode = moduleAlias
|
|
return n
|
|
}
|
|
|
|
func (n CSTImportNode) ImportName() string {
|
|
if n.moduleNameNode != nil {
|
|
return n.moduleNameNode.Content(n.cst.code)
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
func (n CSTImportNode) ImportItem() string {
|
|
if n.moduleItemNode != nil {
|
|
return n.moduleItemNode.Content(n.cst.code)
|
|
}
|
|
|
|
return ""
|
|
}
|
|
|
|
func (n CSTImportNode) ImportAlias() string {
|
|
if n.moduleAliasNode != nil {
|
|
return n.moduleAliasNode.Content(n.cst.code)
|
|
}
|
|
|
|
return ""
|
|
}
|