提交 27a628bc 编写于 作者: M Matt Bierner

Avoid re-implementing Disposable

上级 12ce8ae2
......@@ -7,7 +7,7 @@ import { URI } from 'vs/base/common/uri';
import { Event, Emitter } from 'vs/base/common/event';
import { IDecorationsService, IDecoration, IResourceDecorationChangeEvent, IDecorationsProvider, IDecorationData } from './decorations';
import { TernarySearchTree } from 'vs/base/common/map';
import { Disposable, IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { isThenable } from 'vs/base/common/async';
import { LinkedList } from 'vs/base/common/linkedList';
import { createStyleSheet, createCSSRule, removeCSSRulesContainingSelector } from 'vs/base/browser/dom';
......@@ -334,15 +334,14 @@ class DecorationProviderWrapper {
}
}
export class FileDecorationsService implements IDecorationsService {
export class FileDecorationsService extends Disposable implements IDecorationsService {
_serviceBrand: any;
private readonly _data = new LinkedList<DecorationProviderWrapper>();
private readonly _onDidChangeDecorationsDelayed = new Emitter<URI | URI[]>();
private readonly _onDidChangeDecorations = new Emitter<IResourceDecorationChangeEvent>();
private readonly _onDidChangeDecorationsDelayed = this._register(new Emitter<URI | URI[]>());
private readonly _onDidChangeDecorations = this._register(new Emitter<IResourceDecorationChangeEvent>());
private readonly _decorationStyles: DecorationStyles;
private readonly _disposables: IDisposable[];
readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.any(
this._onDidChangeDecorations.event,
......@@ -356,27 +355,17 @@ export class FileDecorationsService implements IDecorationsService {
constructor(
@IThemeService themeService: IThemeService
) {
this._decorationStyles = new DecorationStyles(themeService);
super();
this._decorationStyles = this._register(new DecorationStyles(themeService));
// every so many events we check if there are
// css styles that we don't need anymore
let count = 0;
let reg = this.onDidChangeDecorations(() => {
this._register(this.onDidChangeDecorations(() => {
if (++count % 17 === 0) {
this._decorationStyles.cleanUp(this._data.iterator());
}
});
this._disposables = [
reg,
this._decorationStyles
];
}
dispose(): void {
dispose(this._disposables);
dispose(this._onDidChangeDecorations);
dispose(this._onDidChangeDecorationsDelayed);
}));
}
registerDecorationsProvider(provider: IDecorationsProvider): IDisposable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册