hsdev
hsdev copied to clipboard
Duplicates in "complete"
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)
]
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, dataBarq, same as above, but unqualifiedMain.Frobz, newtypeMain.Frobz, constructor, not newtype- two unqualified
Frobzfor bothMain.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.
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.
although I suspect that GHC will complain if you try using Main.Barq instead of the unqualified Barq
No, it works :)
I can just see the frequently posted bug over on SH now: "I get fully qualified names instead of ..." :-)