From e0eb90a159d0ede5c8b6aab106a79d2d994f1b7f Mon Sep 17 00:00:00 2001 From: Hiromi ISHII Date: Sat, 22 Jul 2023 17:11:29 +0900 Subject: [PATCH] refactor: Makes `mapNotInScope` local and renames to `qualify` --- .../src/Development/IDE/Plugin/CodeAction.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs index a66b6f49b7..d915496a24 100644 --- a/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs +++ b/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs @@ -1503,12 +1503,16 @@ suggestNewImport df packageExportsMap ps fileContents Diagnostic{..} | GHC94 <- ghcVersion , isNothing (qual <|> qual') , Just q <- qualGHC94 = - mapNotInScope ((q <> ".") <>) thingMissing + qualify q thingMissing | otherwise = thingMissing suggestions = nubSortBy simpleCompareImportSuggestion (constructNewImportSuggestions packageExportsMap (qual <|> qual' <|> qualGHC94, missing) extendImportSuggestions qis) in map (\(ImportSuggestion _ kind (unNewImport -> imp)) -> (imp, kind, TextEdit range (imp <> "\n" <> T.replicate indent " "))) suggestions where + qualify q (NotInScopeDataConstructor d) = NotInScopeDataConstructor (q <> "." <> d) + qualify q (NotInScopeTypeConstructorOrClass d) = NotInScopeTypeConstructorOrClass (q <> "." <> d) + qualify q (NotInScopeThing d) = NotInScopeThing (q <> "." <> d) + L _ HsModule {..} = astA ps suggestNewImport _ _ _ _ _ = [] @@ -1815,11 +1819,6 @@ data NotInScope | NotInScopeThing T.Text deriving Show -mapNotInScope :: (T.Text -> T.Text) -> NotInScope -> NotInScope -mapNotInScope f (NotInScopeDataConstructor d) = NotInScopeDataConstructor (f d) -mapNotInScope f (NotInScopeTypeConstructorOrClass d) = NotInScopeTypeConstructorOrClass (f d) -mapNotInScope f (NotInScopeThing d) = NotInScopeThing (f d) - notInScope :: NotInScope -> T.Text notInScope (NotInScopeDataConstructor t) = t notInScope (NotInScopeTypeConstructorOrClass t) = t