[commit: ghc] master: Don't offer hidden modules for autocomplete. (b72478f)

git at git.haskell.org git at git.haskell.org
Mon Sep 15 20:15:23 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b72478f41b85337b84edab8f625d103e197f116c/ghc

>---------------------------------------------------------------

commit b72478f41b85337b84edab8f625d103e197f116c
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Mon Sep 15 13:14:30 2014 -0700

    Don't offer hidden modules for autocomplete.
    
    It was annoying to test GHCi directly, so I added a ghc-api unit test
    of the function instead.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>


>---------------------------------------------------------------

b72478f41b85337b84edab8f625d103e197f116c
 compiler/main/Packages.lhs                         |  3 ++-
 testsuite/.gitignore                               |  1 +
 testsuite/tests/ghc-api/T9595.hs                   | 23 ++++++++++++++++++++++
 .../cgrun056.stdout => ghc-api/T9595.stdout}       |  0
 testsuite/tests/ghc-api/all.T                      |  1 +
 5 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index c14c8cf..a6a61e9 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -1304,7 +1304,8 @@ lookupModuleWithSuggestions dflags m mb_pn
 
 listVisibleModuleNames :: DynFlags -> [ModuleName]
 listVisibleModuleNames dflags =
-    Map.keys (moduleToPkgConfAll (pkgState dflags))
+    map fst (filter visible (Map.toList (moduleToPkgConfAll (pkgState dflags))))
+  where visible (_, ms) = any originVisible (Map.elems ms)
 
 -- | Find all the 'PackageConfig' in both the preload packages from 'DynFlags' and corresponding to the list of
 -- 'PackageConfig's
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
index 4f8ac87..e8b83e8 100644
--- a/testsuite/.gitignore
+++ b/testsuite/.gitignore
@@ -688,6 +688,7 @@ mk/ghcconfig_*_inplace_bin_ghc-stage2.exe.mk
 /tests/ghc-api/T7478/T7478
 /tests/ghc-api/T8628
 /tests/ghc-api/T8639_api
+/tests/ghc-api/T9595
 /tests/ghc-api/apirecomp001/myghc
 /tests/ghc-api/dynCompileExpr/dynCompileExpr
 /tests/ghc-api/ghcApi
diff --git a/testsuite/tests/ghc-api/T9595.hs b/testsuite/tests/ghc-api/T9595.hs
new file mode 100644
index 0000000..b6c336a
--- /dev/null
+++ b/testsuite/tests/ghc-api/T9595.hs
@@ -0,0 +1,23 @@
+module Main where
+
+import GHC
+import Packages
+import GhcMonad
+import Outputable
+import System.Environment
+import DynFlags
+import Module
+
+main =
+  do [libdir] <- getArgs
+     _ <- runGhc (Just libdir) $ do
+                dflags <- getSessionDynFlags
+                setSessionDynFlags dflags
+                dflags <- getSessionDynFlags
+                liftIO $ print (mkModuleName "Outputable" `elem` listVisibleModuleNames dflags)
+     _ <- runGhc (Just libdir) $ do
+                dflags <- getSessionDynFlags
+                setSessionDynFlags (dflags { packageFlags = [ExposePackage (PackageArg "ghc") Nothing]})
+                dflags <- getSessionDynFlags
+                liftIO $ print (mkModuleName "Outputable" `elem` listVisibleModuleNames dflags)
+     return ()
diff --git a/testsuite/tests/codeGen/should_run/cgrun056.stdout b/testsuite/tests/ghc-api/T9595.stdout
similarity index 100%
copy from testsuite/tests/codeGen/should_run/cgrun056.stdout
copy to testsuite/tests/ghc-api/T9595.stdout
diff --git a/testsuite/tests/ghc-api/all.T b/testsuite/tests/ghc-api/all.T
index 489b3ed..11e8c42 100644
--- a/testsuite/tests/ghc-api/all.T
+++ b/testsuite/tests/ghc-api/all.T
@@ -8,3 +8,4 @@ test('T8639_api', normal,
 test('T8628', normal,
               run_command,
               ['$MAKE -s --no-print-directory T8628'])
+test('T9595', extra_run_opts('"' + config.libdir + '"'), compile_and_run, ['-package ghc'])



More information about the ghc-commits mailing list