Skip to content

Commit cebd00f

Browse files
committed
Get tests to pass
1 parent 2ebf7ae commit cebd00f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/Ide/Plugin/Example.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ codeAction
117117
codeAction _state _pid (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List _xs} = do
118118
let
119119
title = "Add TODO Item 1"
120-
tedit = [TextEdit (Range (Position 0 0) (Position 0 0))
120+
tedit = [TextEdit (Range (Position 2 0) (Position 2 0))
121121
"-- TODO1 added by Example Plugin directly\n"]
122122
edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing
123123
pure $ Right $ List
@@ -160,7 +160,7 @@ addTodoCmd :: AddTodoParams -> IO (Either ResponseError Value,
160160
Maybe (ServerMethod, ApplyWorkspaceEditParams))
161161
addTodoCmd (AddTodoParams uri todoText) = do
162162
let
163-
pos = Position 0 0
163+
pos = Position 3 0
164164
textEdits = List
165165
[TextEdit (Range pos pos)
166166
("-- TODO:" <> todoText <> "\n")

src/Ide/Plugin/Example2.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ codeAction
117117
codeAction _state _pid (TextDocumentIdentifier uri) _range CodeActionContext{_diagnostics=List _xs} = do
118118
let
119119
title = "Add TODO2 Item"
120-
tedit = [TextEdit (Range (Position 0 0) (Position 0 0))
120+
tedit = [TextEdit (Range (Position 3 0) (Position 3 0))
121121
"-- TODO2 added by Example2 Plugin directly\n"]
122122
edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing
123123
pure $ Right $ List
@@ -157,7 +157,7 @@ addTodoCmd :: AddTodoParams -> IO (Either ResponseError Value,
157157
Maybe (ServerMethod, ApplyWorkspaceEditParams))
158158
addTodoCmd (AddTodoParams uri todoText) = do
159159
let
160-
pos = Position 0 0
160+
pos = Position 5 0
161161
textEdits = List
162162
[TextEdit (Range pos pos)
163163
("-- TODO2:" <> todoText <> "\n")

test/functional/PluginSpec.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ spec = do
4242
mark "provides 3.8 code actions"
4343

4444
doc <- openDoc "Format.hs" "haskell"
45-
_diags@(diag1:_) <- waitForDiagnostics
45+
diags@(diag1:_) <- waitForDiagnosticsSource "typecheck"
4646

4747
-- liftIO $ putStrLn $ "diags = " ++ show diags -- AZ
4848
liftIO $ do
49-
-- length diags `shouldBe` 1
50-
diag1 ^. L.range `shouldBe` Range (Position 0 0) (Position 1 0)
49+
length diags `shouldBe` 5
50+
diag1 ^. L.range `shouldBe` Range (Position 2 9) (Position 2 12)
5151
diag1 ^. L.severity `shouldBe` Just DsError
5252
diag1 ^. L.code `shouldBe` Nothing
5353
-- diag1 ^. L.source `shouldBe` Just "example2"
5454

55+
diag1 ^. L.source `shouldBe` Just "typecheck"
5556
-- diag2 ^. L.source `shouldBe` Just "example"
5657

5758
_cas@(CACodeAction ca:_) <- getAllCodeActions doc
@@ -61,18 +62,18 @@ spec = do
6162

6263
liftIO $ [ca ^. L.title] `shouldContain` ["Add TODO Item 1"]
6364

64-
mark "A" -- AZ
65+
-- mark "A" -- AZ
6566
executeCodeAction ca
66-
mark "B" -- AZ
67+
-- mark "B" -- AZ
6768

6869
-- _ <- skipMany (message @RegisterCapabilityRequest)
6970
-- liftIO $ putStrLn $ "B2" -- AZ
7071

71-
_diags2 <- waitForDiagnostics
72+
-- _diags2 <- waitForDiagnosticsSource "typecheck"
7273
-- liftIO $ putStrLn $ "diags2 = " ++ show _diags2 -- AZ
7374

7475
-- contents <- getDocumentEdit doc
75-
mark "C" -- AZ
76+
-- mark "C" -- AZ
7677
-- liftIO $ contents `shouldBe` "main = undefined\nfoo x = x\n"
7778

7879
-- noDiagnostics

0 commit comments

Comments
 (0)