+ let args = toJSON $ AOP (doc ^. uri)
+ (Position 1 14)
+ "Redundant bracket"
+ reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args]))
+ sendRequest_ WorkspaceExecuteCommand reqParams
+
+ editReq <- message :: Session ApplyWorkspaceEditRequest
+ liftIO $ do
+ let (Just cs) = editReq ^. params . edit . changes
+ [(u, List es)] = HM.toList cs
+ u `shouldBe` doc ^. uri
+ es `shouldBe` [TextEdit (Range (Position 1 0) (Position 1 18)) "main = return 42"]
+
+ noDiagnostics
+
+ contents <- documentContents doc
+ liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42\n"
+
+ describe "getDocumentEdit" $
+ it "automatically consumes applyedit requests" $
+ runSession "hie --lsp" "test/data/refactor" $ do
+ doc <- openDoc "Main.hs" "haskell"
+
+ let args = toJSON $ AOP (doc ^. uri)
+ (Position 1 14)
+ "Redundant bracket"
+ reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args]))
+ sendRequest_ WorkspaceExecuteCommand reqParams
+ contents <- getDocumentEdit doc
+ liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42\n"
+ noDiagnostics
+
+ describe "getAllCodeActions" $
+ it "works" $ runSession "hie --lsp" "test/data/refactor" $ do
+ doc <- openDoc "Main.hs" "haskell"
+ _ <- waitForDiagnostics
+ actions <- getAllCodeActions doc
+ liftIO $ do
+ let [CommandOrCodeActionCommand action] = actions
+ action ^. title `shouldBe` "Apply hint:Redundant bracket"
+ action ^. command `shouldSatisfy` T.isSuffixOf ":applyrefact:applyOne"
+
+ describe "getDocumentSymbols" $
+ it "works" $ runSession "hie --lsp" "test/data/renamePass" $ do
+ doc <- openDoc "Desktop/simple.hs" "haskell"
+
+ skipMany loggingNotification
+
+ noDiagnostics
+
+ (mainSymbol:_) <- getDocumentSymbols doc