Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GHC 9.12 #1000

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/presubmit-cabal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false # don't cancel other jobs if one fails
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ghc: [9.2.8, 9.4.8, 9.6.6, 9.8.2, 9.10.1]
ghc: [9.2.8, 9.4.8, 9.6.6, 9.8.2, 9.10.1, 9.12.1]
defaults:
run:
# The default shell on Windows is `pwsh`. However, it doesn't expand
Expand Down
10 changes: 5 additions & 5 deletions hindent.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ library
, directory
, exceptions
, filepath
, ghc-lib-parser >=9.2 && <9.11
, ghc-lib-parser >=9.2 && <9.13
, ghc-lib-parser-ex
, monad-loops
, mtl
Expand Down Expand Up @@ -196,7 +196,7 @@ library hindent-internal
, directory
, exceptions
, filepath
, ghc-lib-parser >=9.2 && <9.11
, ghc-lib-parser >=9.2 && <9.13
, ghc-lib-parser-ex
, monad-loops
, mtl
Expand Down Expand Up @@ -230,7 +230,7 @@ executable hindent
, directory
, exceptions
, filepath
, ghc-lib-parser >=9.2 && <9.11
, ghc-lib-parser >=9.2 && <9.13
, ghc-lib-parser-ex
, hindent
, monad-loops
Expand Down Expand Up @@ -267,7 +267,7 @@ test-suite hindent-test
, directory
, exceptions
, filepath
, ghc-lib-parser >=9.2 && <9.11
, ghc-lib-parser >=9.2 && <9.13
, ghc-lib-parser-ex
, hindent
, hindent-internal
Expand Down Expand Up @@ -307,7 +307,7 @@ benchmark hindent-bench
, directory
, exceptions
, filepath
, ghc-lib-parser >=9.2 && <9.11
, ghc-lib-parser >=9.2 && <9.13
, ghc-lib-parser-ex
, hindent
, hindent-internal
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies:
- directory
- exceptions
- filepath
- ghc-lib-parser >= 9.2 && < 9.11
- ghc-lib-parser >= 9.2 && < 9.13
- ghc-lib-parser-ex
- monad-loops
- mtl
Expand Down
13 changes: 13 additions & 0 deletions src/HIndent/Ast/NodeComments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ fromEpAnn :: GHC.EpAnn a -> NodeComments
fromEpAnn = fromEpAnn' . filterOutEofAndPragmasFromAnn

fromEpAnn' :: GHC.EpAnn a -> NodeComments
#if MIN_VERSION_ghc_lib_parser(9, 12, 1)
fromEpAnn' GHC.EpAnn {..} = NodeComments {..}
where
commentsBefore = GHC.priorComments comments
commentsOnSameLine =
filter isCommentOnSameLine $ GHC.getFollowingComments comments
commentsAfter =
filter (not . isCommentOnSameLine) $ GHC.getFollowingComments comments
isCommentOnSameLine (GHC.L comAnn _) =
GHC.srcSpanEndLine (GHC.epaLocationRealSrcSpan entry)
== GHC.srcSpanStartLine (GHC.epaLocationRealSrcSpan comAnn)
#else
fromEpAnn' GHC.EpAnn {..} = NodeComments {..}
where
commentsBefore = GHC.priorComments comments
Expand All @@ -47,6 +59,7 @@ fromEpAnn' GHC.EpAnn {..} = NodeComments {..}
#if !MIN_VERSION_ghc_lib_parser(9, 10, 1)
fromEpAnn' GHC.EpAnnNotUsed = NodeComments [] [] []
#endif
#endif
filterOutEofAndPragmasFromAnn :: GHC.EpAnn ann -> GHC.EpAnn ann
filterOutEofAndPragmasFromAnn GHC.EpAnn {..} =
GHC.EpAnn {comments = filterOutEofAndPragmasFromComments comments, ..}
Expand Down
Loading