mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
remove unused functions
This commit is contained in:
parent
38be124258
commit
f0b96e793d
@ -88,6 +88,7 @@ graphToAdjList = taggedGraphToAdjList . tagGraph
|
||||
-- Using a PBGraph as the accumulator for the fold would incur
|
||||
-- significant overhead associated with Vector concatenation.
|
||||
-- We use this and then pay the O(v + e) to-Vector cost once.
|
||||
-- The fields are strict because we have StrictData on.
|
||||
data Acc = Acc [Vertex] (HashSet Edge)
|
||||
|
||||
-- Convert a graph with tagged members to a protobuf-compatible adjacency list.
|
||||
|
@ -12,9 +12,6 @@ module Data.Project (
|
||||
, projectEntryPoints
|
||||
, projectFiles
|
||||
, readFile
|
||||
, readBlobFromPath
|
||||
, readBlobPair
|
||||
, addPrelude
|
||||
-- * Files
|
||||
, File (..)
|
||||
, file
|
||||
@ -25,11 +22,8 @@ import Prologue hiding (throwError)
|
||||
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Exception
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Blob
|
||||
import qualified Data.ByteString as B
|
||||
import Data.Language
|
||||
import Data.Source
|
||||
import qualified Data.Text as T
|
||||
import Debug.Trace
|
||||
import Proto3.Suite
|
||||
@ -92,7 +86,6 @@ projectEntryPoints (Project {..})= foldr go [] projectBlobs
|
||||
projectFiles :: Concrete -> [File]
|
||||
projectFiles = fmap toFile . projectBlobs where
|
||||
|
||||
|
||||
data File = File
|
||||
{ filePath :: FilePath
|
||||
, fileLanguage :: Language
|
||||
@ -102,37 +95,14 @@ file :: FilePath -> File
|
||||
file path = File path (languageForFilePath path)
|
||||
where languageForFilePath = languageForType . takeExtension
|
||||
|
||||
-- This is kind of a wart; Blob should really hold a 'File'.
|
||||
toFile :: Blob -> File
|
||||
toFile (Blob _ p l) = File p l
|
||||
|
||||
data ProjectException
|
||||
= FileNotFound FilePath
|
||||
| EmptyPairProvided
|
||||
| PairNotFound (Both FilePath)
|
||||
| HandleNotSupported
|
||||
| WritesNotSupported
|
||||
| NoLanguagesSpecified
|
||||
| UnknownLanguage
|
||||
| MultipleLanguagesSpecified [Language]
|
||||
| TODO
|
||||
deriving (Show, Eq, Typeable, Exception)
|
||||
|
||||
readBlobFromPath :: Member (Exc SomeException) effs
|
||||
=> Concrete
|
||||
-> File
|
||||
-> Eff effs Blob
|
||||
readBlobFromPath g f = readFile g f >>= maybeM (throwError (SomeException (FileNotFound (filePath f))))
|
||||
|
||||
addPrelude :: MonadIO m
|
||||
=> Concrete
|
||||
-> File
|
||||
-> m Concrete
|
||||
addPrelude g File{..} = do
|
||||
traceM "Adding to prelude"
|
||||
contents <- liftIO (B.readFile filePath)
|
||||
let blob = Blob (fromUTF8 contents) filePath fileLanguage
|
||||
pure $ g { projectBlobs = blob : projectBlobs g }
|
||||
|
||||
readFile :: Member (Exc SomeException) effs
|
||||
=> Concrete
|
||||
-> File
|
||||
@ -144,17 +114,3 @@ readFile Project{..} f =
|
||||
| p == "/dev/null" -> pure Nothing
|
||||
| isJust candidate -> pure candidate
|
||||
| otherwise -> throwError (SomeException (FileNotFound p))
|
||||
|
||||
readBlobPair :: Member (Exc SomeException) effs
|
||||
=> Concrete
|
||||
-> File
|
||||
-> File
|
||||
-> Eff effs BlobPair
|
||||
readBlobPair g f1 f2 = Join <$> join (maybeThese <$> readFile g f1 <*> readFile g f2)
|
||||
|
||||
maybeThese :: Member (Exc SomeException) effs => Maybe a -> Maybe b -> Eff effs (These a b)
|
||||
maybeThese a b = case (a, b) of
|
||||
(Just a, Nothing) -> pure (This a)
|
||||
(Nothing, Just b) -> pure (That b)
|
||||
(Just a, Just b) -> pure (These a b)
|
||||
_ -> throwError (SomeException EmptyPairProvided)
|
||||
|
@ -37,14 +37,13 @@ module Semantic.IO
|
||||
|
||||
import qualified Control.Exception as Exc
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.State
|
||||
import Control.Monad.Effect.Exception
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Aeson
|
||||
import Data.Blob
|
||||
import Data.Bool
|
||||
import qualified Data.Project as Project
|
||||
import Data.Project (File (..), ProjectException (..))
|
||||
import Data.Project (File (..))
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Builder as B
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
|
@ -55,7 +55,6 @@ import Control.Monad
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Exception
|
||||
import Control.Monad.Effect.Reader
|
||||
import Control.Monad.Effect.State
|
||||
import Control.Monad.Effect.Trace
|
||||
import Data.Blob
|
||||
import Data.Bool
|
||||
@ -66,7 +65,6 @@ import Data.Record
|
||||
import Data.Sum
|
||||
import qualified Data.Syntax as Syntax
|
||||
import Data.Term
|
||||
import Data.Project
|
||||
import Diffing.Algorithm (Diffable)
|
||||
import Diffing.Interpreter
|
||||
import Parsing.CMark
|
||||
|
Loading…
Reference in New Issue
Block a user