helpers

package
v0.0.0-...-69dbcc0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertSyntaxNodeToAstFile

func ConvertSyntaxNodeToAstFile(node syntax.Node) *ast.File

ConvertSyntaxNodeToAstFile converts a given syntax.Node to an equivalent *ast.File. This function is designed to convert shell-like syntax to Go AST. It creates a new Go file named "main" and a function named "main" within it. The shell-like syntax is traversed and each command is converted to a corresponding Go call expression. The converted expressions are added to the "main" function's body.

Parameters: - node: The syntax.Node to convert.

Returns: - An equivalent *ast.File representing the converted shell-like syntax.

func ExtractVarName

func ExtractVarName(arg string) (string, string)

ExtractVarName extracts the variable name and remaining string from patterns like $(OUT_DIR) or ${OUT_DIR} or $VAR. It supports both $() and ${} formats, and also handles the simple $VAR format. If the input string does not match any of these formats, it returns an empty string for both the variable name and remaining string.

Parameters: - arg: The input string containing the variable pattern.

Returns: - A string representing the extracted variable name. - A string representing the remaining string after the extracted variable name.

func IsAllowedExtension

func IsAllowedExtension(filename string, allowedExts []string) bool

func IsExcludedDir

func IsExcludedDir(pth string, excludedDirs []string) bool

func TrackVariableAssignments

func TrackVariableAssignments(node ast.Node) map[string]string

TrackVariableAssignments traverses the given AST node and identifies variable assignments. It returns a map where the keys are variable names and the values are the corresponding assigned values. If a variable is not assigned a value, the value in the map will be an empty string.

Parameters: - node: The AST node to traverse.

Returns: - A map where the keys are variable names and the values are the corresponding assigned values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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