Fork me on GitHub
#lsp
<
2022-09-13
>
sheluchin12:09:47

How about a move-to-param (like move-to-let) refactoring which adds a param with the given name and replaces all cases of the expression under the cursor with it?

ericdallo12:09:10

Would it add a new arg to the function, changing its arity right? what about the callers of that function? they would need to pass the new arg usually we avoid refactorings that break the code or leave the code invalid

sheluchin12:09:17

@UKFSJSM38 yes, you're right. Unless it's added as a kwarg with a default it would be a breaking change and updating all the call sites would probably bring too much complexity to the UI and the handling code. Thanks for your consideration.

👍 1
snoe17:09:28

So I think intellij (java) allows this, maybe with a static value (nil) for the new arg at call sites or perhaps it requires the interactive refactoring feature. This is related, but with drag it's using existing args. https://github.com/clojure-lsp/clojure-lsp/issues/1131

ericdallo17:09:52

Yeah, the LSP protocol doesn't mention a "update multiple places" feature, but thinking a little bit maybe this is something that should be handled by each client, like server tells, update file a , b and c with these changes, and each client handle how to present to user with a confirm or rollback option. At least would be nice if the the protocol should be clear about that or suggest something

ericdallo17:09:08

Even so, I don't recall most clients (vim, emacs and vscode) having a feature like that which intellij has

snoe17:09:34

Yeah, without protocol direction though I wouldn't want clients to have to build clojure-lsp specific handling. We can do the static value insertion without the suggestion/review feature tho

ericdallo17:09:20

yeah, the static insertion sounds viable

snoe17:09:35

Similar to the "any var" option we could look for vars whose names match the new param name too, but that might run into too easy to break/too hard to review manually.

sheluchin17:09:12

Okay, thanks for chiming in, @U0BUV7XSA. I'll create an issue for this.

👍 1
bringe19:09:53

Has anyone else been seeing codeAction errors? I’ve seen something like this in Calva lately, multiple times, and a friend has as well.

[Error - 10:51:40 AM] Request textDocument/codeAction failed.
  Message: Internal error
  Code: -32603
