From 5d7c75d88d3a165bee2db1fa9777d07ef3f0399b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 20 Apr 2017 13:22:55 -0700 Subject: [PATCH] Add a source property on Diagnostic --- src/compiler/types.ts | 1 + src/server/protocol.ts | 9 +++++++-- src/server/session.ts | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8874fd1a798ec..c4b73f07fc7b3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3350,6 +3350,7 @@ namespace ts { messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; + source?: string; } export enum DiagnosticCategory { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 41d4741559f4d..3c99707e6ab9b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -1824,15 +1824,20 @@ namespace ts.server.protocol { */ text: string; + /** + * The category of the diagnostic message, e.g. "error" vs. "warning" + */ + category: string; + /** * The error code of the diagnostic message. */ code?: number; /** - * The category of the diagnostic message, e.g. "error" vs. "warning" + * The name of the plugin reporting the message. */ - category: string; + source?: string; } export interface DiagnosticEventBody { diff --git a/src/server/session.ts b/src/server/session.ts index 72080d28fe780..9460b3df18655 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -68,7 +68,8 @@ namespace ts.server { end: scriptInfo.positionToLineOffset(diag.start + diag.length), text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), code: diag.code, - category: DiagnosticCategory[diag.category].toLowerCase() + category: DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } @@ -77,7 +78,8 @@ namespace ts.server { start: undefined, end: undefined, text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - category: DiagnosticCategory[diag.category].toLowerCase() + category: DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } @@ -592,6 +594,7 @@ namespace ts.server { length: d.length, category: DiagnosticCategory[d.category].toLowerCase(), code: d.code, + source: d.source, startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) });