debt - remove TPromise from ExtHostSCM and MainThreadSCM
This commit is contained in:
parent
c2c5819fc8
commit
4419709b9b
4 changed files with 19 additions and 17 deletions
|
@ -15,6 +15,7 @@ import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeature
|
|||
import { Command } from 'vs/editor/common/modes';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { ISplice, Sequence } from 'vs/base/common/sequence';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
|
||||
|
@ -73,7 +74,7 @@ class MainThreadSCMResource implements ISCMResource {
|
|||
public decorations: ISCMResourceDecorations
|
||||
) { }
|
||||
|
||||
open(): TPromise<void> {
|
||||
open(): Thenable<void> {
|
||||
return this.proxy.$executeResourceCommand(this.sourceControlHandle, this.groupHandle, this.handle);
|
||||
}
|
||||
|
||||
|
@ -241,7 +242,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return this.proxy.$provideOriginalResource(this.handle, uri)
|
||||
return TPromise.wrap(this.proxy.$provideOriginalResource(this.handle, uri, CancellationToken.None))
|
||||
.then(result => result && URI.revive(result));
|
||||
}
|
||||
|
||||
|
@ -405,7 +406,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
|||
|
||||
if (enabled) {
|
||||
repository.input.validateInput = (value, pos): TPromise<IInputValidation | undefined> => {
|
||||
return this._proxy.$validateInput(sourceControlHandle, value, pos).then(result => {
|
||||
return TPromise.wrap(this._proxy.$validateInput(sourceControlHandle, value, pos).then(result => {
|
||||
if (!result) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -414,7 +415,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
|||
message: result[0],
|
||||
type: result[1]
|
||||
};
|
||||
});
|
||||
}));
|
||||
};
|
||||
} else {
|
||||
repository.input.validateInput = () => TPromise.as(undefined);
|
||||
|
|
|
@ -886,10 +886,10 @@ export interface ExtHostTerminalServiceShape {
|
|||
}
|
||||
|
||||
export interface ExtHostSCMShape {
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: UriComponents): TPromise<UriComponents>;
|
||||
$provideOriginalResource(sourceControlHandle: number, uri: UriComponents, token: CancellationToken): Thenable<UriComponents>;
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): void;
|
||||
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void>;
|
||||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined>;
|
||||
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Thenable<void>;
|
||||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Thenable<[string, number] | undefined>;
|
||||
$setSelectedSourceControls(selectedSourceControlHandles: number[]): Thenable<void>;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
|||
import { Event, Emitter, once } from 'vs/base/common/event';
|
||||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape } from './extHost.protocol';
|
||||
|
@ -18,6 +18,7 @@ import { comparePaths } from 'vs/base/common/comparers';
|
|||
import * as vscode from 'vscode';
|
||||
import { ISplice } from 'vs/base/common/sequence';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
type ProviderHandle = number;
|
||||
type GroupHandle = number;
|
||||
|
@ -237,14 +238,14 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
|||
return this._resourceStatesMap.get(handle);
|
||||
}
|
||||
|
||||
$executeResourceCommand(handle: number): TPromise<void> {
|
||||
$executeResourceCommand(handle: number): Thenable<void> {
|
||||
const command = this._resourceStatesCommandsMap.get(handle);
|
||||
|
||||
if (!command) {
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asWinJsPromise(_ => this._commands.executeCommand(command.command, ...command.arguments));
|
||||
return asThenable(() => this._commands.executeCommand(command.command, ...command.arguments));
|
||||
}
|
||||
|
||||
_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
|
||||
|
@ -558,7 +559,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return inputBox;
|
||||
}
|
||||
|
||||
$provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents): TPromise<UriComponents> {
|
||||
$provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents, token: CancellationToken): Thenable<UriComponents> {
|
||||
const uri = URI.revive(uriComponents);
|
||||
this.logService.trace('ExtHostSCM#$provideOriginalResource', sourceControlHandle, uri.toString());
|
||||
|
||||
|
@ -568,7 +569,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
return asWinJsPromise(token => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
|
||||
return asThenable(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
|
||||
}
|
||||
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): TPromise<void> {
|
||||
|
@ -584,7 +585,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): TPromise<void> {
|
||||
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Thenable<void> {
|
||||
this.logService.trace('ExtHostSCM#$executeResourceCommand', sourceControlHandle, groupHandle, handle);
|
||||
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
@ -602,7 +603,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return group.$executeResourceCommand(handle);
|
||||
}
|
||||
|
||||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): TPromise<[string, number] | undefined> {
|
||||
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Thenable<[string, number] | undefined> {
|
||||
this.logService.trace('ExtHostSCM#$validateInput', sourceControlHandle);
|
||||
|
||||
const sourceControl = this._sourceControls.get(sourceControlHandle);
|
||||
|
@ -615,7 +616,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
|||
return TPromise.as(undefined);
|
||||
}
|
||||
|
||||
return asWinJsPromise(_ => Promise.resolve(sourceControl.inputBox.validateInput(value, cursorPosition))).then(result => {
|
||||
return asThenable(() => sourceControl.inputBox.validateInput(value, cursorPosition)).then(result => {
|
||||
if (!result) {
|
||||
return TPromise.as(undefined);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export interface ISCMResource {
|
|||
readonly resourceGroup: ISCMResourceGroup;
|
||||
readonly sourceUri: URI;
|
||||
readonly decorations: ISCMResourceDecorations;
|
||||
open(): TPromise<void>;
|
||||
open(): Thenable<void>;
|
||||
}
|
||||
|
||||
export interface ISCMResourceGroup extends ISequence<ISCMResource> {
|
||||
|
|
Loading…
Reference in a new issue