Skip to content

Commit ecafd3e

Browse files
authored
Merge pull request #598 from alanz/wip/553-tweak-hlint-format
Hlint: bring over idea2Message for formatting
2 parents 3120065 + 0764e7a commit ecafd3e

File tree

1 file changed

+11
-1
lines changed
  • plugins/hls-hlint-plugin/src/Ide/Plugin

1 file changed

+11
-1
lines changed

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

+11-1
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,22 @@ rules = do
122122
-- we are encoding the fact that idea has refactorings in diagnostic code
123123
, _code = Just (LSP.StringValue $ T.pack $ codePre ++ ideaHint idea)
124124
, _source = Just "hlint"
125-
, _message = T.pack $ show idea
125+
, _message = idea2Message idea
126126
, _relatedInformation = Nothing
127127
, _tags = Nothing
128128
}
129129
where codePre = if null $ ideaRefactoring idea then "" else "refact:"
130130

131+
idea2Message :: Idea -> T.Text
132+
idea2Message idea = T.unlines $ [T.pack $ ideaHint idea, "Found:", " " <> T.pack (ideaFrom idea)]
133+
<> toIdea <> map (T.pack . show) (ideaNote idea)
134+
where
135+
toIdea :: [T.Text]
136+
toIdea = case ideaTo idea of
137+
Nothing -> []
138+
Just i -> [T.pack "Why not:", T.pack $ " " ++ i]
139+
140+
131141
parseErrorToDiagnostic :: ParseError -> Diagnostic
132142
parseErrorToDiagnostic (Hlint.ParseError l msg contents) =
133143
LSP.Diagnostic {

0 commit comments

Comments
 (0)