eng - less TPromise usage
This commit is contained in:
parent
f9d93e884d
commit
ebeff1000b
4 changed files with 22 additions and 29 deletions
|
@ -6,7 +6,6 @@
|
|||
import * as vscode from 'vscode';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MainContext, IMainContext, ExtHostDecorationsShape, MainThreadDecorationsShape, DecorationData, DecorationRequest, DecorationReply } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { Disposable } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
|
@ -44,7 +43,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
|
|||
|
||||
$provideDecorations(requests: DecorationRequest[], token: CancellationToken): Thenable<DecorationReply> {
|
||||
const result: DecorationReply = Object.create(null);
|
||||
return TPromise.join(requests.map(request => {
|
||||
return Promise.all(requests.map(request => {
|
||||
const { handle, uri, id } = request;
|
||||
if (!this._provider.has(handle)) {
|
||||
// might have been unregistered in the meantime
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as Objects from 'vs/base/common/objects';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
@ -863,7 +862,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
|||
public $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<tasks.TaskSet> {
|
||||
let handler = this._handlers.get(handle);
|
||||
if (!handler) {
|
||||
return TPromise.wrapError<tasks.TaskSet>(new Error('no handler found'));
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
return asThenable(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
let sanitized: vscode.Task[] = [];
|
||||
|
|
|
@ -7,7 +7,6 @@ import * as assert from 'assert';
|
|||
import { setUnexpectedErrorHandler, errorHandler } from 'vs/base/common/errors';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as types from 'vs/workbench/api/node/extHostTypes';
|
||||
import { TextModel as EditorModel } from 'vs/editor/common/model/textModel';
|
||||
import { TestRPCProtocol } from './testRPCProtocol';
|
||||
|
@ -50,6 +49,10 @@ let commands: ExtHostCommands;
|
|||
let disposables: vscode.Disposable[] = [];
|
||||
let originalErrorHandler: (e: any) => any;
|
||||
|
||||
function assertRejects(fn: () => Thenable<any>, message: string = 'Expected rejection') {
|
||||
return fn().then(() => assert.ok(false, message), _err => assert.ok(true));
|
||||
}
|
||||
|
||||
suite('ExtHostLanguageFeatureCommands', function () {
|
||||
|
||||
suiteSetup(() => {
|
||||
|
@ -145,15 +148,12 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
|||
|
||||
test('WorkspaceSymbols, invalid arguments', function () {
|
||||
let promises = [
|
||||
commands.executeCommand('vscode.executeWorkspaceSymbolProvider'),
|
||||
commands.executeCommand('vscode.executeWorkspaceSymbolProvider', null),
|
||||
commands.executeCommand('vscode.executeWorkspaceSymbolProvider', undefined),
|
||||
commands.executeCommand('vscode.executeWorkspaceSymbolProvider', true)
|
||||
assertRejects(() => commands.executeCommand('vscode.executeWorkspaceSymbolProvider')),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeWorkspaceSymbolProvider', null)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeWorkspaceSymbolProvider', undefined)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeWorkspaceSymbolProvider', true))
|
||||
];
|
||||
|
||||
return TPromise.join(<any[]>promises).then(undefined, (err: any[]) => {
|
||||
assert.equal(err.length, 4);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
test('WorkspaceSymbols, back and forth', function () {
|
||||
|
@ -209,15 +209,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
|||
|
||||
test('Definition, invalid arguments', function () {
|
||||
let promises = [
|
||||
commands.executeCommand('vscode.executeDefinitionProvider'),
|
||||
commands.executeCommand('vscode.executeDefinitionProvider', null),
|
||||
commands.executeCommand('vscode.executeDefinitionProvider', undefined),
|
||||
commands.executeCommand('vscode.executeDefinitionProvider', true, false)
|
||||
assertRejects(() => commands.executeCommand('vscode.executeDefinitionProvider')),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeDefinitionProvider', null)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeDefinitionProvider', undefined)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeDefinitionProvider', true, false))
|
||||
];
|
||||
|
||||
return TPromise.join(<any[]>promises).then(undefined, (err: any[]) => {
|
||||
assert.equal(err.length, 4);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
test('Definition, back and forth', function () {
|
||||
|
@ -252,15 +250,13 @@ suite('ExtHostLanguageFeatureCommands', function () {
|
|||
|
||||
test('Type Definition, invalid arguments', function () {
|
||||
const promises = [
|
||||
commands.executeCommand('vscode.executeTypeDefinitionProvider'),
|
||||
commands.executeCommand('vscode.executeTypeDefinitionProvider', null),
|
||||
commands.executeCommand('vscode.executeTypeDefinitionProvider', undefined),
|
||||
commands.executeCommand('vscode.executeTypeDefinitionProvider', true, false)
|
||||
assertRejects(() => commands.executeCommand('vscode.executeTypeDefinitionProvider')),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeTypeDefinitionProvider', null)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeTypeDefinitionProvider', undefined)),
|
||||
assertRejects(() => commands.executeCommand('vscode.executeTypeDefinitionProvider', true, false))
|
||||
];
|
||||
|
||||
return TPromise.join(<any[]>promises).then(undefined, (err: any[]) => {
|
||||
assert.equal(err.length, 4);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
});
|
||||
|
||||
test('Type Definition, back and forth', function () {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as assert from 'assert';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
|
||||
import { MainContext, MainThreadTextEditorsShape, WorkspaceEditDto } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
@ -24,7 +23,7 @@ suite('ExtHostTextEditors.applyWorkspaceEdit', () => {
|
|||
|
||||
let rpcProtocol = new TestRPCProtocol();
|
||||
rpcProtocol.set(MainContext.MainThreadTextEditors, new class extends mock<MainThreadTextEditorsShape>() {
|
||||
$tryApplyWorkspaceEdit(_workspaceResourceEdits: WorkspaceEditDto): TPromise<boolean> {
|
||||
$tryApplyWorkspaceEdit(_workspaceResourceEdits: WorkspaceEditDto): Promise<boolean> {
|
||||
workspaceResourceEdits = _workspaceResourceEdits;
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue