@@ -32,82 +32,82 @@ spec = describe "Context of different cursor positions" $ do
3232 it " module header context"
3333 $ withCurrentDirectory " ./test/testdata/context"
3434 $ do
35- fp_ <- makeAbsolute " ./ExampleContext.hs"
35+ fp <- makeAbsolute " ./ExampleContext.hs"
3636 let res = IdeResultOk (Just (ModuleContext " ExampleContext" ))
3737
38- actual <- getContextAt fp_ (toPos (1 , 10 ))
38+ actual <- getContextAt fp (toPos (1 , 10 ))
3939
4040 actual `shouldBe` res
4141
4242
4343 it " module export list context"
4444 $ withCurrentDirectory " ./test/testdata/context"
4545 $ do
46- fp_ <- makeAbsolute " ./ExampleContext.hs"
46+ fp <- makeAbsolute " ./ExampleContext.hs"
4747 let res = IdeResultOk (Just ExportContext )
48- actual <- getContextAt fp_ (toPos (1 , 24 ))
48+ actual <- getContextAt fp (toPos (1 , 24 ))
4949
5050 actual `shouldBe` res
5151
5252 it " value context" $ withCurrentDirectory " ./test/testdata/context" $ do
53- fp_ <- makeAbsolute " ./ExampleContext.hs"
53+ fp <- makeAbsolute " ./ExampleContext.hs"
5454 let res = IdeResultOk (Just ValueContext )
55- actual <- getContextAt fp_ (toPos (7 , 6 ))
55+ actual <- getContextAt fp (toPos (7 , 6 ))
5656
5757 actual `shouldBe` res
5858
5959 it " value addition context" $ withCurrentDirectory " ./test/testdata/context" $ do
60- fp_ <- makeAbsolute " ./ExampleContext.hs"
60+ fp <- makeAbsolute " ./ExampleContext.hs"
6161 let res = IdeResultOk (Just ValueContext )
62- actual <- getContextAt fp_ (toPos (7 , 12 ))
62+ actual <- getContextAt fp (toPos (7 , 12 ))
6363
6464 actual `shouldBe` res
6565
6666 it " import context" $ withCurrentDirectory " ./test/testdata/context" $ do
67- fp_ <- makeAbsolute " ./ExampleContext.hs"
67+ fp <- makeAbsolute " ./ExampleContext.hs"
6868 let res = IdeResultOk (Just (ImportContext " Data.List" ))
69- actual <- getContextAt fp_ (toPos (3 , 8 ))
69+ actual <- getContextAt fp (toPos (3 , 8 ))
7070
7171 actual `shouldBe` res
7272
7373 it " import list context" $ withCurrentDirectory " ./test/testdata/context" $ do
74- fp_ <- makeAbsolute " ./ExampleContext.hs"
74+ fp <- makeAbsolute " ./ExampleContext.hs"
7575 let res = IdeResultOk (Just (ImportListContext " Data.List" ))
76- actual <- getContextAt fp_ (toPos (3 , 20 ))
76+ actual <- getContextAt fp (toPos (3 , 20 ))
7777
7878 actual `shouldBe` res
7979
8080 it " import hiding context" $ withCurrentDirectory " ./test/testdata/context" $ do
81- fp_ <- makeAbsolute " ./ExampleContext.hs"
81+ fp <- makeAbsolute " ./ExampleContext.hs"
8282 let res = IdeResultOk (Just (ImportHidingContext " Control.Monad" ))
83- actual <- getContextAt fp_ (toPos (4 , 32 ))
83+ actual <- getContextAt fp (toPos (4 , 32 ))
8484
8585 actual `shouldBe` res
8686
8787 it " function declaration context"
8888 $ withCurrentDirectory " ./test/testdata/context"
8989 $ do
90- fp_ <- makeAbsolute " ./ExampleContext.hs"
90+ fp <- makeAbsolute " ./ExampleContext.hs"
9191 let res = IdeResultOk (Just TypeContext )
92- actual <- getContextAt fp_ (toPos (6 , 1 ))
92+ actual <- getContextAt fp (toPos (6 , 1 ))
9393
9494 actual `shouldBe` res
95-
95+
9696 it " function signature context"
9797 $ withCurrentDirectory " ./test/testdata/context"
9898 $ do
99- fp_ <- makeAbsolute " ./ExampleContext.hs"
99+ fp <- makeAbsolute " ./ExampleContext.hs"
100100 let res = IdeResultOk (Just TypeContext )
101- actual <- getContextAt fp_ (toPos (6 , 8 ))
101+ actual <- getContextAt fp (toPos (6 , 8 ))
102102 actual `shouldBe` res
103103
104104
105105 it " function definition context"
106106 $ withCurrentDirectory " ./test/testdata/context"
107107 $ do
108- fp_ <- makeAbsolute " ./ExampleContext.hs"
108+ fp <- makeAbsolute " ./ExampleContext.hs"
109109 let res = IdeResultOk (Just ValueContext )
110- actual <- getContextAt fp_ (toPos (7 , 1 ))
110+ actual <- getContextAt fp (toPos (7 , 1 ))
111111 actual `shouldBe` res
112112
113113 -- This is interesting, the context for this is assumed to be ValueContext
@@ -118,69 +118,73 @@ spec = describe "Context of different cursor positions" $ do
118118 it " inner function declaration context"
119119 $ withCurrentDirectory " ./test/testdata/context"
120120 $ do
121- fp_ <- makeAbsolute " ./ExampleContext.hs"
121+ fp <- makeAbsolute " ./ExampleContext.hs"
122122 let res = IdeResultOk (Just ValueContext )
123- actual <- getContextAt fp_ (toPos (9 , 10 ))
123+ actual <- getContextAt fp (toPos (9 , 10 ))
124124 actual `shouldBe` res
125125
126126 it " inner function value context"
127127 $ withCurrentDirectory " ./test/testdata/context"
128128 $ do
129- fp_ <- makeAbsolute " ./ExampleContext.hs"
129+ fp <- makeAbsolute " ./ExampleContext.hs"
130130 let res = IdeResultOk (Just ValueContext )
131- actual <- getContextAt fp_ (toPos (10 , 10 ))
131+ actual <- getContextAt fp (toPos (10 , 10 ))
132132 actual `shouldBe` res
133133
134134
135135 -- Declare a datatype, is Nothing, could be DataContext
136136 it " data declaration context"
137137 $ withCurrentDirectory " ./test/testdata/context"
138138 $ do
139- fp_ <- makeAbsolute " ./ExampleContext.hs"
139+ fp <- makeAbsolute " ./ExampleContext.hs"
140140 let res = IdeResultOk Nothing
141- actual <- getContextAt fp_ (toPos (12 , 8 ))
141+ actual <- getContextAt fp (toPos (12 , 8 ))
142142 actual `shouldBe` res
143143
144144 -- Define a datatype.
145145 it " data definition context"
146146 $ withCurrentDirectory " ./test/testdata/context"
147147 $ do
148- fp_ <- makeAbsolute " ./ExampleContext.hs"
148+ fp <- makeAbsolute " ./ExampleContext.hs"
149149 let res = IdeResultOk (Just TypeContext )
150- actual <- getContextAt fp_ (toPos (12 , 18 ))
150+ actual <- getContextAt fp (toPos (12 , 18 ))
151151 actual `shouldBe` res
152152
153+ -- Declaration of a class. Should be something with types.
153154 it " class declaration context"
154155 $ withCurrentDirectory " ./test/testdata/context"
155156 $ do
156- fp_ <- makeAbsolute " ./ExampleContext.hs"
157- let res = IdeResultOk ( Just ClassContext )
158- actual <- getContextAt fp_ (toPos (15 , 8 ))
157+ fp <- makeAbsolute " ./ExampleContext.hs"
158+ let res = IdeResultOk Nothing
159+ actual <- getContextAt fp (toPos (15 , 8 ))
159160 actual `shouldBe` res
160161
162+ -- Function signature in class declaration.
163+ -- Ought to be TypeContext
161164 it " class declaration function sig context"
162165 $ withCurrentDirectory " ./test/testdata/context"
163166 $ do
164- fp_ <- makeAbsolute " ./ExampleContext.hs"
165- let res = IdeResultOk ( Just ClassContext )
166- actual <- getContextAt fp_ (toPos (16 , 7 ))
167+ fp <- makeAbsolute " ./ExampleContext.hs"
168+ let res = IdeResultOk Nothing
169+ actual <- getContextAt fp (toPos (16 , 7 ))
167170 actual `shouldBe` res
168171
169172 it " instance declaration context"
170173 $ withCurrentDirectory " ./test/testdata/context"
171174 $ do
172- fp_ <- makeAbsolute " ./ExampleContext.hs"
173- let res = IdeResultOk ( Just InstanceContext )
174- actual <- getContextAt fp_ (toPos (18 , 7 ))
175+ fp <- makeAbsolute " ./ExampleContext.hs"
176+ let res = IdeResultOk Nothing
177+ actual <- getContextAt fp (toPos (18 , 7 ))
175178 actual `shouldBe` res
176179
177- -- Function definition
180+ -- Function definition in an instance declaration
181+ -- Should be ValueContext, but nothing is fine, too for now
178182 it " instance declaration function def context"
179183 $ withCurrentDirectory " ./test/testdata/context"
180184 $ do
181- fp_ <- makeAbsolute " ./ExampleContext.hs"
182- let res = IdeResultOk ( Just InstanceContext )
183- actual <- getContextAt fp_ (toPos (19 , 6 ))
185+ fp <- makeAbsolute " ./ExampleContext.hs"
186+ let res = IdeResultOk Nothing
187+ actual <- getContextAt fp (toPos (19 , 6 ))
184188 actual `shouldBe` res
185189
186190 -- This seems plain wrong, if the cursor is on the String "deriving",
@@ -189,9 +193,9 @@ spec = describe "Context of different cursor positions" $ do
189193 it " deriving context"
190194 $ withCurrentDirectory " ./test/testdata/context"
191195 $ do
192- fp_ <- makeAbsolute " ./ExampleContext.hs"
196+ fp <- makeAbsolute " ./ExampleContext.hs"
193197 let res = IdeResultOk Nothing
194- actual <- getContextAt fp_ (toPos (13 , 9 ))
198+ actual <- getContextAt fp (toPos (13 , 9 ))
195199 actual `shouldBe` res
196200
197201 -- Cursor is directly before the open parenthesis of a deriving clause.
@@ -201,9 +205,9 @@ spec = describe "Context of different cursor positions" $ do
201205 it " deriving parenthesis context"
202206 $ withCurrentDirectory " ./test/testdata/context"
203207 $ do
204- fp_ <- makeAbsolute " ./ExampleContext.hs"
208+ fp <- makeAbsolute " ./ExampleContext.hs"
205209 let res = IdeResultOk Nothing
206- actual <- getContextAt fp_ (toPos (13 , 14 ))
210+ actual <- getContextAt fp (toPos (13 , 14 ))
207211 actual `shouldBe` res
208212
209213 -- Cursor is directly after the open parenthesis of a deriving clause.
@@ -215,32 +219,32 @@ spec = describe "Context of different cursor positions" $ do
215219 it " deriving parenthesis context"
216220 $ withCurrentDirectory " ./test/testdata/context"
217221 $ do
218- fp_ <- makeAbsolute " ./ExampleContext.hs"
222+ fp <- makeAbsolute " ./ExampleContext.hs"
219223 let res = IdeResultOk (Just TypeContext )
220- actual <- getContextAt fp_ (toPos (13 , 15 ))
224+ actual <- getContextAt fp (toPos (13 , 15 ))
221225 actual `shouldBe` res
222226
223227 it " deriving typeclass context"
224228 $ withCurrentDirectory " ./test/testdata/context"
225229 $ do
226- fp_ <- makeAbsolute " ./ExampleContext.hs"
230+ fp <- makeAbsolute " ./ExampleContext.hs"
227231 let res = IdeResultOk (Just TypeContext )
228- actual <- getContextAt fp_ (toPos (13 , 18 ))
232+ actual <- getContextAt fp (toPos (13 , 18 ))
229233 actual `shouldBe` res
230234
231235 -- Point at an empty line.
232236 -- There is no context
233237 it " nothing" $ withCurrentDirectory " ./test/testdata/context" $ do
234- fp_ <- makeAbsolute " ./ExampleContext.hs"
238+ fp <- makeAbsolute " ./ExampleContext.hs"
235239 let res = IdeResultOk Nothing
236- actual <- getContextAt fp_ (toPos (2 , 1 ))
240+ actual <- getContextAt fp (toPos (2 , 1 ))
237241 actual `shouldBe` res
238242
239- getContextAt :: [ Char ] -> Position -> IO (IdeResult (Maybe Context ))
240- getContextAt fp_ pos = do
241- let arg = filePathToUri fp_
243+ getContextAt :: FilePath -> Position -> IO (IdeResult (Maybe Context ))
244+ getContextAt fp pos = do
245+ let arg = filePathToUri fp
242246 runSingle (IdePlugins mempty ) $ do
243247 _ <- setTypecheckedModule arg
244- pluginGetFile " getContext: " arg $ \ fp ->
245- ifCachedModuleAndData fp (IdeResultOk Nothing ) $ \ tm _ () ->
248+ pluginGetFile " getContext: " arg $ \ fp_ ->
249+ ifCachedModuleAndData fp_ (IdeResultOk Nothing ) $ \ tm _ () ->
246250 return $ IdeResultOk $ getContext pos (tm_parsed_module tm)
0 commit comments