Documentation
¶
Index ¶
- func AddGlobalVariableSteps(dataFlow []models.DataFlowStep, root *sitter.Node, content []byte, ...) []models.DataFlowStep
- func ExtractFunctionNameFromCall(node *sitter.Node, content []byte) string
- func FindCallExpression(node *sitter.Node) *sitter.Node
- func FindFunctionBounds(root *sitter.Node, node *sitter.Node, startLine uint32) (functionStart, functionEnd uint32)
- func FindFunctionByLine(root *sitter.Node, line uint32, lang string) *sitter.Node
- func FindFunctionByName(root *sitter.Node, name string, content []byte) *sitter.Node
- func FindFunctionCallSites(root *sitter.Node, functionName string, content []byte) []models.FunctionCallSite
- func FindFunctionDeclaration(root *sitter.Node, functionName string, content []byte) *sitter.Node
- func FindGlobalVariableDeclaration(root *sitter.Node, variable string, content []byte) *sitter.Node
- func FindNodeAtLine(node *sitter.Node, targetLine uint32) *sitter.Node
- func FindParentFunction(node *sitter.Node, content []byte) string
- func GetArgumentVariable(callNode *sitter.Node, parameterVariable string, functionNode *sitter.Node, ...) string
- func GetControlType(nodeType string) string
- func GetParameterName(functionNode *sitter.Node, content []byte, originalVariable string, ...) string
- func IsAssignment(node *sitter.Node, content []byte, variable string) (bool, string)
- func IsClassFieldAssignment(node *sitter.Node, content []byte, variable string) bool
- func IsFunctionCall(node *sitter.Node, content []byte, variable string) (bool, string)
- func IsFunctionDeclaration(root, node *sitter.Node, content []byte) string
- func IsFunctionDeclared(root *sitter.Node, functionName string, content []byte) bool
- func IsLiteral(node *sitter.Node) bool
- func IsValidVariableToTrack(root *sitter.Node, variable string, content []byte) bool
- func IsVariableGlobal(root *sitter.Node, variable string, content []byte) bool
- func IsVariableInScope(varName string, functionNode *sitter.Node, content []byte) bool
- func IsVariableUsedInExpression(node *sitter.Node, variable string, content []byte) bool
- func SafeContent(node *sitter.Node, content []byte) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGlobalVariableSteps ¶
func AddGlobalVariableSteps(dataFlow []models.DataFlowStep, root *sitter.Node, content []byte, lineNumber uint32) []models.DataFlowStep
----------------------------------------------------------------------------- AddGlobalVariableSteps - Adds global variable declaration steps for all unique variables in the data flow steps. -----------------------------------------------------------------------------
Parameters:
- dataFlow ([]models.DataFlowStep): The data flow steps to process.
- root (*sitter.Node): The root node of the syntax tree.
- content ([]byte): The content of the source code.
- lineNumber (uint32): The line number to use for generic usage steps.
Returns:
- ([]models.DataFlowStep): The updated data flow steps with global variable declaration steps.
-----------------------------------------------------------------------------
func ExtractFunctionNameFromCall ¶
----------------------------------------------------------------------------- ExtractFunctionNameFromCall - Extracts the function name from a function call node. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The function call node.
- content ([]byte): The content of the source code.
Returns:
- (string): The name of the function being called.
-----------------------------------------------------------------------------
func FindCallExpression ¶
----------------------------------------------------------------------------- FindCallExpression - Finds the call expression node in a given node for multiple languages. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to search for a call expression.
Returns:
- (*sitter.Node): The call expression node if found, otherwise nil.
-----------------------------------------------------------------------------
func FindFunctionBounds ¶
func FindFunctionBounds(root *sitter.Node, node *sitter.Node, startLine uint32) (functionStart, functionEnd uint32)
----------------------------------------------------------------------------- FindFunctionBounds - Finds the start and end lines of a function containing the specified line. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- node (*sitter.Node): The node to check if it is a function declaration.
- startLine (uint32): The line number to search for.
Returns:
- (functionStart, functionEnd uint32): The start and end lines of the function.
-----------------------------------------------------------------------------
func FindFunctionByLine ¶
----------------------------------------------------------------------------- FindFunctionByLine - Finds the function node that contains the specified line. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- line (uint32): The line number to search for.
- lang (string): The programming language of the source code.
Returns:
- (*sitter.Node): The node representing the function if found, otherwise nil.
-----------------------------------------------------------------------------
func FindFunctionByName ¶
----------------------------------------------------------------------------- FindFunctionDeclaration - Finds the declaration of a function by its name in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- functionName (string): The name of the function to find.
- content ([]byte): The content of the source code.
Returns:
- (*sitter.Node): The node representing the function declaration if found, otherwise nil.
-----------------------------------------------------------------------------
func FindFunctionCallSites ¶
func FindFunctionCallSites(root *sitter.Node, functionName string, content []byte) []models.FunctionCallSite
----------------------------------------------------------------------------- FindFunctionCallSites - Searches all lines where a specific function is called. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- functionName (string): The name of the function to search for.
- content ([]byte): The content of the source code.
Returns:
- ([]models.FunctionCallSite): A slice of function call sites.
-----------------------------------------------------------------------------
func FindFunctionDeclaration ¶
----------------------------------------------------------------------------- FindFunctionDeclaration - Finds the declaration of a function by its name in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- functionName (string): The name of the function to find.
- content ([]byte): The content of the source code.
Returns:
- (*sitter.Node): The node representing the function declaration if found, otherwise nil.
-----------------------------------------------------------------------------
func FindGlobalVariableDeclaration ¶
----------------------------------------------------------------------------- FindGlobalVariableDeclaration - Finds the declaration of a global variable in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- variable (string): The name of the variable to search for.
- content ([]byte): The content of the source code.
Returns:
- (*sitter.Node): The node representing the global variable declaration if found, otherwise nil.
-----------------------------------------------------------------------------
func FindNodeAtLine ¶
----------------------------------------------------------------------------- FindNodeAtLine - Finds the node at the specified line in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The root node of the syntax tree.
- targetLine (uint32): The line number to search for.
Returns:
- (*sitter.Node): The node at the specified line if found, otherwise nil.
-----------------------------------------------------------------------------
func FindParentFunction ¶
----------------------------------------------------------------------------- FindParentFunction - Finds the name of the parent function for a given node. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node for which to find the parent function.
- content ([]byte): The content of the source code.
Returns:
- (string): The name of the parent function if found, otherwise an empty string.
-----------------------------------------------------------------------------
func GetArgumentVariable ¶
func GetArgumentVariable(callNode *sitter.Node, parameterVariable string, functionNode *sitter.Node, content []byte) string
----------------------------------------------------------------------------- GetArgumentVariable - Finds the argument variable corresponding to a parameter variable in a function call. -----------------------------------------------------------------------------
Parameters:
- callNode (*sitter.Node): The function call node.
- parameterVariable (string): The parameter variable to search for.
- functionNode (*sitter.Node): The function node containing the parameter.
- content ([]byte): The content of the source code.
Returns:
- (string): The argument variable corresponding to the parameter variable.
-----------------------------------------------------------------------------
func GetControlType ¶
----------------------------------------------------------------------------- GetControlType - Returns a descriptive string for control flow statements across multiple languages. -----------------------------------------------------------------------------
Parameters:
- nodeType (string): The type of the node.
Returns:
- (string): A descriptive string for the control flow statement.
-----------------------------------------------------------------------------
func GetParameterName ¶
func GetParameterName(functionNode *sitter.Node, content []byte, originalVariable string, callSite *sitter.Node) string
----------------------------------------------------------------------------- GetParameterName - Finds the name of the parameter corresponding to a variable in a function call. -----------------------------------------------------------------------------
Parameters:
- functionNode (*sitter.Node): The function node containing the parameter.
- content ([]byte): The content of the source code.
- originalVariable (string): The original variable name.
- callSite (*sitter.Node): The function call node.
Returns:
- (string): The name of the parameter corresponding to the variable.
-----------------------------------------------------------------------------
func IsAssignment ¶
----------------------------------------------------------------------------- IsAssignment - Checks if a variable is used in an assignment or declaration across multiple languages. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to check.
- content ([]byte): The content of the source code.
- variable (string): The variable to check for.
Returns:
- (bool, string): True if the variable is found in the assignment, and the value assigned to it.
-----------------------------------------------------------------------------
func IsClassFieldAssignment ¶
----------------------------------------------------------------------------- IsClassFieldAssignment - Checks if a node represents an assignment to a class field. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to check.
- content ([]byte): The content of the source code.
- variable (string): The variable to check for.
Returns:
- (bool): True if the node represents an assignment to the class field, false otherwise.
-----------------------------------------------------------------------------
func IsFunctionCall ¶
----------------------------------------------------------------------------- IsFunctionCall - Checks if the node represents a function call involving the given variable. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to check.
- content ([]byte): The content of the source code.
- variable (string): The variable to check for.
Returns:
- (bool, string): True if the node represents a function call involving the variable, and the variable name if assigned.
-----------------------------------------------------------------------------
func IsFunctionDeclaration ¶
----------------------------------------------------------------------------- IsFunctionDeclaration - Determines if a node represents a function declaration. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- node (*sitter.Node): The node to check if it is a function declaration.
- content ([]byte): The content of the source code.
Returns:
- (string): The name of the function if the node is a function declaration, otherwise an empty string.
-----------------------------------------------------------------------------
func IsFunctionDeclared ¶
----------------------------------------------------------------------------- IsFunctionDeclared - Checks if a function with the given name is declared in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- functionName (string): The name of the function to search for.
- content ([]byte): The content of the source code.
Returns:
- (bool): True if the function is declared, false otherwise.
-----------------------------------------------------------------------------
func IsLiteral ¶
----------------------------------------------------------------------------- IsLiteral - Checks if the node represents a literal value in the syntax tree. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to check.
Returns:
- (bool): True if the node represents a literal value, false otherwise.
-----------------------------------------------------------------------------
func IsValidVariableToTrack ¶
----------------------------------------------------------------------------- IsValidVariableToTrack - Verifies if the variable name corresponds to a function declaration. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- variable (string): The variable name to check.
- content ([]byte): The content of the source code.
Returns:
- (bool): True if the variable name does not correspond to a function declaration, false otherwise.
-----------------------------------------------------------------------------
func IsVariableGlobal ¶
----------------------------------------------------------------------------- IsVariableGlobal - Checks if a variable is global within the provided root node. -----------------------------------------------------------------------------
Parameters:
- root (*sitter.Node): The root node of the syntax tree.
- variable (string): The name of the variable to check.
- content ([]byte): The content of the source code.
Returns:
- (bool): True if the variable is global, false otherwise.
-----------------------------------------------------------------------------
func IsVariableInScope ¶
----------------------------------------------------------------------------- IsVariableInScope - Checks if the given variable is in scope within the provided function node. -----------------------------------------------------------------------------
Parameters:
- varName (string): The name of the variable to check.
- functionNode (*sitter.Node): The function node to check within.
- content ([]byte): The content of the source code.
Returns:
- (bool): True if the variable is in scope, false otherwise.
-----------------------------------------------------------------------------
func IsVariableUsedInExpression ¶
----------------------------------------------------------------------------- IsVariableUsedInExpression - Checks if a variable is used in an expression within a node. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node to check.
- variable (string): The variable to check for.
- content ([]byte): The content of the source code.
Returns:
- (bool): True if the variable is used in the expression, false otherwise.
-----------------------------------------------------------------------------
func SafeContent ¶
----------------------------------------------------------------------------- SafeContent - Securely extracts the content of a node from the content of the file. -----------------------------------------------------------------------------
Parameters:
- node (*sitter.Node): The node from which to extract content.
- content ([]byte): The content of the source code.
Returns:
- (string): The extracted content as a string.
-----------------------------------------------------------------------------
Types ¶
This section is empty.