@@ -24,8 +24,8 @@ module Development.IDE.Types.Diagnostics (
24 ideErrorPretty,
24 ideErrorPretty,
25 errorDiag,
25 errorDiag,
26 ideTryIOException,
26 ideTryIOException,
27− prettyFileDiagnostics,
27+ showDiagnostics,
28− prettyDiagnostic,
28+ showDiagnosticsColored,
29 prettyDiagnosticStore,
29 prettyDiagnosticStore,
30 defDiagnostic,
30 defDiagnostic,
31 addDiagnostics,
31 addDiagnostics,
@@ -162,35 +162,45 @@ type FileDiagnostics = (Uri, [Diagnostic])
163prettyRange :: Range -> Doc SyntaxClass
163prettyRange :: Range -> Doc SyntaxClass
164prettyRange Range{..} =
164prettyRange Range{..} =
165− label_ "Range" $ vcat
165+ slabel_ "Range" $ vcat
166− [ label_ "Start:" $ prettyPosition _start
166+ [ slabel_ "Start:" $ prettyPosition _start
167− , label_ "End: " $ prettyPosition _end
167+ , slabel_ "End: " $ prettyPosition _end
170prettyPosition :: Position -> Doc SyntaxClass
170prettyPosition :: Position -> Doc SyntaxClass
171−prettyPosition Position{..} = label_ "Position" $ vcat
171+prettyPosition Position{..} = slabel_ "Position" $ vcat
172− [ label_ "Line:" $ pretty _line
172+ [ slabel_ "Line:" $ pretty _line
173− , label_ "Character:" $ pretty _character
173+ , slabel_ "Character:" $ pretty _character
176stringParagraphs :: T.Text -> Doc a
176stringParagraphs :: T.Text -> Doc a
177stringParagraphs = vcat . map (fillSep . map pretty . T.words) . T.lines
177stringParagraphs = vcat . map (fillSep . map pretty . T.words) . T.lines
179+showDiagnostics :: [LSP.Diagnostic] -> T.Text
180+showDiagnostics = srenderPlain . prettyDiagnostics
182+showDiagnosticsColored :: [LSP.Diagnostic] -> T.Text
183+showDiagnosticsColored = srenderColored . prettyDiagnostics
186+prettyDiagnostics :: [LSP.Diagnostic] -> Doc SyntaxClass
187+prettyDiagnostics = vcat . map prettyDiagnostic
179prettyDiagnostic :: LSP.Diagnostic -> Doc SyntaxClass
189prettyDiagnostic :: LSP.Diagnostic -> Doc SyntaxClass
180prettyDiagnostic LSP.Diagnostic{..} =
190prettyDiagnostic LSP.Diagnostic{..} =
182− [label_ "Range: "
192+ [slabel_ "Range: "
183 $ prettyRange _range
193 $ prettyRange _range
184− , label_ "Source: " $ pretty _source
194+ , slabel_ "Source: " $ pretty _source
185− , label_ "Severity:" $ pretty $ show sev
195+ , slabel_ "Severity:" $ pretty $ show sev
186− , label_ "Message: "
196+ , slabel_ "Message: "
187 $ case sev of
197 $ case sev of
188 LSP.DsError -> annotate ErrorSC
198 LSP.DsError -> annotate ErrorSC
189 LSP.DsWarning -> annotate WarningSC
199 LSP.DsWarning -> annotate WarningSC
190 LSP.DsInfo -> annotate InfoSC
200 LSP.DsInfo -> annotate InfoSC
191 LSP.DsHint -> annotate HintSC
201 LSP.DsHint -> annotate HintSC
192 $ stringParagraphs _message
202 $ stringParagraphs _message
193− , label_ "Code:" $ pretty _code
203+ , slabel_ "Code:" $ pretty _code
196 sev = fromMaybe LSP.DsError _severity
206 sev = fromMaybe LSP.DsError _severity
@@ -204,18 +214,18 @@ prettyDiagnosticStore ds =
205prettyFileDiagnostics :: FileDiagnostics -> Doc SyntaxClass
215prettyFileDiagnostics :: FileDiagnostics -> Doc SyntaxClass
206prettyFileDiagnostics (uri, diags) =
216prettyFileDiagnostics (uri, diags) =
207− label_ "Compiler error in" $ vcat
217+ slabel_ "Compiler error in" $ vcat
208− [ label_ "File:" $ pretty filePath
218+ [ slabel_ "File:" $ pretty filePath
209− , label_ "Errors:" $ vcat $ map prettyDiagnostic diags
219+ , slabel_ "Errors:" $ vcat $ map prettyDiagnostic diags
212 -- prettyFileDiags :: (FilePath, [(T.Text, [LSP.Diagnostic])]) -> Doc SyntaxClass
222 -- prettyFileDiags :: (FilePath, [(T.Text, [LSP.Diagnostic])]) -> Doc SyntaxClass
213 -- prettyFileDiags (fp,stages) =
223 -- prettyFileDiags (fp,stages) =
214− -- label_ ("File: "<>fp) $ vcat $ map prettyStage stages
224+ -- slabel_ ("File: "<>fp) $ vcat $ map prettyStage stages
216 -- prettyStage :: (T.Text, [LSP.Diagnostic]) -> Doc SyntaxClass
226 -- prettyStage :: (T.Text, [LSP.Diagnostic]) -> Doc SyntaxClass
217 -- prettyStage (stage,diags) =
227 -- prettyStage (stage,diags) =
218− -- label_ ("Stage: "<>T.unpack stage) $ vcat $ map prettyDiagnostic diags
228+ -- slabel_ ("Stage: "<>T.unpack stage) $ vcat $ map prettyDiagnostic diags
220 filePath :: FilePath
230 filePath :: FilePath
221 filePath = fromMaybe dontKnow $ uriToFilePath uri
231 filePath = fromMaybe dontKnow $ uriToFilePath uri