Skip to content

Commit 2e5253d

Browse files
committed
Move diagnostic tags api out of proposed
Also rename `customTags` to `tags` Fixes microsoft#51104
1 parent c64a6f2 commit 2e5253d

11 files changed

Lines changed: 36 additions & 34 deletions

File tree

extensions/typescript-language-features/src/features/diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class DiagnosticsManager {
155155
return this._diagnostics.get(DiagnosticKind.Suggestion)!.get(file).filter(x => {
156156
if (!this._enableSuggestions) {
157157
// Still show unused
158-
return x.customTags && x.customTags.indexOf(vscode.DiagnosticTag.Unnecessary) !== -1;
158+
return x.tags && x.tags.indexOf(vscode.DiagnosticTag.Unnecessary) !== -1;
159159
}
160160
return true;
161161
});

extensions/typescript-language-features/src/languageProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default class LanguageProvider {
154154
const reportUnnecessary = config.get<boolean>('showUnused', true);
155155
this.diagnosticsManager.diagnosticsReceived(diagnosticsKind, file, diagnostics.filter(diag => {
156156
if (!reportUnnecessary) {
157-
diag.customTags = undefined;
157+
diag.tags = undefined;
158158
if (diag.reportUnnecessary && diag.severity === vscode.DiagnosticSeverity.Hint) {
159159
return false;
160160
}

extensions/typescript-language-features/src/typeScriptServiceClientHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export default class TypeScriptServiceClientHost {
298298
}).filter((x: any) => !!x) as DiagnosticRelatedInformation[];
299299
}
300300
if (diagnostic.reportsUnnecessary) {
301-
converted.customTags = [DiagnosticTag.Unnecessary];
301+
converted.tags = [DiagnosticTag.Unnecessary];
302302
}
303303
(converted as Diagnostic & { reportUnnecessary: any }).reportUnnecessary = diagnostic.reportsUnnecessary;
304304
return converted as Diagnostic & { reportUnnecessary: any };

src/vs/editor/common/services/modelServiceImpl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ModelMarkerHandler {
131131

132132
switch (marker.severity) {
133133
case MarkerSeverity.Hint:
134-
if (marker.customTags && marker.customTags.indexOf(MarkerTag.Unnecessary) >= 0) {
134+
if (marker.tags && marker.tags.indexOf(MarkerTag.Unnecessary) >= 0) {
135135
className = ClassName.EditorUnnecessaryDecoration;
136136
} else {
137137
className = ClassName.EditorHintDecoration;
@@ -159,8 +159,8 @@ class ModelMarkerHandler {
159159
break;
160160
}
161161

162-
if (marker.customTags) {
163-
if (marker.customTags.indexOf(MarkerTag.Unnecessary) !== -1) {
162+
if (marker.tags) {
163+
if (marker.tags.indexOf(MarkerTag.Unnecessary) !== -1) {
164164
inlineClassName = ClassName.EditorUnnecessaryInlineDecoration;
165165
}
166166
}

src/vs/monaco.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ declare namespace monaco.editor {
10931093
endLineNumber: number;
10941094
endColumn: number;
10951095
relatedInformation?: IRelatedInformation[];
1096-
customTags?: MarkerTag[];
1096+
tags?: MarkerTag[];
10971097
}
10981098

10991099
/**
@@ -1109,7 +1109,7 @@ declare namespace monaco.editor {
11091109
endLineNumber: number;
11101110
endColumn: number;
11111111
relatedInformation?: IRelatedInformation[];
1112-
customTags?: MarkerTag[];
1112+
tags?: MarkerTag[];
11131113
}
11141114

11151115
/**

src/vs/platform/markers/common/markerService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class MarkerService implements IMarkerService {
184184
message, source,
185185
startLineNumber, startColumn, endLineNumber, endColumn,
186186
relatedInformation,
187-
customTags,
187+
tags,
188188
} = data;
189189

190190
if (!message) {
@@ -210,7 +210,7 @@ export class MarkerService implements IMarkerService {
210210
endLineNumber,
211211
endColumn,
212212
relatedInformation,
213-
customTags,
213+
tags,
214214
};
215215
}
216216

src/vs/platform/markers/common/markers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export interface IMarkerData {
8787
endLineNumber: number;
8888
endColumn: number;
8989
relatedInformation?: IRelatedInformation[];
90-
customTags?: MarkerTag[];
90+
tags?: MarkerTag[];
9191
}
9292

9393
export interface IResourceMarker {
@@ -107,7 +107,7 @@ export interface IMarker {
107107
endLineNumber: number;
108108
endColumn: number;
109109
relatedInformation?: IRelatedInformation[];
110-
customTags?: MarkerTag[];
110+
tags?: MarkerTag[];
111111
}
112112

113113
export interface MarkerStatistics {

src/vs/vscode.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3938,6 +3938,23 @@ declare module 'vscode' {
39383938
constructor(location: Location, message: string);
39393939
}
39403940

3941+
/**
3942+
* Additional metadata about the type of a diagnostic.
3943+
*/
3944+
export enum DiagnosticTag {
3945+
/**
3946+
* Unused or unnecessary code.
3947+
*
3948+
* Diagnostics with this tag are rendered faded out. The amount of fading
3949+
* is controlled by the `"editorUnnecessaryCode.opacity"` theme color. For
3950+
* example, `"editorUnnecessaryCode.opacity": "#000000c0" will render the
3951+
* code with 75% opacity. For high contrast themes, use the
3952+
* `"editorUnnecessaryCode.border"` the color to underline unnecessary code
3953+
* instead of fading it out.
3954+
*/
3955+
Unnecessary = 1,
3956+
}
3957+
39413958
/**
39423959
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
39433960
* are only valid in the scope of a file.
@@ -3978,6 +3995,11 @@ declare module 'vscode' {
39783995
*/
39793996
relatedInformation?: DiagnosticRelatedInformation[];
39803997

3998+
/**
3999+
* Additional metadata about the diagnostic.
4000+
*/
4001+
tags?: DiagnosticTag[];
4002+
39814003
/**
39824004
* Creates a new diagnostic object.
39834005
*

src/vs/vscode.proposed.d.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -492,26 +492,6 @@ declare module 'vscode' {
492492

493493
//#endregion
494494

495-
//#region mjbvz: Unused diagnostics
496-
/**
497-
* Additional metadata about the type of diagnostic.
498-
*/
499-
export enum DiagnosticTag {
500-
/**
501-
* Unused or unnecessary code.
502-
*/
503-
Unnecessary = 1,
504-
}
505-
506-
export interface Diagnostic {
507-
/**
508-
* Additional metadata about the type of the diagnostic.
509-
*/
510-
customTags?: DiagnosticTag[];
511-
}
512-
513-
//#endregion
514-
515495
//#region mjbvz: File rename events
516496
export interface ResourceRenamedEvent {
517497
readonly oldResource: Uri;

src/vs/workbench/api/node/extHostTypeConverters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export namespace Diagnostic {
111111
code: String(value.code),
112112
severity: DiagnosticSeverity.from(value.severity),
113113
relatedInformation: value.relatedInformation && value.relatedInformation.map(DiagnosticRelatedInformation.from),
114-
customTags: Array.isArray(value.customTags) ? value.customTags.map(DiagnosticTag.from) : undefined,
114+
tags: Array.isArray(value.tags) ? value.tags.map(DiagnosticTag.from) : undefined,
115115
};
116116
}
117117
}

0 commit comments

Comments
 (0)