nodeText extracts the source text of a node from the source file.
(sf *ast.SourceFile, node *ast.Node)
| 9 | |
| 10 | // nodeText extracts the source text of a node from the source file. |
| 11 | func nodeText(sf *ast.SourceFile, node *ast.Node) string { |
| 12 | if node == nil || sf == nil { |
| 13 | return "" |
| 14 | } |
| 15 | text := sf.Text() |
| 16 | pos := node.Pos() |
| 17 | end := node.End() |
| 18 | if pos >= 0 && end >= pos && end <= len(text) { |
| 19 | return text[pos:end] |
| 20 | } |
| 21 | return "" |
| 22 | } |
| 23 | |
| 24 | // ReconstructPipingFlow reconstructs a piping flow into a string expression |
| 25 | // by applying transformations sequentially. |
no outgoing calls