Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #774 from Bubba/data-constructor-quick-fix
Browse files Browse the repository at this point in the history
Add import suggestions for data constructors
  • Loading branch information
alanz authored Aug 20, 2018
2 parents bfa1cd0 + 0abcf6f commit 139e1b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Haskell/Ide/Engine/Plugin/HsImport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ codeActionProvider plId docId _ _ context = do

extractImportableTerm :: T.Text -> Maybe T.Text
extractImportableTerm dirtyMsg = T.strip <$> asum
[T.stripPrefix "Variable not in scope: " msg,
T.init <$> T.stripPrefix "Not in scope: type constructor or class ‘" msg]
[ T.stripPrefix "Variable not in scope: " msg
, T.init <$> T.stripPrefix "Not in scope: type constructor or class ‘" msg
, T.stripPrefix "Data constructor not in scope: " msg]
where msg = head
-- Get rid of the rename suggestion parts
$ T.splitOn "Perhaps you meant "
Expand Down
3 changes: 3 additions & 0 deletions test/unit/CodeActionsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec = do
it "pick up when" $
let msg = "Variable not in scope: when :: Bool -> IO () -> t"
in extractImportableTerm msg `shouldBe` Just "when :: Bool -> IO () -> t"
it "pick up data constructors" $
let msg = "Data constructor not in scope: ExitFailure :: Integer -> t"
in extractImportableTerm msg `shouldBe` Just "ExitFailure :: Integer -> t"

describe "rename code actions" $ do
it "pick up variable not in scope perhaps you meant" $
Expand Down

0 comments on commit 139e1b5

Please sign in to comment.