mirror of
https://github.com/github/semantic.git
synced 2025-01-06 23:46:21 +03:00
Split PackageInfo into a new datatype.
This commit is contained in:
parent
37535b1823
commit
0ebf115fae
@ -6,9 +6,14 @@ import Data.Abstract.ModuleTable as ModuleTable
|
||||
|
||||
type PackageName = Name
|
||||
|
||||
data PackageInfo = PackageInfo
|
||||
{ packageName :: Maybe PackageName
|
||||
, packageVersion :: Maybe Version
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
data Package term = Package
|
||||
{ packageName :: Maybe PackageName
|
||||
, packageVersion :: Maybe Version
|
||||
{ packageInfo :: PackageInfo
|
||||
, packageModules :: ModuleTable [Module term]
|
||||
, packageEntryPoints :: ModuleTable (Maybe Name)
|
||||
}
|
||||
@ -19,6 +24,6 @@ newtype Version = Version { versionString :: String }
|
||||
|
||||
|
||||
fromModules :: [Module term] -> Package term
|
||||
fromModules [] = Package Nothing Nothing mempty mempty
|
||||
fromModules (m:ms) = Package Nothing Nothing (ModuleTable.fromModules (m:ms)) entryPoints
|
||||
fromModules [] = Package (PackageInfo Nothing Nothing) mempty mempty
|
||||
fromModules (m:ms) = Package (PackageInfo Nothing Nothing) (ModuleTable.fromModules (m:ms)) entryPoints
|
||||
where entryPoints = ModuleTable.singleton (moduleName (moduleInfo m)) Nothing
|
||||
|
@ -181,7 +181,7 @@ parseFiles parser paths = traverse (parseFile parser (Just (dropFileName (head p
|
||||
|
||||
parsePackage :: PackageName -> Parser term -> [FilePath] -> IO (Package term)
|
||||
parsePackage name parser files = setName . Package.fromModules <$> parseFiles parser files
|
||||
where setName p = p { Package.packageName = Just name }
|
||||
where setName p = p { packageInfo = PackageInfo (Just name) Nothing }
|
||||
|
||||
|
||||
-- Read a file from the filesystem into a Blob.
|
||||
|
Loading…
Reference in New Issue
Block a user