1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Evaluate Ruby files using the helper.

This commit is contained in:
Rob Rix 2018-03-08 12:50:56 -05:00
parent 5887ba194f
commit e912723b92

View File

@ -37,13 +37,11 @@ file :: MonadIO m => FilePath -> m Blob
file path = fromJust <$> IO.readFile path (languageForFilePath path)
-- Ruby
evaluateRubyFile path = Prelude.fst . evaluate @RubyValue <$>
(file path >>= runTask . parse rubyParser)
evaluateRubyFile path = Prelude.fst . evaluate @RubyValue . snd <$> parseFile rubyParser path
evaluateRubyFiles paths = do
blobs@(b:bs) <- traverse file paths
(t:ts) <- runTask $ traverse (parse rubyParser) blobs
pure $ evaluates @RubyValue (zip bs ts) (b, t)
first:rest <- traverse (parseFile rubyParser) paths
pure $ evaluates @RubyValue rest first
-- Python
typecheckPythonFile path = run @(CachingAnalysis (Evaluating Python.Term Type (CachingEffects Python.Term Type (EvaluatingEffects Python.Term Type)))) . evaluateModule <$> (file path >>= runTask . parse pythonParser)
@ -57,8 +55,8 @@ evaluateDeadTracePythonFile path = run @(DeadCodeAnalysis PythonTracer) . evalua
evaluatePythonFile path = evaluate @PythonValue . snd <$> parseFile pythonParser path
evaluatePythonFiles paths = do
pair:pairs <- traverse (parseFile pythonParser) paths
pure $ evaluates @PythonValue pairs pair
first:rest <- traverse (parseFile pythonParser) paths
pure $ evaluates @PythonValue rest first
parseFile parser path = runTask (file path >>= fmap . (,) <*> parse parser)