Skip to content

Commit 385d83b

Browse files
committed
resolve merging issues
1 parent ae6a060 commit 385d83b

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ haskellInteractionDescriptor recorder plId =
100100
(defaultPluginDescriptor plId "Provides the cabal-add code action in haskell files")
101101
{ pluginHandlers =
102102
mconcat
103-
[ mkPluginHandler LSP.SMethod_TextDocumentCodeAction $ cabalAddCodeAction recorder
103+
[ mkPluginHandler LSP.SMethod_TextDocumentCodeAction cabalAddCodeAction
104104
]
105105
, pluginCommands = [PluginCommand CabalAdd.cabalAddCommand "add a dependency to a cabal file" (CabalAdd.command cabalAddRecorder)]
106106
, pluginRules = pure ()
@@ -332,8 +332,8 @@ gotoDefinition ideState _ msgParam = do
332332
isSectionArgName name (Syntax.Section _ sectionArgName _) = name == CabalFields.onelineSectionArgs sectionArgName
333333
isSectionArgName _ _ = False
334334

335-
cabalAddCodeAction :: Recorder (WithPriority Log) -> PluginMethodHandler IdeState 'LSP.Method_TextDocumentCodeAction
336-
cabalAddCodeAction recorder state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext{_diagnostics=diags}) = do
335+
cabalAddCodeAction :: PluginMethodHandler IdeState 'LSP.Method_TextDocumentCodeAction
336+
cabalAddCodeAction state plId (CodeActionParams _ _ (TextDocumentIdentifier uri) _ CodeActionContext{_diagnostics=diags}) = do
337337
maxCompls <- fmap maxCompletions . liftIO $ runAction "cabal.cabal-add" state getClientConfigAction
338338
let suggestions = take maxCompls $ concatMap CabalAdd.hiddenPackageSuggestion diags
339339
case suggestions of
@@ -351,12 +351,11 @@ cabalAddCodeAction recorder state plId (CodeActionParams _ _ (TextDocumentIdenti
351351
case mbGPD of
352352
Nothing -> pure $ InL []
353353
Just (gpd, _) -> do
354-
actions <- liftIO $ CabalAdd.addDependencySuggestCodeAction cabalAddRecorder plId
355-
verTxtDocId suggestions
356-
haskellFilePath cabalFilePath gpd
354+
actions <- liftIO $ CabalAdd.addDependencySuggestCodeAction plId verTxtDocId
355+
suggestions
356+
haskellFilePath cabalFilePath
357+
gpd
357358
pure $ InL $ fmap InR actions
358-
where
359-
cabalAddRecorder = cmapWithPrio LogCabalAdd recorder
360359

361360

362361
-- ----------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ cabalAddTests =
124124
testHiddenPackageSuggestions :: String -> [T.Text] -> [(T.Text, T.Text)] -> TestTree
125125
testHiddenPackageSuggestions testTitle messages suggestions =
126126
let diags = map (\msg -> messageToDiagnostic msg ) messages
127-
suggestions' = map (safeHead . hiddenPackageSuggestion 1) diags
127+
suggestions' = map (safeHead . hiddenPackageSuggestion) diags
128128
assertions = zipWith (@?=) suggestions' (map Just suggestions)
129129
testNames = map (\(f, s) -> "Check if " ++ T.unpack f ++ (if s == "" then "" else "-") ++ T.unpack s ++ " was parsed correctly") suggestions
130130
test = testGroup testTitle $ zipWith testCase testNames assertions

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,6 @@ codeActionTests = testGroup "Code Actions"
231231
guard (_title == "Replace with " <> license)
232232
pure action
233233

234-
235-
generateHiddenPackageTestSession :: FilePath -> FilePath -> T.Text -> [Int] -> Session ()
236-
generateHiddenPackageTestSession cabalFile haskellFile dependency indicesRes = do
237-
hsdoc <- openDoc haskellFile "haskell"
238-
cabDoc <- openDoc cabalFile "cabal"
239-
_ <- waitForDiagnosticsFrom hsdoc
240-
cas <- Maybe.mapMaybe (^? _R) <$> getAllCodeActions hsdoc
241-
let selectedCas = filter (\ca -> "Add dependency" `T.isPrefixOf` (ca ^. L.title)) cas
242-
mapM_ executeCodeAction selectedCas
243-
_ <- skipManyTill anyMessage $ getDocumentEdit cabDoc -- Wait for the changes in cabal file
244-
contents <- documentContents cabDoc
245-
liftIO $ assertEqual (T.unpack dependency <> " isn't found in the cabal file") indicesRes (Text.indices dependency contents)
246-
247-
testHiddenPackageSuggestions :: String -> [T.Text] -> [(T.Text, T.Text)] -> TestTree
248-
testHiddenPackageSuggestions testTitle messages suggestions =
249-
let suggestions' = map (safeHead . hiddenPackageSuggestion 1) messages
250-
assertions = zipWith (@?=) suggestions' (map Just suggestions)
251-
testNames = map (\(f, s) -> "Check if " ++ T.unpack f ++ "-" ++ T.unpack s ++ " was parsed correctly") suggestions
252-
test = testGroup testTitle $ zipWith testCase testNames assertions
253-
in test
254-
255234
-- ----------------------------------------------------------------------------
256235
-- Goto Definition Tests
257236
-- ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)