on master help sign in
Improvements to the IDE (#1006)

* Make the extensions of the Haskell files configurable * Make sure we capture the errors from parsing, not the warnings

commitbec100b635987bb04975a7116c81faf80fc6daa1 authorNeil Mitchell <35463327+neil-da@users.noreply.github.com> dateWed 8 May 2019, 14:27 (7 years ago) parent73b9de2
4 files changed+10−8
src/Development/IDE/Functions/Compile.hs+2−2 src/Development/IDE/Functions/FindImports.hs+6−5 src/Development/IDE/State/Rules.hs+1−1 src/Development/IDE/Types/Options.hs+1
src/Development/IDE/Functions/Compile.hs+2−2
@@ -444,8 +444,8 @@ parseFileContents preprocessor filename (time, contents) = do
444444 dflags <- parsePragmasIntoDynFlags filename contents
445445 case unP Parser.parseModule (mkPState dflags contents loc) of
446446#ifdef USE_GHC
447− PFailed getMessages _ _ ->
448− Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
447+ PFailed _ logMsg msgErr ->
448+ Ex.throwE $ mkErrorDoc dflags locErr msgErr
449449#else
450450 PFailed s ->
451451 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
src/Development/IDE/Functions/FindImports.hs+6−5
@@ -66,12 +66,12 @@ getImportsParsed dflags (L loc parsed) = do
6666-- | locate a module in the file system. Where we go from *daml to Haskell
6767locateModuleFile :: MonadIO m
6868 => DynFlags
69+ -> [String]
6970 -> (FilePath -> m Bool)
7071 -> ModuleName
7172 -> m (Maybe FilePath)
72−locateModuleFile dflags doesExist modName = do
73− let libPaths = importPaths dflags
74− let candidates = [ prefix </> M.moduleNameSlashes modName <.> "daml" | prefix <- libPaths ]
73+locateModuleFile dflags exts doesExist modName = do
74+ let candidates = [ prefix </> M.moduleNameSlashes modName <.> ext | prefix <- importPaths dflags, ext <- exts]
7575 findM doesExist candidates
7676
7777-- | locate a module in either the file system or the package database. Where we go from *daml to
@@ -79,18 +79,19 @@ locateModuleFile dflags doesExist modName = do
7979locateModule
8080 :: MonadIO m
8181 => DynFlags
82+ -> [String]
8283 -> (FilePath -> m Bool)
8384 -> Located ModuleName
8485 -> Maybe FastString
8586 -> m (Either [FileDiagnostic] Import)
86−locateModule dflags doesExist modName mbPkgName = do
87+locateModule dflags exts doesExist modName mbPkgName = do
8788 case mbPkgName of
8889 -- if a package name is given we only go look for a package
8990 Just _pkgName -> lookupInPackageDB dflags
9091 Nothing -> do
9192 -- first try to find the module as a file. If we can't find it try to find it in the package
9293 -- database.
93− mbFile <- locateModuleFile dflags doesExist $ unLoc modName
94+ mbFile <- locateModuleFile dflags exts doesExist $ unLoc modName
9495 case mbFile of
9596 Nothing -> lookupInPackageDB dflags
9697 Just file -> return $ Right $ FileImport file
src/Development/IDE/State/Rules.hs+1−1
@@ -191,7 +191,7 @@ getLocatedImportsRule =
191191 opt <- getOpts
192192 dflags <- liftIO $ Compile.getGhcDynFlags opt pm packageState
193193 xs <- forM imports $ \(mbPkgName, modName) ->
194− (modName, ) <$> locateModule dflags getFileExists modName mbPkgName
194+ (modName, ) <$> locateModule dflags (Compile.optExtensions opt) getFileExists modName mbPkgName
195195 return (concat $ lefts $ map snd xs, Just $ map (second eitherToMaybe) xs)
196196
197197
src/Development/IDE/Types/Options.hs+1
@@ -21,6 +21,7 @@ data IdeOptions = IdeOptions
2121 -- the import path should be setup for that module.
2222 , optPkgLocationOpts :: IdePkgLocationOptions
2323 , optWriteIface :: Bool
24+ , optExtensions :: [String]
2425
2526 , optMbPackageName :: Maybe String
2627