summaryrefslogtreecommitdiff
path: root/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs')
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs52
1 files changed, 52 insertions, 0 deletions
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
new file mode 100644
index 0000000000..b9bdaeb37a
--- /dev/null
+++ b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
@@ -0,0 +1,52 @@
+module Simple.SourcePlugin where
+
+import Control.Monad.IO.Class
+import Data.List (intercalate)
+import Data.Maybe (isJust)
+import Plugins
+import HscTypes
+import TcRnTypes
+import HsExtension
+import Avail
+import HsExpr
+import Outputable
+import HsImpExp
+import HsDecls
+import HsDoc
+
+plugin :: Plugin
+plugin = defaultPlugin { parsedResultAction = parsedPlugin
+ , typeCheckResultAction = typecheckPlugin
+ , spliceRunAction = metaPlugin'
+ , interfaceLoadAction = interfaceLoadPlugin'
+ , renamedResultAction = renamedAction
+ }
+
+parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule
+ -> Hsc HsParsedModule
+parsedPlugin opts _ pm
+ = do liftIO $ putStrLn $ "parsePlugin(" ++ intercalate "," opts ++ ")"
+ return pm
+
+renamedAction :: [CommandLineOption]
+ -> TcGblEnv -> HsGroup GhcRn
+ -> TcM (TcGblEnv, HsGroup GhcRn)
+renamedAction _ env grp
+ = do liftIO $ putStrLn "typeCheckPlugin (rn)"
+ return (env, grp)
+
+typecheckPlugin :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
+typecheckPlugin _ _ tc
+ = do liftIO $ putStrLn "typeCheckPlugin (tc)"
+ return tc
+
+metaPlugin' :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)
+metaPlugin' _ meta
+ = do liftIO $ putStrLn $ "metaPlugin: " ++ (showSDocUnsafe $ ppr meta)
+ return meta
+
+interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface
+interfaceLoadPlugin' _ iface
+ = do liftIO $ putStrLn $ "interfacePlugin: "
+ ++ (showSDocUnsafe $ ppr $ mi_module iface)
+ return iface