From 32c2e926608de18c1e64285dafce6f8e51cc59ed Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 12 Feb 2018 14:28:56 -0800 Subject: [PATCH] Couple of extra helper utils --- src/Semantic/Util.hs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index 4b441c5cc..c83ece3be 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -21,8 +21,23 @@ import Semantic import Semantic.IO as IO import Semantic.Task +import Data.AST +import Data.Union +import Data.Abstract.Value +import Data.Abstract.Address +import qualified Language.Python.Assignment as Python + +type PythonValue = Value Precise (Term (Union Python.Syntax) (Record Location)) + file :: MonadIO m => FilePath -> m Blob -file path = IO.readFile path (languageForFilePath path) >>= pure . fromJust +file path = fromJust <$> IO.readFile path (languageForFilePath path) + +files :: MonadIO m => [FilePath] -> m [Blob] +files = traverse file + +parsePythonFiles :: [FilePath] -> IO [Python.Term] +parsePythonFiles paths = files paths + >>= runTask . traverse (parse pythonParser) diffWithParser :: (HasField fields Data.Span.Span, HasField fields Range, @@ -49,4 +64,4 @@ diffBlobWithParser :: (HasField fields Data.Span.Span, -> Task (Term syntax (Record (Maybe Declaration : fields))) diffBlobWithParser parser = run (\ blob -> parse parser blob >>= decorate (declarationAlgebra blob)) where - run parse sourceBlob = parse sourceBlob + run parse = parse