mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 14:30:13 +00:00
Move diagnostic tags api out of proposed
Also rename `customTags` to `tags` Fixes #51104
This commit is contained in:
parent
c64a6f291b
commit
2e5253d493
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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
4
src/vs/monaco.d.ts
vendored
|
@ -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[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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
22
src/vs/vscode.d.ts
vendored
|
@ -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.
|
||||
*
|
||||
|
|
20
src/vs/vscode.proposed.d.ts
vendored
20
src/vs/vscode.proposed.d.ts
vendored
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue