mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 13:55:41 +01:00
Provide related information to diagnostics (#48)
Provide related information to diagnostics
This commit is contained in:
commit
2bbb4ed4b9
1 changed files with 22 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue