1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

Provide term spans to Evaluatable instances.

This commit is contained in:
Rob Rix 2018-05-09 15:03:27 -04:00
parent ecac6bcbd0
commit 668da46396
3 changed files with 10 additions and 4 deletions

View File

@ -57,6 +57,7 @@ type EvaluatableConstraints location term value effects =
, Reader (Environment location value)
, Reader ModuleInfo
, Reader PackageInfo
, Reader Span
, Resumable (AddressError location value)
, Resumable (EnvironmentError value)
, Resumable (EvalError value)

View File

@ -36,8 +36,8 @@ graph graphType renderer project
(Proxy :: Proxy '[ Evaluatable, Declarations1, FreeVariables1, Functor, Eq1, Ord1, Show1 ]) (projectLanguage project) = do
package <- parsePackage parser prelude project
let analyzeTerm = case graphType of
ImportGraph -> graphingLoadErrors
CallGraph -> graphingLoadErrors . graphingTerms
ImportGraph -> withTermSpans . graphingLoadErrors
CallGraph -> withTermSpans . graphingLoadErrors . graphingTerms
analyze runGraphAnalysis (evaluatePackageWith graphingModules analyzeTerm package) >>= extractGraph >>= case renderer of
JSONGraphRenderer -> pure . toOutput
DOTGraphRenderer -> pure . renderGraph
@ -47,6 +47,7 @@ graph graphType renderer project
runGraphAnalysis
= run
. evaluating
. runReader (lowerBound :: Span)
. runIgnoringTraces
. resumingLoadError
. resumingUnspecialized

View File

@ -14,6 +14,7 @@ import Data.Abstract.Type
import Data.Blob
import Data.File
import qualified Data.Language as Language
import Data.Semilattice.Lower
import qualified GHC.TypeLits as TypeLevel
import Language.Preluded
import Parsing.Parser
@ -29,6 +30,7 @@ justEvaluating
= runM
. fmap (first reassociate)
. evaluating
. runReader (lowerBound :: Span)
. runPrintingTraces
. runLoadError
. runValueError
@ -42,6 +44,7 @@ justEvaluating
evaluatingWithHoles
= runM
. evaluating
. runReader (lowerBound :: Span)
. runPrintingTraces
. resumingLoadError
. resumingUnspecialized
@ -57,6 +60,7 @@ checking
= runM
. fmap (first reassociate)
. evaluating
. runReader (lowerBound :: Span)
. runPrintingTraces
. providingLiveSet
. runLoadError
@ -88,8 +92,8 @@ rubyPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Ruby
pythonPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Python.Term))) (Just Language.Python)
-- Evaluate a project, starting at a single entrypoint.
evaluateProject parser lang prelude path = evaluatePackageWith id id <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
evaluateProjectWithCaching parser lang prelude path = evaluatePackageWith convergingModules cachingTerms <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
evaluateProject parser lang prelude path = evaluatePackageWith id withTermSpans <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
evaluateProjectWithCaching parser lang prelude path = evaluatePackageWith convergingModules (withTermSpans . cachingTerms) <$> runTask (readProject Nothing path lang [] >>= parsePackage parser prelude)
parseFile :: Parser term -> FilePath -> IO term