1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Allow evaling a single file again

This commit is contained in:
Timothy Clem 2018-04-25 12:47:34 -07:00
parent 8e50c3b5f9
commit 2bcae799ce
2 changed files with 8 additions and 6 deletions

View File

@ -56,11 +56,11 @@ parsePackage parser preludeFile project@Project{..} = do
parseModules parser project@Project{..} = distributeFor allFiles (WrapTask . parseModule parser (Just projectRootDir)) parseModules parser project@Project{..} = distributeFor allFiles (WrapTask . parseModule parser (Just projectRootDir))
where allFiles = projectAllFiles project where allFiles = projectAllFiles project
-- | Parse a file into a 'Module'. -- | Parse a file into a 'Module'.
parseModule :: Members '[Files, Task] effs => Parser term -> Maybe FilePath -> File -> Eff effs (Module term) parseModule :: Members '[Files, Task] effs => Parser term -> Maybe FilePath -> File -> Eff effs (Module term)
parseModule parser rootDir file = do parseModule parser rootDir file = do
blob <- readBlob file blob <- readBlob file
moduleForBlob rootDir blob <$> parse parser blob moduleForBlob rootDir blob <$> parse parser blob
type ImportGraphAnalysis term effects value = type ImportGraphAnalysis term effects value =

View File

@ -41,7 +41,6 @@ import qualified Language.Ruby.Assignment as Ruby
import qualified Language.TypeScript.Assignment as TypeScript import qualified Language.TypeScript.Assignment as TypeScript
-- type TestEvaluating term = Evaluating Precise term (Value Precise)
type JustEvaluating term = Evaluating (Located Precise term) term (Value (Located Precise term)) type JustEvaluating term = Evaluating (Located Precise term) term (Value (Located Precise term))
type EvaluatingWithHoles term = BadModuleResolutions (BadVariables (BadValues (Quietly (Evaluating (Located Precise term) term (Value (Located Precise term)))))) type EvaluatingWithHoles term = BadModuleResolutions (BadVariables (BadValues (Quietly (Evaluating (Located Precise term) term (Value (Located Precise term))))))
type ImportGraphingWithHoles term = ImportGraphing (EvaluatingWithHoles term) type ImportGraphingWithHoles term = ImportGraphing (EvaluatingWithHoles term)
@ -58,6 +57,9 @@ pythonPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Py
-- Evaluate a project, starting at a single entrypoint. -- Evaluate a project, starting at a single entrypoint.
evaluateProject parser prelude path = evaluatePackage <$> runTask (readProject Nothing (file path :| []) >>= parsePackage parser prelude) evaluateProject parser prelude path = evaluatePackage <$> runTask (readProject Nothing (file path :| []) >>= parsePackage parser prelude)
evalRubyFile path = runAnalysis @(JustEvaluating Ruby.Term) <$> evaluateFile rubyParser path
evaluateFile parser path = evaluateModule <$> runTask (parseModule parser Nothing (file path))
-- Read and parse a file. -- Read and parse a file.
parseFile :: Parser term -> FilePath -> IO term parseFile :: Parser term -> FilePath -> IO term