提交 3bf2a074 编写于 作者: A Alex Dima

Reduce usage of winjs promise progress

上级 5ffd9f50
...@@ -352,7 +352,7 @@ export class Barrier { ...@@ -352,7 +352,7 @@ export class Barrier {
constructor() { constructor() {
this._isOpen = false; this._isOpen = false;
this._promise = new TPromise<boolean>((c, e, p) => { this._promise = new TPromise<boolean>((c, e) => {
this._completePromise = c; this._completePromise = c;
}, () => { }, () => {
console.warn('You should really not try to cancel this ready promise!'); console.warn('You should really not try to cancel this ready promise!');
......
...@@ -91,7 +91,7 @@ class SimpleWorkerProtocol { ...@@ -91,7 +91,7 @@ class SimpleWorkerProtocol {
c: null, c: null,
e: null e: null
}; };
let result = new TPromise<any>((c, e, p) => { let result = new TPromise<any>((c, e) => {
reply.c = c; reply.c = c;
reply.e = e; reply.e = e;
}, () => { }, () => {
...@@ -232,7 +232,7 @@ export class SimpleWorkerClient<T> extends Disposable { ...@@ -232,7 +232,7 @@ export class SimpleWorkerClient<T> extends Disposable {
loaderConfiguration = (<any>self).requirejs.s.contexts._.config; loaderConfiguration = (<any>self).requirejs.s.contexts._.config;
} }
this._lazyProxy = new TPromise<T>((c, e, p) => { this._lazyProxy = new TPromise<T>((c, e) => {
lazyProxyFulfill = c; lazyProxyFulfill = c;
lazyProxyReject = e; lazyProxyReject = e;
}, () => { /* no cancel */ }); }, () => { /* no cancel */ });
...@@ -273,7 +273,7 @@ export class SimpleWorkerClient<T> extends Disposable { ...@@ -273,7 +273,7 @@ export class SimpleWorkerClient<T> extends Disposable {
} }
private _request(method: string, args: any[]): TPromise<any> { private _request(method: string, args: any[]): TPromise<any> {
return new TPromise<any>((c, e, p) => { return new TPromise<any>((c, e) => {
this._onModuleLoaded.then(() => { this._onModuleLoaded.then(() => {
this._protocol.sendMessage(method, args).then(c, e); this._protocol.sendMessage(method, args).then(c, e);
}, e); }, e);
...@@ -363,7 +363,7 @@ export class SimpleWorkerServer { ...@@ -363,7 +363,7 @@ export class SimpleWorkerServer {
let cc: ValueCallback; let cc: ValueCallback;
let ee: ErrorCallback; let ee: ErrorCallback;
let r = new TPromise<any>((c, e, p) => { let r = new TPromise<any>((c, e) => {
cc = c; cc = c;
ee = e; ee = e;
}); });
......
...@@ -234,7 +234,7 @@ export abstract class AbstractProcess<TProgressData> { ...@@ -234,7 +234,7 @@ export abstract class AbstractProcess<TProgressData> {
if (this.cmd) { if (this.cmd) {
childProcess = cp.spawn(this.cmd, this.args, this.options); childProcess = cp.spawn(this.cmd, this.args, this.options);
} else if (this.module) { } else if (this.module) {
this.childProcessPromise = new TPromise<cp.ChildProcess>((c, e, p) => { this.childProcessPromise = new TPromise<cp.ChildProcess>((c, e) => {
fork(this.module, this.args, <ForkOptions>this.options, (error: any, childProcess: cp.ChildProcess) => { fork(this.module, this.args, <ForkOptions>this.options, (error: any, childProcess: cp.ChildProcess) => {
if (error) { if (error) {
e(error); e(error);
...@@ -323,7 +323,7 @@ export abstract class AbstractProcess<TProgressData> { ...@@ -323,7 +323,7 @@ export abstract class AbstractProcess<TProgressData> {
} }
private useExec(): TPromise<boolean> { private useExec(): TPromise<boolean> {
return new TPromise<boolean>((c, e, p) => { return new TPromise<boolean>((c, e) => {
if (!this.shell || !Platform.isWindows) { if (!this.shell || !Platform.isWindows) {
c(false); c(false);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import * as errors from 'vs/base/common/errors'; import * as errors from 'vs/base/common/errors';
import * as paths from 'vs/base/common/paths'; import * as paths from 'vs/base/common/paths';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { PPromise, ProgressCallback, TProgressCallback, TPromise, TValueCallback } from 'vs/base/common/winjs.base'; import { PPromise, TProgressCallback, TPromise, TValueCallback } from 'vs/base/common/winjs.base';
export class DeferredTPromise<T> extends TPromise<T> { export class DeferredTPromise<T> extends TPromise<T> {
...@@ -16,17 +16,15 @@ export class DeferredTPromise<T> extends TPromise<T> { ...@@ -16,17 +16,15 @@ export class DeferredTPromise<T> extends TPromise<T> {
private completeCallback: TValueCallback<T>; private completeCallback: TValueCallback<T>;
private errorCallback: (err: any) => void; private errorCallback: (err: any) => void;
private progressCallback: ProgressCallback;
constructor() { constructor() {
let captured: any; let captured: any;
super((c, e, p) => { super((c, e) => {
captured = { c, e, p }; captured = { c, e };
}, () => this.oncancel()); }, () => this.oncancel());
this.canceled = false; this.canceled = false;
this.completeCallback = captured.c; this.completeCallback = captured.c;
this.errorCallback = captured.e; this.errorCallback = captured.e;
this.progressCallback = captured.p;
} }
public complete(value: T) { public complete(value: T) {
...@@ -37,10 +35,6 @@ export class DeferredTPromise<T> extends TPromise<T> { ...@@ -37,10 +35,6 @@ export class DeferredTPromise<T> extends TPromise<T> {
this.errorCallback(err); this.errorCallback(err);
} }
public progress(p: any) {
this.progressCallback(p);
}
private oncancel(): void { private oncancel(): void {
this.canceled = true; this.canceled = true;
} }
......
...@@ -11,7 +11,7 @@ suite('WinJS and ES6 Promises', function () { ...@@ -11,7 +11,7 @@ suite('WinJS and ES6 Promises', function () {
test('Promise.resolve', function () { test('Promise.resolve', function () {
let resolveTPromise; let resolveTPromise;
const tPromise = new winjs.Promise(function (c, e, p) { const tPromise = new winjs.Promise((c, e) => {
resolveTPromise = c; resolveTPromise = c;
}); });
...@@ -28,7 +28,7 @@ suite('WinJS and ES6 Promises', function () { ...@@ -28,7 +28,7 @@ suite('WinJS and ES6 Promises', function () {
test('new Promise', function () { test('new Promise', function () {
let resolveTPromise; let resolveTPromise;
const tPromise = new winjs.Promise(function (c, e, p) { const tPromise = new winjs.Promise((c, e) => {
resolveTPromise = c; resolveTPromise = c;
}); });
......
...@@ -46,7 +46,7 @@ export function createTextBufferFactory(text: string): model.ITextBufferFactory ...@@ -46,7 +46,7 @@ export function createTextBufferFactory(text: string): model.ITextBufferFactory
} }
export function createTextBufferFactoryFromStream(stream: IStringStream, filter?: (chunk: string) => string): TPromise<model.ITextBufferFactory> { export function createTextBufferFactoryFromStream(stream: IStringStream, filter?: (chunk: string) => string): TPromise<model.ITextBufferFactory> {
return new TPromise<model.ITextBufferFactory>((c, e, p) => { return new TPromise<model.ITextBufferFactory>((c, e) => {
let done = false; let done = false;
let builder = createTextBufferBuilder(); let builder = createTextBufferBuilder();
......
...@@ -42,7 +42,7 @@ export class Colorizer { ...@@ -42,7 +42,7 @@ export class Colorizer {
let render = (str: string) => { let render = (str: string) => {
domNode.innerHTML = str; domNode.innerHTML = str;
}; };
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err), render); return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err));
} }
private static _tokenizationSupportChangedPromise(language: string): TPromise<void> { private static _tokenizationSupportChangedPromise(language: string): TPromise<void> {
...@@ -54,7 +54,7 @@ export class Colorizer { ...@@ -54,7 +54,7 @@ export class Colorizer {
} }
}; };
return new TPromise<void>((c, e, p) => { return new TPromise<void>((c, e) => {
listener = TokenizationRegistry.onDidChange((e) => { listener = TokenizationRegistry.onDidChange((e) => {
if (e.changedLanguages.indexOf(language) >= 0) { if (e.changedLanguages.indexOf(language) >= 0) {
stopListening(); stopListening();
......
...@@ -133,7 +133,7 @@ export class IntegrityServiceImpl implements IIntegrityService { ...@@ -133,7 +133,7 @@ export class IntegrityServiceImpl implements IIntegrityService {
private _resolve(filename: string, expected: string): TPromise<ChecksumPair> { private _resolve(filename: string, expected: string): TPromise<ChecksumPair> {
let fileUri = URI.parse(require.toUrl(filename)); let fileUri = URI.parse(require.toUrl(filename));
return new TPromise<ChecksumPair>((c, e, p) => { return new TPromise<ChecksumPair>((c, e) => {
fs.readFile(fileUri.fsPath, (err, buff) => { fs.readFile(fileUri.fsPath, (err, buff) => {
if (err) { if (err) {
return e(err); return e(err);
......
...@@ -208,7 +208,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler { ...@@ -208,7 +208,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
* Parses original message bundle, returns null if the original message bundle is null. * Parses original message bundle, returns null if the original message bundle is null.
*/ */
private static resolveOriginalMessageBundle(originalMessageBundle: string, errors: json.ParseError[]) { private static resolveOriginalMessageBundle(originalMessageBundle: string, errors: json.ParseError[]) {
return new TPromise<{ [key: string]: string; }>((c, e, p) => { return new TPromise<{ [key: string]: string; }>((c, e) => {
if (originalMessageBundle) { if (originalMessageBundle) {
pfs.readFile(originalMessageBundle).then(originalBundleContent => { pfs.readFile(originalMessageBundle).then(originalBundleContent => {
c(json.parse(originalBundleContent.toString(), errors)); c(json.parse(originalBundleContent.toString(), errors));
...@@ -226,7 +226,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler { ...@@ -226,7 +226,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
* If the localized file is not present, returns null for the original and marks original as localized. * If the localized file is not present, returns null for the original and marks original as localized.
*/ */
private static findMessageBundles(nlsConfig: NlsConfiguration, basename: string): TPromise<{ localized: string, original: string }> { private static findMessageBundles(nlsConfig: NlsConfiguration, basename: string): TPromise<{ localized: string, original: string }> {
return new TPromise<{ localized: string, original: string }>((c, e, p) => { return new TPromise<{ localized: string, original: string }>((c, e) => {
function loop(basename: string, locale: string): void { function loop(basename: string, locale: string): void {
let toCheck = `${basename}.nls.${locale}.json`; let toCheck = `${basename}.nls.${locale}.json`;
pfs.fileExists(toCheck).then(exists => { pfs.fileExists(toCheck).then(exists => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册