mirror of
https://github.com/github/semantic.git
synced 2024-12-30 10:27:45 +03:00
Add projectEntryPoints back
This commit is contained in:
parent
421cc0d1a1
commit
c20b882c5b
@ -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)
|
||||
|
@ -15,6 +15,7 @@ data Project = Project
|
||||
{ projectRootDir :: FilePath
|
||||
, projectFiles :: [File]
|
||||
, projectLanguage :: Language
|
||||
, projectEntryPoints :: [File]
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user