Пример #1
0
func _AttachAnnotation(node ast.Node, annotations ...*ast.Annotation) {

	anns := Annotations(node)

	anns = append(anns, annotations...)

	node.SetExtra(ExtraAnnotation, anns)
}
Пример #2
0
// 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)
}
Пример #3
0
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
}
Пример #4
0
func _setNodePos(node ast.Node, start lexer.Position, end lexer.Position) {
	node.SetExtra(ExtraStartPos, start)
	node.SetExtra(ExtraEndPos, end)
}