@@ -32,82 +32,82 @@ spec = describe "Context of different cursor positions" $ do
32
32
it " module header context"
33
33
$ withCurrentDirectory " ./test/testdata/context"
34
34
$ do
35
- fp_ <- makeAbsolute " ./ExampleContext.hs"
35
+ fp <- makeAbsolute " ./ExampleContext.hs"
36
36
let res = IdeResultOk (Just (ModuleContext " ExampleContext" ))
37
37
38
- actual <- getContextAt fp_ (toPos (1 , 10 ))
38
+ actual <- getContextAt fp (toPos (1 , 10 ))
39
39
40
40
actual `shouldBe` res
41
41
42
42
43
43
it " module export list context"
44
44
$ withCurrentDirectory " ./test/testdata/context"
45
45
$ do
46
- fp_ <- makeAbsolute " ./ExampleContext.hs"
46
+ fp <- makeAbsolute " ./ExampleContext.hs"
47
47
let res = IdeResultOk (Just ExportContext )
48
- actual <- getContextAt fp_ (toPos (1 , 24 ))
48
+ actual <- getContextAt fp (toPos (1 , 24 ))
49
49
50
50
actual `shouldBe` res
51
51
52
52
it " value context" $ withCurrentDirectory " ./test/testdata/context" $ do
53
- fp_ <- makeAbsolute " ./ExampleContext.hs"
53
+ fp <- makeAbsolute " ./ExampleContext.hs"
54
54
let res = IdeResultOk (Just ValueContext )
55
- actual <- getContextAt fp_ (toPos (7 , 6 ))
55
+ actual <- getContextAt fp (toPos (7 , 6 ))
56
56
57
57
actual `shouldBe` res
58
58
59
59
it " value addition context" $ withCurrentDirectory " ./test/testdata/context" $ do
60
- fp_ <- makeAbsolute " ./ExampleContext.hs"
60
+ fp <- makeAbsolute " ./ExampleContext.hs"
61
61
let res = IdeResultOk (Just ValueContext )
62
- actual <- getContextAt fp_ (toPos (7 , 12 ))
62
+ actual <- getContextAt fp (toPos (7 , 12 ))
63
63
64
64
actual `shouldBe` res
65
65
66
66
it " import context" $ withCurrentDirectory " ./test/testdata/context" $ do
67
- fp_ <- makeAbsolute " ./ExampleContext.hs"
67
+ fp <- makeAbsolute " ./ExampleContext.hs"
68
68
let res = IdeResultOk (Just (ImportContext " Data.List" ))
69
- actual <- getContextAt fp_ (toPos (3 , 8 ))
69
+ actual <- getContextAt fp (toPos (3 , 8 ))
70
70
71
71
actual `shouldBe` res
72
72
73
73
it " import list context" $ withCurrentDirectory " ./test/testdata/context" $ do
74
- fp_ <- makeAbsolute " ./ExampleContext.hs"
74
+ fp <- makeAbsolute " ./ExampleContext.hs"
75
75
let res = IdeResultOk (Just (ImportListContext " Data.List" ))
76
- actual <- getContextAt fp_ (toPos (3 , 20 ))
76
+ actual <- getContextAt fp (toPos (3 , 20 ))
77
77
78
78
actual `shouldBe` res
79
79
80
80
it " import hiding context" $ withCurrentDirectory " ./test/testdata/context" $ do
81
- fp_ <- makeAbsolute " ./ExampleContext.hs"
81
+ fp <- makeAbsolute " ./ExampleContext.hs"
82
82
let res = IdeResultOk (Just (ImportHidingContext " Control.Monad" ))
83
- actual <- getContextAt fp_ (toPos (4 , 32 ))
83
+ actual <- getContextAt fp (toPos (4 , 32 ))
84
84
85
85
actual `shouldBe` res
86
86
87
87
it " function declaration context"
88
88
$ withCurrentDirectory " ./test/testdata/context"
89
89
$ do
90
- fp_ <- makeAbsolute " ./ExampleContext.hs"
90
+ fp <- makeAbsolute " ./ExampleContext.hs"
91
91
let res = IdeResultOk (Just TypeContext )
92
- actual <- getContextAt fp_ (toPos (6 , 1 ))
92
+ actual <- getContextAt fp (toPos (6 , 1 ))
93
93
94
94
actual `shouldBe` res
95
-
95
+
96
96
it " function signature context"
97
97
$ withCurrentDirectory " ./test/testdata/context"
98
98
$ do
99
- fp_ <- makeAbsolute " ./ExampleContext.hs"
99
+ fp <- makeAbsolute " ./ExampleContext.hs"
100
100
let res = IdeResultOk (Just TypeContext )
101
- actual <- getContextAt fp_ (toPos (6 , 8 ))
101
+ actual <- getContextAt fp (toPos (6 , 8 ))
102
102
actual `shouldBe` res
103
103
104
104
105
105
it " function definition context"
106
106
$ withCurrentDirectory " ./test/testdata/context"
107
107
$ do
108
- fp_ <- makeAbsolute " ./ExampleContext.hs"
108
+ fp <- makeAbsolute " ./ExampleContext.hs"
109
109
let res = IdeResultOk (Just ValueContext )
110
- actual <- getContextAt fp_ (toPos (7 , 1 ))
110
+ actual <- getContextAt fp (toPos (7 , 1 ))
111
111
actual `shouldBe` res
112
112
113
113
-- This is interesting, the context for this is assumed to be ValueContext
@@ -118,69 +118,73 @@ spec = describe "Context of different cursor positions" $ do
118
118
it " inner function declaration context"
119
119
$ withCurrentDirectory " ./test/testdata/context"
120
120
$ do
121
- fp_ <- makeAbsolute " ./ExampleContext.hs"
121
+ fp <- makeAbsolute " ./ExampleContext.hs"
122
122
let res = IdeResultOk (Just ValueContext )
123
- actual <- getContextAt fp_ (toPos (9 , 10 ))
123
+ actual <- getContextAt fp (toPos (9 , 10 ))
124
124
actual `shouldBe` res
125
125
126
126
it " inner function value context"
127
127
$ withCurrentDirectory " ./test/testdata/context"
128
128
$ do
129
- fp_ <- makeAbsolute " ./ExampleContext.hs"
129
+ fp <- makeAbsolute " ./ExampleContext.hs"
130
130
let res = IdeResultOk (Just ValueContext )
131
- actual <- getContextAt fp_ (toPos (10 , 10 ))
131
+ actual <- getContextAt fp (toPos (10 , 10 ))
132
132
actual `shouldBe` res
133
133
134
134
135
135
-- Declare a datatype, is Nothing, could be DataContext
136
136
it " data declaration context"
137
137
$ withCurrentDirectory " ./test/testdata/context"
138
138
$ do
139
- fp_ <- makeAbsolute " ./ExampleContext.hs"
139
+ fp <- makeAbsolute " ./ExampleContext.hs"
140
140
let res = IdeResultOk Nothing
141
- actual <- getContextAt fp_ (toPos (12 , 8 ))
141
+ actual <- getContextAt fp (toPos (12 , 8 ))
142
142
actual `shouldBe` res
143
143
144
144
-- Define a datatype.
145
145
it " data definition context"
146
146
$ withCurrentDirectory " ./test/testdata/context"
147
147
$ do
148
- fp_ <- makeAbsolute " ./ExampleContext.hs"
148
+ fp <- makeAbsolute " ./ExampleContext.hs"
149
149
let res = IdeResultOk (Just TypeContext )
150
- actual <- getContextAt fp_ (toPos (12 , 18 ))
150
+ actual <- getContextAt fp (toPos (12 , 18 ))
151
151
actual `shouldBe` res
152
152
153
+ -- Declaration of a class. Should be something with types.
153
154
it " class declaration context"
154
155
$ withCurrentDirectory " ./test/testdata/context"
155
156
$ 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 ))
159
160
actual `shouldBe` res
160
161
162
+ -- Function signature in class declaration.
163
+ -- Ought to be TypeContext
161
164
it " class declaration function sig context"
162
165
$ withCurrentDirectory " ./test/testdata/context"
163
166
$ 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 ))
167
170
actual `shouldBe` res
168
171
169
172
it " instance declaration context"
170
173
$ withCurrentDirectory " ./test/testdata/context"
171
174
$ 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 ))
175
178
actual `shouldBe` res
176
179
177
- -- Function definition
180
+ -- Function definition in an instance declaration
181
+ -- Should be ValueContext, but nothing is fine, too for now
178
182
it " instance declaration function def context"
179
183
$ withCurrentDirectory " ./test/testdata/context"
180
184
$ 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 ))
184
188
actual `shouldBe` res
185
189
186
190
-- This seems plain wrong, if the cursor is on the String "deriving",
@@ -189,9 +193,9 @@ spec = describe "Context of different cursor positions" $ do
189
193
it " deriving context"
190
194
$ withCurrentDirectory " ./test/testdata/context"
191
195
$ do
192
- fp_ <- makeAbsolute " ./ExampleContext.hs"
196
+ fp <- makeAbsolute " ./ExampleContext.hs"
193
197
let res = IdeResultOk Nothing
194
- actual <- getContextAt fp_ (toPos (13 , 9 ))
198
+ actual <- getContextAt fp (toPos (13 , 9 ))
195
199
actual `shouldBe` res
196
200
197
201
-- Cursor is directly before the open parenthesis of a deriving clause.
@@ -201,9 +205,9 @@ spec = describe "Context of different cursor positions" $ do
201
205
it " deriving parenthesis context"
202
206
$ withCurrentDirectory " ./test/testdata/context"
203
207
$ do
204
- fp_ <- makeAbsolute " ./ExampleContext.hs"
208
+ fp <- makeAbsolute " ./ExampleContext.hs"
205
209
let res = IdeResultOk Nothing
206
- actual <- getContextAt fp_ (toPos (13 , 14 ))
210
+ actual <- getContextAt fp (toPos (13 , 14 ))
207
211
actual `shouldBe` res
208
212
209
213
-- Cursor is directly after the open parenthesis of a deriving clause.
@@ -215,30 +219,30 @@ spec = describe "Context of different cursor positions" $ do
215
219
it " deriving parenthesis context"
216
220
$ withCurrentDirectory " ./test/testdata/context"
217
221
$ do
218
- fp_ <- makeAbsolute " ./ExampleContext.hs"
222
+ fp <- makeAbsolute " ./ExampleContext.hs"
219
223
let res = IdeResultOk (Just TypeContext )
220
- actual <- getContextAt fp_ (toPos (13 , 15 ))
224
+ actual <- getContextAt fp (toPos (13 , 15 ))
221
225
actual `shouldBe` res
222
226
223
227
it " deriving typeclass context"
224
228
$ withCurrentDirectory " ./test/testdata/context"
225
229
$ do
226
- fp_ <- makeAbsolute " ./ExampleContext.hs"
230
+ fp <- makeAbsolute " ./ExampleContext.hs"
227
231
let res = IdeResultOk (Just TypeContext )
228
- actual <- getContextAt fp_ (toPos (13 , 18 ))
232
+ actual <- getContextAt fp (toPos (13 , 18 ))
229
233
actual `shouldBe` res
230
234
231
235
-- Point at an empty line.
232
236
-- There is no context
233
237
it " nothing" $ withCurrentDirectory " ./test/testdata/context" $ do
234
- fp_ <- makeAbsolute " ./ExampleContext.hs"
238
+ fp <- makeAbsolute " ./ExampleContext.hs"
235
239
let res = IdeResultOk Nothing
236
- actual <- getContextAt fp_ (toPos (2 , 1 ))
240
+ actual <- getContextAt fp (toPos (2 , 1 ))
237
241
actual `shouldBe` res
238
242
239
243
getContextAt :: [Char ] -> Position -> IO (IdeResult (Maybe Context ))
240
- getContextAt fp_ pos = do
241
- let arg = filePathToUri fp_
244
+ getContextAt fp pos = do
245
+ let arg = filePathToUri fp
242
246
runSingle (IdePlugins mempty ) $ do
243
247
_ <- setTypecheckedModule arg
244
248
pluginGetFile " getContext: " arg $ \ fp ->
0 commit comments