Skip to content

Replace WinJS.Promise.wrap with Promise.resolve #64596

@jrieken

Description

@jrieken

Time to finish to tackle the last WinJS.Promise usages. Please use resolve instead of wrap. ❗️ be aware of runtime differences even for promises that created via these factory functions.

@bpasero

src/vs/workbench/test/workbenchTestServices.ts
  1122,19:		return TPromise.wrap(void 0);
  1118,19:		return TPromise.wrap(void 0);
  1114,19:		return TPromise.wrap({ button: 0 });
  850,19:		return TPromise.wrap(timeout(0).then(() => ({
  233,19:		return TPromise.wrap(this.confirmResult);
  229,19:		return TPromise.wrap(this.promptPath);

@roblourens

src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts
  170,19:		return TPromise.wrap<void>(null);

@bpasero

src/vs/workbench/services/textfile/test/textFileService.test.ts
  209,103:loadOrCreate', () => TPromise.wrap(mockedEditorInput));

@bpasero

src/vs/workbench/services/textfile/test/textFileEditorModel.test.ts
  20,18:	return TPromise.wrap(thenableTimeout(n));

@bpasero

src/vs/workbench/services/textfile/electron-browser/textFileService.ts
  82,20:			return TPromise.wrap(ConfirmResult.DONT_SAVE);
  77,20:			return TPromise.wrap(ConfirmResult.DONT_SAVE); // no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests)

@bpasero

src/vs/workbench/services/textfile/common/textFileService.ts
  732,35:waitForPromises.push(TPromise.wrap(p).then(undefined, errors.onUnexpectedError));
  540,29:targetPromise = TPromise.wrap(target);

@bpasero

src/vs/workbench/services/textfile/common/textFileEditorModel.ts
  626,20:			return TPromise.wrap<void>(null);
  587,20:			return TPromise.wrap<void>(null);
  210,20:			return TPromise.wrap<void>(null);

@bpasero

src/vs/workbench/services/editor/browser/editorService.ts
  243,19:		return TPromise.wrap<IEditor>(null);

@alexr00

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts
  1737,32:terminatePromise = TPromise.wrap({ confirmed: true });
  991,20:			return TPromise.wrap<void>(undefined);
  986,20:			return TPromise.wrap<void>(undefined);

@ramya-rao-a @roblourens

src/vs/workbench/parts/experiments/test/electron-browser/experimentService.test.ts
  48,19:		return TPromise.wrap(experimentData.experiments);

@ramya-rao-a @roblourens

src/vs/workbench/parts/experiments/node/experimentService.ts
  358,22:					return TPromise.wrap(ExperimentState.NoRun);
  341,20:			return TPromise.wrap(ExperimentState.NoRun);
  335,20:			return TPromise.wrap(ExperimentState.NoRun);
  331,20:			return TPromise.wrap(ExperimentState.NoRun);
  327,20:			return TPromise.wrap(ExperimentState.Run);
  323,20:			return TPromise.wrap(ExperimentState.NoRun);
  319,20:			return TPromise.wrap(processedExperiment.state);
  133,43:_loadExperimentsPromise = TPromise.wrap(this.lifecycleService.when(LifecyclePhase.Eventually)).then(() => this.loadExperiments());

@bpasero

src/vs/workbench/common/editor.ts
  419,19:		return TPromise.wrap(ConfirmResult.DONT_SAVE);

@bpasero

src/vs/workbench/browser/parts/editor/editorControl.ts
  175,19:		return TPromise.wrap(control.setInput(editor, options, operation.token)).then(() => {

@bpasero

src/vs/platform/workspaces/node/workspacesIpc.ts
  49,19:		return TPromise.wrap(this.channel.call('createWorkspace', folders));

@bpasero

src/vs/platform/windows/node/windowsIpc.ts
  345,19:		return TPromise.wrap(this.channel.call('openAboutDialog'));
  341,19:		return TPromise.wrap(this.channel.call('updateTouchBar', [windowId, items]));
  337,19:		return TPromise.wrap(this.channel.call('startCrashReporter', config));
  333,19:		return TPromise.wrap(this.channel.call('openExternal', url));
  329,19:		return TPromise.wrap(this.channel.call('getActiveWindowId'));
  325,19:		return TPromise.wrap(this.channel.call('showItemInFolder', path));
  321,19:		return TPromise.wrap(this.channel.call('log', [severity, messages]));
  317,19:		return TPromise.wrap(this.channel.call('getWindowCount'));
  313,19:		return TPromise.wrap(this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; }));
  309,19:		return TPromise.wrap(this.channel.call('showWindow', windowId));
  301,19:		return TPromise.wrap(this.channel.call('openWindow', [windowId, paths, options]));
  297,19:		return TPromise.wrap(this.channel.call('toggleSharedProcess'));
  293,19:		return TPromise.wrap(this.channel.call('whenSharedProcessReady'));
  289,19:		return TPromise.wrap(this.channel.call('relaunch', [options]));
  285,19:		return TPromise.wrap(this.channel.call('quit'));
  281,19:		return TPromise.wrap(this.channel.call('setDocumentEdited', [windowId, flag]));
  277,19:		return TPromise.wrap(this.channel.call('onWindowTitleDoubleClick', windowId));
  273,19:		return TPromise.wrap(this.channel.call('minimizeWindow', windowId));
  269,19:		return TPromise.wrap(this.channel.call('unmaximizeWindow', windowId));
  265,19:		return TPromise.wrap(this.channel.call('maximizeWindow', windowId));
  261,19:		return TPromise.wrap(this.channel.call('isMaximized', windowId));
  257,19:		return TPromise.wrap(this.channel.call('isFocused', windowId));
  253,19:		return TPromise.wrap(this.channel.call('closeWindow', windowId));
  249,19:		return TPromise.wrap(this.channel.call('focusWindow', windowId));
  245,19:		return TPromise.wrap(this.channel.call('toggleWindowTabsBar'));
  241,19:		return TPromise.wrap(this.channel.call('mergeAllWindowTabs'));
  237,19:		return TPromise.wrap(this.channel.call('moveWindowTabToNewWindow'));
  233,19:		return TPromise.wrap(this.channel.call('showNextWindowTab'));
  229,19:		return TPromise.wrap(this.channel.call('showPreviousWindowTab'));
  225,19:		return TPromise.wrap(this.channel.call('newWindowTab'));
  216,19:		return TPromise.wrap<IRecentlyOpened>(this.channel.call('getRecentlyOpened', windowId))
  212,19:		return TPromise.wrap(this.channel.call('clearRecentlyOpened'));
  208,19:		return TPromise.wrap(this.channel.call('removeFromRecentlyOpened', paths));
  204,19:		return TPromise.wrap(this.channel.call('addRecentlyOpened', files));
  200,19:		return TPromise.wrap(this.channel.call('setRepresentedFilename', [windowId, fileName]));
  196,19:		return TPromise.wrap(this.channel.call('toggleFullScreen', windowId));
  192,19:		return TPromise.wrap(this.channel.call('saveAndEnterWorkspace', [windowId, path]));
  188,19:		return TPromise.wrap(this.channel.call('createAndEnterWorkspace', [windowId, folders, path]));
  184,19:		return TPromise.wrap(this.channel.call('enterWorkspace', [windowId, path]));
  180,19:		return TPromise.wrap(this.channel.call('closeWorkspace', windowId));
  176,19:		return TPromise.wrap(this.channel.call('toggleDevTools', windowId));
  172,19:		return TPromise.wrap(this.channel.call('openDevTools', [windowId, options]));
  168,19:		return TPromise.wrap(this.channel.call('reloadWindow', [windowId, args]));
  164,19:		return TPromise.wrap(this.channel.call('showOpenDialog', [windowId, options]));
  160,19:		return TPromise.wrap(this.channel.call('showSaveDialog', [windowId, options]));
  156,19:		return TPromise.wrap(this.channel.call('showMessageBox', [windowId, options]));
  152,19:		return TPromise.wrap(this.channel.call('pickWorkspaceAndOpen', options));
  148,19:		return TPromise.wrap(this.channel.call('pickFolderAndOpen', options));
  144,19:		return TPromise.wrap(this.channel.call('pickFileAndOpen', options));
  140,19:		return TPromise.wrap(this.channel.call('pickFileFolderAndOpen', options));

@bpasero

src/vs/platform/windows/electron-main/windowsService.ts
  565,19:		return TPromise.wrap(true);
  557,19:		return TPromise.wrap(false);

@bpasero

src/vs/code/electron-main/windows.ts
  2042,19:		return TPromise.wrap(true); // OK
  2025,20:			return TPromise.wrap(false); // window is already opened on a workspace with that path
  2021,20:			return TPromise.wrap(true);

@bpasero

src/vs/code/electron-main/app.ts
  497,20:			return TPromise.wrap(machineId);

@jrieken

src/vs/base/test/common/winjs.promise.test.ts
  52,26:let p1 = winjs.Promise.wrap<number>(new Promise<number>(function (c, e) { c(1); }));
  47,26:let p1 = winjs.Promise.wrap<number>(new Promise<number>(function (c, e) { c(1); }));

@jrieken

src/vs/base/common/winjs.polyfill.promise.ts
  44,43:PolyfillPromise(WinJSPromise.wrap(value));

@jrieken

src/vs/base/common/winjs.base.d.ts
  26,16:	public static wrap<T>(value: T | PromiseLike<T>): Promise<T>;

Metadata

Metadata

Labels

debtCode quality issuesengineeringVS Code - Build / issue tracking / etc.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions