1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

preliminary implementation of findFiles

This commit is contained in:
Patrick Thomson 2018-06-11 16:18:16 -04:00
parent ea1b44085a
commit 084129cde0
3 changed files with 12 additions and 4 deletions

View File

@ -129,9 +129,17 @@ maybeThese a b = case (a, b) of
(Just a, Just b) -> pure (These a b)
_ -> throwError (SomeException EmptyPairProvided)
-- TODO: write some tests so we can be sure this actually works
-- and does what findFileInDir does
findFiles :: Member (Exc SomeException) effs
=> Concrete
-> FilePath
-> [String]
-> Eff effs [FilePath]
findFiles _ _ _ = throwError (SomeException TODO)
-> [FilePath]
findFiles Project{..} dir exts = do
p <- blobPath <$> projectBlobs
guard (p == dir)
guard (takeExtension p `elem` exts)
-- TODO: not clear to me the best way to ensure these are in the
-- exclude directories
pure p

View File

@ -289,7 +289,7 @@ runFilesGuided = interpret $ \files -> case files of
Write _ _ -> throwError (SomeException WritesNotSupported)
Read (FromPath path) -> get >>= \p -> Project.readBlobFromPath p path
Read (FromPathPair paths) -> get >>= \p -> runBothWith (Project.readBlobPair p) paths
FindFiles dir exts excludeDirs -> get >>= \p -> Project.findFiles (p { Project.projectExcludeDirs = excludeDirs }) dir exts
FindFiles dir exts excludeDirs -> get >>= \p -> pure (Project.findFiles (p { Project.projectExcludeDirs = excludeDirs }) dir exts)
ReadProject{} -> get
-- | Catch exceptions in 'IO' actions embedded in 'Eff', handling them with the passed function.

View File

@ -30,7 +30,7 @@ import Data.Bifunctor (first)
import Data.Blob as X
import Data.ByteString.Builder (toLazyByteString)
import Data.ByteString.Lazy (toStrict)
import Data.Project as X
import Data.Project as X hiding (findFiles)
import Data.Functor.Listable as X
import Data.Language as X
import Data.List.NonEmpty as X (NonEmpty(..))