-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get node at (line, col) #891
Comments
I think probably the inverse of |
Yeah that would probably be the best solution. |
Hi. I had encountered this problem too and I saw #893. const source: SourceFile = ...;
const pos = source.compilerNode.getPositionOfLineAndCharacter(line, col);
|
Interesting, that function must've been added in a more recent version. |
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 usingsourceFile.getLineAndColumnAtPos
(#801) but I can't find anything for the reverse.Describe alternatives you've considered
I bodged together this:
But that doesn't seem like an efficient solution.
The text was updated successfully, but these errors were encountered: