ast-types
ast-types copied to clipboard
Connecting a reference back to its object
Hello! I am new to language parsing so please correct me if I use the wrong terminology. I'm searching for a library that would hand be an AST that would provide information for a consumer to connect a reference at one location to its original definition.
For example:
var output = "Hello" // <- object X
function coolDude(asdf) { // <- function A
asdf += " ~~not so cool dude"
return asdf
}
function addWorld(to) {
function coolDude(asdf) { // <- function B
asdf += " cool duuuude"
return asdf
}
to += " world!"
return coolDude(to) // <- tell me Call B refers to object/function B (not function A)
}
output = addWorld(output /* <- refers to object X */)
output = coolDude(output) // <- tell me Call A refers to object/function A
etc etc.
I am unclear how to get this information through ast-types or if it is possible, going through the examples and breaking in at different points seems to only give me literal parsed information (location an expression is in source, what type of expression it is, correlated metadata such as arguments for a callee, etc etc).
Any help or direction would be much appreciated, thank you!