Get node at (line, col)
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
I get line & column coordinates from an external source, I want to get the node(s) at this coordinate.
**Describe the solution you'd like**
The obvious solution would be `sourceFile.getChildAtPos`, but this takes a 1D coordinate. I can convert from "pos" to line+col using `sourceFile.getLineAndColumnAtPos` (#801) but I can't find anything for the reverse.
**Describe alternatives you've considered**
I bodged together this:
```ts
for (const node of source.getDescendants()) {
if (line === node.getStartLineNumber() && col === node.getStart() - node.getStartLinePos()) {
// We have our node!
}
}
```
But that doesn't seem like an efficient solution.
Contributor guide
Assessment
This issue has not been assessed yet.