Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Commit

Permalink
Provide related information to diagnostics (#48)
Browse files Browse the repository at this point in the history
Provide related information to diagnostics
  • Loading branch information
alexdima authored Dec 17, 2019
2 parents 92c4b95 + fd244a1 commit 2bbb4ed
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/languageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,31 @@ export class DiagnosticsAdapter extends Adapter {
endColumn,
message: flattenDiagnosticMessageText(diag.messageText, '\n'),
code: diag.code.toString(),
tags: diag.reportsUnnecessary ? [monaco.MarkerTag.Unnecessary] : []
tags: diag.reportsUnnecessary ? [monaco.MarkerTag.Unnecessary] : [],
relatedInformation: this._convertRelatedInformation(resource, diag.relatedInformation),
};
}

private _convertRelatedInformation(resource: Uri, relatedInformation?: ts.DiagnosticRelatedInformation[]): monaco.editor.IRelatedInformation[] {
if (relatedInformation === undefined)
return undefined;

return relatedInformation.map(info => {
const relatedResource = info.file === undefined ? resource : monaco.Uri.parse(info.file.fileName);
const { lineNumber: startLineNumber, column: startColumn } = this._offsetToPosition(relatedResource, info.start);
const { lineNumber: endLineNumber, column: endColumn } = this._offsetToPosition(relatedResource, info.start + info.length);

return {
resource: relatedResource,
startLineNumber,
startColumn,
endLineNumber,
endColumn,
message: flattenDiagnosticMessageText(info.messageText, '\n')
};
});
}

private _tsDiagnosticCategoryToMarkerSeverity(category: ts.DiagnosticCategory): monaco.MarkerSeverity {
switch (category) {
case ts.DiagnosticCategory.Error: return monaco.MarkerSeverity.Error
Expand Down

0 comments on commit 2bbb4ed

Please sign in to comment.