@@ -58,20 +58,11 @@ descriptor plId = (defaultPluginDescriptor plId)
58
58
(tacticDesc $ tcCommandName tc)
59
59
(tacticCmd $ commandTactic tc))
60
60
[minBound .. maxBound ]
61
- , pluginHandlers = mkPluginHandler STextDocumentCodeAction codeActionProvider
61
+ , pluginHandlers =
62
+ mkPluginHandler STextDocumentCodeAction codeActionProvider
62
63
}
63
64
64
65
65
- tacticDesc :: T. Text -> T. Text
66
- tacticDesc name = " fill the hole using the " <> name <> " tactic"
67
-
68
-
69
- ------------------------------------------------------------------------------
70
- -- | The name of the command for the LS.
71
- tcCommandName :: TacticCommand -> T. Text
72
- tcCommandName = T. pack . show
73
-
74
-
75
66
76
67
codeActionProvider :: PluginMethodHandler IdeState TextDocumentCodeAction
77
68
codeActionProvider state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) range _ctx)
@@ -188,22 +179,23 @@ mergeFunBindMatches
188
179
-> SrcSpan
189
180
-> HsBind GhcPs
190
181
-> Either String (HsBind GhcPs )
191
- mergeFunBindMatches make_decl span (fb@ FunBind {fun_matches = mg@ MG {mg_alts = L alts_src alts}}) =
192
- pure $
193
- fb
194
- { fun_matches = mg
195
- { mg_alts = L alts_src $ do
196
- alt@ (L alt_src match) <- alts
197
- case span `isSubspanOf` alt_src of
198
- True -> do
199
- let pats = fmap fromPatCompatPs $ m_pats match
200
- (L _ (ValD _ (FunBind {fun_matches = MG {mg_alts = L _ to_add}}))) =
201
- make_decl pats
202
- to_add
203
- False -> pure alt
204
- }
182
+ mergeFunBindMatches make_decl span
183
+ (fb@ FunBind {fun_matches = mg@ MG {mg_alts = L alts_src alts}}) =
184
+ pure $ fb
185
+ { fun_matches = mg
186
+ { mg_alts = L alts_src $ do
187
+ alt@ (L alt_src match) <- alts
188
+ case span `isSubspanOf` alt_src of
189
+ True -> do
190
+ let pats = fmap fromPatCompatPs $ m_pats match
191
+ L _ (ValD _ (FunBind {fun_matches = MG
192
+ {mg_alts = L _ to_add}})) = make_decl pats
193
+ to_add
194
+ False -> pure alt
205
195
}
206
- mergeFunBindMatches _ _ _ = Left " mergeFunBindMatches: called on something that isnt a funbind"
196
+ }
197
+ mergeFunBindMatches _ _ _ =
198
+ Left " mergeFunBindMatches: called on something that isnt a funbind"
207
199
208
200
209
201
throwError :: String -> TransformT (Either String ) a
@@ -226,13 +218,16 @@ graftDecl span
226
218
-- TODO(sandy): add another case for default methods in class definitions
227
219
graftDecl span
228
220
make_decl
229
- (L src (InstD ext cid@ ClsInstD {cid_inst = cidi@ ClsInstDecl {cid_sigs = _sigs, cid_binds = binds}}))
221
+ (L src (InstD ext
222
+ cid@ ClsInstD {cid_inst =
223
+ cidi@ ClsInstDecl {cid_sigs = _sigs, cid_binds = binds}}))
230
224
= do
231
225
binds' <-
232
226
for (bagToList binds) $ \ b@ (L bsrc bind) -> do
233
227
case bind of
234
- fb@ FunBind {}
235
- | span `isSubspanOf` bsrc -> either throwError (pure . L bsrc) $ mergeFunBindMatches make_decl span fb
228
+ fb@ FunBind {} | span `isSubspanOf` bsrc ->
229
+ either throwError (pure . L bsrc) $
230
+ mergeFunBindMatches make_decl span fb
236
231
_ -> pure b
237
232
238
233
pure $ Just $ pure $ L src $ InstD ext $ cid
@@ -241,8 +236,12 @@ graftDecl span
241
236
}
242
237
}
243
238
graftDecl span _ x = do
244
- traceMX " biggest" $ unsafeRender $ locateBiggest @ (Match GhcPs (LHsExpr GhcPs )) span x
245
- traceMX " first" $ unsafeRender $ locateFirst @ (Match GhcPs (LHsExpr GhcPs )) x
239
+ traceMX " biggest" $
240
+ unsafeRender $
241
+ locateBiggest @ (Match GhcPs (LHsExpr GhcPs )) span x
242
+ traceMX " first" $
243
+ unsafeRender $
244
+ locateFirst @ (Match GhcPs (LHsExpr GhcPs )) x
246
245
throwError " graftDecl: don't know about this AST form"
247
246
248
247
0 commit comments