Proposal: Any instance of a definition name should be considered a reference, not just calls

Right now, it seems we're treating only function calls as references. Instead, we should treat any instance of a function's name as a reference. This is how GitHub's code navigator and the LSP does it. And here's an example in Python to show why:

def bar():
    # ...

def foo(callback):
    # ...

def fizz():
    foo(bar)

We can clearly see that bar is used in fizz, but because it's not directly called in fizz there wouldn't be a link between the two. If we instead treated the expression bar as a reference, then we'd create a link between fizz and bar at the line where it's passed into foo. This is much better than simply ignoring the connection altogether. Imagine an agent is traversing the graph to understand how bar is used in the codebase. If it found the reference in fizz, then perhaps it would decide to jump into the definition of foo to see how bar is being used there too.

Another example:

def fizz():
    my_fn = foo if condition else bar
    my_fn()

This is an example of runtime ambiguity. We don't know if fizz calls foo or bar until we know how the if statement evaluates, which happens at runtime. As a result, we wouldn't link fizz to foo OR bar to avoid ambiguity. But if we treated the usage of foo and bar in the conditional as references, then we would create links with foo and bar.

Edited by Jonathan Shobrook