A name knows where it lives
I used to find where a name came from by searching the file. Then I would search the project. Sometimes I found the right name in the wrong place. Pooka 0.4.0 has a language server now, and it can do that small bit of detective work.
Two names, two addresses
module main
total(amount: Int) -> Int {
let previous = amount
let amount = 20
previous + amount
}
There are two references to amount. The first takes you to the parameter. The second takes you to the local binding. The resolver already makes this distinction when checking the program. The editor can ask it for the same answer and get the declaration's source range.
For a call like item.read(), the type checker supplies the address. It knows the type of item and which class provided the method. If a subclass inherits the method, the jump takes you to the declaration in the parent. An override gives you a different address.
Before the file is saved
The bit I wanted most was to move a declaration in one buffer and jump to it from another without saving. So the server checks with the open buffers laid over the files on disk. Those temporary edits stay out of the build cache.
The trick is keeping those answers out of the editor's way. On Jinks, one typed jump took about three seconds on my machine. An outline request sent while it was working came back in two milliseconds. There is work left in making the jump faster, but I can keep using the editor while it thinks.
The first version is out in Pooka 0.4.0. The editor guide shows how to try it.