1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

make sure Util loads a prelude

This commit is contained in:
Patrick Thomson 2018-06-12 13:58:16 -04:00
parent ffbe4dbbda
commit 6d287d8cce

View File

@ -77,9 +77,23 @@ pythonPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Py
javaScriptPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath TypeScript.Term))) Language.JavaScript
-- Evaluate a project, starting at a single entrypoint.
evaluateProject parser lang prelude path = evaluatePackageWith id withTermSpans . fmap quieterm <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
evaluateProjectWithCaching parser lang prelude path = evaluatePackageWith convergingModules (withTermSpans . cachingTerms) . fmap quieterm <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
evaluateProject parser lang prelude path = evaluatePackageWith id withTermSpans . fmap quieterm <$> runTask (readProject Nothing path lang [] >>= addPrelude lang >>= parsePackage parser prelude)
evaluateProjectWithCaching parser lang prelude path = evaluatePackageWith convergingModules (withTermSpans . cachingTerms) . fmap quieterm <$> runTask (readProject Nothing path lang [] >>= addPrelude lang >>= parsePackage parser prelude)
addPrelude :: Member IO effs => Language.Language -> Concrete -> Eff effs Concrete
addPrelude l proj = do
let p = case l of
Language.Ruby -> rubyPrelude
Language.Python -> pythonPrelude
Language.TypeScript -> javaScriptPrelude
Language.JavaScript -> javaScriptPrelude
_ -> Nothing
case p of
Nothing -> pure proj
Just pth -> do
bl <- readBlobFromPath pth
pure $ proj { projectBlobs = bl : projectBlobs proj }
parseFile :: Parser term -> FilePath -> IO term
parseFile parser = runTask . (parse parser <=< readBlob . file)