@@ -147,7 +147,7 @@ executeCommandHandlers ecs = requestHandler SWorkspaceExecuteCommand execCmd
147
147
extensiblePlugins :: [(PluginId , PluginDescriptor IdeState )] -> Plugin Config
148
148
extensiblePlugins xs = mempty { P. pluginHandlers = handlers }
149
149
where
150
- getPluginDescriptor pid = fromJust $ lookup pid xs
150
+ getPluginDescriptor pid = lookup pid xs
151
151
IdeHandlers handlers' = foldMap bakePluginId xs
152
152
bakePluginId :: (PluginId , PluginDescriptor IdeState ) -> IdeHandlers
153
153
bakePluginId (pid,pluginDesc) = IdeHandlers $ DMap. map
@@ -159,20 +159,35 @@ extensiblePlugins xs = mempty { P.pluginHandlers = handlers }
159
159
(IdeMethod m :=> IdeHandler fs') <- DMap. assocs handlers'
160
160
pure $ requestHandler m $ \ ide params -> do
161
161
config <- Ide.PluginUtils. getClientConfig
162
- let fs = filter (\ (pid,_) -> pluginEnabled m params (getPluginDescriptor pid) config) fs'
163
- case nonEmpty fs of
164
- Nothing -> pure $ Left $ ResponseError InvalidRequest
165
- (" No plugin enabled for " <> T. pack (show m) <> " , available: " <> T. pack (show $ map fst fs))
162
+ let pluginInfo = map (\ (pid,_) -> (pid, getPluginDescriptor pid)) fs'
163
+ cleanPluginInfo <- go pluginInfo []
164
+ case cleanPluginInfo of
165
+ Left err -> pure $ Left err
166
+ Right pluginInfos -> do
167
+ let fs = map snd $ filter (\ ((_, desc), _) -> pluginEnabled m params desc config) (zip pluginInfos fs')
168
+ case nonEmpty fs of
169
+ Nothing -> pure $ Left $ ResponseError InvalidRequest
170
+ (" No plugin enabled for " <> T. pack (show m) <> " , available: " <> T. pack (show $ map fst fs))
171
+ Nothing
172
+ Just fs -> do
173
+ let msg e pid = " Exception in plugin " <> T. pack (show pid) <> " while processing " <> T. pack (show m) <> " : " <> T. pack (show e)
174
+ es <- runConcurrently msg (show m) fs ide params
175
+ let (errs,succs) = partitionEithers $ toList es
176
+ case nonEmpty succs of
177
+ Nothing -> pure $ Left $ combineErrors errs
178
+ Just xs -> do
179
+ caps <- LSP. getClientCapabilities
180
+ pure $ Right $ combineResponses m config caps params xs
181
+
182
+ go :: [(PluginId , Maybe (PluginDescriptor c ))] -> [(PluginId , PluginDescriptor c )] -> LSP. LspM Config (Either ResponseError [(PluginId , PluginDescriptor c )])
183
+ go ((pid, Nothing ): _) _ = pure $ Left $ ResponseError InvalidRequest
184
+ (" No plugindescriptor found for " <> pidT <> " , available: " )
166
185
Nothing
167
- Just fs -> do
168
- let msg e pid = " Exception in plugin " <> T. pack (show pid) <> " while processing " <> T. pack (show m) <> " : " <> T. pack (show e)
169
- es <- runConcurrently msg (show m) fs ide params
170
- let (errs,succs) = partitionEithers $ toList es
171
- case nonEmpty succs of
172
- Nothing -> pure $ Left $ combineErrors errs
173
- Just xs -> do
174
- caps <- LSP. getClientCapabilities
175
- pure $ Right $ combineResponses m config caps params xs
186
+ where
187
+ PluginId pidT = pid
188
+ go ((pid, Just desc): xs) ys = go xs (ys ++ [(pid, desc)])
189
+ go [] ys = pure $ Right ys
190
+
176
191
-- ---------------------------------------------------------------------
177
192
178
193
extensibleNotificationPlugins :: [(PluginId , PluginNotificationHandlers IdeState )] -> Plugin Config
0 commit comments