Skip to content

Commit 3238e4e

Browse files
committed
eval-plugin for GHC 9.2: find all comments
1 parent edc7160 commit 3238e4e

File tree

1 file changed

+11
-3
lines changed
  • plugins/hls-eval-plugin/src/Ide/Plugin/Eval

1 file changed

+11
-3
lines changed

plugins/hls-eval-plugin/src/Ide/Plugin/Eval/Rules.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,20 @@ queueForEvaluation ide nfp = do
5858

5959
#if MIN_VERSION_ghc(9,2,0)
6060
getAnnotations :: Development.IDE.GHC.Compat.Located HsModule -> [LEpaComment]
61-
getAnnotations (L _ (HsModule { hsmodAnn = anns'})) = priorComments $ epAnnComments anns'
61+
getAnnotations (L _ m@(HsModule { hsmodAnn = anns'})) = let annComments = epAnnComments anns'
62+
in priorComments annComments
63+
<> concatMap getCommentsForDecl (hsmodDecls m)
64+
<> concatMap getCommentsForDecl (hsmodImports m)
65+
66+
getCommentsForDecl :: GenLocated (SrcSpanAnn' (EpAnn ann)) e
67+
-> [LEpaComment]
68+
getCommentsForDecl (L (SrcSpanAnn (EpAnn _ _ cs) _) _) = priorComments cs <> getFollowingComments cs
69+
getCommentsForDecl (L (SrcSpanAnn (EpAnnNotUsed) _) _) = []
6270

6371
apiAnnComments' :: ParsedModule -> [SrcLoc.RealLocated EpaCommentTok]
6472
apiAnnComments' pm = do
65-
L span' (EpaComment c span) <- getAnnotations $ pm_parsed_source pm
66-
pure (L (anchor span') c)
73+
L span (EpaComment c _) <- getAnnotations $ pm_parsed_source pm
74+
pure (L (anchor span) c)
6775

6876
pattern RealSrcSpanAlready :: SrcLoc.RealSrcSpan -> SrcLoc.RealSrcSpan
6977
pattern RealSrcSpanAlready x = x

0 commit comments

Comments
 (0)