graph

package
v0.0.0-...-a36e8e9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableVerboseLogging

func EnableVerboseLogging()

EnableVerboseLogging enables verbose logging mode.

func FilterEntities

func FilterEntities(node []*Node, query parser.Query) bool

func Fmt

func Fmt(format string, args ...interface{})

Fmt prints formatted output if verbose logging is enabled.

func FormatType

func FormatType(v interface{}) string

FormatType formats various types to string representation.

func GenerateMethodID

func GenerateMethodID(methodName string, parameters []string, sourceFile string) string

GenerateMethodID generates a unique SHA256 hash ID for a method.

func GenerateSha256

func GenerateSha256(input string) string

GenerateSha256 generates a SHA256 hash from an input string.

func IsGitHubActions

func IsGitHubActions() bool

IsGitHubActions checks if running in GitHub Actions environment.

func Log

func Log(message string, args ...interface{})

Log logs a message if verbose logging is enabled.

func QueryEntities

func QueryEntities(graph *CodeGraph, query parser.Query) (nodes [][]*Node, output [][]interface{})

func ReplacePredicateVariables

func ReplacePredicateVariables(query parser.Query) string

Types

type CodeGraph

type CodeGraph struct {
	Nodes map[string]*Node
	Edges []*Edge
}

CodeGraph represents the entire code graph with nodes and edges.

func Initialize

func Initialize(directory string) *CodeGraph

Initialize initializes the code graph by parsing all source files in a directory.

func NewCodeGraph

func NewCodeGraph() *CodeGraph

NewCodeGraph creates and initializes a new CodeGraph instance.

func (*CodeGraph) AddEdge

func (g *CodeGraph) AddEdge(from, to *Node)

AddEdge adds an edge between two nodes in the code graph.

func (*CodeGraph) AddNode

func (g *CodeGraph) AddNode(node *Node)

AddNode adds a node to the code graph.

func (*CodeGraph) FindNodesByType

func (g *CodeGraph) FindNodesByType(nodeType string) []*Node

FindNodesByType finds all nodes of a given type.

type Edge

type Edge struct {
	From *Node
	To   *Node
}

Edge represents a directed edge between two nodes in the code graph.

type Env

type Env struct {
	Node *Node
}

func (*Env) GetAnnotations

func (env *Env) GetAnnotations() []string

func (*Env) GetArgumentNames

func (env *Env) GetArgumentNames() []string

func (*Env) GetArgumentTypes

func (env *Env) GetArgumentTypes() []string

func (*Env) GetAssertStmt

func (env *Env) GetAssertStmt() *model.AssertStmt

func (*Env) GetBinaryExpr

func (env *Env) GetBinaryExpr() *model.BinaryExpr

func (*Env) GetBlockStmt

func (env *Env) GetBlockStmt() *model.BlockStmt

func (*Env) GetBreakStmt

func (env *Env) GetBreakStmt() *model.BreakStmt

func (*Env) GetClassInstanceExpr

func (env *Env) GetClassInstanceExpr() *model.ClassInstanceExpr

func (*Env) GetClassInstanceExprName

func (env *Env) GetClassInstanceExprName() string

func (*Env) GetContinueStmt

func (env *Env) GetContinueStmt() *model.ContinueStmt

func (*Env) GetDoStmt

func (env *Env) GetDoStmt() *model.DoStmt

func (*Env) GetDoc

func (env *Env) GetDoc() *model.Javadoc

func (*Env) GetForStmt

func (env *Env) GetForStmt() *model.ForStmt

func (*Env) GetIfStmt

func (env *Env) GetIfStmt() *model.IfStmt

func (*Env) GetInterfaces

func (env *Env) GetInterfaces() []string

func (*Env) GetLeftOperand

func (env *Env) GetLeftOperand() string

func (*Env) GetName

func (env *Env) GetName() string

func (*Env) GetReturnStmt

func (env *Env) GetReturnStmt() *model.ReturnStmt

func (*Env) GetReturnType

func (env *Env) GetReturnType() string

func (*Env) GetRightOperand

func (env *Env) GetRightOperand() string

func (*Env) GetScope

func (env *Env) GetScope() string

func (*Env) GetSuperClass

func (env *Env) GetSuperClass() string

func (*Env) GetThrowsTypes

func (env *Env) GetThrowsTypes() []string

func (*Env) GetVariableDataType

func (env *Env) GetVariableDataType() string

func (*Env) GetVariableValue

func (env *Env) GetVariableValue() string

func (*Env) GetVisibility

func (env *Env) GetVisibility() string

func (*Env) GetWhileStmt

func (env *Env) GetWhileStmt() *model.WhileStmt

func (*Env) GetYieldStmt

func (env *Env) GetYieldStmt() *model.YieldStmt

func (*Env) HasAccess

func (env *Env) HasAccess() bool

func (*Env) IsJavaSourceFile

func (env *Env) IsJavaSourceFile() bool

func (*Env) ToString

func (env *Env) ToString() string

type Node

type Node struct {
	ID                   string
	Type                 string
	Name                 string
	CodeSnippet          string // DEPRECATED: Will be removed, use GetCodeSnippet() instead
	SourceLocation       *SourceLocation
	LineNumber           uint32
	OutgoingEdges        []*Edge
	IsExternal           bool
	Modifier             string
	ReturnType           string
	MethodArgumentsType  []string
	MethodArgumentsValue []string
	PackageName          string
	ImportPackage        []string
	SuperClass           string
	Interface            []string
	DataType             string
	Scope                string
	VariableValue        string

	File string

	ThrowsExceptions  []string
	Annotation        []string
	JavaDoc           *model.Javadoc
	BinaryExpr        *model.BinaryExpr
	ClassInstanceExpr *model.ClassInstanceExpr
	IfStmt            *model.IfStmt
	WhileStmt         *model.WhileStmt
	DoStmt            *model.DoStmt
	ForStmt           *model.ForStmt
	BreakStmt         *model.BreakStmt
	ContinueStmt      *model.ContinueStmt
	YieldStmt         *model.YieldStmt
	AssertStmt        *model.AssertStmt
	ReturnStmt        *model.ReturnStmt
	BlockStmt         *model.BlockStmt
	// contains filtered or unexported fields
}

Node represents a node in the code graph with various properties describing code elements like classes, methods, variables, etc.

func (*Node) GetCodeSnippet

func (n *Node) GetCodeSnippet() string

GetCodeSnippet returns the code snippet for this node. If SourceLocation is set, it reads from the file (lazy loading). Otherwise, it returns the deprecated CodeSnippet field for backward compatibility.

type SourceLocation

type SourceLocation struct {
	File      string
	StartByte uint32
	EndByte   uint32
}

SourceLocation stores the file location of a code snippet for lazy loading.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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