From 0764e7ade389dd931aabff6dd0bb9b2f61856979 Mon Sep 17 00:00:00 2001 From: Alan Zimmerman Date: Sat, 14 Nov 2020 14:39:32 +0000 Subject: [PATCH] Hlint: bring over idea2Message for formatting This restores the hlint formatting from haskell-ide-engine Closes #553 --- plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs index d500ccd765..6dcc384119 100644 --- a/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs +++ b/plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs @@ -122,12 +122,22 @@ rules = do -- we are encoding the fact that idea has refactorings in diagnostic code , _code = Just (LSP.StringValue $ T.pack $ codePre ++ ideaHint idea) , _source = Just "hlint" - , _message = T.pack $ show idea + , _message = idea2Message idea , _relatedInformation = Nothing , _tags = Nothing } where codePre = if null $ ideaRefactoring idea then "" else "refact:" + idea2Message :: Idea -> T.Text + idea2Message idea = T.unlines $ [T.pack $ ideaHint idea, "Found:", " " <> T.pack (ideaFrom idea)] + <> toIdea <> map (T.pack . show) (ideaNote idea) + where + toIdea :: [T.Text] + toIdea = case ideaTo idea of + Nothing -> [] + Just i -> [T.pack "Why not:", T.pack $ " " ++ i] + + parseErrorToDiagnostic :: ParseError -> Diagnostic parseErrorToDiagnostic (Hlint.ParseError l msg contents) = LSP.Diagnostic {