Prototyping declarative action contribution for threads

This commit is contained in:
Matt Bierner
2018-04-10 16:06:51 -07:00
parent bd83b6da57
commit 260d29928d
8 changed files with 65 additions and 26 deletions

View File

@@ -120,7 +120,7 @@ export function createApiFactory(
const extHostWindow = rpcProtocol.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(rpcProtocol));
rpcProtocol.set(ExtHostContext.ExtHostExtensionService, extensionService);
const extHostProgress = rpcProtocol.set(ExtHostContext.ExtHostProgress, new ExtHostProgress(rpcProtocol.getProxy(MainContext.MainThreadProgress)));
const exthostCommentProviders = rpcProtocol.set(ExtHostContext.ExtHostComments, new ExtHostComments(rpcProtocol, extHostDocuments));
const exthostCommentProviders = rpcProtocol.set(ExtHostContext.ExtHostComments, new ExtHostComments(rpcProtocol, extHostCommands.converter, extHostDocuments));
// Check that no named customers are missing
const expected: ProxyIdentifier<any>[] = Object.keys(ExtHostContext).map((key) => ExtHostContext[key]);

View File

@@ -11,11 +11,11 @@ import URI, { UriComponents } from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import * as modes from 'vs/editor/common/modes';
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
import * as extHostTypeConverter from 'vs/workbench/api/node/extHostTypeConverters';
import * as vscode from 'vscode';
import { flatten } from '../../../base/common/arrays';
import { ExtHostCommentsShape, IMainContext, MainContext, MainThreadCommentsShape } from './extHost.protocol';
import * as extHostTypeConverter from 'vs/workbench/api/node/extHostTypeConverters';
import { CommandsConverter } from './extHostCommands';
export class ExtHostComments implements ExtHostCommentsShape {
@@ -27,6 +27,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
constructor(
mainContext: IMainContext,
private readonly _commandsConverter: CommandsConverter,
private readonly _documents: ExtHostDocuments,
) {
this._proxy = mainContext.getProxy(MainContext.MainThreadComments);
@@ -58,15 +59,17 @@ export class ExtHostComments implements ExtHostCommentsShape {
return TPromise.join(allProviderResults);
})
.then(flatten)
.then(comments => comments.map(convertCommentThread));
.then(comments => comments.map(x => convertCommentThread(x, this._commandsConverter)));
}
}
function convertCommentThread(vscodeCommentThread: vscode.CommentThread): modes.CommentThread {
function convertCommentThread(vscodeCommentThread: vscode.CommentThread, commandsConverter: CommandsConverter): modes.CommentThread {
return {
threadId: vscodeCommentThread.threadId,
range: extHostTypeConverter.fromRange(vscodeCommentThread.range),
newCommentRange: extHostTypeConverter.fromRange(vscodeCommentThread.newCommentRange),
comments: vscodeCommentThread.comments.map(convertComment)
comments: vscodeCommentThread.comments.map(convertComment),
actions: vscodeCommentThread.actions.map(commandsConverter.toInternal)
};
}