@@ -555,43 +555,38 @@ findTypeDef uri pos = pluginGetFile "findTypeDef: " uri $ \file ->
555
555
(IdeResultOk [] ) -- Default result
556
556
(\ info -> do
557
557
let rfm = revMap info
558
- mm = moduleMap info
559
558
tmap = typeMap info
560
559
oldPos = newPosToOld info pos
561
560
562
- case (\ x -> Just $ getArtifactsAtPos x mm) =<< oldPos of
563
- Just ((_, mn) : _) -> gotoModule rfm mn
564
- _ -> do
565
- let
566
- -- | Get SrcSpan of the name at the given position.
567
- -- If the old position is Nothing, e.g. there is no cached info about it,
568
- -- Nothing is returned.
569
- --
570
- -- Otherwise, searches for the Type of the given position
571
- -- and retrieves its SrcSpan.
572
- getTypeSrcSpanFromPosition
573
- :: Maybe Position -> ExceptT () IdeDeferM SrcSpan
574
- getTypeSrcSpanFromPosition maybeOldPosition = do
575
- oldPosition <- liftMaybe maybeOldPosition
576
- let tmapRes = getArtifactsAtPos oldPosition tmap
577
- case tmapRes of
578
- [] -> throwError ()
579
- a -> do
580
- -- take last type since this is always the most accurate one
581
- tyCon <- liftMaybe $ tyConAppTyCon_maybe (snd $ last a)
582
- case nameSrcSpan (getName tyCon) of
583
- UnhelpfulSpan _ -> throwError ()
584
- realSpan -> return realSpan
585
-
586
- liftMaybe :: Monad m => Maybe a -> ExceptT () m a
587
- liftMaybe val = liftEither $ case val of
588
- Nothing -> Left ()
589
- Just s -> Right s
590
-
591
- runExceptT (getTypeSrcSpanFromPosition oldPos) >>= \ case
592
- Left () -> return $ IdeResultOk []
593
- Right realSpan ->
594
- lift $ srcSpanToFileLocation " hare:findTypeDef" rfm realSpan
561
+ -- | Get SrcSpan of the name at the given position.
562
+ -- If the old position is Nothing, e.g. there is no cached info about it,
563
+ -- Nothing is returned.
564
+ --
565
+ -- Otherwise, searches for the Type of the given position
566
+ -- and retrieves its SrcSpan.
567
+ getTypeSrcSpanFromPosition
568
+ :: Maybe Position -> ExceptT () IdeDeferM SrcSpan
569
+ getTypeSrcSpanFromPosition maybeOldPosition = do
570
+ oldPosition <- liftMaybe maybeOldPosition
571
+ let tmapRes = getArtifactsAtPos oldPosition tmap
572
+ case tmapRes of
573
+ [] -> throwError ()
574
+ a -> do
575
+ -- take last type since this is always the most accurate one
576
+ tyCon <- liftMaybe $ tyConAppTyCon_maybe (snd $ last a)
577
+ case nameSrcSpan (getName tyCon) of
578
+ UnhelpfulSpan _ -> throwError ()
579
+ realSpan -> return realSpan
580
+
581
+ liftMaybe :: Monad m => Maybe a -> ExceptT () m a
582
+ liftMaybe val = liftEither $ case val of
583
+ Nothing -> Left ()
584
+ Just s -> Right s
585
+
586
+ runExceptT (getTypeSrcSpanFromPosition oldPos) >>= \ case
587
+ Left () -> return $ IdeResultOk []
588
+ Right realSpan ->
589
+ lift $ srcSpanToFileLocation " hare:findTypeDef" rfm realSpan
595
590
)
596
591
597
592
-- | Return the definition
0 commit comments