Browse Source

Removes inheritance from Disposable

main
Eric Amodio 6 years ago
parent
commit
1f657bbbb3
18 changed files with 20 additions and 61 deletions
  1. +1
    -3
      src/annotations/annotationProvider.ts
  2. +1
    -3
      src/annotations/fileAnnotationController.ts
  3. +1
    -3
      src/annotations/lineAnnotationController.ts
  4. +1
    -3
      src/codelens/codeLensController.ts
  5. +2
    -6
      src/commands/common.ts
  6. +1
    -3
      src/git/models/repository.ts
  7. +1
    -3
      src/gitService.ts
  8. +1
    -3
      src/hovers/lineHoverController.ts
  9. +2
    -6
      src/keyboard.ts
  10. +1
    -3
      src/statusbar/statusBarController.ts
  11. +1
    -3
      src/trackers/activeEditorTracker.ts
  12. +1
    -3
      src/trackers/documentTracker.ts
  13. +1
    -5
      src/trackers/lineTracker.ts
  14. +1
    -3
      src/trackers/trackedDocument.ts
  15. +1
    -3
      src/views/explorerCommands.ts
  16. +1
    -2
      src/views/nodes/explorerNode.ts
  17. +1
    -3
      src/views/resultsExplorer.ts
  18. +1
    -3
      src/webviews/webviewEditor.ts

+ 1
- 3
src/annotations/annotationProvider.ts View File

@ -23,7 +23,7 @@ export enum AnnotationStatus {
export type TextEditorCorrelationKey = string; export type TextEditorCorrelationKey = string;
export abstract class AnnotationProviderBase extends Disposable {
export abstract class AnnotationProviderBase implements Disposable {
static getCorrelationKey(editor: TextEditor | undefined): TextEditorCorrelationKey { static getCorrelationKey(editor: TextEditor | undefined): TextEditorCorrelationKey {
return editor !== undefined ? (editor as any).id : ''; return editor !== undefined ? (editor as any).id : '';
} }
@ -42,8 +42,6 @@ export abstract class AnnotationProviderBase extends Disposable {
protected decoration: TextEditorDecorationType, protected decoration: TextEditorDecorationType,
protected highlightDecoration: TextEditorDecorationType | undefined protected highlightDecoration: TextEditorDecorationType | undefined
) { ) {
super(() => this.dispose());
this.correlationKey = AnnotationProviderBase.getCorrelationKey(this.editor); this.correlationKey = AnnotationProviderBase.getCorrelationKey(this.editor);
this.document = this.editor.document; this.document = this.editor.document;

+ 1
- 3
src/annotations/fileAnnotationController.ts View File

@ -55,7 +55,7 @@ export const Decorations = {
recentChangesHighlight: undefined as TextEditorDecorationType | undefined recentChangesHighlight: undefined as TextEditorDecorationType | undefined
}; };
export class FileAnnotationController extends Disposable {
export class FileAnnotationController implements Disposable {
private _onDidToggleAnnotations = new EventEmitter<void>(); private _onDidToggleAnnotations = new EventEmitter<void>();
get onDidToggleAnnotations(): Event<void> { get onDidToggleAnnotations(): Event<void> {
return this._onDidToggleAnnotations.event; return this._onDidToggleAnnotations.event;
@ -70,8 +70,6 @@ export class FileAnnotationController extends Disposable {
private _annotationType: FileAnnotationType | undefined = undefined; private _annotationType: FileAnnotationType | undefined = undefined;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this)); this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this._toggleModes = new Map(); this._toggleModes = new Map();

+ 1
- 3
src/annotations/lineAnnotationController.ts View File

@ -24,15 +24,13 @@ const annotationDecoration: TextEditorDecorationType = window.createTextEditorDe
rangeBehavior: DecorationRangeBehavior.ClosedOpen rangeBehavior: DecorationRangeBehavior.ClosedOpen
} as DecorationRenderOptions); } as DecorationRenderOptions);
export class LineAnnotationController extends Disposable {
export class LineAnnotationController implements Disposable {
private _disposable: Disposable; private _disposable: Disposable;
private _debugSessionEndDisposable: Disposable | undefined; private _debugSessionEndDisposable: Disposable | undefined;
private _editor: TextEditor | undefined; private _editor: TextEditor | undefined;
private _enabled: boolean = false; private _enabled: boolean = false;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from( this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this), configuration.onDidChange(this.onConfigurationChanged, this),
Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this), Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this),

+ 1
- 3
src/codelens/codeLensController.ts View File

@ -11,15 +11,13 @@ import {
} from '../trackers/gitDocumentTracker'; } from '../trackers/gitDocumentTracker';
import { GitCodeLensProvider } from './gitCodeLensProvider'; import { GitCodeLensProvider } from './gitCodeLensProvider';
export class CodeLensController extends Disposable {
export class CodeLensController implements Disposable {
private _canToggle: boolean = false; private _canToggle: boolean = false;
private _disposable: Disposable | undefined; private _disposable: Disposable | undefined;
private _provider: GitCodeLensProvider | undefined; private _provider: GitCodeLensProvider | undefined;
private _providerDisposable: Disposable | undefined; private _providerDisposable: Disposable | undefined;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this)); this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent); this.onConfigurationChanged(configuration.initializingChangeEvent);
} }

