Skip to content

Commit e1100c4

Browse files
committed
More compatibility changes
1 parent 35ee61a commit e1100c4

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

  • ghcide/src/Development/IDE/Plugin/Completions

ghcide/src/Development/IDE/Plugin/Completions/Context.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ module Development.IDE.Plugin.Completions.Context
1414
) where
1515

1616
import Control.DeepSeq (NFData (..), rwhnf)
17+
import Control.Monad (join)
1718
import Data.Generics (Data (..), GenericQ,
1819
extQ, mkQ)
1920
import Data.Hashable (Hashable)
20-
import Data.List.Extra (nubOrd)
21-
import Data.Maybe (fromJust, isJust,
22-
mapMaybe)
23-
import Data.List.Extra (nubOrd)
24-
import Data.Maybe (isJust, mapMaybe,
25-
maybeToList)
2621
import Data.List.Extra (nub)
2722
import Data.Maybe (isJust, mapMaybe,
2823
maybeToList)
@@ -100,10 +95,9 @@ groupedChunks n group getPos locate xs = go xs
10095
} : go rest
10196

10297
-- | Build lazy 'ContextChunk' by processing @n@ source items at a time.
103-
singletonChunk :: ContextGroup -> (a -> Maybe Range) -> (a -> Range -> ContextResult) -> a -> ContextChunk
104-
singletonChunk group getPos locate inp = Chunk s e group (locate inp)
105-
where
106-
Range s e = fromJust $ getPos inp
98+
singletonChunk :: ContextGroup -> (a -> Maybe Range) -> (a -> Range -> ContextResult) -> a -> Maybe ContextChunk
99+
singletonChunk group getPos locate inp = flip fmap (getPos inp) $
100+
\(Range s e) -> Chunk s e group (locate inp)
107101

108102
-- | Used during context finding, combines into the tightest interval.
109103
-- As an intuition, the primary interface is through
@@ -145,6 +139,11 @@ getContextMap pm =
145139
<> groupedChunks 10 ImportGroup rangeOf getImportContext hsmodImports
146140
<> groupedChunks 4 DeclarationGroup rangeOf getDeclContext hsmodDecls
147141
where
142+
#if MIN_VERSION_ghc(9,9,0)
143+
moduleChunk = maybeToList (singletonChunk HeaderGroup rangeOf getHeaderContext hsmodName)
144+
#else
145+
moduleChunk = maybeToList $ join $ fmap (singletonChunk HeaderGroup rangeOf getHeaderContext) hsmodName
146+
#endif
148147
HsModule {hsmodName, hsmodImports, hsmodDecls} =
149148
unLoc (pm_parsed_source pm)
150149

0 commit comments

Comments
 (0)