very first proposed API for multiple roots, #28526

This commit is contained in:
Johannes Rieken
2017-06-21 11:22:31 +02:00
parent 264b773bf2
commit 8e746dfdc7
3 changed files with 29 additions and 5 deletions

View File

@@ -54,6 +54,12 @@ export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode;
}
function assertProposedApi(extension: IExtensionDescription): void {
if (!extension.enableProposedApi) {
throw new Error(`[${extension.id}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.id}`);
}
}
function proposedApiFunction<T>(extension: IExtensionDescription, fn: T): T {
if (extension.enableProposedApi) {
return fn;
@@ -348,6 +354,13 @@ export function createApiFactory(
set rootPath(value) {
throw errors.readonly();
},
get workspaceFolders() {
assertProposedApi(extension);
return extHostWorkspace.getRoots();
},
onDidChangeWorkspaceFolders: proposedApiFunction(extension, (listener, thisArgs?, disposables?) => {
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
}),
asRelativePath: (pathOrUri) => {
return extHostWorkspace.getRelativePath(pathOrUri);
},