async loading children

This commit is contained in:
Pine Wu
2016-10-03 14:04:54 -07:00
parent 5276b19f72
commit 8081e2e395
7 changed files with 54 additions and 12 deletions

View File

@@ -264,6 +264,7 @@ export abstract class ExtHostEditorsShape {
export abstract class ExtHostExplorersShape {
$provideTreeContent(treeContentProviderId: string): TPromise<string> { throw ni(); };
$resolveChildren(treeContentProviderId: string, node: vscode.ITreeNode): TPromise<string> { throw ni(); }
}
export abstract class ExtHostExtensionServiceShape {

View File

@@ -46,4 +46,15 @@ export class ExtHostExplorers extends ExtHostExplorersShape {
return JSON.stringify(treeContent);
}));
}
$resolveChildren(treeContentProviderId: string, node: vscode.ITreeNode): TPromise<string> {
const provider = this._treeContentProviders[treeContentProviderId];
if (!provider) {
throw new Error(`no TreeContentProvider registered with id '${treeContentProviderId}'`);
}
return TPromise.wrap(provider.resolveChildren(node).then(children => {
return JSON.stringify(children);
}));
}
}

View File

@@ -28,6 +28,11 @@ export class MainThreadExplorers extends MainThreadExplorersShape {
return this._proxy.$provideTreeContent(providerId).then(jsonTree => {
return <ITreeNode>JSON.parse(jsonTree);
})
},
resolveChildren: (node: ITreeNode): TPromise<ITreeNode[]> => {
return this._proxy.$resolveChildren(providerId, node).then(jsonChildren => {
return <ITreeNode[]>JSON.parse(jsonChildren);
})
}
});
}