getNodeText returns the trimmed source text of a node.
(node *ast.Node, sf *ast.SourceFile)
| 60 | |
| 61 | // getNodeText returns the trimmed source text of a node. |
| 62 | func getNodeText(node *ast.Node, sf *ast.SourceFile) string { |
| 63 | if node != nil && node.Parent != nil && node.Parent.Kind == ast.KindPropertyDeclaration && node.Parent.Name() == node && node.Parent.Parent != nil && node.Parent.Parent.Kind == ast.KindClassDeclaration { |
| 64 | if className := node.Parent.Parent.Name(); className != nil { |
| 65 | classText := strings.TrimSpace(scanner.GetSourceTextOfNodeFromSourceFile(sf, className, false)) |
| 66 | propText := strings.TrimSpace(scanner.GetSourceTextOfNodeFromSourceFile(sf, node, false)) |
| 67 | if classText != "" && propText != "" { |
| 68 | return classText + "." + propText |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | return strings.TrimSpace(scanner.GetSourceTextOfNodeFromSourceFile(sf, node, false)) |
| 73 | } |
| 74 | |
| 75 | // getNodeSourceFile walks up the parent chain to find the SourceFile ancestor. |
| 76 | func getNodeSourceFile(node *ast.Node) *ast.SourceFile { |
no outgoing calls
no test coverage detected