1
1
mirror of https://github.com/github/semantic.git synced 2024-12-28 17:32:05 +03:00

Rename Files to Semantic.IO.

This commit is contained in:
Rob Rix 2017-11-27 13:09:03 -05:00
parent 1e95b0270e
commit 062d9cbfa9
6 changed files with 24 additions and 24 deletions

View File

@ -47,7 +47,6 @@ library
, Diffing.Algorithm.RWS.FeatureVector
, Diffing.Algorithm.SES
, Diffing.Interpreter
, Files
, Info
, Language
, Language.Markdown.Assignment
@ -75,6 +74,7 @@ library
, Renderer.TOC
, Semantic
, Semantic.CLI
, Semantic.IO
, Semantic.Log
, Semantic.Stat
, Semantic.Task

View File

@ -7,7 +7,6 @@ module Semantic.CLI
) where
import Control.Monad ((<=<))
import Files (languageForFilePath)
import Data.ByteString (ByteString)
import Data.Foldable (find)
import Data.Functor.Both hiding (fst, snd)
@ -20,8 +19,9 @@ import Language
import Options.Applicative hiding (action)
import Renderer
import qualified Paths_semantic_diff as Library (version)
import qualified Semantic.Task as Task
import Semantic.IO (languageForFilePath)
import qualified Semantic.Log as Log
import qualified Semantic.Task as Task
import System.IO (Handle, stdin, stdout)
import qualified Semantic (parseBlobs, diffBlobPairs)
import Text.Read

View File

@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings, TypeSynonymInstances, DeriveAnyClass, DuplicateRecordFields, ScopedTypeVariables, TupleSections #-}
module Files
module Semantic.IO
( readFile
, isDirectory
, readBlobPairsFromHandle
@ -60,7 +60,7 @@ readBlobsFromHandle = fmap toBlobs . readFromHandle
where toBlobs BlobParse{..} = fmap toBlob blobs
readBlobsFromPaths :: MonadIO m => [(FilePath, Maybe Language)] -> m [Blob.Blob]
readBlobsFromPaths = traverse (uncurry Files.readFile)
readBlobsFromPaths = traverse (uncurry Semantic.IO.readFile)
readBlobsFromDir :: MonadIO m => FilePath -> m [Blob.Blob]
readBlobsFromDir path = do

View File

@ -46,13 +46,13 @@ import Data.Term
import Data.Union
import Decorator (RAlgebra, decoratorWithAlgebra)
import Info hiding (Category(..))
import qualified Files
import Language
import Parser
import Parser.CMark
import Parser.TreeSitter
import System.Exit (die)
import System.IO (Handle, stderr)
import qualified Semantic.IO as IO
import Semantic.Log
import Semantic.Stat as Stat
import Semantic.Queue
@ -176,10 +176,10 @@ runTaskWithOptions options task = do
where
go :: Task a -> IO (Either SomeException a)
go = iterFreerA (\ task yield -> case task of
ReadBlobs (Left handle) -> (Files.readBlobsFromHandle handle >>= yield) `catchError` (pure . Left . toException)
ReadBlobs (Right paths@[(path, Nothing)]) -> (Files.isDirectory path >>= bool (Files.readBlobsFromPaths paths) (Files.readBlobsFromDir path) >>= yield) `catchError` (pure . Left . toException)
ReadBlobs (Right paths) -> (Files.readBlobsFromPaths paths >>= yield) `catchError` (pure . Left . toException)
ReadBlobPairs source -> (either Files.readBlobPairsFromHandle (traverse (traverse (uncurry Files.readFile))) source >>= yield) `catchError` (pure . Left . toException)
ReadBlobs (Left handle) -> (IO.readBlobsFromHandle handle >>= yield) `catchError` (pure . Left . toException)
ReadBlobs (Right paths@[(path, Nothing)]) -> (IO.isDirectory path >>= bool (IO.readBlobsFromPaths paths) (IO.readBlobsFromDir path) >>= yield) `catchError` (pure . Left . toException)
ReadBlobs (Right paths) -> (IO.readBlobsFromPaths paths >>= yield) `catchError` (pure . Left . toException)
ReadBlobPairs source -> (either IO.readBlobPairsFromHandle (traverse (traverse (uncurry IO.readFile))) source >>= yield) `catchError` (pure . Left . toException)
WriteToOutput destination contents -> either B.hPutStr B.writeFile destination contents >>= yield
WriteLog level message pairs -> queueLogMessage logger level message pairs >>= yield
WriteStat stat -> queue statter stat >>= yield

View File

@ -3,25 +3,25 @@
module Semantic.Util where
import Control.Monad.IO.Class
import Data.Blob
import Files
import Data.Record
import Data.Functor.Classes
import Diffing.Algorithm
import Data.Align.Generic
import Data.Blob
import Data.Diff
import Data.Functor.Both
import Data.Functor.Classes
import Data.Range
import Data.Record
import Data.Span
import Data.Term
import Diffing.Algorithm
import Diffing.Interpreter
import Parser
import Data.Functor.Both
import Data.Term
import Data.Diff
import Semantic
import Semantic.Task
import Renderer.TOC
import Data.Range
import Data.Span
import Semantic
import Semantic.IO as IO
import Semantic.Task
file :: MonadIO m => FilePath -> m Blob
file path = Files.readFile path (languageForFilePath path)
file path = IO.readFile path (languageForFilePath path)
diffWithParser :: (HasField fields Data.Span.Span,
HasField fields Range,

View File

@ -1,12 +1,12 @@
module CommandSpec where
import Files
import Data.Blob
import Data.Functor.Both as Both
import Data.Maybe
import Data.String
import Language
import Prelude hiding (readFile)
import Semantic.IO
import System.Exit (ExitCode(..))
import System.IO (IOMode(..), openFile)
import Test.Hspec hiding (shouldBe, shouldNotBe, shouldThrow, errorCall)