on master help sign in
Improvements to the IDE (#1006)
bec100bNeil Mitchell
src/Development/IDE/Functions/Compile.hs+2−2
@@ -444,8 +444,8 @@ parseFileContents preprocessor filename (time, contents) = do
444 dflags <- parsePragmasIntoDynFlags filename contents
444 dflags <- parsePragmasIntoDynFlags filename contents
445 case unP Parser.parseModule (mkPState dflags contents loc) of
445 case unP Parser.parseModule (mkPState dflags contents loc) of
446#ifdef USE_GHC
446#ifdef USE_GHC
447− PFailed getMessages _ _ ->
447+ PFailed _ logMsg msgErr ->
448− Ex.throwE $ toDiagnostics dflags $ snd $ getMessages dflags
448+ Ex.throwE $ mkErrorDoc dflags locErr msgErr
449#else
449#else
450 PFailed s ->
450 PFailed s ->
451 Ex.throwE $ toDiagnostics dflags $ snd $ getMessages s dflags
451 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
66-- | locate a module in the file system. Where we go from *daml to Haskell
66-- | locate a module in the file system. Where we go from *daml to Haskell
67locateModuleFile :: MonadIO m
67locateModuleFile :: MonadIO m
68 => DynFlags
68 => DynFlags
69+ -> [String]
69 -> (FilePath -> m Bool)
70 -> (FilePath -> m Bool)
70 -> ModuleName
71 -> ModuleName
71 -> m (Maybe FilePath)
72 -> m (Maybe FilePath)
72−locateModuleFile dflags doesExist modName = do
73+locateModuleFile dflags exts doesExist modName = do
73− let libPaths = importPaths dflags
74− let candidates = [ prefix </> M.moduleNameSlashes modName <.> "daml" | prefix <- libPaths ]
74+ let candidates = [ prefix </> M.moduleNameSlashes modName <.> ext | prefix <- importPaths dflags, ext <- exts]
75 findM doesExist candidates
75 findM doesExist candidates
76
76
77-- | locate a module in either the file system or the package database. Where we go from *daml to
77-- | 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
79locateModule
79locateModule
80 :: MonadIO m
80 :: MonadIO m
81 => DynFlags
81 => DynFlags
82+ -> [String]
82 -> (FilePath -> m Bool)
83 -> (FilePath -> m Bool)
83 -> Located ModuleName
84 -> Located ModuleName
84 -> Maybe FastString
85 -> Maybe FastString
85 -> m (Either [FileDiagnostic] Import)
86 -> m (Either [FileDiagnostic] Import)
86−locateModule dflags doesExist modName mbPkgName = do
87+locateModule dflags exts doesExist modName mbPkgName = do
87 case mbPkgName of
88 case mbPkgName of
88 -- if a package name is given we only go look for a package
89 -- if a package name is given we only go look for a package
89 Just _pkgName -> lookupInPackageDB dflags
90 Just _pkgName -> lookupInPackageDB dflags
90 Nothing -> do
91 Nothing -> do
91 -- first try to find the module as a file. If we can't find it try to find it in the package
92 -- first try to find the module as a file. If we can't find it try to find it in the package
92 -- database.
93 -- database.
93− mbFile <- locateModuleFile dflags doesExist $ unLoc modName
94+ mbFile <- locateModuleFile dflags exts doesExist $ unLoc modName
94 case mbFile of
95 case mbFile of
95 Nothing -> lookupInPackageDB dflags
96 Nothing -> lookupInPackageDB dflags
96 Just file -> return $ Right $ FileImport file
97 Just file -> return $ Right $ FileImport file
src/Development/IDE/State/Rules.hs+1−1
@@ -191,7 +191,7 @@ getLocatedImportsRule =
191 opt <- getOpts
191 opt <- getOpts
192 dflags <- liftIO $ Compile.getGhcDynFlags opt pm packageState
192 dflags <- liftIO $ Compile.getGhcDynFlags opt pm packageState
193 xs <- forM imports $ \(mbPkgName, modName) ->
193 xs <- forM imports $ \(mbPkgName, modName) ->
194− (modName, ) <$> locateModule dflags getFileExists modName mbPkgName
194+ (modName, ) <$> locateModule dflags (Compile.optExtensions opt) getFileExists modName mbPkgName
195 return (concat $ lefts $ map snd xs, Just $ map (second eitherToMaybe) xs)
195 return (concat $ lefts $ map snd xs, Just $ map (second eitherToMaybe) xs)
196
196
197
197
src/Development/IDE/Types/Options.hs+1
@@ -21,6 +21,7 @@ data IdeOptions = IdeOptions
21 -- the import path should be setup for that module.
21 -- the import path should be setup for that module.
22 , optPkgLocationOpts :: IdePkgLocationOptions
22 , optPkgLocationOpts :: IdePkgLocationOptions
23 , optWriteIface :: Bool
23 , optWriteIface :: Bool
24+ , optExtensions :: [String]
24
25
25 , optMbPackageName :: Maybe String
26 , optMbPackageName :: Maybe String
26
27