Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jrieken opened this issue Dec 7, 2018 · 2 comments
Closed

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

jrieken opened this issue Dec 7, 2018 · 2 comments
Assignees
Labels
debt Code quality issues engineering VS Code - Build / issue tracking / etc.

Comments

@jrieken
Copy link
Member

jrieken commented Dec 7, 2018

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>;
@jrieken jrieken added this to the December 2018 milestone Dec 7, 2018
@jrieken jrieken added debt Code quality issues engineering VS Code - Build / issue tracking / etc. labels Dec 7, 2018
@sandy081 sandy081 removed their assignment Dec 7, 2018
roblourens added a commit that referenced this issue Dec 7, 2018
@joaomoreno
Copy link
Member

Done!

@joaomoreno

src/vs/workbench/services/textmodelResolver/common/textModelResolverService.ts
  103,55:map(p => () => TPromise.wrap(p.provideTextContent(resource)));

@joaomoreno

src/vs/workbench/parts/update/electron-browser/releaseNotesEditor.ts
  167,22:					return TPromise.wrap(text);

@joaomoreno

src/vs/workbench/parts/scm/electron-browser/dirtydiffDecorator.ts
  140,19:		return TPromise.wrap(this.instantiationService.invokeFunction(accessor => this.action.run(accessor, this.editor, null)));

@joaomoreno

src/vs/workbench/api/electron-browser/mainThreadSCM.ts
  424,21:				return TPromise.wrap(this._proxy.$validateInput(sourceControlHandle, value, pos).then(result => {
  250,19:		return TPromise.wrap(this.proxy.$provideOriginalResource(this.handle, uri, CancellationToken.None))

@joaomoreno

src/vs/platform/launch/electron-main/launchService.ts
  255,19:		return TPromise.wrap({

@joaomoreno

src/vs/platform/driver/node/driver.ts
  253,19:		return TPromise.wrap(this.channel.call('writeInTerminal', [selector, text]));
  249,19:		return TPromise.wrap(this.channel.call('getTerminalBuffer', selector));
  245,19:		return TPromise.wrap(this.channel.call('typeInEditor', [selector, text]));
  241,19:		return TPromise.wrap(this.channel.call('getElements', [selector, recursive]));
  237,19:		return TPromise.wrap(this.channel.call('isActiveElement', selector));
  233,19:		return TPromise.wrap(this.channel.call('getTitle'));
  229,19:		return TPromise.wrap(this.channel.call('setValue', [selector, text]));
  225,19:		return TPromise.wrap(this.channel.call('doubleClick', selector));
  221,19:		return TPromise.wrap(this.channel.call('click', [selector, xoffset, yoffset]));
  173,19:		return TPromise.wrap(this.channel.call('reloadWindowDriver', windowId));
  169,19:		return TPromise.wrap(this.channel.call('registerWindowDriver', windowId));
  131,19:		return TPromise.wrap(this.channel.call('writeInTerminal', [windowId, selector, text]));
  127,19:		return TPromise.wrap(this.channel.call('getTerminalBuffer', [windowId, selector]));
  123,19:		return TPromise.wrap(this.channel.call('typeInEditor', [windowId, selector, text]));
  119,19:		return TPromise.wrap(this.channel.call('getElements', [windowId, selector, recursive]));
  115,19:		return TPromise.wrap(this.channel.call('isActiveElement', [windowId, selector]));
  111,19:		return TPromise.wrap(this.channel.call('getTitle', [windowId]));
  107,19:		return TPromise.wrap(this.channel.call('setValue', [windowId, selector, text]));
  103,19:		return TPromise.wrap(this.channel.call('doubleClick', [windowId, selector]));
  99,19:		return TPromise.wrap(this.channel.call('click', [windowId, selector, xoffset, yoffset]));
  95,19:		return TPromise.wrap(this.channel.call('dispatchKeybinding', [windowId, keybinding]));
  91,19:		return TPromise.wrap(this.channel.call('reloadWindow', windowId));
  87,19:		return TPromise.wrap(this.channel.call('capturePage', windowId));
  83,19:		return TPromise.wrap(this.channel.call('getWindowIds'));

@joaomoreno

src/vs/platform/driver/electron-browser/driver.ts
  93,21:				return TPromise.wrap(timeout(100));
  91,20:			return TPromise.wrap(timeout(10)).then(() => {

@joaomoreno joaomoreno removed their assignment Dec 10, 2018
joaomoreno added a commit that referenced this issue Dec 10, 2018
joaomoreno added a commit that referenced this issue Dec 10, 2018
joaomoreno added a commit that referenced this issue Dec 10, 2018
@bpasero bpasero reopened this Dec 11, 2018
@bpasero
Copy link
Member

bpasero commented Dec 11, 2018

Forgot some...

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues engineering VS Code - Build / issue tracking / etc.
Projects
None yet
Development

No branches or pull requests

6 participants