Skip to content

Commit

Permalink
Move diagnostic tags api out of proposed
Browse files Browse the repository at this point in the history
Also rename `customTags` to `tags`

Fixes #51104
  • Loading branch information
mjbvz committed Jun 18, 2018
1 parent c64a6f2 commit 2e5253d
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/common/services/modelServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ declare namespace monaco.editor {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}

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

/**
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/markers/common/markerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class MarkerService implements IMarkerService {
message, source,
startLineNumber, startColumn, endLineNumber, endColumn,
relatedInformation,
customTags,
tags,
} = data;

if (!message) {
Expand All @@ -210,7 +210,7 @@ export class MarkerService implements IMarkerService {
endLineNumber,
endColumn,
relatedInformation,
customTags,
tags,
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/markers/common/markers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface IMarkerData {
endLineNumber: number;
endColumn: number;
relatedInformation?: IRelatedInformation[];
customTags?: MarkerTag[];
tags?: MarkerTag[];
}

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

export interface MarkerStatistics {
Expand Down
22 changes: 22 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -3978,6 +3995,11 @@ declare module 'vscode' {
*/
relatedInformation?: DiagnosticRelatedInformation[];

/**
* Additional metadata about the diagnostic.
*/
tags?: DiagnosticTag[];

/**
* Creates a new diagnostic object.
*
Expand Down
20 changes: 0 additions & 20 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2e5253d

Please sign in to comment.