toitware / ide-tools

Tools for working with Toit in different IDEs
MIT License
2 stars 2 forks source link

Connection got disposed when Ctrl-hovering over `print` #184

Closed kasperl closed 2 years ago

kasperl commented 2 years ago

Using jaguar v0.5.0 and the 1.4.0 extension, I consistently get 'Connection got disposed' errors when I hold Ctrl and hover over print in the following simple example:

main:
  print "Hello, World"

The logged error looks like this:

[Error - 9:00:24 PM] Server initialization failed.
Error: Connection got disposed.
    at Object.dispose (/Users/kasper/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:81955)
    at Object.dispose (/Users/kasper/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:138651)
    at /Users/kasper/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:135583
kasperl commented 2 years ago

Also happens with Object from the core libs, but not with elements imported from other local libs. Probably related to imports into the SDK bundled libraries?

jstroem commented 2 years ago

Looking a bit more into this. It seems that the lsp-client tries to open a wrong workspace when getting the definition back from the current toitlsp:

2022-01-05T11:26:32.451+0100    DEBUG   lsp/server.go:159   jsonrpc2: --> request #6: textDocument/definition: {"textDocument":{"uri":"file:///Users/jesperlindstromnielsen/projects/jaguar/example/main.toit"},"position":{"line":7,"character":5}}

2022-01-05T11:26:32.452+0100    DEBUG   Compiler    compiler/compiler.go:371    running compiler    {"input": "62740\nGOTO DEFINITION\n/Users/jesperlindstromnielsen/projects/jaguar/example/main.toit\n7\n5\n", "cmd": "/Users/jesperlindstromnielsen/projects/opentoit/build/host/sdk/bin/toit.compile --lsp --project-root /Users/jesperlindstromnielsen/projects/jaguar"}
2022-01-05T11:26:32.521+0100    DEBUG   lsp/server.go:159   jsonrpc2: <-- result #6: textDocument/definition: [{"uri":"file:///Users/jesperlindstromnielsen/projects/opentoit/build/host/sdk/lib/core/print.toit","range":{"start":{"line":10,"character":0},"end":{"line":10,"character":5}}}]

[Trace - 11:26:32] Received response 'textDocument/definition - (6)' in 71ms.
Result: [
    {
        "uri": "file:///Users/jesperlindstromnielsen/projects/opentoit/build/host/sdk/lib/core/print.toit",
        "range": {
            "start": {
                "line": 10,
                "character": 0
            },
            "end": {
                "line": 10,
                "character": 5
            }
        }
    }
]

[Trace - 11:26:32] Sending request 'initialize - (0)'.
Params: {
    "processId": 55110,
    "rootPath": "/Users/jesperlindstromnielsen/projects/jaguar",
    "rootUri": "file:///Users/jesperlindstromnielsen/projects/jaguar",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional"
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                }
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true
            },
            "documentLink": {
                "dynamicRegistration": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            }
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///Users/jesperlindstromnielsen/projects/jaguar",
            "name": "jaguar"
        }
    ]
}

[Trace - 11:26:32] Sending request 'shutdown - (1)'.
2022-01-05T11:26:32.556+0100    DEBUG   lsp/server.go:159   jsonrpc2: --> request #0: initialize: {"processId":55110,"rootPath":"/Users/jesperlindstromnielsen/projects/jaguar","rootUri":"file:///Users/jesperlindstromnielsen/projects/jaguar","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true}}},"trace":"verbose","workspaceFolders":[{"uri":"file:///Users/jesperlindstromnielsen/projects/jaguar","name":"jaguar"}]}

2022-01-05T11:26:32.556+0100    DEBUG   lsp/server.go:159   jsonrpc2: --> request #1: shutdown: null

2022-01-05T11:26:32.556+0100    DEBUG   lsp/server.go:159   jsonrpc2: <-- result #1: shutdown: null

[Trace - 11:26:32] Received response 'shutdown - (1)' in 11ms.
No result returned.

[Trace - 11:26:32] Sending notification 'exit'.
No parameters provided.
Error - 11:26:32] Server initialization failed.
Error: Connection got disposed.
    at Object.dispose (/Users/jesperlindstromnielsen/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:81955)
    at Object.dispose (/Users/jesperlindstromnielsen/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:138651)
    at /Users/jesperlindstromnielsen/.vscode/extensions/toit.toit-1.4.0/dist/extension.js:1:135583

Note: the error does not happen if you try to the definition of something that is in the current workspace you are working in.