提交 914c6d96 编写于 作者: A Alex Dima

More native promise adoption

上级 cc785ad4
......@@ -12,7 +12,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { MarshalledObject } from 'vs/base/common/marshalling';
import { URI } from 'vs/base/common/uri';
import { IURITransformer } from 'vs/base/common/uriIpc';
import { TPromise } from 'vs/base/common/winjs.base';
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/node/ipc';
import { LazyPromise } from 'vs/workbench/services/extensions/node/lazyPromise';
import { IRPCProtocol, ProxyIdentifier, getStringIdentifierForProxy } from 'vs/workbench/services/extensions/node/proxyIdentifier';
......@@ -444,9 +443,9 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
private _invokeHandler(rpcId: number, methodName: string, args: any[]): Thenable<any> {
try {
return TPromise.as(this._doInvokeHandler(rpcId, methodName, args));
return Promise.resolve(this._doInvokeHandler(rpcId, methodName, args));
} catch (err) {
return TPromise.wrapError(err);
return Promise.reject(err);
}
}
......@@ -464,7 +463,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
private _remoteCall(rpcId: number, methodName: string, args: any[]): Thenable<any> {
if (this._isDisposed) {
return TPromise.wrapError<any>(errors.canceled());
return Promise.reject<any>(errors.canceled());
}
let cancellationToken: CancellationToken | null = null;
if (args.length > 0 && CancellationToken.isCancellationToken(args[args.length - 1])) {
......@@ -473,7 +472,7 @@ export class RPCProtocol extends Disposable implements IRPCProtocol {
if (cancellationToken && cancellationToken.isCancellationRequested) {
// No need to do anything...
return TPromise.wrapError<any>(errors.canceled());
return Promise.reject<any>(errors.canceled());
}
const req = ++this._lastMessageId;
......
......@@ -6,7 +6,6 @@
import * as assert from 'assert';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { Emitter, Event } from 'vs/base/common/event';
import { TPromise } from 'vs/base/common/winjs.base';
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/node/ipc';
import { ProxyIdentifier } from 'vs/workbench/services/extensions/node/proxyIdentifier';
import { RPCProtocol } from 'vs/workbench/services/extensions/node/rpcProtocol';
......@@ -34,7 +33,7 @@ suite('RPCProtocol', () => {
let bProxy: BClass;
class BClass {
$m(a1: any, a2: any): Thenable<any> {
return TPromise.as(delegate.call(null, a1, a2));
return Promise.resolve(delegate.call(null, a1, a2));
}
}
......@@ -131,7 +130,7 @@ suite('RPCProtocol', () => {
test('cancelling a call via CancellationToken quickly', function (done) {
// this is an implementation which, when cancellation is triggered, will return 7
delegate = (a1: number, token: CancellationToken) => {
return new TPromise((resolve, reject) => {
return new Promise((resolve, reject) => {
token.onCancellationRequested((e) => {
resolve(7);
});
......@@ -164,7 +163,7 @@ suite('RPCProtocol', () => {
test('error promise', function (done) {
delegate = (a1: number, a2: number) => {
return TPromise.wrapError(undefined);
return Promise.reject(undefined);
};
bProxy.$m(4, 1).then((res) => {
assert.fail('unexpected');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册