Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wz1000 committed Dec 12, 2022
1 parent f9008fe commit a4fe2bf
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Development.IDE.Plugin.Plugins.ImportUtils
import Data.List.NonEmpty (NonEmpty ((:|)))
import qualified Data.Text as T
import Development.IDE.Plugin.CodeAction.ExactPrint (wildCardSymbol)
import Development.IDE.Types.Exports (IdentInfo (..))
import Development.IDE.Types.Exports
import Language.LSP.Types (CodeActionKind (..))

-- | Possible import styles for an 'IdentInfo'.
Expand Down Expand Up @@ -49,16 +49,18 @@ data ImportStyle
deriving Show

importStyles :: IdentInfo -> NonEmpty ImportStyle
importStyles IdentInfo {parent, rendered, isDatacon}
| Just p <- parent
importStyles i@(IdentInfo {parent})
| Just p <- pr
-- Constructors always have to be imported via their parent data type, but
-- methods and associated type/data families can also be imported as
-- top-level exports.
= ImportViaParent rendered p
:| [ImportTopLevel rendered | not isDatacon]
= ImportViaParent rend p
:| [ImportTopLevel rend | not (isDatacon i)]
<> [ImportAllConstructors p]
| otherwise
= ImportTopLevel rendered :| []
= ImportTopLevel rend :| []
where rend = rendered i
pr = occNameText <$> parent

-- | Used for adding new imports
renderImportStyle :: ImportStyle -> T.Text
Expand Down

0 comments on commit a4fe2bf

Please sign in to comment.