Skip to content

Commit e896d77

Browse files
committed
Remove gotoDefinition polymorphism
1 parent 33e03d2 commit e896d77

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import Language.LSP.Protocol.Types hiding
3434
-- compiler and infrastructure
3535
import Development.IDE.Core.PositionMapping
3636
import Development.IDE.Core.RuleTypes
37+
import Development.IDE.Core.Shake (IdeAction)
3738
import Development.IDE.GHC.Compat
3839
import qualified Development.IDE.GHC.Compat.Util as Util
3940
import Development.IDE.GHC.Util (printOutputable)
@@ -184,26 +185,24 @@ documentHighlight hf rf pos = pure highlights
184185
else DocumentHighlightKind_Read
185186

186187
gotoTypeDefinition
187-
:: MonadIO m
188-
=> WithHieDb
189-
-> LookupModule m
188+
:: WithHieDb
189+
-> LookupModule IdeAction
190190
-> IdeOptions
191191
-> HieAstResult
192192
-> Position
193-
-> MaybeT m [Location]
193+
-> MaybeT IdeAction [Location]
194194
gotoTypeDefinition withHieDb lookupModule ideOpts srcSpans pos
195195
= lift $ typeLocationsAtPoint withHieDb lookupModule ideOpts pos srcSpans
196196

197197
-- | Locate the definition of the name at a given position.
198198
gotoDefinition
199-
:: MonadIO m
200-
=> WithHieDb
201-
-> LookupModule m
199+
:: WithHieDb
200+
-> LookupModule IdeAction
202201
-> IdeOptions
203202
-> M.Map ModuleName NormalizedFilePath
204203
-> HieASTs a
205204
-> Position
206-
-> MaybeT m [Location]
205+
-> MaybeT IdeAction [Location]
207206
gotoDefinition withHieDb getHieFile ideOpts imports srcSpans pos
208207
= lift $ locationsAtPoint withHieDb getHieFile ideOpts imports pos srcSpans
209208

@@ -286,14 +285,12 @@ atPoint IdeOptions{} (HAR _ hf _ _ kind) mDkMap mEnv pos = listToMaybe $ pointCo
286285
_ -> Just $ "*Defined " <> printOutputable (pprNameDefnLoc name) <> "*"
287286

288287
typeLocationsAtPoint
289-
:: forall m
290-
. MonadIO m
291-
=> WithHieDb
292-
-> LookupModule m
288+
:: WithHieDb
289+
-> LookupModule IdeAction
293290
-> IdeOptions
294291
-> Position
295292
-> HieAstResult
296-
-> m [Location]
293+
-> IdeAction [Location]
297294
typeLocationsAtPoint withHieDb lookupModule _ideOptions pos (HAR _ ast _ _ hieKind) =
298295
case hieKind of
299296
HieFromDisk hf ->
@@ -336,15 +333,13 @@ getTypes :: [Type] -> [Name]
336333
getTypes ts = concatMap namesInType ts
337334

338335
locationsAtPoint
339-
:: forall m a
340-
. MonadIO m
341-
=> WithHieDb
342-
-> LookupModule m
336+
:: WithHieDb
337+
-> LookupModule IdeAction
343338
-> IdeOptions
344339
-> M.Map ModuleName NormalizedFilePath
345340
-> Position
346341
-> HieASTs a
347-
-> m [Location]
342+
-> IdeAction [Location]
348343
locationsAtPoint withHieDb lookupModule _ideOptions imports pos ast =
349344
let ns = concat $ pointCommand ast pos (M.keys . getNodeIds)
350345
zeroPos = Position 0 0
@@ -353,7 +348,7 @@ locationsAtPoint withHieDb lookupModule _ideOptions imports pos ast =
353348
in fmap (nubOrd . concat) $ mapMaybeM (either (pure . modToLocation) $ nameToLocation withHieDb lookupModule) ns
354349

355350
-- | 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])
357352
nameToLocation withHieDb lookupModule name = runMaybeT $
358353
case nameSrcSpan name of
359354
sp@(RealSrcSpan rsp _)
@@ -389,7 +384,7 @@ nameToLocation withHieDb lookupModule name = runMaybeT $
389384
xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
390385
xs -> lift $ mapMaybeM (runMaybeT . defRowToLocation lookupModule) xs
391386

392-
defRowToLocation :: Monad m => LookupModule m -> Res DefRow -> MaybeT m Location
387+
defRowToLocation :: LookupModule IdeAction -> Res DefRow -> MaybeT IdeAction Location
393388
defRowToLocation lookupModule (row:.info) = do
394389
let start = Position (fromIntegral $ defSLine row - 1) (fromIntegral $ defSCol row - 1)
395390
end = Position (fromIntegral $ defELine row - 1) (fromIntegral $ defECol row - 1)

0 commit comments

Comments
 (0)