steel-language-server: support renaming variables#325
steel-language-server: support renaming variables#325mattwparas merged 4 commits intomattwparas:masterfrom
Conversation
|
|
0706c1a to
70f7f31
Compare
|
this does not quite work, as without lowering (which is not done for the (let countdown ((i 10))
(if (= i 0) 'liftoff
(begin
(display i)
(newline)
(countdown (- i 1)))))doing full reproducing codeas you can see there are multiple different identifiers with multiple different syntax objects with different if i replace the here i can just resolve the identifier to the i pushed a temporary proof-of-concept commit as d6cb6ea that does just exactly that, but that is less than ideal because i have to recompute the map on every call of rename and i have to (probably) reallocate the slice, because it is stored as a rope. with that commit applied, everything (at least in my kind of limited testing) works for me as expected. as i do not fully understand the code base (sorry if i did this pr a little rash), is there a reason the |
|
Sorry - been a busy week! To answer your immediate question, the reason it is parsed without lowering is to handle macros, generally speaking. Otherwise - I don't remember the specific reason that the LSP parses without lowering here. I will take a more involved look and try to provide some more clarify |
|
Okay - I've come back to this, sorry for the delay: The
|
|
So this is why the analysis looks funny. This is the fully expanded code: (%plain-let ((##countdown3 123)) ;; dummy value that should probably be something like 'unintialized
(%plain-let ((####countdown33 (#%box ##countdown3)))
(%plain-let ((##_____countdown04 (λ (##i4)
(if (= ##i4 0)
(quote
liftoff)
(begin
(display ##i4)
(newline)
((#%unbox ####countdown33)
(- ##i4 1)))))))
(begin
(#%set-box! ####countdown33 ##_____countdown04)
((#%unbox ####countdown33) 10))))) |
|
So, after looking at this, I actually think your solution makes the most sense. Given that renaming should really only apply "source code level" stuff, re-parsing and attempting to resolve stuff pre macro expansion makes a lot of sense. Given that, I'm happy to approve and live on it for a bit to see how it plays. Were you happy with this as is, or did you want to do any more on it? |
|
i was not quite happy with the commit marked with i will have to get back to this later though, as i am very tired and need to wake up early tomorrow (though i'll probably deal with the morge conflict in #338 before that) |
|
No rush at all 😃 I'll hold off on merging then |
|
did that now: i added a new |
|
Thanks! Lets get this in so it can start getting some use |
support the
textDocument/renameandtextDocument/prepareRenamelsp requests. currently only works forLetVarandLocalidentifiers, as i was unsure of how to properly handleGlobalidentifiers with regards to(require ...)and those two were the easiest to implement by far.on an unrelated side note: i noticed that
(map ...)is not marked as a builtin, which i think it should be?. not sure how to fix that though.