Move diagnostic tags api out of proposed

Also rename `customTags` to `tags`

Fixes #51104
This commit is contained in:
Matt Bierner 2018-06-18 10:07:21 -07:00
parent c64a6f291b
commit 2e5253d493
11 changed files with 36 additions and 34 deletions

View file

@ -155,7 +155,7 @@ export class DiagnosticsManager {
return this._diagnostics.get(DiagnosticKind.Suggestion)!.get(file).filter(x => {
if (!this._enableSuggestions) {
// Still show unused
return x.customTags && x.customTags.indexOf(vscode.DiagnosticTag.Unnecessary) !== -1;
return x.tags && x.tags.indexOf(vscode.DiagnosticTag.Unnecessary) !== -1;
}
return true;
});

View file

@ -154,7 +154,7 @@ export default class LanguageProvider {
const reportUnnecessary = config.get<boolean>('showUnused', true);
this.diagnosticsManager.diagnosticsReceived(diagnosticsKind, file, diagnostics.filter(diag => {
if (!reportUnnecessary) {
diag.customTags = undefined;
diag.tags = undefined;
if (diag.reportUnnecessary && diag.severity === vscode.DiagnosticSeverity.Hint) {
return false;
}

View file

@ -298,7 +298,7 @@ export default class TypeScriptServiceClientHost {
}).filter((x: any) => !!x) as DiagnosticRelatedInformation[];
}
if (diagnostic.reportsUnnecessary) {
converted.customTags = [DiagnosticTag.Unnecessary];
converted.tags = [DiagnosticTag.Unnecessary];
}
(converted as Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
return converted as Diagnostic & { reportUnnecessary: any };

View file

@ -131,7 +131,7 @@ class ModelMarkerHandler {
switch (marker.severity) {
case MarkerSeverity.Hint:
if (marker.customTags && marker.customTags.indexOf(MarkerTag.Unnecessary) >= 0) {
if (marker.tags && marker.tags.indexOf(MarkerTag.Unnecessary) >= 0) {
className = ClassName.EditorUnnecessaryDecoration;
} else {
className = ClassName.EditorHintDecoration;
@ -159,8 +159,8 @@ class ModelMarkerHandler {
break;
}
if (marker.customTags) {
if (marker.customTags.indexOf(MarkerTag.Unnecessary) !== -1) {
if (marker.tags) {
if (marker.tags.indexOf(MarkerTag.Unnecessary) !== -1) {
inlineClassName = ClassName.EditorUnnecessaryInlineDecoration;
}
}

4
src/vs/monaco.d.ts vendored
View file

@ -1093,7 +1093,7 @@ declare namespace monaco.editor {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}
/**
@ -1109,7 +1109,7 @@ declare namespace monaco.editor {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}
/**

View file

@ -184,7 +184,7 @@ export class MarkerService implements IMarkerService {
message, source,
startLineNumber, startColumn, endLineNumber, endColumn,
relatedInformation,
customTags,
tags,
} = data;
if (!message) {
@ -210,7 +210,7 @@ export class MarkerService implements IMarkerService {
endLineNumber,
endColumn,
relatedInformation,
customTags,
tags,
};
}

View file

@ -87,7 +87,7 @@ export interface IMarkerData {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}
export interface IResourceMarker {
@ -107,7 +107,7 @@ export interface IMarker {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}
export interface MarkerStatistics {

22
src/vs/vscode.d.ts vendored
View file

@ -3938,6 +3938,23 @@ declare module 'vscode' {
constructor(location: Location, message: string);
}
/**
* Additional metadata about the type of a diagnostic.
*/
export enum DiagnosticTag {
/**
* Unused or unnecessary code.
*
* Diagnostics with this tag are rendered faded out. The amount of fading
* is controlled by the `"editorUnnecessaryCode.opacity"` theme color. For
* example, `"editorUnnecessaryCode.opacity": "#000000c0" will render the
* code with 75% opacity. For high contrast themes, use the
* `"editorUnnecessaryCode.border"` the color to underline unnecessary code
* instead of fading it out.
*/
Unnecessary = 1,
}
/**
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
* are only valid in the scope of a file.
@ -3978,6 +3995,11 @@ declare module 'vscode' {
*/
relatedInformation?: DiagnosticRelatedInformation[];
/**
* Additional metadata about the diagnostic.
*/
tags?: DiagnosticTag[];
/**
* Creates a new diagnostic object.
*

View file

@ -492,26 +492,6 @@ declare module 'vscode' {
//#endregion
//#region mjbvz: Unused diagnostics
/**
* Additional metadata about the type of diagnostic.
*/
export enum DiagnosticTag {
/**
* Unused or unnecessary code.
*/
Unnecessary = 1,
}
export interface Diagnostic {
/**
* Additional metadata about the type of the diagnostic.
*/
customTags?: DiagnosticTag[];
}
//#endregion
//#region mjbvz: File rename events
export interface ResourceRenamedEvent {
readonly oldResource: Uri;

View file

@ -111,7 +111,7 @@ export namespace Diagnostic {
code: String(value.code),
severity: DiagnosticSeverity.from(value.severity),
relatedInformation: value.relatedInformation && value.relatedInformation.map(DiagnosticRelatedInformation.from),
customTags: Array.isArray(value.customTags) ? value.customTags.map(DiagnosticTag.from) : undefined,
tags: Array.isArray(value.tags) ? value.tags.map(DiagnosticTag.from) : undefined,
};
}
}

View file

@ -750,7 +750,7 @@ export class Diagnostic {
code: string | number;
severity: DiagnosticSeverity;
relatedInformation: DiagnosticRelatedInformation[];
customTags?: DiagnosticTag[];
tags?: DiagnosticTag[];
constructor(range: Range, message: string, severity: DiagnosticSeverity = DiagnosticSeverity.Error) {
this.range = range;