提交 e42c30a2 编写于 作者: P Peng Lyu

CommentController.

上级 61c634d8
......@@ -980,7 +980,7 @@ declare module 'vscode' {
input: string;
}
export interface CommentControl {
export interface CommentController {
readonly id: string;
readonly label: string;
/**
......@@ -997,11 +997,19 @@ declare module 'vscode' {
}
namespace comment {
export function createCommentControl(id: string, label: string): CommentControl;
export function createCommentController(id: string, label: string): CommentController;
}
namespace workspace {
/**
* DEPRECATED
* Use vscode.comment.createCommentController instead.
*/
export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
/**
* DEPRECATED
* Use vscode.comment.createCommentController instead and we don't differentiate document comments and workspace comments anymore.
*/
export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
}
......
......@@ -132,7 +132,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
constructor(
public commentThreadHandle: number,
public control: MainThreadCommentControl,
public controller: MainThreadCommentController,
public extensionId: string,
public threadId: string,
public resource: string,
......@@ -151,7 +151,7 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
toJSON(): any {
return {
$mid: 7,
commentControlHandle: this.control.handle,
commentControlHandle: this.controller.handle,
commentThreadHandle: this.commentThreadHandle,
};
}
......@@ -180,7 +180,7 @@ export class MainThreadCommentingRanges implements modes.CommentingRanges {
constructor(
public commentingRangesHandle: number,
public control: MainThreadCommentControl,
public controller: MainThreadCommentController,
public resource: URI,
private _ranges: IRange[],
private _newCommentThreadCommand: modes.Command,
......@@ -192,7 +192,7 @@ export class MainThreadCommentingRanges implements modes.CommentingRanges {
}
}
export class MainThreadCommentControl {
export class MainThreadCommentController {
get handle(): number {
return this._handle;
}
......@@ -352,7 +352,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
private _documentProviders = new Map<number, IDisposable>();
private _workspaceProviders = new Map<number, IDisposable>();
private _handlers = new Map<number, string>();
private _commentControls = new Map<number, MainThreadCommentControl>();
private _commentControllers = new Map<number, MainThreadCommentController>();
private _activeCommentThread?: MainThreadCommentThread;
private _activeComment?: modes.Comment;
......@@ -372,9 +372,9 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._activeCommentThreadDisposables = [];
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
this._disposables.push(this._commentService.onDidChangeActiveCommentThread(async thread => {
let control = (thread as MainThreadCommentThread).control;
let controller = (thread as MainThreadCommentThread).controller;
if (!control) {
if (!controller) {
return;
}
......@@ -383,26 +383,26 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._activeCommentThreadDisposables.push(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose
this._input = input;
this._proxy.$onActiveCommentWidgetChange(control.handle, this._activeCommentThread, this._activeComment, this._input ? this._input.value : undefined);
this._proxy.$onActiveCommentWidgetChange(controller.handle, this._activeCommentThread, this._activeComment, this._input ? this._input.value : undefined);
}));
await this._proxy.$onActiveCommentWidgetChange(control.handle, this._activeCommentThread, this._activeComment, this._input ? this._input.value : undefined);
await this._proxy.$onActiveCommentWidgetChange(controller.handle, this._activeCommentThread, this._activeComment, this._input ? this._input.value : undefined);
}));
this._disposables.push(this._commentService.onDidChangeActiveCommentingRange(value => {
let control = (value.commentingRangesInfo as MainThreadCommentingRanges).control;
let controller = (value.commentingRangesInfo as MainThreadCommentingRanges).controller;
if (!control) {
if (!controller) {
return;
}
this._proxy.$onActiveCommentingRangeChange(control.handle, value.range);
this._proxy.$onActiveCommentingRangeChange(controller.handle, value.range);
}));
}
$registerCommentControl(handle: number, id: string, label: string): void {
const provider = new MainThreadCommentControl(this._proxy, this._commentService, handle, id, label);
this._commentService.registerCommentControl(String(handle), provider);
this._commentControls.set(handle, provider);
$registerCommentController(handle: number, id: string, label: string): void {
const provider = new MainThreadCommentController(this._proxy, this._commentService, handle, id, label);
this._commentService.registerCommentController(String(handle), provider);
this._commentControllers.set(handle, provider);
const commentsPanelAlreadyConstructed = this._panelService.getPanels().some(panel => panel.id === COMMENTS_PANEL_ID);
if (!commentsPanelAlreadyConstructed) {
......@@ -412,7 +412,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], commands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return undefined;
......@@ -422,7 +422,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$deleteCommentThread(handle: number, commentThreadHandle: number) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -432,7 +432,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$createCommentingRanges(handle: number, commentingRangesHandle: number, resource: UriComponents, ranges: IRange[], command: modes.Command) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return undefined;
......@@ -442,7 +442,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$deleteCommentingRanges(handle: number, commentingRangesHandle: number) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return undefined;
......@@ -453,7 +453,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$updateCommentingRanges(handle: number, commentingRangesHandle: number, newRanges: IRange[]): void {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -462,7 +462,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
provider.updateCommentingRanges(commentingRangesHandle, newRanges);
}
$updateCommentingRangesCommands(handle: number, commentingRangesHandle: number, command: modes.Command): void {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -472,7 +472,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$updateComments(handle: number, commentThreadHandle: number, comments: modes.Comment[]) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -482,7 +482,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$setInputValue(handle: number, commentThreadHandle: number, input: string) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -493,7 +493,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$updateCommentThreadCommands(handle: number, commentThreadHandle: number, acceptInputCommands: modes.Command[]) {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......@@ -503,7 +503,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
}
$updateCommentThreadRange(handle: number, commentThreadHandle: number, range: any): void {
let provider = this._commentControls.get(handle);
let provider = this._commentControllers.get(handle);
if (!provider) {
return;
......
......@@ -670,8 +670,8 @@ export function createApiFactory(
};
const comment: typeof vscode.comment = {
createCommentControl(id: string, label: string) {
return extHostComment.createCommentControl(extension, id, label);
createCommentController(id: string, label: string) {
return extHostComment.createCommentController(extension, id, label);
}
};
......
......@@ -119,7 +119,7 @@ export interface CommentProviderFeatures {
}
export interface MainThreadCommentsShape extends IDisposable {
$registerCommentControl(handle: number, id: string, label: string): void;
$registerCommentController(handle: number, id: string, label: string): void;
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], commands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 | undefined;
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
$updateComments(handle: number, commentThreadHandle: number, comments: modes.Comment[]): void;
......@@ -1105,8 +1105,8 @@ export interface ExtHostProgressShape {
export interface ExtHostCommentsShape {
$provideDocumentComments(handle: number, document: UriComponents): Promise<modes.CommentInfo>;
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread>;
$onActiveCommentWidgetChange(commentControlhandle: number, commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string): Promise<number | undefined>;
$onActiveCommentingRangeChange(commentControlhandle: number, range: IRange): void;
$onActiveCommentWidgetChange(commentControllerHandle: number, commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string): Promise<number | undefined>;
$onActiveCommentingRangeChange(commentControllerHandle: number, range: IRange): void;
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread>;
$editComment(handle: number, document: UriComponents, comment: modes.Comment, text: string): Promise<void>;
$deleteComment(handle: number, document: UriComponents, comment: modes.Comment): Promise<void>;
......
......@@ -30,9 +30,9 @@ export class ExtHostComments implements ExtHostCommentsShape {
private _proxy: MainThreadCommentsShape;
private _commentControls: Map<ProviderHandle, ExtHostCommentControl> = new Map<ProviderHandle, ExtHostCommentControl>();
private _commentControllers: Map<ProviderHandle, ExtHostCommentController> = new Map<ProviderHandle, ExtHostCommentController>();
private _commentControlsByExtension: Map<string, ExtHostCommentControl[]> = new Map<string, ExtHostCommentControl[]>();
private _commentControllersByExtension: Map<string, ExtHostCommentController[]> = new Map<string, ExtHostCommentController[]>();
private _documentProviders = new Map<number, HandlerData<vscode.DocumentCommentProvider>>();
private _workspaceProviders = new Map<number, HandlerData<vscode.WorkspaceCommentProvider>>();
......@@ -47,21 +47,21 @@ export class ExtHostComments implements ExtHostCommentsShape {
_commands.registerArgumentProcessor({
processArgument: arg => {
if (arg && arg.$mid === 6) {
const commentControl = this._commentControls.get(arg.handle);
const commentController = this._commentControllers.get(arg.handle);
if (!commentControl) {
if (!commentController) {
return arg;
}
return commentControl;
return commentController;
} else if (arg && arg.$mid === 7) {
const commentControl = this._commentControls.get(arg.commentControlHandle);
const commentController = this._commentControllers.get(arg.commentControlHandle);
if (!commentControl) {
if (!commentController) {
return arg;
}
const commentThread = commentControl.getCommentThread(arg.commentThreadHandle);
const commentThread = commentController.getCommentThread(arg.commentThreadHandle);
if (!commentThread) {
return arg;
......@@ -75,48 +75,48 @@ export class ExtHostComments implements ExtHostCommentsShape {
});
}
createCommentControl(extension: IExtensionDescription, id: string, label: string): vscode.CommentControl {
createCommentController(extension: IExtensionDescription, id: string, label: string): vscode.CommentController {
const handle = ExtHostComments.handlePool++;
const commentControl = new ExtHostCommentControl(extension, handle, this._commands.converter, this._proxy, id, label);
this._commentControls.set(commentControl.handle, commentControl);
const commentController = new ExtHostCommentController(extension, handle, this._commands.converter, this._proxy, id, label);
this._commentControllers.set(commentController.handle, commentController);
const commentControls = this._commentControlsByExtension.get(ExtensionIdentifier.toKey(extension.identifier)) || [];
commentControls.push(commentControl);
this._commentControlsByExtension.set(ExtensionIdentifier.toKey(extension.identifier), commentControls);
const commentControllers = this._commentControllersByExtension.get(ExtensionIdentifier.toKey(extension.identifier)) || [];
commentControllers.push(commentController);
this._commentControllersByExtension.set(ExtensionIdentifier.toKey(extension.identifier), commentControllers);
return commentControl;
return commentController;
}
$onActiveCommentWidgetChange(commentControlhandle: number, commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string): Promise<number | undefined> {
const commentControl = this._commentControls.get(commentControlhandle);
$onActiveCommentWidgetChange(commentControllerHandle: number, commentThread: modes.CommentThread2, comment: modes.Comment | undefined, input: string): Promise<number | undefined> {
const commentController = this._commentControllers.get(commentControllerHandle);
if (!commentControl) {
if (!commentController) {
return Promise.resolve(undefined);
}
commentControl.$onActiveCommentWidgetChange(commentThread, comment, input);
return Promise.resolve(commentControlhandle);
commentController.$onActiveCommentWidgetChange(commentThread, comment, input);
return Promise.resolve(commentControllerHandle);
}
$onCommentWidgetInputChange(commentControlhandle: number, value: string): Promise<void> {
const commentControl = this._commentControls.get(commentControlhandle);
$onCommentWidgetInputChange(commentControllerHandle: number, value: string): Promise<void> {
const commentController = this._commentControllers.get(commentControllerHandle);
if (!commentControl || !commentControl.widget) {
if (!commentController || !commentController.widget) {
return Promise.resolve(undefined);
}
commentControl.widget.input = value;
commentController.widget.input = value;
return Promise.resolve(undefined);
}
$onActiveCommentingRangeChange(commentControlhandle: number, range: IRange) {
const commentControl = this._commentControls.get(commentControlhandle);
$onActiveCommentingRangeChange(commentControllerHandle: number, range: IRange) {
const commentController = this._commentControllers.get(commentControllerHandle);
if (!commentControl) {
if (!commentController) {
return;
}
commentControl.setActiveCommentingRange(extHostTypeConverter.Range.to(range));
commentController.setActiveCommentingRange(extHostTypeConverter.Range.to(range));
}
registerWorkspaceCommentProvider(
......@@ -412,7 +412,7 @@ export class ExtHostCommentingRanges implements vscode.CommentingRanges {
set ranges(newRanges: vscode.Range[]) {
this._ranges = newRanges;
this._proxy.$updateCommentingRanges(this._commentControlHandle, this.handle, this._ranges.map(extHostTypeConverter.Range.from));
this._proxy.$updateCommentingRanges(this._commentControllerHandle, this.handle, this._ranges.map(extHostTypeConverter.Range.from));
}
get newCommentThreadCommand(): vscode.Command {
......@@ -423,19 +423,19 @@ export class ExtHostCommentingRanges implements vscode.CommentingRanges {
this._command = command;
const internal = this._commandsConverter.toInternal(command);
this._proxy.$updateCommentingRangesCommands(this._commentControlHandle, this.handle, internal);
this._proxy.$updateCommentingRangesCommands(this._commentControllerHandle, this.handle, internal);
}
constructor(
private _proxy: MainThreadCommentsShape,
private readonly _commandsConverter: CommandsConverter,
private _commentControlHandle: number,
private _commentControllerHandle: number,
private _resource: vscode.Uri,
private _ranges: vscode.Range[],
private _command: vscode.Command,
) {
this._proxy.$createCommentingRanges(
this._commentControlHandle,
this._commentControllerHandle,
this.handle,
this._resource,
this._ranges.map(extHostTypeConverter.Range.from),
......@@ -444,11 +444,11 @@ export class ExtHostCommentingRanges implements vscode.CommentingRanges {
}
dispose() {
this._proxy.$deleteCommentingRanges(this._commentControlHandle, this.handle);
this._proxy.$deleteCommentingRanges(this._commentControllerHandle, this.handle);
}
}
class ExtHostCommentControl implements vscode.CommentControl {
class ExtHostCommentController implements vscode.CommentController {
get id(): string {
return this._id;
}
......@@ -475,7 +475,7 @@ class ExtHostCommentControl implements vscode.CommentControl {
private _id: string,
private _label: string
) {
this._proxy.$registerCommentControl(this.handle, _id, _label);
this._proxy.$registerCommentController(this.handle, _id, _label);
}
createCommentThread(id: string, resource: vscode.Uri, range: vscode.Range, comments: vscode.Comment[], acceptInputCommands: vscode.Command[], collapsibleState?: vscode.CommentThreadCollapsibleState): vscode.CommentThread {
......
......@@ -13,7 +13,7 @@ import { keys } from 'vs/base/common/map';
import { CancellationToken } from 'vs/base/common/cancellation';
import { assign } from 'vs/base/common/objects';
import { ICommentThreadChangedEvent } from 'vs/workbench/contrib/comments/common/commentModel';
import { MainThreadCommentControl } from 'vs/workbench/api/electron-browser/mainThreadComments';
import { MainThreadCommentController } from 'vs/workbench/api/electron-browser/mainThreadComments';
export const ICommentService = createDecorator<ICommentService>('commentService');
......@@ -44,7 +44,7 @@ export interface ICommentService {
setDocumentComments(resource: URI, commentInfos: ICommentInfo[]): void;
setWorkspaceComments(owner: string, commentsByResource: CommentThread[]): void;
removeWorkspaceComments(owner: string): void;
registerCommentControl(owner: string, commentControl: MainThreadCommentControl): void;
registerCommentController(owner: string, commentControl: MainThreadCommentController): void;
registerDataProvider(owner: string, commentProvider: DocumentCommentProvider): void;
unregisterDataProvider(owner: string): void;
updateComments(ownerId: string, event: CommentThreadChangedEvent): void;
......@@ -101,7 +101,7 @@ export class CommentService extends Disposable implements ICommentService {
private _commentProviders = new Map<string, DocumentCommentProvider>();
private _commentControls = new Map<string, MainThreadCommentControl>();
private _commentControls = new Map<string, MainThreadCommentController>();
constructor() {
super();
......@@ -132,7 +132,7 @@ export class CommentService extends Disposable implements ICommentService {
this._onDidSetAllCommentThreads.fire({ ownerId: owner, commentThreads: [] });
}
registerCommentControl(owner: string, commentControl: MainThreadCommentControl): void {
registerCommentController(owner: string, commentControl: MainThreadCommentController): void {
this._commentControls.set(owner, commentControl);
this._onDidSetDataProvider.fire();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册