summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2014-07-04 17:01:08 +0100
committerEdward Z. Yang <ezyang@cs.stanford.edu>2014-07-25 17:59:55 -0700
commit7f5c10864e7c26b90c7ff4ed09d00c8a09aa4349 (patch)
tree45cc2f6c46f9cf583c8aeb7b324933d65586c1d5 /ghc
parentdae46da7de4d8c7104aea1be48586336bbd486ca (diff)
downloadhaskell-7f5c10864e7c26b90c7ff4ed09d00c8a09aa4349.tar.gz
Module reexports, fixing #8407.
The general approach is to add a new field to the package database, reexported-modules, which considered by the module finder as possible module declarations. Unlike declaring stub module files, multiple reexports of the same physical package at the same name do not result in an ambiguous import. Has submodule updates for Cabal and haddock. NB: When a reexport renames a module, that renaming is *not* accessible from inside the package. This is not so much a deliberate design choice as for implementation expediency (reexport resolution happens only when a package is in the package database.) TODO: Error handling when there are duplicate reexports/etc is not very well tested. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Conflicts: compiler/main/HscTypes.lhs testsuite/.gitignore utils/haddock
Diffstat (limited to 'ghc')
-rw-r--r--ghc/InteractiveUI.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 9ac3be4773..ab4ea8721b 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -39,7 +39,8 @@ import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC,
setInteractivePrintName )
import Module
import Name
-import Packages ( trusted, getPackageDetails, exposed, exposedModules, pkgIdMap )
+import Packages ( ModuleExport(..), trusted, getPackageDetails, exposed,
+ exposedModules, reexportedModules, pkgIdMap )
import PprTyThing
import RdrName ( getGRE_NameQualifier_maybes )
import SrcLoc
@@ -2544,11 +2545,14 @@ wrapIdentCompleterWithModifier modifChars fun = completeWordWithPrev Nothing wor
where
getModifier = find (`elem` modifChars)
+-- | Return a list of visible module names for autocompletion.
allExposedModules :: DynFlags -> [ModuleName]
allExposedModules dflags
- = concat (map exposedModules (filter exposed (eltsUFM pkg_db)))
+ = concatMap extract (filter exposed (eltsUFM pkg_db))
where
pkg_db = pkgIdMap (pkgState dflags)
+ extract pkg = exposedModules pkg ++ map exportName (reexportedModules pkg)
+ -- Extract the *new* name, because that's what is user visible
completeExpression = completeQuotedWord (Just '\\') "\"" listFiles
completeIdentifier