From c20b882c5b826d0d204d0c69f56d22d5620c56da Mon Sep 17 00:00:00 2001 From: joshvera Date: Tue, 24 Apr 2018 16:14:01 -0400 Subject: [PATCH] Add projectEntryPoints back --- src/Data/Abstract/Package.hs | 9 +++++---- src/Data/File.hs | 1 + src/Semantic/Graph.hs | 4 ++-- src/Semantic/IO.hs | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Data/Abstract/Package.hs b/src/Data/Abstract/Package.hs index 61ea2520b..5b5d26cca 100644 --- a/src/Data/Abstract/Package.hs +++ b/src/Data/Abstract/Package.hs @@ -33,10 +33,11 @@ data Package term = Package } deriving (Eq, Functor, Ord, Show) -fromModules :: PackageName -> Maybe Version -> Maybe (Module term) -> [Module term] -> Package term -fromModules name version prelude = Package (PackageInfo name version) . go prelude +fromModules :: PackageName -> Maybe Version -> Maybe (Module term) -> Int -> [Module term] -> Package term +fromModules name version prelude entryPoints = Package (PackageInfo name version) . go prelude where go :: Maybe (Module term) -> [Module term] -> PackageBody term go p [] = PackageBody mempty p mempty - go p modules = PackageBody (ModuleTable.fromModules modules) p entryPoints - where entryPoints = ModuleTable . Map.fromList $ (,Nothing) . modulePath . moduleInfo <$> modules + go p modules = PackageBody (ModuleTable.fromModules modules) p entryPoints' + where + entryPoints' = ModuleTable . Map.fromList $ (,Nothing) . modulePath . moduleInfo <$> if entryPoints == 0 then modules else (take entryPoints modules) diff --git a/src/Data/File.hs b/src/Data/File.hs index 89c51c39f..91498f753 100644 --- a/src/Data/File.hs +++ b/src/Data/File.hs @@ -15,6 +15,7 @@ data Project = Project { projectRootDir :: FilePath , projectFiles :: [File] , projectLanguage :: Language + , projectEntryPoints :: [File] } deriving (Eq, Ord, Show) diff --git a/src/Semantic/Graph.hs b/src/Semantic/Graph.hs index 52480dd32..1ee7ba8a7 100644 --- a/src/Semantic/Graph.hs +++ b/src/Semantic/Graph.hs @@ -49,13 +49,13 @@ parsePackage :: Members '[Distribute WrappedTask, Files, Task] effs -> Eff effs (Package term) parsePackage parser preludeFile project@Project{..} = do prelude <- traverse (parseModule parser Nothing) preludeFile - Package.fromModules n Nothing prelude <$> parseModules parser project + Package.fromModules n Nothing prelude (length projectEntryPoints) <$> parseModules parser project where n = name (projectName project) -- | Parse all files in a project into 'Module's. parseModules :: Members '[Distribute WrappedTask, Files, Task] effs => Parser term -> Project -> Eff effs [Module term] - parseModules parser project@Project{..} = distributeFor projectFiles (WrapTask . parseModule parser (Just projectRootDir)) + parseModules parser project@Project{..} = distributeFor (projectEntryPoints <> projectFiles) (WrapTask . parseModule parser (Just projectRootDir)) -- | Parse a file into a 'Module'. parseModule :: Members '[Files, Task] effs => Parser term -> Maybe FilePath -> File -> Eff effs (Module term) diff --git a/src/Semantic/IO.hs b/src/Semantic/IO.hs index 66fa16ad6..695ebedda 100644 --- a/src/Semantic/IO.hs +++ b/src/Semantic/IO.hs @@ -90,7 +90,7 @@ readBlobsFromPaths files = catMaybes <$> traverse readFile files readProjectFromPaths :: MonadIO m => FilePath -> Language -> m Project readProjectFromPaths rootDir lang = do paths <- liftIO $ fmap fold (globDir (compile . mappend "**/*." <$> exts) rootDir) - pure $ Project rootDir (toFile <$> paths) lang + pure $ Project rootDir (toFile <$> paths) lang [] where toFile path = File path (Just lang) exts = extensionsForLanguage lang @@ -98,7 +98,7 @@ readProjectFromPaths rootDir lang = do readProjectEntryFromPath :: MonadIO m => FilePath -> Language -> m Project readProjectEntryFromPath path lang = do paths <- liftIO $ filter (/= path) <$> fmap fold (globDir (compile . mappend "**/*." <$> exts) rootDir) - pure $ Project rootDir (toFile <$> (path : paths)) lang + pure $ Project rootDir (toFile <$> (path : paths)) lang [toFile path] where rootDir = takeDirectory path toFile path = File path (Just lang)