本文整理汇总了Golang中github.com/gsrpc/gslang/ast.Node类的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: _AttachAnnotation
func _AttachAnnotation(node ast.Node, annotations ...*ast.Annotation) {
anns := Annotations(node)
anns = append(anns, annotations...)
node.SetExtra(ExtraAnnotation, anns)
}
示例2: Annotations
// Annotations .
func Annotations(node ast.Node) (anns []*ast.Annotation) {
val, ok := node.GetExtra(ExtraAnnotation)
if ok {
anns = val.([]*ast.Annotation)
}
return
}
示例3: _RemoveAnnotation
// Annotations .
func _RemoveAnnotation(node ast.Node, annotation *ast.Annotation) {
anns := Annotations(node)
var newanns []*ast.Annotation
for _, ann := range anns {
if ann == annotation {
continue
}
newanns = append(newanns, ann)
}
node.SetExtra(ExtraAnnotation, anns)
}
示例4: Pos
// Pos .
func Pos(node ast.Node) (start lexer.Position, end lexer.Position) {
val, ok := node.GetExtra(ExtraStartPos)
if ok {
start = val.(lexer.Position)
}
val, ok = node.GetExtra(ExtraEndPos)
if ok {
end = val.(lexer.Position)
}
return
}
示例5: _AttachComment
func _AttachComment(node ast.Node, comment *ast.Comment) bool {
nodeStart, nodeEnd := Pos(node)
commentStart, commentEnd := Pos(comment)
if nodeStart.Lines == commentEnd.Lines ||
nodeStart.Lines == commentEnd.Lines+1 ||
nodeEnd.Lines == commentStart.Lines {
node.SetExtra(ExtraComment, comment)
return true
}
return false
}
示例6: FindAnnotations
// FindAnnotations .
func FindAnnotations(node ast.Node, name string) (retval []*ast.Annotation) {
val, ok := node.GetExtra(ExtraAnnotation)
if ok {
anns := val.([]*ast.Annotation)
for _, ann := range anns {
if ann.Type.Ref == nil {
continue
}
if ann.Type.Ref.FullName() == name {
retval = append(retval, ann)
}
}
}
return
}
示例7: FindAnnotation
// FindAnnotation .
func FindAnnotation(node ast.Node, name string) (*ast.Annotation, bool) {
val, ok := node.GetExtra(ExtraAnnotation)
if ok {
anns := val.([]*ast.Annotation)
for _, ann := range anns {
if ann.Type.Ref == nil {
continue
}
if ann.Type.Ref.FullName() == name {
return ann, true
}
}
}
return nil, false
}
示例8: _setNodePos
func _setNodePos(node ast.Node, start lexer.Position, end lexer.Position) {
node.SetExtra(ExtraStartPos, start)
node.SetExtra(ExtraEndPos, end)
}