Allow link on Diagnostic#code for #11847

Squashed commit of the following:

commit 76689c23011bf960f5ba3e199659e8180455466d
Author: Pine Wu <octref@gmail.com>
Date:   Fri Jan 24 10:19:44 2020 +0100

    Clarify API

commit 88d772d62da5d912b54285aa52dc6d6a108ca587
Author: Pine Wu <octref@gmail.com>
Date:   Fri Jan 24 10:17:28 2020 +0100

    Tooltip

commit 11ef8012ae3e560d6db6fff26ba3c258e7eae4a6
Author: Pine Wu <octref@gmail.com>
Date:   Thu Jan 23 16:50:28 2020 +0100

    Hover to show link color and use cmd/alt click

commit 38655a70b3eed56b99e8018fb5c79bd41b6c4f56
Author: Pine Wu <octref@gmail.com>
Date:   Thu Jan 23 15:21:13 2020 +0100

    Add hack to always render underline a bit below

commit 959f6b13bf81885cc370f6099e5123142089599e
Author: Pine Wu <octref@gmail.com>
Date:   Thu Jan 23 11:32:37 2020 +0100

    Fix compile error

commit b5c50e872935e74503451bd2801227f82b8410f4
Author: Pine Wu <octref@gmail.com>
Date:   Thu Jan 23 11:19:52 2020 +0100

    Bring code link everywhere for Diagnostics

commit f88cd4cc4e2064fd96853373e26c12670161bf60
Author: Pine Wu <octref@gmail.com>
Date:   Wed Jan 22 17:24:54 2020 +0100

    Add Diagnostic#code2 and render it in hover/inline/panel

commit 2a13e3e4f62fd3707f2c03c1e814a8fdc557c367
Author: Pine Wu <octref@gmail.com>
Date:   Wed Jan 22 13:49:42 2020 +0100

    WIP
This commit is contained in:
Pine Wu
2020-01-24 10:30:19 +01:00
parent e4eec1db9c
commit 38549a606c
13 changed files with 372 additions and 37 deletions

View File

@@ -127,11 +127,19 @@ export namespace DiagnosticTag {
export namespace Diagnostic {
export function from(value: vscode.Diagnostic): IMarkerData {
let code: string | { value: string; link: URI } | undefined = isString(value.code) || isNumber(value.code) ? String(value.code) : undefined;
if (value.code2) {
code = {
value: String(value.code2.value),
link: value.code2.link
};
}
return {
...Range.from(value.range),
message: value.message,
source: value.source,
code: isString(value.code) || isNumber(value.code) ? String(value.code) : undefined,
code,
severity: DiagnosticSeverity.from(value.severity),
relatedInformation: value.relatedInformation && value.relatedInformation.map(DiagnosticRelatedInformation.from),
tags: Array.isArray(value.tags) ? coalesce(value.tags.map(DiagnosticTag.from)) : undefined,
@@ -141,7 +149,7 @@ export namespace Diagnostic {
export function to(value: IMarkerData): vscode.Diagnostic {
const res = new types.Diagnostic(Range.to(value), value.message, DiagnosticSeverity.to(value.severity));
res.source = value.source;
res.code = value.code;
res.code = isString(value.code) ? value.code : value.code?.value;
res.relatedInformation = value.relatedInformation && value.relatedInformation.map(DiagnosticRelatedInformation.to);
res.tags = value.tags && coalesce(value.tags.map(DiagnosticTag.to));
return res;