Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Add 'imported-from' command. #823

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7b8f1fd
Add 'imported-from' command.
carlohamalainen Jul 12, 2016
5d6be7f
[imported-from] Try fixing 7.10 dependencies
lierdakil Aug 9, 2016
3f27490
Comment out unused test cases.
carlohamalainen Aug 9, 2016
b61d3e8
Avoid fromMaybe.
carlohamalainen Aug 9, 2016
2bc7947
Fix a regression on 7.8.4 for the imported-from command.
carlohamalainen Aug 9, 2016
0e30488
Use lastNote instead of last, etc.
carlohamalainen Aug 11, 2016
9d281e4
Remove my clunky "find-module" code and some tidyup.
carlohamalainen Aug 13, 2016
e73eea5
Fix two compile errors.
carlohamalainen Aug 13, 2016
d26da6e
Tidyup type signatures.
carlohamalainen Aug 14, 2016
8c4ee88
Remove unused local definitions.
carlohamalainen Aug 15, 2016
60dfa8a
Nicer parser for postfix matching.
carlohamalainen Aug 15, 2016
90667e6
Show local URL if available; otherwise hackage.haskell.org.
carlohamalainen Aug 15, 2016
8d0de10
imported-from: first cleanup pass
DanielG Aug 27, 2016
cbb0182
Cleanup the scattered copyright blurbs
DanielG Aug 27, 2016
4ea88f4
imported-from: another cleanup pass
DanielG Aug 27, 2016
3f282a8
Rough sketch for imported-from idea
lierdakil Oct 22, 2016
5e80208
Minor fix to rough sketch for imported-from idea
lierdakil Oct 22, 2016
7f5e16b
Refine imported-from
lierdakil Oct 23, 2016
0a56669
Imported-from spec update
lierdakil Oct 23, 2016
9752899
[imported-from] Show originating package name
lierdakil Oct 23, 2016
ccf5847
[imported-from] ghc8 compat
lierdakil Oct 23, 2016
886e466
[imported-from] ghc-7.8 compat
lierdakil Oct 23, 2016
2e93d4f
[imported-from] compat cleanup
lierdakil Oct 23, 2016
09e747e
[imported-from] comment on `gfindtype` in Gap (ghc 7.8 compat)
lierdakil Oct 23, 2016
18e59e8
[imported-from] Clean `findSpanName`
lierdakil Oct 24, 2016
d04522d
[imported-from] Allow outputting several names
lierdakil Oct 24, 2016
1032e60
[imported-from] Remove redundant import
lierdakil Oct 24, 2016
477c3e5
[imported-from] Fix some things with `showOutput`
lierdakil Oct 24, 2016
eb8e402
[imported-from] Fix broken test
lierdakil Oct 24, 2016
4713389
Merge remote-tracking branch 'origin/master' into imported-from
lierdakil Oct 25, 2016
87390ee
[imported-from] Removed unused definitions
lierdakil Oct 25, 2016
0ca8134
Merge branch 'master' into imported-from
lierdakil Oct 25, 2016
f5e911b
[imported-from] Print a warning when can't find haddock interface
lierdakil Oct 25, 2016
f7f4fd8
[imported-from] Add some minimal error reporting
lierdakil Oct 25, 2016
87808c9
imported-from: code style cleanup
DanielG Oct 26, 2016
570aef3
Merging master.
carlohamalainen Aug 14, 2017
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
22 changes: 21 additions & 1 deletion Language/Haskell/GhcMod/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ gmeDoc e = case e of
\ Try enabling them:" $$
nest 4 (backticks $ text "cabal configure --enable-tests [--enable-benchmarks]")

backticks d = char '`' <> d <> char '`'
ctxDoc = moduleDoc *** compsDoc
>>> first (<> colon) >>> uncurry (flip hang 4)

Expand All @@ -104,6 +103,27 @@ gmeDoc e = case e of
GMETooManyCabalFiles cfs ->
text $ "Multiple cabal files found. Possible cabal files: \""
++ intercalate "\", \"" cfs ++"\"."
GMEMissingHaddockInterface f ->
text ("Haddock interface file missing: " ++ f) $$
text "" $$
haddockSuggestion
GMENoVisibleExports moduleName package ->
text $ "Failed to find visible exports of \"" ++ moduleName ++ "\" in \"" ++ package ++ "\""

where

backticks d = char '`' <> d <> char '`'

haddockSuggestion =
text "- To generate Haddock docs for dependencies, try:" $$
nest 4 (backticks $ text "cabal install --enable-documentation --haddock-hyperlink-source --only-dependencies") $$
text "" $$
text "- or set" $$
nest 4 (backticks $ text "documentation: True") $$
text "in ~/.cabal/config" $$
text "" $$
text "- or with Stack:" $$
nest 4 (backticks $ text "stack haddock")

ghcExceptionDoc :: GhcException -> Doc
ghcExceptionDoc e@(CmdLineError _) =
Expand Down
50 changes: 50 additions & 0 deletions Language/Haskell/GhcMod/Gap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ module Language.Haskell.GhcMod.Gap (
, mkErrStyle'
, everythingStagedWithContext
, withCleanupSession
, ghcQualify
, ghcIdeclHiding
, ghc_sl_fs
, ghc_ms_textual_imps
) where

import Control.Applicative hiding (empty)
Expand Down Expand Up @@ -118,6 +122,10 @@ import Control.DeepSeq (NFData(rnf))
import Data.ByteString.Lazy.Internal (ByteString(..))
#endif

#if __GLASGOW_HASKELL__ >= 800
import BasicTypes (sl_fs, StringLiteral)
#endif

import Bag
import Lexer as L
import Parser
Expand Down Expand Up @@ -687,3 +695,45 @@ withCleanupSession action = do
df <- getSessionDynFlags
GHC.defaultCleanupHandler df action
#endif

-- | Things for Language.Haskell.GhcMod.ImportedFrom

#if __GLASGOW_HASKELL__ >= 710
ghcQualify :: PrintUnqualified
ghcQualify = reallyAlwaysQualify
#else
ghcQualify :: PrintUnqualified
ghcQualify = alwaysQualify
#endif

#if __GLASGOW_HASKELL__ >= 710
ghcIdeclHiding :: GHC.ImportDecl GHC.RdrName -> Maybe (Bool, SrcLoc.Located [GHC.LIE GHC.RdrName])
ghcIdeclHiding = GHC.ideclHiding
#else
-- Here, we have
--
-- ideclHiding :: Maybe (Bool, [LIE name])
--
-- so we have to use noLoc to get a SrcLoc.Located type in the second part of the tuple.
ghcIdeclHiding :: GHC.ImportDecl GHC.RdrName -> Maybe (Bool, SrcLoc.Located [GHC.LIE GHC.RdrName])
ghcIdeclHiding x = case GHC.ideclHiding x of
Just (b, lie) -> Just (b, GHC.noLoc lie)
Nothing -> Nothing

#endif

#if __GLASGOW_HASKELL__ >= 800
ghc_sl_fs :: StringLiteral -> FastString
ghc_sl_fs = sl_fs
#else
ghc_sl_fs = id
#endif


ghc_ms_textual_imps :: GHC.ModSummary -> [Located (ImportDecl RdrName)]
#if __GLASGOW_HASKELL__ >= 800
-- What does GHC8 give in the first part of the tuple?
ghc_ms_textual_imps ms = map (fmap simpleImportDecl . snd) (ms_textual_imps ms)
#else
ghc_ms_textual_imps = ms_textual_imps
#endif
Loading