mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Extend disposable
This commit is contained in:
parent
f8f2538d20
commit
f26d81979f
|
@ -10,6 +10,7 @@ import * as nls from 'vscode-nls';
|
|||
import { wait } from '../test/testUtils';
|
||||
import { ITypeScriptServiceClient, ServerResponse } from '../typescriptService';
|
||||
import { coalesce, flatten } from '../utils/arrays';
|
||||
import { Disposable } from '../utils/dispose';
|
||||
import { exists } from '../utils/fs';
|
||||
import { isTsConfigFileName } from '../utils/languageDescription';
|
||||
import { Lazy } from '../utils/lazy';
|
||||
|
@ -34,28 +35,24 @@ interface TypeScriptTaskDefinition extends vscode.TaskDefinition {
|
|||
/**
|
||||
* Provides tasks for building `tsconfig.json` files in a project.
|
||||
*/
|
||||
class TscTaskProvider implements vscode.TaskProvider {
|
||||
class TscTaskProvider extends Disposable implements vscode.TaskProvider {
|
||||
|
||||
private readonly projectInfoRequestTimeout = 2000;
|
||||
private readonly findConfigFilesTimeout = 5000;
|
||||
|
||||
private autoDetect = AutoDetect.on;
|
||||
private readonly tsconfigProvider: TsConfigProvider;
|
||||
private readonly disposables: vscode.Disposable[] = [];
|
||||
|
||||
public constructor(
|
||||
private readonly client: Lazy<ITypeScriptServiceClient>
|
||||
) {
|
||||
super();
|
||||
this.tsconfigProvider = new TsConfigProvider();
|
||||
|
||||
vscode.workspace.onDidChangeConfiguration(this.onConfigurationChanged, this, this.disposables);
|
||||
this._register(vscode.workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
|
||||
this.onConfigurationChanged();
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.disposables.forEach(x => x.dispose());
|
||||
}
|
||||
|
||||
public async provideTasks(token: vscode.CancellationToken): Promise<vscode.Task[]> {
|
||||
const folders = vscode.workspace.workspaceFolders;
|
||||
if ((this.autoDetect === AutoDetect.off) || !folders || !folders.length) {
|
||||
|
|
Loading…
Reference in a new issue