hsdev 0.2.2.0 → 0.2.2.1
raw patch · 3 files changed
+40/−12 lines, 3 filesdep ~directory
Dependency ranges changed: directory
Files
- hsdev.cabal +10/−9
- src/HsDev/Project.hs +2/−1
- src/HsDev/Util.hs +28/−2
hsdev.cabal view
@@ -1,5 +1,5 @@ name: hsdev -version: 0.2.2.0 +version: 0.2.2.1 synopsis: Haskell development library description: Haskell development library and tool with support of autocompletion, symbol info, go to declaration, find references, hayoo search etc. @@ -102,12 +102,14 @@ build-depends: haddock-api >= 2.17.0 && < 2.18.0, ghc >= 8.0.0 && < 8.1.0, - ghc-boot + ghc-boot, + directory >= 1.2.6.0 if impl(ghc < 8.0) build-depends: haddock-api >= 2.16.0 && < 2.17.0, ghc >= 7.10.0 && < 7.11.0, - bin-package-db + bin-package-db, + directory == 1.2.2.* build-depends: base >= 4.7 && < 5, @@ -122,7 +124,6 @@ cpphs >= 1.19.0, data-default >= 0.5.0, deepseq >= 1.4.0, - directory >= 1.2.0, exceptions >= 0.6.0, filepath >= 1.4.0, fsnotify >= 0.2.1, @@ -168,7 +169,7 @@ bytestring >= 0.10.0, containers >= 0.5.0, deepseq >= 1.4.0, - directory >= 1.2.0, + directory, exceptions >= 0.6.0, filepath >= 1.4.0, monad-loops >= 0.4.0, @@ -194,7 +195,7 @@ bytestring >= 0.10.0, containers >= 0.5.0, data-default >= 0.5.0, - directory >= 1.2.0, + directory, filepath >= 1.4.0, mtl >= 2.2.0, optparse-applicative >= 0.11, @@ -216,7 +217,7 @@ bytestring >= 0.10.0, containers >= 0.5.0, data-default >= 0.5.0, - directory >= 1.2.0, + directory, haskell-src-exts >= 1.18.0 && < 1.20.0, lens >= 4.8, mtl >= 2.2.0, @@ -278,7 +279,7 @@ aeson-pretty >= 0.7.0, bytestring >= 0.10.0, data-default >= 0.5.0, - directory >= 1.2.0, + directory, filepath >= 1.4.0, lens >= 4.8, mtl >= 2.2.0, @@ -298,7 +299,7 @@ async >= 2.0, data-default >= 0.5.0, deepseq >= 1.4.0, - directory >= 1.2.0, + directory, filepath >= 1.4.0, containers >= 0.5.0, hformat == 0.1.*,
src/HsDev/Project.hs view
@@ -2,6 +2,7 @@ module HsDev.Project.Types, infoSourceDirsDef, + analyzeCabal, readProject, loadProject, withExtensions, infos, inTarget, fileTarget, fileTargets, findSourceDir, sourceDirs, @@ -56,7 +57,7 @@ toInfo info = Info { _infoDepends = map pkgName (PD.targetBuildDepends info), _infoLanguage = PD.defaultLanguage info, - _infoExtensions = PD.defaultExtensions info, + _infoExtensions = PD.defaultExtensions info ++ PD.otherExtensions info ++ PD.oldExtensions info, _infoGHCOptions = fromMaybe [] $ lookup GHC (PD.options info), _infoSourceDirs = PD.hsSourceDirs info }
src/HsDev/Util.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts, OverloadedStrings, TemplateHaskell #-} +{-# LANGUAGE FlexibleContexts, OverloadedStrings, TemplateHaskell, CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module HsDev.Util ( @@ -36,6 +36,7 @@ MonadIO(..) ) where +import Control.Applicative import Control.Arrow (second, left, (&&&)) import Control.Exception import Control.Concurrent.Async @@ -63,6 +64,15 @@ import System.IO import Text.Read (readMaybe) +#if !MIN_VERSION_directory(1,2,6) +#if mingw32_HOST_OS +import qualified System.Win32 as Win32 +import Data.Bits ((.&.)) +#else +import qualified System.Posix as Posix +#endif +#endif + import HsDev.Version -- | Run action with current directory set @@ -70,11 +80,27 @@ withCurrentDirectory cur act = C.bracket (liftIO Dir.getCurrentDirectory) (liftIO . Dir.setCurrentDirectory) $ const (liftIO (Dir.setCurrentDirectory cur) >> act) +-- | Is directory symbolic link +dirIsSymLink :: FilePath -> IO Bool +#if MIN_VERSION_directory(1,2,6) +dirIsSymLink = Dir.isSymbolicLink +#else +dirIsSymLink path = do +#if mingw32_HOST_OS + isReparsePoint <$> Win32.getFileAttributes path + where + fILE_ATTRIBUTE_REPARSE_POINT = 0x400 + isReparsePoint attr = attr .&. fILE_ATTRIBUTE_REPARSE_POINT /= 0 +#else + Posix.isSymbolicLink <$> Posix.getSymbolicLinkStatus path +#endif +#endif + -- | Get directory contents safely: no fail, ignoring symbolic links, also prepends paths with dir name directoryContents :: FilePath -> IO [FilePath] directoryContents p = handle ignore $ do b <- Dir.doesDirectoryExist p - isLink <- Dir.isSymbolicLink p + isLink <- dirIsSymLink p if b && (not isLink) then liftM (map (p </>) . filter (`notElem` [".", ".."])) (Dir.getDirectoryContents p) else return []