Merge pull request #15296 from Microsoft/Fix15224

Fix #15224: Add a `source` property on Diagnostic interface
This commit is contained in:
Mohamed Hegazy
2017-04-20 14:01:04 -07:00
committed by GitHub
3 changed files with 13 additions and 4 deletions

View File

@@ -3350,6 +3350,7 @@ namespace ts {
messageText: string | DiagnosticMessageChain;
category: DiagnosticCategory;
code: number;
source?: string;
}
export enum DiagnosticCategory {

View File

@@ -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 {

View File

@@ -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)
});