@@ -290,54 +290,32 @@ codeActionProvider pId docId _ _ (J.Range pos _) _ =
290290 let name = Hie. showName $ snd h
291291 debugm $ show name
292292 IdeResultOk <$> sequence [
293- mkLiftOneAction name
294- , mkLiftTopAction name
295- , mkDemoteAction name
296- , mkDeleteAction name
297- , mkDuplicateAction name
293+ mkAction " liftonelevel"
294+ J. CodeActionRefactorExtract $ " Lift " <> name <> " one level"
295+ , mkAction " lifttotoplevel"
296+ J. CodeActionRefactorExtract $ " Lift " <> name <> " to top level"
297+ , mkAction " demote"
298+ J. CodeActionRefactorInline $ " Demote " <> name <> " one level"
299+ , mkAction " deletedef"
300+ J. CodeActionRefactor $ " Delete definition of " <> name
301+ , mkHptAction " dupdef"
302+ J. CodeActionRefactor " Duplicate definition of " name
298303 ]
299304 _ -> case getArtifactsAtPos pos (locMap info) of
300305 [h] -> do
301306 let name = Hie. showName $ snd h
302- debugm $ show name
303307 IdeResultOk <$> sequence [
304- mkCaseSplitAction name
308+ mkAction " casesplit"
309+ J. CodeActionRefactorRewrite $ " Case split on " <> name
305310 ]
306311 _ -> return $ IdeResultOk []
307-
308312 where
309- mkLiftOneAction name = do
310- let args = [J. toJSON $ Hie. HP (docId ^. J. uri) pos]
311- title = " Lift " <> name <> " one level"
312- liftCmd <- mkLspCommand pId " liftonelevel" title (Just args)
313- return $ J. CodeAction title (Just J. CodeActionRefactorExtract ) mempty Nothing (Just liftCmd)
314-
315- mkLiftTopAction name = do
316- let args = [J. toJSON $ Hie. HP (docId ^. J. uri) pos]
317- title = " Lift " <> name <> " to top level"
318- liftCmd <- mkLspCommand pId " lifttotoplevel" title (Just args)
319- return $ J. CodeAction title (Just J. CodeActionRefactorExtract ) mempty Nothing (Just liftCmd)
320-
321- mkDemoteAction name = do
313+ mkAction aId kind title = do
322314 let args = [J. toJSON $ Hie. HP (docId ^. J. uri) pos]
323- title = " Demote " <> name <> " one level"
324- demCmd <- mkLspCommand pId " demote" title (Just args)
325- return $ J. CodeAction title (Just J. CodeActionRefactorInline ) mempty Nothing (Just demCmd)
315+ cmd <- mkLspCommand pId aId title (Just args)
316+ return $ J. CodeAction title (Just kind) mempty Nothing (Just cmd)
326317
327- mkDeleteAction name = do
328- let args = [J. toJSON $ Hie. HP (docId ^. J. uri) pos]
329- title = " Delete definition of " <> name
330- delCmd <- mkLspCommand pId " deletedef" title (Just args)
331- return $ J. CodeAction title (Just J. CodeActionRefactor ) mempty Nothing (Just delCmd)
332-
333- mkDuplicateAction name = do
318+ mkHptAction aId kind title name = do
334319 let args = [J. toJSON $ HPT (docId ^. J. uri) pos (name <> " '" )]
335- title = " Duplicate definition of " <> name
336- dupCmd <- mkLspCommand pId " dupdef" title (Just args)
337- return $ J. CodeAction title (Just J. CodeActionRefactor ) mempty Nothing (Just dupCmd)
338-
339- mkCaseSplitAction name = do
340- let args = [J. toJSON $ Hie. HP (docId ^. J. uri) pos]
341- title = " Case split on " <> name
342- splCmd <- mkLspCommand pId " casesplit" title (Just args)
343- return $ J. CodeAction title (Just J. CodeActionRefactorRewrite ) mempty Nothing (Just splCmd)
320+ cmd <- mkLspCommand pId aId title (Just args)
321+ return $ J. CodeAction (title <> name) (Just kind) mempty Nothing (Just cmd)
0 commit comments