@@ -26,8 +26,8 @@ module Ide.Types
26
26
, IdeCommand (.. )
27
27
, IdeMethod (.. )
28
28
, IdeNotification (.. )
29
+ , GhcOptsModifications (.. )
29
30
, IdePlugins (IdePlugins , ipMap)
30
- , DynFlagsModifications (.. )
31
31
, ConfigDescriptor (.. ), defaultConfigDescriptor, configForPlugin, pluginEnabledConfig
32
32
, CustomConfig (.. ), mkCustomConfig
33
33
, FallbackCodeActionParams (.. )
@@ -109,6 +109,11 @@ import System.FilePath
109
109
import System.IO.Unsafe
110
110
import Text.Regex.TDFA.Text ()
111
111
112
+ #if MIN_VERSION_ghc(9,2,0)
113
+ import GHC.Plugins (StaticPlugin )
114
+ #endif
115
+
116
+
112
117
-- ---------------------------------------------------------------------
113
118
114
119
data IdePlugins ideState = IdePlugins_
@@ -137,28 +142,40 @@ lookupPluginId ls cmd = pluginId <$> find go ls
137
142
where
138
143
go desc = cmd `elem` map commandId (pluginCommands desc)
139
144
140
- -- | Hooks for modifying the 'DynFlags' at different times of the compilation
141
- -- process. Plugins can install a 'DynFlagsModifications' via
142
- -- 'pluginModifyDynflags' in their 'PluginDescriptor'.
143
- data DynFlagsModifications =
144
- DynFlagsModifications
145
- { -- | Invoked immediately at the package level. Changes to the 'DynFlags'
146
- -- made in 'dynFlagsModifyGlobal' are guaranteed to be seen everywhere in
147
- -- the compilation pipeline.
148
- dynFlagsModifyGlobal :: DynFlags -> DynFlags
149
- -- | Invoked just before the parsing step, and reset immediately
150
- -- afterwards. 'dynFlagsModifyParser' allows plugins to enable language
151
- -- extensions only during parsing. for example, to let them enable
152
- -- certain pieces of syntax.
145
+ {- | Hooks for modifying the 'DynFlags' at different times of the compilation
146
+ process. Plugins can install a 'GhcOptsModifications' via
147
+ 'pluginModifyDynflags' in their 'PluginDescriptor'.
148
+ -}
149
+ data GhcOptsModifications = GhcOptsModifications
150
+ { dynFlagsModifyGlobal :: DynFlags -> DynFlags
151
+ -- ^ Invoked immediately at the package level. Changes to the 'DynFlags'
152
+ -- made in 'dynFlagsModifyGlobal' are guaranteed to be seen everywhere in
153
+ -- the compilation pipeline.
153
154
, dynFlagsModifyParser :: DynFlags -> DynFlags
155
+ -- ^ Invoked just before the parsing step, and reset immediately
156
+ -- afterwards. 'dynFlagsModifyParser' allows plugins to enable language
157
+ -- extensions only during parsing. for example, to let them enable
158
+ -- certain pieces of syntax.
159
+ # if MIN_VERSION_ghc (9 ,2 ,0 )
160
+ , staticPlugins :: [StaticPlugin ]
161
+ # endif
154
162
}
155
163
156
- instance Semigroup DynFlagsModifications where
157
- DynFlagsModifications g1 p1 <> DynFlagsModifications g2 p2 =
158
- DynFlagsModifications (g2 . g1) (p2 . p1)
164
+ #if MIN_VERSION_ghc(9,2,0)
165
+ instance Semigroup GhcOptsModifications where
166
+ GhcOptsModifications g1 p1 plugins1 <> GhcOptsModifications g2 p2 plugins2 =
167
+ GhcOptsModifications (g2 . g1) (p2 . p1) (plugins1 <> plugins2)
159
168
160
- instance Monoid DynFlagsModifications where
161
- mempty = DynFlagsModifications id id
169
+ instance Monoid GhcOptsModifications where
170
+ mempty = GhcOptsModifications id id []
171
+ #else
172
+ instance Semigroup GhcOptsModifications where
173
+ GhcOptsModifications g1 p1 <> GhcOptsModifications g2 p2 =
174
+ GhcOptsModifications (g2 . g1) (p2 . p1)
175
+
176
+ instance Monoid GhcOptsModifications where
177
+ mempty = GhcOptsModifications id id
178
+ #endif
162
179
163
180
-- ---------------------------------------------------------------------
164
181
@@ -177,7 +194,7 @@ data PluginDescriptor (ideState :: *) =
177
194
, pluginHandlers :: PluginHandlers ideState
178
195
, pluginConfigDescriptor :: ConfigDescriptor
179
196
, pluginNotificationHandlers :: PluginNotificationHandlers ideState
180
- , pluginModifyDynflags :: DynFlagsModifications
197
+ , pluginModifyDynflags :: GhcOptsModifications
181
198
, pluginCli :: Maybe (ParserInfo (IdeCommand ideState ))
182
199
, pluginFileType :: [T. Text ]
183
200
-- ^ File extension of the files the plugin is responsible for.
0 commit comments