Skip to content

Commit 9b61896

Browse files
committed
fix tests, edit autogen-modules completion to remove redundancy
1 parent 3dd647a commit 9b61896

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ import Ide.Plugin.Cabal.LicenseSuggest (licenseNames)
2323
-- Completion Data
2424
-- ----------------------------------------------------------------
2525

26+
supportedCabalVersions :: [CabalSpecVersion]
27+
supportedCabalVersions = [CabalSpecV2_2 .. maxBound]
28+
2629
-- | Keyword for cabal version; required to be the top line in a cabal file
2730
cabalVersionKeyword :: Map KeyWordName Completer
2831
cabalVersionKeyword =
2932
Map.singleton "cabal-version:" $
3033
constantCompleter $
3134
-- We only suggest cabal versions newer than 2.2
3235
-- since we don't recommend using older ones.
33-
map (T.pack . showCabalSpecVersion) [CabalSpecV2_2 .. maxBound]
36+
map (T.pack . showCabalSpecVersion) supportedCabalVersions
3437

3538
-- | Top level keywords of a cabal file.
3639
--
@@ -87,7 +90,6 @@ libraryFields =
8790
("visibility:", constantCompleter ["private", "public"]),
8891
("reexported-modules:", noopCompleter),
8992
("signatures:", noopCompleter),
90-
("autogen-modules:", modulesCompleter sourceDirsExtractionLibrary),
9193
("other-modules:", modulesCompleter sourceDirsExtractionLibrary)
9294
]
9395

@@ -96,15 +98,13 @@ executableFields =
9698
Map.fromList
9799
[ ("main-is:", mainIsCompleter sourceDirsExtractionExecutable),
98100
("scope:", constantCompleter ["public", "private"]),
99-
("autogen-modules:", modulesCompleter sourceDirsExtractionExecutable),
100101
("other-modules:", modulesCompleter sourceDirsExtractionExecutable)
101102
]
102103

103104
testSuiteFields :: Map KeyWordName Completer
104105
testSuiteFields =
105106
Map.fromList
106107
[ ("type:", constantCompleter ["exitcode-stdio-1.0", "detailed-0.9"]),
107-
("autogen-modules:", modulesCompleter sourceDirsExtractionTestSuite),
108108
("main-is:", mainIsCompleter sourceDirsExtractionTestSuite),
109109
("other-modules:", modulesCompleter sourceDirsExtractionTestSuite)
110110
]
@@ -113,7 +113,6 @@ benchmarkFields :: Map KeyWordName Completer
113113
benchmarkFields =
114114
Map.fromList
115115
[ ("type:", noopCompleter),
116-
("autogen-modules:", modulesCompleter sourceDirsExtractionBenchmark),
117116
("main-is:", mainIsCompleter sourceDirsExtractionBenchmark),
118117
("other-modules:", modulesCompleter sourceDirsExtractionBenchmark)
119118
]
@@ -166,7 +165,8 @@ flagFields =
166165
libExecTestBenchCommons :: Map KeyWordName Completer
167166
libExecTestBenchCommons =
168167
Map.fromList
169-
[ ("build-depends:", noopCompleter),
168+
[ ("import:", importCompleter),
169+
("build-depends:", noopCompleter),
170170
("hs-source-dirs:", directoryCompleter),
171171
("default-extensions:", noopCompleter),
172172
("other-extensions:", noopCompleter),
@@ -181,9 +181,10 @@ libExecTestBenchCommons =
181181
("ghcjs-prof-options:", constantCompleter ghcOptions),
182182
("ghcjs-shared-options:", constantCompleter ghcOptions),
183183
("includes:", filePathCompleter),
184-
("autogen-includes:", filePathCompleter),
185184
("install-includes:", filePathCompleter),
186185
("include-dirs:", directoryCompleter),
186+
("autogen-includes:", filePathCompleter),
187+
("autogen-modules:", filePathCompleter),
187188
("c-sources:", filePathCompleter),
188189
("cxx-sources:", filePathCompleter),
189190
("asm-sources:", filePathCompleter),
@@ -265,6 +266,3 @@ weightedLicenseNames =
265266

266267
ghcOptions :: [T.Text]
267268
ghcOptions = map T.pack $ flagsForCompletion False
268-
269-
supportedCabalVersions :: [CabalSpecVersion]
270-
supportedCabalVersions = [CabalSpecV2_2 .. maxBound]

plugins/hls-cabal-plugin/test/Completer.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ autogenFieldCompletionTests =
345345
, testAutogenField "executable" "autogen-completion/autogen-completion.cabal" (Position 11 9) ["autogen-modules:", "autogen-includes:"]
346346
, testAutogenField "test-suite" "autogen-completion/autogen-completion.cabal" (Position 16 9) ["autogen-modules:", "autogen-includes:"]
347347
, testAutogenField "benchmark" "autogen-completion/autogen-completion.cabal" (Position 21 9) ["autogen-modules:", "autogen-includes:"]
348-
, testAutogenField "foreign-library" "autogen-completion/autogen-completion.cabal" (Position 26 9) ["autogen-includes:"]
349-
, testAutogenField "common" "autogen-completion/autogen-completion.cabal" (Position 29 9) ["autogen-includes:"]
348+
, testAutogenField "common" "autogen-completion/autogen-completion.cabal" (Position 29 9) ["autogen-modules:", "autogen-includes:"]
350349
]
351350

352351
where

0 commit comments

Comments
 (0)