提交 5a57f27d 编写于 作者: J Johannes Rieken

refine interfaces

上级 737f55bb
......@@ -61,19 +61,15 @@ class MarkersFileDecorations implements IWorkbenchContribution {
const markers = this._markerService.read({ resource })
.sort((a, b) => Severity.compare(a.severity, b.severity));
if (!isFalsyOrEmpty(markers)) {
const data = this._toFileDecorationData(markers[0]);
this._decorationsService.setFileDecoration(this._type, resource, data);
} else {
this._decorationsService.unsetFileDecoration(this._type, resource);
}
const data = !isFalsyOrEmpty(markers) ? this._toFileDecorationData(markers[0]) : undefined;
this._decorationsService.setFileDecoration(this._type, resource, data);
}
}
private _toFileDecorationData(marker: IMarker): IFileDecorationData {
const { message, severity } = marker;
const { severity } = marker;
const color = severity === Severity.Error ? editorErrorForeground : editorWarningForeground;
return { message, severity, color };
return { severity, color };
}
}
......
......@@ -15,7 +15,6 @@ import Severity from 'vs/base/common/severity';
export class FileDecorations implements IWorkbenchContribution {
private readonly _disposables: IDisposable[];
// private readonly _type: DecorationType;
private readonly _repositoryListeners = new Map<ISCMRepository, IDisposable>();
constructor(
......@@ -50,8 +49,8 @@ export class FileDecorations implements IWorkbenchContribution {
this._decorationsService.setFileDecoration(type, resource.sourceUri, {
severity: Severity.Info,
message: resource.decorations.tooltip,
color: resource.decorations.color
color: resource.decorations.color,
icon: { light: resource.decorations.icon, dark: resource.decorations.iconDark }
});
newDecorations.set(resource.sourceUri.toString(), resource.sourceUri);
}
......@@ -59,7 +58,7 @@ export class FileDecorations implements IWorkbenchContribution {
oldDecorations.forEach((value, key) => {
if (!newDecorations.has(key)) {
this._decorationsService.unsetFileDecoration(type, value);
this._decorationsService.setFileDecoration(type, value);
}
});
......
......@@ -12,13 +12,6 @@ import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
export const IFileDecorationsService = createDecorator<IFileDecorationsService>('IFileDecorationsService');
export interface IFileDecoration {
readonly type: DecorationType;
readonly message: string;
readonly color: ColorIdentifier;
readonly severity: Severity;
}
export abstract class DecorationType {
readonly label: string;
protected constructor(label: string) {
......@@ -29,10 +22,14 @@ export abstract class DecorationType {
}
}
export interface IFileDecoration extends IFileDecorationData {
readonly type: DecorationType;
}
export interface IFileDecorationData {
message: string;
color: ColorIdentifier;
severity: Severity;
readonly severity: Severity;
readonly color?: ColorIdentifier;
readonly icon?: URI | { dark: URI, light: URI };
}
export interface IFileDecorationsService {
......@@ -43,9 +40,7 @@ export interface IFileDecorationsService {
registerDecorationType(label: string): DecorationType;
setFileDecoration(type: DecorationType, target: URI, data: IFileDecorationData): void;
unsetFileDecoration(type: DecorationType, target: URI): void;
setFileDecoration(type: DecorationType, target: URI, data?: IFileDecorationData): void;
getDecorations(uri: URI, includeChildren: boolean): IFileDecoration[];
......
......@@ -46,13 +46,12 @@ export class FileDecorationsService implements IFileDecorationsService {
return type;
}
setFileDecoration(type: DecorationType, target: URI, data: IFileDecorationData): void {
this._types.get(type).set(target.toString(), { type, ...data });
this._onDidChangeFileDecoration.fire(target);
}
unsetFileDecoration(type: DecorationType, target: URI): void {
this._types.get(type).delete(target.toString());
setFileDecoration(type: DecorationType, target: URI, data?: IFileDecorationData): void {
if (data) {
this._types.get(type).set(target.toString(), { type, ...data });
} else {
this._types.get(type).delete(target.toString());
}
this._onDidChangeFileDecoration.fire(target);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册