🔨 change how ids work in scm providers. remove drag

This commit is contained in:
Joao Moreno
2017-03-24 16:44:38 +01:00
parent ce1222ba68
commit e4a765da2d
7 changed files with 18 additions and 42 deletions

View File

@@ -14,6 +14,7 @@ export class GitSCMProvider implements SCMProvider {
private disposables: Disposable[] = [];
get id(): string { return 'git'; }
get resources(): SCMResourceGroup[] { return this.model.resources; }
get onDidChange(): Event<SCMResourceGroup[]> {
@@ -42,7 +43,7 @@ export class GitSCMProvider implements SCMProvider {
}
constructor(private model: Model, private commandCenter: CommandCenter) {
scm.registerSCMProvider('git', this);
scm.registerSCMProvider(this);
}
open(resource: Resource): ProviderResult<void> {

View File

@@ -640,17 +640,17 @@ declare module 'vscode' {
export interface SCMResourceGroup {
/**
* The identifier of this SCM resource group.
* The identifier of the SCM resource group.
*/
readonly id: string;
/**
* The UI label of this SCM resource group.
* The UI label of the SCM resource group.
*/
readonly label: string;
/**
* The collection of [SCM resources](#SCMResource) within this SCM resource group.
* The collection of [SCM resources](#SCMResource) within the SCM resource group.
*/
readonly resources: SCMResource[];
}
@@ -662,7 +662,12 @@ declare module 'vscode' {
export interface SCMProvider {
/**
* A human-readable label for the name of this SCM Provider.
* The identifier of the SCM provider.
*/
readonly id: string;
/**
* A human-readable label for the name of the SCM Provider.
*/
readonly label: string;
@@ -755,9 +760,9 @@ declare module 'vscode' {
* Registers an [SCM provider](#SCMProvider).
*
* @param id The provider's id.
* @return A disposable which unregisters this provider.
* @return A disposable which unregisters the provider.
*/
export function registerSCMProvider(id: string, provider: SCMProvider): Disposable;
export function registerSCMProvider(provider: SCMProvider): Disposable;
}
/**

View File

@@ -454,8 +454,8 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
}
@proposed(extension)
registerSCMProvider(id, provider) {
return extHostSCM.registerSCMProvider(id, provider);
registerSCMProvider(provider) {
return extHostSCM.registerSCMProvider(provider);
}
}

View File

@@ -253,7 +253,6 @@ export interface SCMProviderFeatures {
label: string;
supportsOpen: boolean;
supportsAcceptChanges: boolean;
supportsDrag: boolean;
supportsOriginalResource: boolean;
}
@@ -412,7 +411,6 @@ export abstract class ExtHostTerminalServiceShape {
export abstract class ExtHostSCMShape {
$open(id: string, resourceGroupId: string, uri: string): TPromise<void> { throw ni(); }
$acceptChanges(id: string): TPromise<void> { throw ni(); }
$drag(id: string, fromResourceGroupId: string, fromUri: string, toResourceGroupId: string): TPromise<void> { throw ni(); }
$getOriginalResource(id: string, uri: URI): TPromise<URI> { throw ni(); }
$onInputBoxValueChange(value: string): TPromise<void> { throw ni(); }
}

View File

@@ -141,7 +141,9 @@ export class ExtHostSCM {
return resource;
}
registerSCMProvider(providerId: string, provider: vscode.SCMProvider): Disposable {
registerSCMProvider(provider: vscode.SCMProvider): Disposable {
const providerId = provider.id;
if (this._providers[providerId]) {
throw new Error(`Provider ${providerId} already registered`);
}
@@ -153,7 +155,6 @@ export class ExtHostSCM {
label: provider.label,
supportsOpen: !!provider.open,
supportsAcceptChanges: !!provider.acceptChanges,
supportsDrag: !!provider.drag,
supportsOriginalResource: !!provider.getOriginalResource
});
@@ -228,26 +229,6 @@ export class ExtHostSCM {
return asWinJsPromise(token => provider.acceptChanges(token));
}
$drag(providerId: string, fromResourceGroupId: string, fromUri: string, toResourceGroupId: string): TPromise<void> {
const provider = this._providers[providerId];
if (!provider) {
return TPromise.as(null);
}
const providerCache = this.cache[providerId];
const fromResourceGroup = providerCache[fromResourceGroupId];
const resource = fromResourceGroup && fromResourceGroup.resources[fromUri];
const toResourceGroup = providerCache[toResourceGroupId];
const resourceGroup = toResourceGroup && toResourceGroup.resourceGroup;
if (!resource || !resourceGroup) {
return TPromise.as(null);
}
return asWinJsPromise(token => provider.drag(resource, resourceGroup, token));
}
$getOriginalResource(id: string, uri: URI): TPromise<URI> {
const provider = this._providers[id];

View File

@@ -60,14 +60,6 @@ class MainThreadSCMProvider implements ISCMProvider {
return this.proxy.$acceptChanges(this.id);
}
drag(from: ISCMResource, to: ISCMResourceGroup): TPromise<void> {
if (!this.features.supportsDrag) {
return TPromise.as(null);
}
return this.proxy.$drag(this.id, from.resourceGroupId, from.uri.toString(), to.id);
}
getOriginalResource(uri: URI): TPromise<URI> {
if (!this.features.supportsOriginalResource) {
return TPromise.as(null);

View File

@@ -45,7 +45,6 @@ export interface ISCMProvider extends IDisposable {
open(uri: ISCMResource): TPromise<void>;
acceptChanges(): TPromise<void>;
drag(from: ISCMResource, to: ISCMResourceGroup): TPromise<void>;
getOriginalResource(uri: URI): TPromise<URI>;
}