nwolverson / purescript-language-server

MIT License
184 stars 41 forks source link

Reference Provider not working #88

Closed andys8 closed 4 years ago

andys8 commented 4 years ago

With purescript-language-server and Vim/CoC "Find references/usages" is not working in most cases.

Example

https://github.com/jonasbuntinx/purescript-react-realworld/blob/d59eaf5c3431ea465db792f291eede42dc6190c7/src/Conduit/Page/Article.purs#L52

Vscode

Vscode is working

image

Vim

Vim is not working

image

[Trace - 10:10:40 PM] Sending request 'textDocument/references - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Page/Article.purs"
    },
    "position": {
        "line": 51,
        "character": 0
    },
    "context": {
        "includeDeclaration": false
    }
}

[Trace - 10:10:40 PM] Received response 'textDocument/references - (2)' in 5ms.
Result: []

Comparison with purs ide

I tried if I could use purs ide client to show references or not.

With load and usages, the result is empty.

{ "command": "load" }

{ "command": "usages", "params": { "module": "Conduit.Page.Article", "namespace": "value", "identifier": "mkArticlePage" } }
{"result":[],"resultType":"success"}

But when building a file that's using it, before it'll work:

{ "command": "rebuild", "params": { "file": "src/Conduit/Root.purs", "actualFile": "src/Conduit/Root.purs" } }
{"result":[],"resultType":"success"}
{ "command": "usages", "params": { "module": "Conduit.Page.Article", "namespace": "value", "identifier": "mkArticlePage" } }
{"result":[{"start":[30,18],"name":"src/Conduit/Root.purs","end":[30,31]}],"resultType":"success"}

Debugging

I haven't looked into the code.

Versions

vim version: VIM - Vi IMproved 8.2 8021490 node version: v12.15.0 coc.nvim version: 0.0.78-9f9d8a32c4

purescript-language-server: master 0fd2cdb17cea2c76efd13b2ea76482465bde2cce

andys8 commented 4 years ago

I found a way to reliably get usages to work in a specific case. Hopefully that will help with debugging the actual cause.

  1. Open module Conduit.Root (using module)
  2. Jump to defintion on mkArticlePage
  3. It'll fail
[Trace - 10:34:53 PM] Sending request 'textDocument/definition - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Root.purs"
    },
    "position": {
        "line": 29,
        "character": 20
    }
}

[Trace - 10:34:53 PM] Received response 'textDocument/definition - (1)' in 29ms.
No result returned.
  1. Click again "Jump to defintion"
  2. This time it'll work and open Conduit.Page.Article
[Trace - 10:36:12 PM] Sending request 'textDocument/definition - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Root.purs"
    },
    "position": {
        "line": 29,
        "character": 17
    }
}

[Trace - 10:36:12 PM] Received response 'textDocument/definition - (2)' in 9ms.
Result: {
    "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Page/Article.purs",
    "range": {
        "start": {
            "line": 51,
            "character": 0
        },
        "end": {
            "line": 51,
            "character": 0
        }
    }
}
  1. Now "Jump to / show usage" on the definition of mkArticlePage
  2. It'll jump back to where it's used
[Trace - 10:38:26 PM] Sending request 'textDocument/references - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Page/Article.purs"
    },
    "position": {
        "line": 51,
        "character": 0
    },
    "context": {
        "includeDeclaration": false
    }
}

[Trace - 10:38:26 PM] Received response 'textDocument/references - (3)' in 22ms.
Result: [
    {
        "uri": "file:///home/andreas/dev/repository/purescript-react-realworld/src/Conduit/Root.purs",
        "range": {
            "start": {
                "line": 29,
                "character": 17
            },
            "end": {
                "line": 29,
                "character": 30
            }
        }
    }
]
nwolverson commented 4 years ago

Can you confirm the purs ide server globs are the same in both cases, if that isn't so then there's not much hope