From 19b47833cd24f0cb79eeea83fae8ffaf213548b4 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 6 Mar 2018 08:56:29 -0800 Subject: [PATCH] TypeScript eval helpers --- src/Semantic/Util.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Semantic/Util.hs b/src/Semantic/Util.hs index aae481164..63fd3c36e 100644 --- a/src/Semantic/Util.hs +++ b/src/Semantic/Util.hs @@ -24,9 +24,11 @@ import Semantic.Task import qualified Language.Ruby.Assignment as Ruby import qualified Language.Python.Assignment as Python +import qualified Language.TypeScript.Assignment as TypeScript type RubyValue = Value Precise (Term (Union Ruby.Syntax) (Record Location)) type PythonValue = Value Precise (Term (Union Python.Syntax) (Record Location)) +type TypeScriptValue = Value Precise (Term (Union TypeScript.Syntax) (Record Location)) file :: MonadIO m => FilePath -> m Blob file path = fromJust <$> IO.readFile path (languageForFilePath path) @@ -40,7 +42,6 @@ evaluateRubyFiles paths = do (t:ts) <- runTask $ traverse (parse rubyParser) blobs pure $ evaluates @RubyValue (zip bs ts) (b, t) - -- Python evaluatePythonFile path = evaluate @PythonValue <$> (file path >>= runTask . parse pythonParser) @@ -50,6 +51,15 @@ evaluatePythonFiles paths = do (t:ts) <- runTask $ traverse (parse pythonParser) blobs pure $ evaluates @PythonValue (zip bs ts) (b, t) +-- TypeScript +evaluateTypeScriptFile path = Prelude.fst . evaluate @TypeScriptValue <$> + (file path >>= runTask . parse typescriptParser) + +evaluateTypeScriptFiles paths = do + blobs@(b:bs) <- traverse file paths + (t:ts) <- runTask $ traverse (parse typescriptParser) blobs + pure $ evaluates @TypeScriptValue (zip bs ts) (b, t) + -- Diff helpers diffWithParser :: (HasField fields Data.Span.Span,