summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandrRuchkin <>2017-03-20 15:06:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-03-20 15:06:00 (GMT)
commit7d15d7dbf823ad8048df43602993ec55bea1b110 (patch)
treeb105d31e9fd4a9ab6c441ad71e77ac90b7a4732a
parent1bc70f9cf612b5351bcb9302b4211da6be047c56 (diff)
version 0.2.2.10.2.2.1
-rw-r--r--hsdev.cabal19
-rw-r--r--src/HsDev/Project.hs3
-rw-r--r--src/HsDev/Util.hs30
3 files changed, 40 insertions, 12 deletions
diff --git a/hsdev.cabal b/hsdev.cabal
index d8638ff..78083a6 100644
--- a/hsdev.cabal
+++ b/hsdev.cabal
@@ -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 @@ library
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 @@ library
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 @@ executable hsdev
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 @@ executable hsinspect
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 @@ executable hsclearimports
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 @@ executable hsautofix
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 @@ test-suite test
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.*,
diff --git a/src/HsDev/Project.hs b/src/HsDev/Project.hs
index a483ffc..a47362a 100644
--- a/src/HsDev/Project.hs
+++ b/src/HsDev/Project.hs
@@ -2,6 +2,7 @@ module HsDev.Project (
module HsDev.Project.Types,
infoSourceDirsDef,
+ analyzeCabal,
readProject, loadProject,
withExtensions,
infos, inTarget, fileTarget, fileTargets, findSourceDir, sourceDirs,
@@ -56,7 +57,7 @@ analyzeCabal source = case liftM flattenDescr $ parsePackageDescription source o
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 }
diff --git a/src/HsDev/Util.hs b/src/HsDev/Util.hs
index a866f83..3c9be36 100644
--- a/src/HsDev/Util.hs
+++ b/src/HsDev/Util.hs
@@ -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 @@ module HsDev.Util (
MonadIO(..)
) where
+import Control.Applicative
import Control.Arrow (second, left, (&&&))
import Control.Exception
import Control.Concurrent.Async
@@ -63,6 +64,15 @@ import System.FilePath
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 :: (MonadIO m, C.MonadMask m) => FilePath -> m a -> m a
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 []