Skip to content

textDocument/references returns references only in the current file for Stack projects #4677

@alienvspredator

Description

@alienvspredator

textDocument/references method returns results for type references found only in the current file for a Stack project.

Given the following project structure:

app/
  | Main.hs
src/
  | Game/
    | State.hs
package.yaml
Setup.hs
stack.yaml
example.cabal

And the State.hs content:

-- State.hs
module Game.State (GameState (..)) where

import Game.Core.Position (Position)

data GameState where
  GameState :: {position :: Position, message :: String} -> GameState

GameState is used in the Main.hs as well.

Sending the textDocument/definition request to the LSP with the following params

{
    "textDocument": {
        "uri": "file:///example/src/Game/State.hs"
    },
    "position": {
        "line": 5,
        "character": 7
    },
    "context": {
        "includeDeclaration": true
    }
}

Results in the following response

[
    {
        "range": {
            "end": {
                "character": 11,
                "line": 5
            },
            "start": {
                "character": 2,
                "line": 5
            }
        },
        "uri": "file:///example/src/Game/State.hs"
    },
    {
        "range": {
            "end": {
                "character": 24,
                "line": 5
            },
            "start": {
                "character": 16,
                "line": 5
            }
        },
        "uri": "file:///example/src/Game/State.hs"
    },
    {
        "range": {
            "end": {
                "character": 45,
                "line": 5
            },
            "start": {
                "character": 38,
                "line": 5
            }
        },
        "uri": "file:///example/src/Game/State.hs"
    }
]

Results for example/src/app/Main.hs are missing.

Your environment

Which OS do you use?
macOS

Which version of GHC do you use and how did you install it?
9.10.2 from ghcup

How is your project built?
Stack 3.7.1

Which version of HLS do you use and how did you install it?
2.11.0

Have you configured HLS in any way (especially: a hie.yaml file)?
No

Steps to reproduce

Send textDocument/references request for a data definition using GADTs.

Expected behaviour

Results are found in the whole project.

Actual behaviour

Results are found only in the file where the data is defined.

Debug information

Request/Response from LSP above

Metadata

Metadata

Assignees

No one assigned

    Labels

    build tool: stacktype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions