3
3
module Ide.Plugin.Cabal.Completion.Completer.Module where
4
4
5
5
import qualified Data.List as List
6
- import Data.Maybe (fromJust ,
7
- fromMaybe )
6
+ import Data.Maybe (fromMaybe )
8
7
import qualified Data.Text as T
9
8
import Development.IDE (IdeState (shakeExtras ))
10
9
import Development.IDE.Core.Shake (runIdeAction ,
@@ -19,7 +18,11 @@ import Distribution.PackageDescription (Benchmark (..),
19
18
mkUnqualComponentName ,
20
19
testBuildInfo )
21
20
import Distribution.Utils.Path (getSymbolicPath )
22
- import Ide.Plugin.Cabal.Completion.Completer.FilePath
21
+ import Ide.Plugin.Cabal.Completion.Completer.FilePath
22
+ ( listFileCompletions ,
23
+ mkCompletionDirectory ,
24
+ mkPathCompletion ,
25
+ PathCompletionInfo (.. ) )
23
26
import Ide.Plugin.Cabal.Completion.Completer.Types
24
27
import Ide.Plugin.Cabal.Completion.Types
25
28
@@ -33,6 +36,7 @@ import System.Directory (doesFileExist)
33
36
import qualified System.FilePath as FP
34
37
import qualified System.FilePath.Posix as Posix
35
38
import qualified Text.Fuzzy.Parallel as Fuzzy
39
+
36
40
{- | Completer to be used when module paths can be completed for the field.
37
41
38
42
Takes an extraction function which extracts the source directories
@@ -72,10 +76,12 @@ sourceDirsExtractionLibrary gpd =
72
76
sourceDirsExtractionExecutable :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
73
77
sourceDirsExtractionExecutable Nothing _ = []
74
78
sourceDirsExtractionExecutable (Just name) gpd
75
- | exeName executable == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ buildInfo executable
79
+ | Just executable <- executableM
80
+ , exeName executable == (mkUnqualComponentName $ T. unpack name) =
81
+ map getSymbolicPath $ hsSourceDirs $ buildInfo executable
76
82
| otherwise = []
77
83
where
78
- executable = condTreeData $ snd $ fromJust res
84
+ executableM = fmap ( condTreeData . snd ) res
79
85
execsM = condExecutables gpd
80
86
res =
81
87
List. find
@@ -90,10 +96,12 @@ sourceDirsExtractionExecutable (Just name) gpd
90
96
sourceDirsExtractionTestSuite :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
91
97
sourceDirsExtractionTestSuite Nothing _ = []
92
98
sourceDirsExtractionTestSuite (Just name) gpd
93
- | testName testSuite == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ testBuildInfo testSuite
99
+ | Just testSuite <- testSuiteM
100
+ , testName testSuite == (mkUnqualComponentName $ T. unpack name) =
101
+ map getSymbolicPath $ hsSourceDirs $ testBuildInfo testSuite
94
102
| otherwise = []
95
103
where
96
- testSuite = condTreeData $ snd $ fromJust res
104
+ testSuiteM = fmap ( condTreeData . snd ) res
97
105
testSuitesM = condTestSuites gpd
98
106
res =
99
107
List. find
@@ -108,10 +116,12 @@ sourceDirsExtractionTestSuite (Just name) gpd
108
116
sourceDirsExtractionBenchmark :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
109
117
sourceDirsExtractionBenchmark Nothing _ = []
110
118
sourceDirsExtractionBenchmark (Just name) gpd
111
- | benchmarkName bMark == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ benchmarkBuildInfo bMark
119
+ | Just bMark <- bMarkM
120
+ , benchmarkName bMark == (mkUnqualComponentName $ T. unpack name) =
121
+ map getSymbolicPath $ hsSourceDirs $ benchmarkBuildInfo bMark
112
122
| otherwise = []
113
123
where
114
- bMark = condTreeData $ snd $ fromJust res
124
+ bMarkM = fmap ( condTreeData . snd ) res
115
125
bMarksM = condBenchmarks gpd
116
126
res =
117
127
List. find
0 commit comments