1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Remove readProjectEntry

This commit is contained in:
joshvera 2018-04-25 12:10:33 -04:00
parent 0c8450edb6
commit f7e6609069
7 changed files with 5 additions and 23 deletions

View File

@ -11,7 +11,6 @@ module Semantic.IO
, NoLanguageForBlob(..)
, readBlob
, readProject
, readProjectEntry
, readBlobs
, readBlobPairs
, writeToOutput
@ -98,17 +97,6 @@ readProjectFromPaths path lang = do
toFile path = File path (Just lang)
exts = extensionsForLanguage lang
readProjectEntryFromPath :: MonadIO m => FilePath -> Language -> m Project
readProjectEntryFromPath path lang = do
isDir <- isDirectory path
let (filterFun, entryPoints) = if isDir then (id, []) else (filter (/= path), [toFile path])
paths <- liftIO $ filterFun <$> fmap fold (globDir (compile . mappend "**/*." <$> exts) rootDir)
pure $ Project rootDir (toFile <$> paths) lang entryPoints
where
rootDir = takeDirectory path
toFile path = File path (Just lang)
exts = extensionsForLanguage lang
readBlobsFromDir :: MonadIO m => FilePath -> m [Blob.Blob]
readBlobsFromDir path = do
paths <- liftIO (globDir1 (compile "[^vendor]**/*[.rb|.js|.tsx|.go|.py]") path)
@ -174,9 +162,6 @@ readBlobPairs = send . ReadBlobPairs
readProject :: Member Files effs => FilePath -> Language -> Eff effs Project
readProject dir = send . ReadProject dir
readProjectEntry :: Member Files effs => FilePath -> Language -> Eff effs Project
readProjectEntry file = send . ReadProjectEntry file
-- | A task which writes a 'B.ByteString' to a 'Handle' or a 'FilePath'.
writeToOutput :: Member Files effs => Either Handle FilePath -> B.ByteString -> Eff effs ()
writeToOutput path = send . WriteToOutput path
@ -188,7 +173,6 @@ data Files out where
ReadBlobs :: Either Handle [File] -> Files [Blob.Blob]
ReadBlobPairs :: Either Handle [Both File] -> Files [Blob.BlobPair]
ReadProject :: FilePath -> Language -> Files Project
ReadProjectEntry :: FilePath -> Language -> Files Project
WriteToOutput :: Either Handle FilePath -> B.ByteString -> Files ()
-- | Run a 'Files' effect in 'IO'.
@ -200,7 +184,6 @@ runFiles = interpret $ \ files -> case files of
ReadBlobs (Right paths) -> rethrowing (readBlobsFromPaths paths)
ReadBlobPairs source -> rethrowing (either readBlobPairsFromHandle (traverse (runBothWith readFilePair)) source)
ReadProject dir language -> rethrowing (readProjectFromPaths dir language)
ReadProjectEntry file language -> rethrowing (readProjectEntryFromPath file language)
WriteToOutput destination contents -> liftIO (either B.hPutStr B.writeFile destination contents)

View File

@ -58,7 +58,6 @@ pythonPrelude = Just $ File (TypeLevel.symbolVal (Proxy :: Proxy (PreludePath Py
-- Evaluate a project, starting at a single entrypoint.
evaluateProject parser lang prelude path = evaluatePackage <$> runTask (readProject path lang >>= parsePackage parser prelude)
evaluateProjectEntry parser lang prelude path = evaluatePackage <$> runTask (readProjectEntry path lang >>= parsePackage parser prelude)
parseFile :: Parser term -> FilePath -> IO term
parseFile parser = runTask . (parse parser <=< readBlob . file)

View File

@ -32,4 +32,4 @@ spec = parallel $ do
where
fixtures = "test/fixtures/go/analysis/"
evaluate entry = evalGoProject (fixtures <> entry)
evalGoProject path = runAnalysis @(TestEvaluating Go.Term) <$> evaluateProjectEntry goParser Language.Go Nothing path
evalGoProject path = runAnalysis @(TestEvaluating Go.Term) <$> evaluateProject goParser Language.Go Nothing path

View File

@ -36,4 +36,4 @@ spec = parallel $ do
where
fixtures = "test/fixtures/php/analysis/"
evaluate entry = evalPHPProject (fixtures <> entry)
evalPHPProject path = runAnalysis @(TestEvaluating PHP.Term) <$> evaluateProjectEntry phpParser Language.PHP Nothing path
evalPHPProject path = runAnalysis @(TestEvaluating PHP.Term) <$> evaluateProject phpParser Language.PHP Nothing path

View File

@ -51,4 +51,4 @@ spec = parallel $ do
addr = Address . Precise
fixtures = "test/fixtures/python/analysis/"
evaluate entry = evalPythonProject (fixtures <> entry)
evalPythonProject path = runAnalysis @(TestEvaluating Python.Term) <$> evaluateProjectEntry pythonParser Language.Python pythonPrelude path
evalPythonProject path = runAnalysis @(TestEvaluating Python.Term) <$> evaluateProject pythonParser Language.Python pythonPrelude path

View File

@ -72,4 +72,4 @@ spec = parallel $ do
addr = Address . Precise
fixtures = "test/fixtures/ruby/analysis/"
evaluate entry = evalRubyProject (fixtures <> entry)
evalRubyProject path = runAnalysis @(TestEvaluating Ruby.Term) <$> evaluateProjectEntry rubyParser Language.Ruby rubyPrelude path
evalRubyProject path = runAnalysis @(TestEvaluating Ruby.Term) <$> evaluateProject rubyParser Language.Ruby rubyPrelude path

View File

@ -43,4 +43,4 @@ spec = parallel $ do
where
fixtures = "test/fixtures/typescript/analysis/"
evaluate entry = evalTypeScriptProject (fixtures <> entry)
evalTypeScriptProject path = runAnalysis @(TestEvaluating TypeScript.Term) <$> evaluateProjectEntry typescriptParser Language.TypeScript Nothing path
evalTypeScriptProject path = runAnalysis @(TestEvaluating TypeScript.Term) <$> evaluateProject typescriptParser Language.TypeScript Nothing path