1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 12:23:08 +03:00

Use the simple carrier in util and the repl.

This commit is contained in:
Rob Rix 2019-09-30 16:57:51 -04:00
parent afc4e46942
commit 8dcf0bef24
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
2 changed files with 7 additions and 7 deletions

View File

@ -7,7 +7,7 @@ module Semantic.REPL
import Control.Abstract hiding (Continue, List, string)
import Control.Abstract.ScopeGraph (runScopeError)
import Control.Abstract.Heap (runHeapError)
import Control.Carrier.Parse.Measured
import Control.Carrier.Parse.Simple
import Control.Effect.Carrier
import Control.Effect.Catch
import Control.Effect.Lift
@ -35,7 +35,7 @@ import Numeric (readDec)
import Parsing.Parser (rubyParser)
import Prologue
import Semantic.Analysis
import Semantic.Config (logOptionsFromConfig)
import Semantic.Config (configTreeSitterParseTimeout, logOptionsFromConfig)
import Semantic.Distribute
import Semantic.Graph
import Semantic.Resolution
@ -70,7 +70,7 @@ repl proxy parser paths =
. runReader (TaskSession config "-" False logger statter)
. Files.runFiles
. runResolution
. runParse $ do
$ runParse (configTreeSitterParseTimeout config) $ do
blobs <- catMaybes <$> traverse readBlobFromFile (flip File (Language.reflect proxy) <$> paths)
package <- fmap (fmap quieterm) <$> parsePackage parser (Project (takeDirectory (maybe "/" fst (uncons paths))) blobs (Language.reflect proxy) [])
modules <- topologicalSort <$> runImportGraphToModules proxy (snd <$> package)

View File

@ -20,7 +20,7 @@ import Prelude hiding (readFile)
import Control.Abstract
import Control.Abstract.Heap (runHeapError)
import Control.Abstract.ScopeGraph (runScopeError)
import Control.Carrier.Parse.Measured
import Control.Carrier.Parse.Simple
import Control.Effect.Lift
import Control.Effect.Trace (runTraceByPrinting)
import Control.Exception (displayException)
@ -103,7 +103,7 @@ evaluateProject proxy parser paths = withOptions debugOptions $ \ config logger
-- Evaluate a project consisting of the listed paths.
evaluateProject' session proxy parser paths = do
res <- runTask session . runParse $ do
res <- runTask session $ asks configTreeSitterParseTimeout >>= \ timeout -> runParse timeout $ do
blobs <- catMaybes <$> traverse readBlobFromFile (flip File (Language.reflect proxy) <$> paths)
package <- fmap (quieterm . snd) <$> parsePackage parser (Project (takeDirectory (maybe "/" fst (uncons paths))) blobs (Language.reflect proxy) [])
modules <- topologicalSort <$> runImportGraphToModules proxy package
@ -122,8 +122,8 @@ parseFile parser = runTask' . (parse parser <=< readBlob . fileForPath)
parseFileQuiet parser = runTaskQuiet . (parse parser <=< readBlob . fileForPath)
runTask', runTaskQuiet :: ParseC TaskC a -> IO a
runTask' task = runTaskWithOptions debugOptions (runParse task) >>= either (die . displayException) pure
runTaskQuiet task = runTaskWithOptions defaultOptions (runParse task) >>= either (die . displayException) pure
runTask' task = runTaskWithOptions debugOptions (asks configTreeSitterParseTimeout >>= \ timeout -> runParse timeout task) >>= either (die . displayException) pure
runTaskQuiet task = runTaskWithOptions defaultOptions (asks configTreeSitterParseTimeout >>= \ timeout -> runParse timeout task) >>= either (die . displayException) pure
mergeErrors :: Either (SomeError (Sum errs)) (Either (SomeError err) result) -> Either (SomeError (Sum (err ': errs))) result
mergeErrors = either (\ (SomeError sum) -> Left (SomeError (weaken sum))) (either (\ (SomeError err) -> Left (SomeError (inject err))) Right)