hsdev icon indicating copy to clipboard operation
hsdev copied to clipboard

Duplicates in "complete"

Open bscottm opened this issue 7 years ago • 4 comments

Test script (hsdev started in another terminal via stack exec -- hsdev run -l /tmp/hsdev/log):

stack exec -- hsdev scan -p <path>
stack exec -- hsdev complete '' -f Main.hs

Output:

[
  {
    "pos": {
      "line": 20,
      "column": 6
    },
    "id": {
      "name": "Barq",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "qualifier": "Main",
    "info": {
      "args": [],
      "what": "data",
      "ctx": []
    }
  },
  {
    "pos": {
      "line": 20,
      "column": 6
    },
    "id": {
      "name": "Barq",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "info": {
      "args": [],
      "what": "data",
      "ctx": []
    }
  },
  {
    "pos": {
      "line": 18,
      "column": 17
    },
    "id": {
      "name": "Frobz",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "qualifier": "Main",
    "info": {
      "args": [
        "Int"
      ],
      "what": "ctor",
      "type": "Frobz"
    }
  },
  {
    "pos": {
      "line": 18,
      "column": 9
    },
    "id": {
      "name": "Frobz",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "qualifier": "Main",
    "info": {
      "args": [],
      "what": "newtype",
      "ctx": []
    }
  },
  {
    "pos": {
      "line": 18,
      "column": 17
    },
    "id": {
      "name": "Frobz",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "info": {
      "args": [
        "Int"
      ],
      "what": "ctor",
      "type": "Frobz"
    }
  },
  {
    "pos": {
      "line": 18,
      "column": 9
    },
    "id": {
      "name": "Frobz",
      "module": {
        "location": {
          "project": "/Users/bsm21317/play/haskell/st3proj/st3proj.cabal",
          "file": "/Users/bsm21317/play/haskell/st3proj/src/Main.hs"
        },
        "name": "Main"
      }
    },
    "info": {
      "args": [],
      "what": "newtype",
      "ctx": []
    }
  }
// (etc)

]

bscottm avatar May 16 '18 17:05 bscottm

It's not actually duplicates, as long as complete returns qualified names, i.e. it should return both M.lookup and lookup in case of import Data.Map as M

In this case it returns

  • Main.Barq, data
  • Barq, same as above, but unqualified
  • Main.Frobz, newtype
  • Main.Frobz, constructor, not newtype
  • two unqualified Frobz for both Main.Frobz

Maybe it's better to return symbol with all possible names, i.e. one entry for Barq with fiels scope_names: ["Barq", "Main.Barq"] or smth like this.

mvoidex avatar May 16 '18 17:05 mvoidex

No exactly immediately obvious to the casual observer. Honestly, SublimeHaskell complete doesn't use much of the data returned (I'll have to check what SH does with the qualifiers, because those could actually be important.)

The scope_names idea has merit as a compact representation of possible completions (although I suspect that GHC will complain if you try using Main.Barq instead of the unqualified Barq.)

Suggestion: See what the Atom plugin needs, return the minimum data that both editors need. You can always return additional information in a later version of hsdev.

bscottm avatar May 19 '18 00:05 bscottm

although I suspect that GHC will complain if you try using Main.Barq instead of the unqualified Barq

No, it works :)

mvoidex avatar May 21 '18 17:05 mvoidex

I can just see the frequently posted bug over on SH now: "I get fully qualified names instead of ..." :-)

bscottm avatar May 22 '18 16:05 bscottm