Skip to content

Commit 64f6c6a

Browse files
authored
Fix ModLocation creation (#414)
* Fix ModLocation creation * Simplify
1 parent 4e89d45 commit 64f6c6a

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/Development/IDE/Core/Compile.hs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import Lexer
4242
import ErrUtils
4343
#endif
4444

45+
import Finder
4546
import qualified GHC
4647
import GhcMonad
4748
import GhcPlugins as GHC hiding (fst3, (<>))
@@ -212,7 +213,7 @@ upgradeWarningToError (nfp, sh, fd) =
212213
hideDiag :: DynFlags -> (WarnReason, FileDiagnostic) -> (WarnReason, FileDiagnostic)
213214
hideDiag originalFlags (Reason warning, (nfp, _sh, fd))
214215
| not (wopt warning originalFlags) = (Reason warning, (nfp, HideDiag, fd))
215-
hideDiag _originalFlags t = t
216+
hideDiag _originalFlags t = t
216217

217218
addRelativeImport :: NormalizedFilePath -> ParsedModule -> DynFlags -> DynFlags
218219
addRelativeImport fp modu dflags = dflags
@@ -317,18 +318,8 @@ getModSummaryFromBuffer
317318
getModSummaryFromBuffer fp contents dflags parsed = do
318319
(modName, imports) <- liftEither $ getImportsParsed dflags parsed
319320

320-
let modLoc = ModLocation
321-
{ ml_hs_file = Just fp
322-
, ml_hi_file = derivedFile "hi"
323-
, ml_obj_file = derivedFile "o"
324-
#if MIN_GHC_API_VERSION(8,8,0)
325-
, ml_hie_file = derivedFile "hie"
326-
#endif
327-
-- This does not consider the dflags configuration
328-
-- (-osuf and -hisuf, object and hi dir.s).
329-
-- However, we anyway don't want to generate them.
330-
}
331-
InstalledUnitId unitId = thisInstalledUnitId dflags
321+
modLoc <- liftIO $ mkHomeModLocation dflags modName fp
322+
let InstalledUnitId unitId = thisInstalledUnitId dflags
332323
return $ ModSummary
333324
{ ms_mod = mkModule (fsToUnitId unitId) modName
334325
, ms_location = modLoc
@@ -353,11 +344,7 @@ getModSummaryFromBuffer fp contents dflags parsed = do
353344
, ms_parsed_mod = Nothing
354345
}
355346
where
356-
(sourceType, derivedFile) =
357-
let (stem, ext) = splitExtension fp in
358-
if "-boot" `isSuffixOf` ext
359-
then (HsBootFile, \newExt -> stem <.> newExt ++ "-boot")
360-
else (HsSrcFile , \newExt -> stem <.> newExt)
347+
sourceType = if "-boot" `isSuffixOf` takeExtension fp then HsBootFile else HsSrcFile
361348

362349

363350
-- | Given a buffer, flags, file path and module summary, produce a

0 commit comments

Comments
 (0)