Skip to content

Commit c440682

Browse files
Account for boot files in processDependencyInformation
1 parent eb1bfc9 commit c440682

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

ghcide/src/Development/IDE/Import/DependencyInformation.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ import Development.IDE.GHC.Compat
5353
import Development.IDE.GHC.Compat.Util (Fingerprint)
5454
import qualified Development.IDE.GHC.Compat.Util as Util
5555
import Development.IDE.GHC.Orphans ()
56-
import Development.IDE.Import.FindImports (ArtifactsLocation (..))
56+
import Development.IDE.Import.FindImports (ArtifactsLocation (..),
57+
isBootLocation)
5758
import Development.IDE.Types.Diagnostics
5859
import Development.IDE.Types.Location
5960
import GHC.Generics (Generic)
@@ -273,7 +274,17 @@ processDependencyInformation RawDependencyInformation{..} rawBootMap mg shallowF
273274
foldr (\(p, cs) res ->
274275
let new = IntMap.fromList (map (, IntSet.singleton (coerce p)) (coerce cs))
275276
in IntMap.unionWith IntSet.union new res ) IntMap.empty successEdges
276-
reverseModuleMap = mkModuleEnv $ map (\(i,sm) -> (showableModule sm, FilePathId i)) $ IntMap.toList rawModuleMap
277+
-- Map 'Module' to 'FilePathId', but skip hs-boot files: 'Module'
278+
-- does not distinguish boot from non-boot, so the real source file
279+
-- and its hs-boot share the same key. Callers (notably the
280+
-- 'GetLinkable' rule via 'lookupModuleFile') need the non-boot
281+
-- file because hs-boot files don't have linkables.
282+
reverseModuleMap = mkModuleEnv
283+
[ (showableModule sm, FilePathId i)
284+
| (i, sm) <- IntMap.toList rawModuleMap
285+
, Just al <- [IntMap.lookup i (idToPathMap rawPathIdMap)]
286+
, not (isBootLocation al)
287+
]
277288

278289

279290
-- | Given a dependency graph, buildResultGraph detects and propagates errors in that graph as follows:

ghcide/src/Development/IDE/Import/FindImports.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ data Import
4141
data ArtifactsLocation = ArtifactsLocation
4242
{ artifactFilePath :: !NormalizedFilePath
4343
, artifactModLocation :: !(Maybe ModLocation)
44-
, artifactIsSource :: !Bool -- ^ True if a module is a source input
44+
, artifactIsSource :: !Bool -- ^ 'True' for a real Haskell source file ('HsSrcFile');
45+
-- 'False' for a boot ('HsBootFile') or signature ('HsigFile') file.
4546
, artifactModule :: !(Maybe Module)
4647
} deriving Show
4748

0 commit comments

Comments
 (0)