mirror of
https://github.com/github/semantic.git
synced 2024-12-21 13:51:44 +03:00
TypeScript eval helpers
This commit is contained in:
parent
eecbe4bb45
commit
19b47833cd
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user