Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add command for testing defined names functionality.

  • Loading branch information...
commit 9a46168894832ff3d2702c75a1b1add69a0d2fbb 1 parent 4a85fea
@nominolo authored
View
4 emacs/scion.el
@@ -2237,6 +2237,10 @@ forces it to be off. NIL toggles the current state."
(interactive)
(scion-eval '(dump-sources)))
+(defun scion-dump-defined-names ()
+ (interactive)
+ (scion-eval '(dump-defined-names)))
+
(define-key scion-mode-map "\C-c\C-t" 'scion-thing-at-point)
(provide 'scion)
View
6 src/Scion/Inspect/DefinitionSite.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
-- |
-- Module : Scion.Inspect.DefinitionSite
-- Copyright : (c) Thomas Schilling 2009
@@ -23,12 +24,15 @@ import Name ( getOccString )
------------------------------------------------------------------------
+instance Show ModuleName where
+ show m = moduleNameString m
+
data DefSite
= DefSite ModuleName String Location
-- ^ The definition of the given identifier.
| InstanceSite ModuleName String String Location
-- ^ XXX: An instance of something
- deriving (Eq, Ord)
+ deriving (Eq, Ord, Show)
definedNames :: (ModuleName, FilePath) -> HsGroup Name
-> [DefSite]
View
21 src/Scion/Server/Commands.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ScopedTypeVariables, CPP #-}
+{-# LANGUAGE ScopedTypeVariables, CPP, PatternGuards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- |
-- Module : Scion.Server.Commands
@@ -19,6 +19,7 @@ import Scion.Utils
import Scion.Session
import Scion.Server.Protocol
import Scion.Inspect
+import Scion.Inspect.DefinitionSite
import Scion.Configure
import FastString
@@ -80,6 +81,7 @@ allCommands =
, cmdLoad
, cmdSetVerbosity
, cmdGetVerbosity
+ , cmdDumpDefinedNames
]
------------------------------------------------------------------------------
@@ -358,3 +360,20 @@ cmdCurrentCabalFile =
case r of
Right f -> return (Just f)
Left (_::SomeScionException) -> return Nothing)
+
+cmdDumpDefinedNames :: Command
+cmdDumpDefinedNames =
+ Command $ do
+ string "dump-defined-names"
+ return $ toString <$> ((do
+ tc_rslt <- gets bgTcCache
+ case tc_rslt of
+ Just (Typechecked r) | Just rn <- renamedSource r -> do
+ let (hsgrp, _imports, _exports, _docs, _haddockinfo) = rn
+ Just modsum <- gets focusedModule
+ let mod_name = moduleName (ms_mod modsum)
+ base_dir <- projectRootDir
+ let sites = definedNames (mod_name, base_dir) hsgrp
+ liftIO $ mapM_ print sites
+ _other -> return ()
+ return ()) `gcatch` (\(_ :: SomeException) -> return ()))
Please sign in to comment.
Something went wrong with that request. Please try again.