MarcWeber / hasktags

Produces ctags "tags" and etags "TAGS" files for Haskell programs
Other
131 stars 33 forks source link

qualified tags should have their qualification stripped before storing them #50

Open dmwit opened 6 years ago

dmwit commented 6 years ago

Currently when hasktags encounters tags with qualified names, it puts the entire qualified name in the ctags file. For example, with the following Haskell code:

type instance A B = C
type instance MC.A B = C

I get the following ctags file:

A   test.hs 1
MC.A    test.hs 2
instance    test.hs 1
instance    test.hs 2

Leaving aside the spurious tags for instance for the moment, I think the second line should have A instead of MC.A.

In case it matters (or makes things simpler somehow), I believe that type and data families are currently the only place where bindings can be qualified.

(This is a follow-on to my comments on issue #39. I initially commented there due to a misunderstanding; this is a separate issue, and that one should stay closed.)

jhenahan commented 6 years ago

Thanks for the new report! I’ll be looking into it this weekend, I hope.

codygman commented 5 years ago

Will this affect if you have qualified imports ala elm? Like:

Import qualified Mod1 as A
import qualified Mod2 as B

And they both have:

A.get
B.get

Wouldn't retaining the qualified names be better?

dmwit commented 5 years ago

Retaining qualified names is not better, because the qualification is only local: when viewing another module, if I see the name get, I cannot know just from that whether I should be jumping to the tag for get, A.get, or B.get. If there are three definitions of get with different qualifications, the tags file should list all three.

Of course, for a name like get this won't happen, because you currently cannot put qualified value-level names in binding position, as I mentioned in the original bug report. But the point stands anyway: local qualifications should be dropped when creating the tags file, so that there is a predictable tag to request when looking at things outside that local scope.