[object Object]
The client<->server comm looks like this:
[Trace - 11:53:37 AM] Sending request 'textDocument/codeAction - (56)'.
Params: {
    "textDocument": {
        "uri": "<my-file-path>"
    },
    "range": {
        "start": {
            "line": 62,
            "character": 28
        },
        "end": {
            "line": 62,
            "character": 28
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 11:53:37 AM] Received response 'textDocument/codeAction - (56)' in 17ms. Request failed: Internal error (-32603).
Error data: {
    "id": 56,
    "method": "textDocument/codeAction"

bringe19:09:24

There’s a null pointer exception in the server logs:

2022-09-13T18:53:37.963Z  ERROR [clojure-lsp.server:39] - Error receiving message: Internal error (-32603)
{:id 56, :method "textDocument/codeAction"}
[37mcom.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine[m  [32mPosixPlatformThreads.java:  202[m
            [37mcom.oracle.svm.core.thread.PlatformThreads.threadStartRoutine[m  [32m     PlatformThreads.java:  705[m
                                                     [37mjava.lang.Thread.run[m  [32m              Thread.java:  829[m
                       [37mjava.util.concurrent.ThreadPoolExecutor$Worker.run[m  [32m  ThreadPoolExecutor.java:  628[m
                        [37mjava.util.concurrent.ThreadPoolExecutor.runWorker[m  [32m  ThreadPoolExecutor.java: 1128[m
                                      [37mjava.util.concurrent.FutureTask.run[m  [32m          FutureTask.java:  264[m
                                                                      [37m...[m  [32m                               [m
                                      [33mclojure.core/binding-conveyor-fn/[1;33mfn[m  [32m                 core.clj: 2047[m
                                  [33mclojure-lsp.feature.code-actions/all/[1;33mfn[m  [32m         code_actions.clj:  329[m
                              [33mclojure-lsp.feature.drag/[1;33mcan-drag-backward?[m  [32m                 drag.clj:  493[m
                                       [33mclojure-lsp.feature.drag/[1;33mcan-drag?[m  [32m                 drag.clj:  492[m
                                            [33mclojure-lsp.feature.drag/[1;33mplan[m  [32m                 drag.clj:  483[m
                                     [33mclojure-lsp.feature.drag/[1;33mtarget-locs[m  [32m                 drag.clj:  476[m
                                                     [33mrewrite-clj.zip/[1;33mnode[m  [32m                 zip.cljc:  178[m
                                      [33mrewrite-clj.custom-zipper.core/[1;33mnode[m  [32m                core.cljc:   55[m
                                                         [33mclojure.zip/[1;33mnode[m  [32m                  zip.clj:   67[m
         [1;31mjava.lang.NullPointerException[m: [3m[m
[1;31mjava.util.concurrent.ExecutionException[m: [3mjava.lang.NullPointerException[m

bringe19:09:55

This only happens sometimes. And I haven’t determined the cause or how to reproduce.

pez19:09:17

This happens to me all the time and is quite annoying. I'm a bad Clojure citizen for not reporting. 😃 Anyway, super easy to repro. Just ignore a binding pair in a map or let box by prepending it with #_#_.

(let [x 1
      y 2]
  x)
Make that:
(let [x 1
      #_#_y 2]
  x)
BOOM.

💥 1
ericdallo20:09:44

I think that was fixed on master https://github.com/clojure-lsp/clojure-lsp/pull/1228 Could you test the nightly build?

🎊 1
bringe22:09:33

Awesome. I can check this soon if someone else doesn’t before me.

bringe16:09:44

@UKFSJSM38 Where can I get the nightly builds?

ericdallo16:09:07

yep or from #clojure-lsp-builds

👍 1
bringe16:09:20

Does the install script install the latest? And does the nightly build report the last released version when --version is run?

bringe16:09:46

clojure-lsp --version
clojure-lsp 2022.09.01-15.27.31
clj-kondo 2022.09.08

ericdallo16:09:58

the install script uses the latest stable release unless you pass the --nightly param

ericdallo16:09:15

for nightly builds, --version should print a -nightly IIRC

bringe16:09:20

I used sudo ./install --version nightly and got the above output :thinking_face:

bringe16:09:17

Just downloaded the nightly build zip from the builds channel and it also reports the latest release, so I guess it is the nightly build..

bringe16:09:11

Anyway, I confirmed that the nightly build fixes the issue, using the repro from @U0ETXRFEW above. 🎉

👍 2
🎉 1
ericdallo16:09:33

Yeah, maybe we lost that suffix after we recently moved nightly builds to a separated repo, which made us refactoring the nightly build CI

pez16:09:14

Calva's nighly install is still broken, btw. I don't know what's (not) going on.

1
ericdallo16:09:50

I'll take a look at the output version not showing nightly

ericdallo13:09:50

from clojure-lsp side, it seems the version output is correct @U9A1RLFNV :thinking_face:

bringe15:09:16

This is what I get with the nightly build I downloaded for macos-aarch64:

./clojure-lsp --version
clojure-lsp 2022.09.01-15.27.31
clj-kondo 2022.09.08

ericdallo15:09:14

oh, there is a chance to be only with macos-aarch64, since it's the only build which is built from cirrus-ci (github doesn't support aarch64 yet)

ericdallo16:09:27

@U9A1RLFNV I think it's fixed, could you test it again please?

bringe16:09:47

Works 🎉

./clojure-lsp --version
clojure-lsp 2022.09.15-16.16.12-nightly
clj-kondo 2022.09.08

nice 1
ericdallo16:09:38

Nice! And is calva bringing nightly properly?

bringe16:09:29

I’m not sure. @U0ETXRFEW would you mind verifying that?