dylan-lang / lsp-dylan

Language Server for Dylan (alpha)
MIT License
8 stars 2 forks source link

textDocument/definition finds wrong file #23

Closed cgay closed 3 months ago

cgay commented 1 year ago

Below is the log for M-. on find-project while editing lsp-dylan.dylan:

D 2022-11-05T16:54:39.000+0000 [Main thread] Invoking "textDocument/definition" with id 132 and params {"position":{"character":27,"line":274},"textDocument":{"uri":"file:///home/cgay/dylan/workspaces/lsp/lsp-dylan/lsp-dylan.dylan"}}
D 2022-11-05T16:54:39.000+0000 [Main thread] find-project -> module is {class <module-object>}lsp-dylan-impl
D 2022-11-05T16:54:39.000+0000 [Main thread] definition = {<generic-function-object> 26}, location = {<compiler-range-source-location> {flat file "project-objects"} (56, 0) - (57, 65) 27}
D 2022-11-05T16:54:39.000+0000 [Main thread] definition = {<method-object> 28}, location = {<compiler-range-source-location> {flat file "projects"} (485, 0) - (495, 23) 29}
D 2022-11-05T16:54:39.000+0000 [Main thread] textDocument/definition: Lookup find-project and got target={<posix-file-locator> "/home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/project-objects.dylan"}, line=63, char=0
D 2022-11-05T16:54:39.000+0000 [Main thread] textDocument/definition: Lookup find-project and got target={<posix-file-locator> "/home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/projects.dylan"}, line=491, char=0
D 2022-11-05T16:54:39.000+0000 [Main thread] send-raw-message: {"result":[{"range":{"end":{"character":0,"line":63},"start":{"character":0,"line":63}},"uri":"file:///home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/project-objects.dylan"},{"range":{"end":{"character":0,"line":491},"start":{"character":0,"line":491}},"uri":"file:///home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/projects.dylan"}],"id":132,"jsonrpc":"2.0"}
D 2022-11-05T16:54:39.000+0000 [Main thread] send-response: {"result":[{"range":{"end":{"character":0,"line":63},"start":{"character":0,"line":63}},"uri":"file:///home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/project-objects.dylan"},{"range":{"end":{"character":0,"line":491},"start":{"character":0,"line":491}},"uri":"file:///home/cgay/dylan/workspaces/lsp/lsp-dylan/_build/databases/projects.dylan"}],"id":132,"jsonrpc":"2.0"}
D 2022-11-05T16:54:39.000+0000 [Main thread] lsp-active-state-loop: waiting for message

lsp-mode reports "No definition found". Note that the pathname found was lsp-dylan/_build/databases/project-objects.dylan, which is obviously never going to work.

This makes me suspect that only relative pathnames are stored in the compiler database and they get merged against something. I couldn't find an easy way to dump the db so I'll fall back on adding debug logging in the compiler.

I can't think of a good reason not to store absolute pathnames in the db. It's not as though the db is intended to be moved around, and if sources are moved the code must be rebuilt anyway. Was it just circa 1990s space savings that motivated it? Storing the full pathname might just be the easiest fix. (But this is all just speculation for now.)

cgay commented 3 months ago

I can't reproduce this. Much has changed...closing.