3
3
{-# LANGUAGE GADTs #-}
4
4
{-# LANGUAGE OverloadedStrings #-}
5
5
{-# LANGUAGE RankNTypes #-}
6
+ {-# LANGUAGE TypeFamilies #-}
6
7
7
8
module Development.IDE.GHC.ExactPrint
8
9
( Graft (.. ),
@@ -16,8 +17,11 @@ module Development.IDE.GHC.ExactPrint
16
17
transformM ,
17
18
useAnnotatedSource ,
18
19
annotateParsedSource ,
20
+ getAnnotatedParsedSourceRule ,
21
+ GetAnnotatedParsedSource (.. ),
19
22
ASTElement (.. ),
20
23
ExceptStringT (.. ),
24
+ Annotated (.. ),
21
25
)
22
26
where
23
27
@@ -39,6 +43,9 @@ import Development.IDE.Core.Rules
39
43
import Development.IDE.Core.Shake
40
44
import Development.IDE.GHC.Compat hiding (parseExpr )
41
45
import Development.IDE.Types.Location
46
+ import Development.Shake (RuleResult , Rules )
47
+ import Development.Shake.Classes
48
+ import qualified GHC.Generics as GHC
42
49
import Generics.SYB
43
50
import Ide.PluginUtils
44
51
import Language.Haskell.GHC.ExactPrint
@@ -54,19 +61,30 @@ import Control.Arrow
54
61
55
62
------------------------------------------------------------------------------
56
63
64
+ data GetAnnotatedParsedSource = GetAnnotatedParsedSource
65
+ deriving (Eq , Show , Typeable , GHC.Generic )
66
+
67
+ instance Hashable GetAnnotatedParsedSource
68
+ instance NFData GetAnnotatedParsedSource
69
+ instance Binary GetAnnotatedParsedSource
70
+ type instance RuleResult GetAnnotatedParsedSource = Annotated ParsedSource
71
+
57
72
-- | Get the latest version of the annotated parse source.
58
- useAnnotatedSource ::
59
- String ->
60
- IdeState ->
61
- NormalizedFilePath ->
62
- IO (Maybe (Annotated ParsedSource ))
63
- useAnnotatedSource herald state nfp =
64
- fmap annotateParsedSource
65
- <$> runAction herald state (use GetParsedModule nfp)
73
+ getAnnotatedParsedSourceRule :: Rules ()
74
+ getAnnotatedParsedSourceRule = define $ \ GetAnnotatedParsedSource nfp -> do
75
+ pm <- use GetParsedModule nfp
76
+ return ([] , fmap annotateParsedSource pm)
66
77
67
78
annotateParsedSource :: ParsedModule -> Annotated ParsedSource
68
79
annotateParsedSource = fixAnns
69
80
81
+ useAnnotatedSource ::
82
+ String ->
83
+ IdeState ->
84
+ NormalizedFilePath ->
85
+ IO (Maybe (Annotated ParsedSource ))
86
+ useAnnotatedSource herald state nfp =
87
+ runAction herald state (use GetAnnotatedParsedSource nfp)
70
88
------------------------------------------------------------------------------
71
89
72
90
{- | A transformation for grafting source trees together. Use the semigroup
0 commit comments