@@ -8,19 +8,15 @@ import qualified Data.Text as T
88import Development.IDE.GHC.Compat.Core (flagsForCompletion )
99import Distribution.CabalSpecVersion (CabalSpecVersion (CabalSpecV2_2 ),
1010 showCabalSpecVersion )
11- -- import Ide.Plugin.Cabal.Completion.Completer.FilePath
12- -- import Ide.Plugin.Cabal.Completion.Completer.Module
13- -- import Ide.Plugin.Cabal.Completion.Completer.Paths
1411import Ide.Plugin.Cabal.Completion.Completer.FilePath (directoryCompleter ,
1512 filePathCompleter )
1613import Ide.Plugin.Cabal.Completion.Completer.Simple
1714import Ide.Plugin.Cabal.Completion.Completer.Types (Completer )
1815import Ide.Plugin.Cabal.Completion.Types
19- -- import Ide.Plugin.Cabal.LicenseSuggest (licenseNames)
2016
2117-- | Ad-hoc data type for modelling the available top-level stanzas.
2218-- Not intended right now for anything else but to avoid string
23- -- comparisons in 'stanzaKeywordMap' and 'libExecTestBenchCommons' .
19+ -- comparisons in 'stanzaKeywordMap'.
2420data TopLevelStanza
2521 = Package
2622 | ProgramOptions
@@ -29,30 +25,16 @@ data TopLevelStanza
2925-- Completion Data
3026-- ----------------------------------------------------------------
3127
32- -- supportedCabalVersions :: [CabalSpecVersion]
33- -- supportedCabalVersions = [CabalSpecV2_2 .. maxBound]
34-
35- -- -- | Keyword for cabal version; required to be the top line in a cabal file
36- -- cabalVersionKeyword :: Map KeyWordName Completer
37- -- cabalVersionKeyword =
38- -- Map.singleton "cabal-version:" $
39- -- constantCompleter $
40- -- -- We only suggest cabal versions newer than 2.2
41- -- -- since we don't recommend using older ones.
42- -- map (T.pack . showCabalSpecVersion) supportedCabalVersions
43-
44- -- | Top level keywords of a cabal file.
28+ -- | Top level keywords of a cabal.project file.
4529--
4630-- TODO: we could add descriptions of field values and
4731-- then show them when inside the field's context
4832cabalProjectKeywords :: Map KeyWordName Completer
4933cabalProjectKeywords =
5034 Map. fromList
51- [ -- projectConfigFieldGrammar
52- (" packages:" , filePathCompleter),
35+ [ (" packages:" , filePathCompleter),
5336 (" optional-packages:" , filePathCompleter),
5437 (" extra-packages:" , filePathCompleter),
55- -- projectConfigBuildOnlyFieldGrammar
5638 (" verbose:" , constantCompleter [" 0" , " 1" , " 2" , " 3" ]),
5739 (" build-summary:" , filePathCompleter),
5840 (" build-log:" , noopCompleter),
@@ -68,7 +50,6 @@ cabalProjectKeywords =
6850 (" ignore-expiry:" , constantCompleter [" False" , " True" ]),
6951 (" remote-repo-cache:" , noopCompleter),
7052 (" logs-dir:" , noopCompleter),
71- -- projectConfigSharedFieldGrammar
7253 (" builddir:" , noopCompleter),
7354 (" project-dir:" , noopCompleter),
7455 (" project-file:" , noopCompleter),
@@ -101,16 +82,14 @@ cabalProjectKeywords =
10182 (" prefer-oldest:" , noopCompleter),
10283 (" extra-prog-path-shared-only:" , noopCompleter),
10384 (" multi-repl:" , noopCompleter),
104- -- extras
10585 (" benchmarks:" , constantCompleter [" False" , " True" ]),
10686 (" import:" , filePathCompleter)
10787 ]
10888
10989packageFields :: Map KeyWordName Completer
11090packageFields =
11191 Map. fromList
112- [ -- packageConfigFieldGrammar
113- (" haddock-all:" , constantCompleter [" False" , " True" ]),
92+ [ (" haddock-all:" , constantCompleter [" False" , " True" ]),
11493 (" extra-prog-path:" , filePathCompleter),
11594 (" flags:" , noopCompleter),
11695 (" library-vanilla:" , constantCompleter [" True" , " False" ]),
@@ -171,18 +150,10 @@ packageFields =
171150 (" test-fail-when-no-test-suites:" , noopCompleter),
172151 (" test-options:" , noopCompleter),
173152 (" benchmark-options:" , noopCompleter),
174- -- packageConfigCoverageGrammar
175153 (" coverage:" , constantCompleter [" False" , " True" ]),
176- -- other
177154 (" ghc-options:" , noopCompleter)
178155 ]
179156
180- -- just for testing right now, to be filled in later
181- programOptionsFields :: Map KeyWordName Completer
182- programOptionsFields = Map. fromList
183- [ (" ghc-options:" , noopCompleter)
184- ]
185-
186157sourceRepoFields :: Map KeyWordName Completer
187158sourceRepoFields = Map. fromList
188159 [ (" type:" , constantCompleter
@@ -196,18 +167,18 @@ sourceRepoFields = Map.fromList
196167 " bzr" ,
197168 " arch" ,
198169 " monotone"
199- ]), -- just used the one from cabal
170+ ]),
200171 (" location:" , noopCompleter),
201172 (" tag:" , noopCompleter),
202173 (" subdir:" , noopCompleter)
203174 ]
204175
205- -- | Map, containing all stanzas in a cabal file as keys,
176+ -- | Map, containing all stanzas in a cabal.project file as keys,
206177-- and lists of their possible nested keywords as values.
207178stanzaKeywordMap :: Map StanzaType (Map KeyWordName Completer )
208179stanzaKeywordMap =
209180 Map. fromList
210181 [ (" package" , packageFields),
211- (" program-options" , programOptionsFields ),
182+ (" program-options" , packageFields ),
212183 (" source-repository-package" , sourceRepoFields)
213184 ]
0 commit comments