@@ -34,6 +34,7 @@ import Language.LSP.Protocol.Types hiding
34
34
-- compiler and infrastructure
35
35
import Development.IDE.Core.PositionMapping
36
36
import Development.IDE.Core.RuleTypes
37
+ import Development.IDE.Core.Shake (IdeAction )
37
38
import Development.IDE.GHC.Compat
38
39
import qualified Development.IDE.GHC.Compat.Util as Util
39
40
import Development.IDE.GHC.Util (printOutputable )
@@ -184,26 +185,24 @@ documentHighlight hf rf pos = pure highlights
184
185
else DocumentHighlightKind_Read
185
186
186
187
gotoTypeDefinition
187
- :: MonadIO m
188
- => WithHieDb
189
- -> LookupModule m
188
+ :: WithHieDb
189
+ -> LookupModule IdeAction
190
190
-> IdeOptions
191
191
-> HieAstResult
192
192
-> Position
193
- -> MaybeT m [Location ]
193
+ -> MaybeT IdeAction [Location ]
194
194
gotoTypeDefinition withHieDb lookupModule ideOpts srcSpans pos
195
195
= lift $ typeLocationsAtPoint withHieDb lookupModule ideOpts pos srcSpans
196
196
197
197
-- | Locate the definition of the name at a given position.
198
198
gotoDefinition
199
- :: MonadIO m
200
- => WithHieDb
201
- -> LookupModule m
199
+ :: WithHieDb
200
+ -> LookupModule IdeAction
202
201
-> IdeOptions
203
202
-> M. Map ModuleName NormalizedFilePath
204
203
-> HieASTs a
205
204
-> Position
206
- -> MaybeT m [Location ]
205
+ -> MaybeT IdeAction [Location ]
207
206
gotoDefinition withHieDb getHieFile ideOpts imports srcSpans pos
208
207
= lift $ locationsAtPoint withHieDb getHieFile ideOpts imports pos srcSpans
209
208
@@ -286,14 +285,12 @@ atPoint IdeOptions{} (HAR _ hf _ _ kind) mDkMap mEnv pos = listToMaybe $ pointCo
286
285
_ -> Just $ " *Defined " <> printOutputable (pprNameDefnLoc name) <> " *"
287
286
288
287
typeLocationsAtPoint
289
- :: forall m
290
- . MonadIO m
291
- => WithHieDb
292
- -> LookupModule m
288
+ :: WithHieDb
289
+ -> LookupModule IdeAction
293
290
-> IdeOptions
294
291
-> Position
295
292
-> HieAstResult
296
- -> m [Location ]
293
+ -> IdeAction [Location ]
297
294
typeLocationsAtPoint withHieDb lookupModule _ideOptions pos (HAR _ ast _ _ hieKind) =
298
295
case hieKind of
299
296
HieFromDisk hf ->
@@ -336,15 +333,13 @@ getTypes :: [Type] -> [Name]
336
333
getTypes ts = concatMap namesInType ts
337
334
338
335
locationsAtPoint
339
- :: forall m a
340
- . MonadIO m
341
- => WithHieDb
342
- -> LookupModule m
336
+ :: WithHieDb
337
+ -> LookupModule IdeAction
343
338
-> IdeOptions
344
339
-> M. Map ModuleName NormalizedFilePath
345
340
-> Position
346
341
-> HieASTs a
347
- -> m [Location ]
342
+ -> IdeAction [Location ]
348
343
locationsAtPoint withHieDb lookupModule _ideOptions imports pos ast =
349
344
let ns = concat $ pointCommand ast pos (M. keys . getNodeIds)
350
345
zeroPos = Position 0 0
@@ -353,7 +348,7 @@ locationsAtPoint withHieDb lookupModule _ideOptions imports pos ast =
353
348
in fmap (nubOrd . concat ) $ mapMaybeM (either (pure . modToLocation) $ nameToLocation withHieDb lookupModule) ns
354
349
355
350
-- | Given a 'Name' attempt to find the location where it is defined.
356
- nameToLocation :: MonadIO m => WithHieDb -> LookupModule m -> Name -> m (Maybe [Location ])
351
+ nameToLocation :: WithHieDb -> LookupModule IdeAction -> Name -> IdeAction (Maybe [Location ])
357
352
nameToLocation withHieDb lookupModule name = runMaybeT $
358
353
case nameSrcSpan name of
359
354
sp@ (RealSrcSpan rsp _)
@@ -389,7 +384,7 @@ nameToLocation withHieDb lookupModule name = runMaybeT $
389
384
xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
390
385
xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
391
386
392
- defRowToLocation :: Monad m => LookupModule m -> Res DefRow -> MaybeT m Location
387
+ defRowToLocation :: LookupModule IdeAction -> Res DefRow -> MaybeT IdeAction Location
393
388
defRowToLocation lookupModule (row:. info) = do
394
389
let start = Position (fromIntegral $ defSLine row - 1 ) (fromIntegral $ defSCol row - 1 )
395
390
end = Position (fromIntegral $ defELine row - 1 ) (fromIntegral $ defECol row - 1 )
0 commit comments