Skip to content

Commit

Permalink
refactor: Makes mapNotInScope local and renames to qualify
Browse files Browse the repository at this point in the history
  • Loading branch information
konn committed Jul 22, 2023
1 parent d96d470 commit e0eb90a
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ _ _ _ _ = []

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e0eb90a

Please sign in to comment.