+ 2
- 6
src/commands/common.ts View File

@ -213,7 +213,7 @@ function isTextEditor(editor: any): editor is TextEditor {
); );
} }
export abstract class Command extends Disposable {
export abstract class Command implements Disposable {
static getMarkdownCommandArgsCore<T>(command: Commands, args: T): string { static getMarkdownCommandArgsCore<T>(command: Commands, args: T): string {
return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`; return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`;
} }
@ -223,8 +223,6 @@ export abstract class Command extends Disposable {
private _disposable: Disposable; private _disposable: Disposable;
constructor(command: Commands | Commands[]) { constructor(command: Commands | Commands[]) {
super(() => this.dispose());
if (typeof command === 'string') { if (typeof command === 'string') {
this._disposable = commands.registerCommand( this._disposable = commands.registerCommand(
command, command,
@ -354,12 +352,10 @@ export abstract class ActiveEditorCachedCommand extends ActiveEditorCommand {
abstract execute(editor: TextEditor, ...args: any[]): any; abstract execute(editor: TextEditor, ...args: any[]): any;
} }
export abstract class EditorCommand extends Disposable {
export abstract class EditorCommand implements Disposable {
private _disposable: Disposable; private _disposable: Disposable;
constructor(command: Commands | Commands[]) { constructor(command: Commands | Commands[]) {
super(() => this.dispose());
if (!Array.isArray(command)) { if (!Array.isArray(command)) {
command = [command]; command = [command];
} }

+ 1
- 3
src/git/models/repository.ts View File

@ -59,7 +59,7 @@ export enum RepositoryStorage {
StatusNode = 'statusNode' StatusNode = 'statusNode'
} }
export class Repository extends Disposable {
export class Repository implements Disposable {
private _onDidChange = new EventEmitter<RepositoryChangeEvent>(); private _onDidChange = new EventEmitter<RepositoryChangeEvent>();
get onDidChange(): Event<RepositoryChangeEvent> { get onDidChange(): Event<RepositoryChangeEvent> {
return this._onDidChange.event; return this._onDidChange.event;
@ -95,8 +95,6 @@ export class Repository extends Disposable {
suspended: boolean, suspended: boolean,
closed: boolean = false closed: boolean = false
) { ) {
super(() => this.dispose());
if (root) { if (root) {
this.formattedName = folder.name; this.formattedName = folder.name;
} }

+ 1
- 3
src/gitService.ts View File

@ -78,7 +78,7 @@ export enum GitRepoSearchBy {
Sha = 'sha' Sha = 'sha'
} }
export class GitService extends Disposable {
export class GitService implements Disposable {
static emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined); static emptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
static deletedSha = 'ffffffffffffffffffffffffffffffffffffffff'; static deletedSha = 'ffffffffffffffffffffffffffffffffffffffff';
static stagedUncommittedSha = Git.stagedUncommittedSha; static stagedUncommittedSha = Git.stagedUncommittedSha;
@ -97,8 +97,6 @@ export class GitService extends Disposable {
private _versionedUriCache: Map<string, GitUri>; private _versionedUriCache: Map<string, GitUri>;
constructor() { constructor() {
super(() => this.dispose());
this._repositoryTree = TernarySearchTree.forPaths(); this._repositoryTree = TernarySearchTree.forPaths();
this._trackedCache = new Map(); this._trackedCache = new Map();
this._versionedUriCache = new Map(); this._versionedUriCache = new Map();

+ 1
- 3
src/hovers/lineHoverController.ts View File

@ -18,14 +18,12 @@ import { configuration } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { LinesChangeEvent } from '../trackers/gitLineTracker'; import { LinesChangeEvent } from '../trackers/gitLineTracker';
export class LineHoverController extends Disposable {
export class LineHoverController implements Disposable {
private _debugSessionEndDisposable: Disposable | undefined; private _debugSessionEndDisposable: Disposable | undefined;
private _disposable: Disposable; private _disposable: Disposable;
private _hoverProviderDisposable: Disposable | undefined; private _hoverProviderDisposable: Disposable | undefined;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from( this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this), configuration.onDidChange(this.onConfigurationChanged, this),
debug.onDidStartDebugSession(this.onDebugSessionStarted, this) debug.onDidStartDebugSession(this.onDebugSessionStarted, this)

+ 2
- 6
src/keyboard.ts View File

@ -19,12 +19,10 @@ export declare interface KeyMapping {
const mappings: KeyMapping[] = []; const mappings: KeyMapping[] = [];
export class KeyboardScope extends Disposable {
export class KeyboardScope implements Disposable {
constructor( constructor(
private readonly mapping: KeyMapping private readonly mapping: KeyMapping
) { ) {
super(() => this.dispose());
for (const key in mapping) { for (const key in mapping) {
mapping[key] = mapping[key] || keyNoopCommand; mapping[key] = mapping[key] || keyNoopCommand;
} }
@ -81,12 +79,10 @@ export class KeyboardScope extends Disposable {
} }
} }
export class Keyboard extends Disposable {
export class Keyboard implements Disposable {
private _disposable: Disposable; private _disposable: Disposable;
constructor() { constructor() {
super(() => this.dispose());
const subscriptions = keys.map(key => const subscriptions = keys.map(key =>
commands.registerCommand(`${extensionId}.key.${key}`, () => this.execute(key), this) commands.registerCommand(`${extensionId}.key.${key}`, () => this.execute(key), this)
); );

+ 1
- 3
src/statusbar/statusBarController.ts View File

@ -7,14 +7,12 @@ import { Container } from '../container';
import { CommitFormatter, GitCommit, ICommitFormatOptions } from '../gitService'; import { CommitFormatter, GitCommit, ICommitFormatOptions } from '../gitService';
import { LinesChangeEvent } from '../trackers/gitLineTracker'; import { LinesChangeEvent } from '../trackers/gitLineTracker';
export class StatusBarController extends Disposable {
export class StatusBarController implements Disposable {
private _blameStatusBarItem: StatusBarItem | undefined; private _blameStatusBarItem: StatusBarItem | undefined;
private _disposable: Disposable; private _disposable: Disposable;
private _modeStatusBarItem: StatusBarItem | undefined; private _modeStatusBarItem: StatusBarItem | undefined;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this)); this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent); this.onConfigurationChanged(configuration.initializingChangeEvent);
} }

+ 1
- 3
src/trackers/activeEditorTracker.ts View File

@ -3,13 +3,11 @@ import { commands, Disposable, TextEditor, window } from 'vscode';
import { BuiltInCommands } from '../constants'; import { BuiltInCommands } from '../constants';
import { Functions } from '../system'; import { Functions } from '../system';
export class ActiveEditorTracker extends Disposable {
export class ActiveEditorTracker implements Disposable {
private _disposable: Disposable; private _disposable: Disposable;
private _resolver: ((editor: TextEditor | undefined) => void) | undefined; private _resolver: ((editor: TextEditor | undefined) => void) | undefined;
constructor() { constructor() {
super(() => this.dispose());
const fn = Functions.debounce((e: TextEditor | undefined) => this._resolver && this._resolver(e), 50); const fn = Functions.debounce((e: TextEditor | undefined) => this._resolver && this._resolver(e), 50);
this._disposable = window.onDidChangeActiveTextEditor(fn); this._disposable = window.onDidChangeActiveTextEditor(fn);
} }

+ 1
- 3
src/trackers/documentTracker.ts View File

@ -34,7 +34,7 @@ export interface DocumentDirtyIdleTriggerEvent {
readonly document: TrackedDocument<T>; readonly document: TrackedDocument<T>;
} }
export class DocumentTracker<T> extends Disposable {
export class DocumentTracker<T> implements Disposable {
private _onDidChangeBlameState = new EventEmitter<DocumentBlameStateChangeEvent<T>>(); private _onDidChangeBlameState = new EventEmitter<DocumentBlameStateChangeEvent<T>>();
get onDidChangeBlameState(): Event<DocumentBlameStateChangeEvent<T>> { get onDidChangeBlameState(): Event<DocumentBlameStateChangeEvent<T>> {
return this._onDidChangeBlameState.event; return this._onDidChangeBlameState.event;
@ -55,8 +55,6 @@ export class DocumentTracker extends Disposable {
private readonly _documentMap: Map<TextDocument | string, TrackedDocument<T>> = new Map(); private readonly _documentMap: Map<TextDocument | string, TrackedDocument<T>> = new Map();
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from( this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this), configuration.onDidChange(this.onConfigurationChanged, this),
window.onDidChangeActiveTextEditor(this.onActiveTextEditorChanged, this), window.onDidChangeActiveTextEditor(this.onActiveTextEditorChanged, this),

+ 1
- 5
src/trackers/lineTracker.ts View File

@ -11,7 +11,7 @@ export interface LinesChangeEvent {
readonly pending?: boolean; readonly pending?: boolean;
} }
export class LineTracker<T> extends Disposable {
export class LineTracker<T> implements Disposable {
private _onDidChangeActiveLines = new EventEmitter<LinesChangeEvent>(); private _onDidChangeActiveLines = new EventEmitter<LinesChangeEvent>();
get onDidChangeActiveLines(): Event<LinesChangeEvent> { get onDidChangeActiveLines(): Event<LinesChangeEvent> {
return this._onDidChangeActiveLines.event; return this._onDidChangeActiveLines.event;
@ -22,10 +22,6 @@ export class LineTracker extends Disposable {
private readonly _state: Map<number, T | undefined> = new Map(); private readonly _state: Map<number, T | undefined> = new Map();
constructor() {
super(() => this.dispose());
}
dispose() { dispose() {
this.stop(); this.stop();
} }

+ 1
- 3
src/trackers/trackedDocument.ts View File

@ -12,7 +12,7 @@ export interface DocumentBlameStateChangeEvent {
readonly blameable: boolean; readonly blameable: boolean;
} }
export class TrackedDocument<T> extends Disposable {
export class TrackedDocument<T> implements Disposable {
private _onDidBlameStateChange = new EventEmitter<DocumentBlameStateChangeEvent<T>>(); private _onDidBlameStateChange = new EventEmitter<DocumentBlameStateChangeEvent<T>>();
get onDidBlameStateChange(): Event<DocumentBlameStateChangeEvent<T>> { get onDidBlameStateChange(): Event<DocumentBlameStateChangeEvent<T>> {
return this._onDidBlameStateChange.event; return this._onDidBlameStateChange.event;
@ -31,8 +31,6 @@ export class TrackedDocument extends Disposable {
public dirty: boolean, public dirty: boolean,
private _eventDelegates: { onDidBlameStateChange(e: DocumentBlameStateChangeEvent<T>): void } private _eventDelegates: { onDidBlameStateChange(e: DocumentBlameStateChangeEvent<T>): void }
) { ) {
super(() => this.dispose());
this._repo = this.initialize(_document.uri); this._repo = this.initialize(_document.uri);
} }

+ 1
- 3
src/views/explorerCommands.ts View File

@ -41,14 +41,12 @@ interface ICompareSelected {
uri?: Uri; uri?: Uri;
} }
export class ExplorerCommands extends Disposable {
export class ExplorerCommands implements Disposable {
private _disposable: Disposable | undefined; private _disposable: Disposable | undefined;
private _terminal: Terminal | undefined; private _terminal: Terminal | undefined;
private _terminalCwd: string | undefined; private _terminalCwd: string | undefined;
constructor() { constructor() {
super(() => this.dispose());
commands.registerCommand('gitlens.explorers.openChanges', this.openChanges, this); commands.registerCommand('gitlens.explorers.openChanges', this.openChanges, this);
commands.registerCommand('gitlens.explorers.openChangesWithWorking', this.openChangesWithWorking, this); commands.registerCommand('gitlens.explorers.openChangesWithWorking', this.openChangesWithWorking, this);
commands.registerCommand('gitlens.explorers.openFile', this.openFile, this); commands.registerCommand('gitlens.explorers.openFile', this.openFile, this);

+ 1
- 2
src/views/nodes/explorerNode.ts View File

@ -66,7 +66,7 @@ export type Explorer = GitExplorer | HistoryExplorer | ResultsExplorer;
// let id = 0; // let id = 0;
export abstract class ExplorerNode extends Disposable {
export abstract class ExplorerNode implements Disposable {
readonly supportsPaging: boolean = false; readonly supportsPaging: boolean = false;
maxCount: number | undefined; maxCount: number | undefined;
@ -77,7 +77,6 @@ export abstract class ExplorerNode extends Disposable {
constructor( constructor(
public readonly uri: GitUri public readonly uri: GitUri
) { ) {
super(() => this.dispose());
// this.id = id++; // this.id = id++;
} }

+ 1
- 3
src/views/resultsExplorer.ts View File

@ -31,7 +31,7 @@ import {
export * from './nodes'; export * from './nodes';
export class ResultsExplorer extends Disposable implements TreeDataProvider<ExplorerNode> {
export class ResultsExplorer implements TreeDataProvider<ExplorerNode>, Disposable {
private _disposable: Disposable | undefined; private _disposable: Disposable | undefined;
private _roots: ExplorerNode[] = []; private _roots: ExplorerNode[] = [];
private _tree: TreeView<ExplorerNode> | undefined; private _tree: TreeView<ExplorerNode> | undefined;
@ -42,8 +42,6 @@ export class ResultsExplorer extends Disposable implements TreeDataProvider
} }
constructor() { constructor() {
super(() => this.dispose());
Container.explorerCommands; Container.explorerCommands;
commands.registerCommand('gitlens.resultsExplorer.refresh', this.refreshNodes, this); commands.registerCommand('gitlens.resultsExplorer.refresh', this.refreshNodes, this);
commands.registerCommand('gitlens.resultsExplorer.refreshNode', this.refreshNode, this); commands.registerCommand('gitlens.resultsExplorer.refreshNode', this.refreshNode, this);

+ 1
- 3
src/webviews/webviewEditor.ts View File

@ -16,14 +16,12 @@ import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Message, SettingsChangedMessage } from '../ui/ipc'; import { Message, SettingsChangedMessage } from '../ui/ipc';
export abstract class WebviewEditor<TBootstrap> extends Disposable {
export abstract class WebviewEditor<TBootstrap> implements Disposable {
private _disposable: Disposable | undefined; private _disposable: Disposable | undefined;
private _disposablePanel: Disposable | undefined; private _disposablePanel: Disposable | undefined;
private _panel: WebviewPanel | undefined; private _panel: WebviewPanel | undefined;
constructor() { constructor() {
super(() => this.dispose());
this._disposable = Disposable.from( this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this), configuration.onDidChange(this.onConfigurationChanged, this),
...this.registerCommands() ...this.registerCommands()

Loading…
Cancel
Save