Skip to content

Commit

Permalink
Remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
fendor committed Nov 19, 2022
1 parent 3d80afa commit fcd4bff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
27 changes: 4 additions & 23 deletions plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Parse.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Ide.Plugin.Cabal.Parse
( parseCabalFile
, parseCabalFileContents
( parseCabalFileContents
-- * Re-exports
, FilePath
, NonEmpty(..)
Expand All @@ -11,7 +10,6 @@ module Ide.Plugin.Cabal.Parse
, GenericPackageDescription(..)
) where

import Control.Monad (unless)
import qualified Data.ByteString as BS
import Data.List.NonEmpty (NonEmpty (..))
import Distribution.Fields (PError (..),
Expand All @@ -21,26 +19,9 @@ import Distribution.PackageDescription.Parsec (parseGenericPacka
import Distribution.Parsec.Position (Position (..))
import Distribution.Types.GenericPackageDescription (GenericPackageDescription (..))
import Distribution.Types.Version (Version)
import qualified System.Directory as Dir
import qualified System.Exit as Exit


parseCabalFile
:: FilePath
-> IO ([PWarning], Either (Maybe Version, NonEmpty PError) GenericPackageDescription)
parseCabalFile =
readAndParseFile'
where
readAndParseFile' fpath = do
exists <- Dir.doesFileExist fpath
unless exists $
Exit.die $
"Error Parsing: file \"" ++ fpath ++ "\" doesn't exist. Cannot continue."
bs <- BS.readFile fpath
parseCabalFileContents bs

parseCabalFileContents
:: BS.ByteString -- ^ UTF-8 encoded bytestring
-> IO ([PWarning], Either (Maybe Version, NonEmpty PError) GenericPackageDescription)
:: BS.ByteString -- ^ UTF-8 encoded bytestring
-> IO ([PWarning], Either (Maybe Version, NonEmpty PError) GenericPackageDescription)
parseCabalFileContents bs =
pure $ runParseResult (parseGenericPackageDescription bs)
pure $ runParseResult (parseGenericPackageDescription bs)
3 changes: 2 additions & 1 deletion plugins/hls-cabal-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Ide.Plugin.Cabal.Parse as Lib
import qualified Language.LSP.Types.Lens as J
import System.FilePath
import Test.Hls
import qualified Data.ByteString as BS

cabalPlugin :: Recorder (WithPriority Log) -> PluginDescriptor IdeState
cabalPlugin recorder = descriptor recorder "cabal"
Expand Down Expand Up @@ -51,7 +52,7 @@ unitTests :: TestTree
unitTests =
testGroup "Unit Tests"
[ testCase "Simple Parsing works" $ do
(warnings, pm) <- Lib.parseCabalFile $ testDataDir </> "simple.cabal"
(warnings, pm) <- Lib.parseCabalFileContents =<< BS.readFile (testDataDir </> "simple.cabal")
liftIO $ do
null warnings @? "Found unexpected warnings"
isRight pm @? "Failed to parse GenericPackageDescription"
Expand Down

0 comments on commit fcd4bff

Please sign in to comment.