| 85 | } |
| 86 | |
| 87 | function findNode(sourceFile: ts.SourceFile, position: number, length?: number): ts.Node | undefined { |
| 88 | let found: ts.Node | undefined; |
| 89 | let lastFoundNode: ts.Node | undefined; |
| 90 | sourceFile.forEachChild(visit); |
| 91 | |
| 92 | function visit(node: ts.Node) { |
| 93 | if (node.pos === position) { |
| 94 | found = node; |
| 95 | return; |
| 96 | } else if (node.pos > position) { |
| 97 | return; |
| 98 | } else if (length && node.pos < position && node.end >= position + length) { |
| 99 | lastFoundNode = node; |
| 100 | } |
| 101 | ts.forEachChild(node, visit); |
| 102 | } |
| 103 | return found || lastFoundNode; |
| 104 | } |
| 105 | |
| 106 | type TelemetryProperty = { |
| 107 | name: string; |