Skip to content

Add references for pragmas #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import qualified Bag as GHC
import qualified BasicTypes as GHC
import qualified DataCon as GHC
import qualified Name as GHC
import BooleanFormula
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See outer comment about GHC 7.10 failing.

import FastString (unpackFS)
import GHC
import qualified Id as GHC
Expand Down Expand Up @@ -506,7 +507,29 @@ refsFromRenamed ctx declAlts (hsGroup, _, _, _) =
TypeSig names _ _ ->
#endif
mapMaybe (\(L l n) -> give ctx (nameLocToRef n TypeDecl l)) names
(PatSynSig lnames _) ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See universeBi comment below, maybe you can get away with a catch-all clause + biPlate, like

other -> (...map magic with nameLocToRef...) universeBi other

lkupSigNames [lnames]
(FixSig (FixitySig lnames _)) ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are cases which were not yet crosslinked, could you also update the tests? At least the GHC backend tests at https://github.com/google/haskell-indexer/blob/master/haskell-indexer-backend-ghc/tests/Language/Haskell/Indexer/Backend/Ghc/Test/TypeLinkTestBase.hs, and optionally the GHC+Kythe end-to-end tests - see https://github.com/google/haskell-indexer/tree/master/kythe-verification/testdata/basic, though for GHC+Kythe the type-link tests are not yet ported.

lkupSigNames lnames
(InlineSig lname _) -> lkupSigNames [lname]
(SpecSig lname ltypes _) -> lkupSigNames [lname]
(SpecInstSig st lst) -> []
(MinimalSig st lbf) -> lkupSigNames (namesFromLBooleanFormula lbf)
_ -> []
where
lkupSigNames names =
mapMaybe (\(L l n) -> give ctx (nameLocToRef n Ref l)) names

namesFromBooleanFormula :: BooleanFormula a -> [a]
namesFromBooleanFormula bf =
case bf of
Var a -> [a]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Travelsing this AST seems pretty compact, but consider using *plate. For example:

let allNames = universeBi aBooleanFormula

This might also help unifying changes across GHC versions, trading a bit of performance (which could be gotten back if we would use Data.Data.Lens and pull in lens, but benchmarking needed).

And lbfs -> concatMap namesFromLBooleanFormula lbfs
Or lbfs -> concatMap namesFromLBooleanFormula lbfs
Parens lbf -> namesFromLBooleanFormula lbf

namesFromLBooleanFormula :: LBooleanFormula a -> [a]
namesFromLBooleanFormula (L _ bf) = namesFromBooleanFormula bf

-- | Exports subclasses/overrides relationships from typeclasses.
relationsFromRenamed :: ExtractCtx -> DeclAltMap -> RenamedSource
Expand Down