dstutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dstutil provides utilities for DST (Decorated Syntax Tree) manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertStatements

func InsertStatements(body *dst.BlockStmt, stmtStr string) bool

InsertStatements inserts statements at the beginning of a function body.

func MatchesExact

func MatchesExact(a, b dst.Stmt) bool

MatchesExact compares two statements for exact equality. Unlike MatchesSkeleton, this also compares literal values.

func MatchesSkeleton

func MatchesSkeleton(a, b dst.Stmt) bool

MatchesSkeleton compares two statements by their AST structure. It returns true if both statements have the same "skeleton" - same node types and static identifiers, but potentially different dynamic values (variables, literals).

func ParseStatements

func ParseStatements(stmtStr string) ([]dst.Stmt, error)

ParseStatements parses a statement string into DST statements. Supports multiple statements separated by newlines.

func RemoveStatements

func RemoveStatements(body *dst.BlockStmt, index, count int) bool

RemoveStatements removes `count` statements starting at the given index.

func UpdateStatements

func UpdateStatements(body *dst.BlockStmt, index, count int, stmtStr string) bool

UpdateStatements updates statements starting at the given index. It replaces `count` statements with the parsed statements from stmtStr.

Types

This section is empty.

Jump to

Keyboard shortcuts

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