Documentation
¶
Overview ¶
Package syntaxgo_astnode provides utilities to work with AST nodes Handle node position info and extract code content from AST nodes Support operations like code extraction, modification, and deletion
syntaxgo_astnode 包提供处理 AST 节点的工具 处理节点位置信息并从 AST 节点提取代码内容 支持代码提取、修改和删除等操作
Index ¶
- func ChangeNodeCode(source []byte, astNode ast.Node, newCode []byte) []byte
- func ChangeNodeCodeSetSomeNewLines(source []byte, astNode ast.Node, newCode []byte, numLine int) []byte
- func DeleteNodeCode(source []byte, astNode ast.Node) []byte
- func GetCode(source []byte, astNode ast.Node) []byte
- func GetText(source []byte, astNode ast.Node) string
- func SdxEdx(astNode ast.Node) (sdx, edx int)
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeNodeCode ¶
ChangeNodeCode replaces the code corresponding to the given AST node with new code in the source. ChangeNodeCode 用新代码替换源代码中与给定 AST 节点对应的代码。
func ChangeNodeCodeSetSomeNewLines ¶
func ChangeNodeCodeSetSomeNewLines(source []byte, astNode ast.Node, newCode []byte, numLine int) []byte
ChangeNodeCodeSetSomeNewLines replaces the code corresponding to the given AST node with new code and adds new lines in the source. ChangeNodeCodeSetSomeNewLines 用新代码替换源代码中与给定 AST 节点对应的代码,并添加新行。
func DeleteNodeCode ¶
DeleteNodeCode removes the code corresponding to the given AST node from the source. DeleteNodeCode 从源代码中删除与给定 AST 节点对应的代码。
func GetCode ¶
GetCode returns the code corresponding to the given AST node from the source. GetCode 从源代码中返回与给定 AST 节点对应的代码。
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a syntax node with position information. Node 表示一个带有位置信息的语法节点。
func NewNode ¶
NewNode creates a new Node with the specified start and end positions. NewNode 创建一个带有指定起始和结束位置的 Node。
func NewNodeV1 ¶
NewNodeV1 creates a new Node from an existing ast.Node. NewNodeV1 从一个现有的 ast.Node 创建一个新的 Node。
func NewNodeV2 ¶
NewNodeV2 creates a new Node with the specified start and end positions as integers. NewNodeV2 创建一个带有指定起始和结束位置(整数)的 Node。
func (*Node) GetCode ¶
GetCode returns the code corresponding to the Node from the source. GetCode 从源代码中返回与 Node 对应的代码。
func (*Node) GetText ¶
GetText returns the text corresponding to the Node from the source. GetText 从源代码中返回与 Node 对应的文本。