mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 12:04:04 +01:00
Remove old proposed commenting API
This commit is contained in:
@@ -3,85 +3,25 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable, IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor, isCodeEditor, isDiffEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable, DisposableStore, dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { keys } from 'vs/base/common/map';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ExtHostCommentsShape, ExtHostContext, IExtHostContext, MainContext, MainThreadCommentsShape, CommentProviderFeatures } from '../common/extHost.protocol';
|
||||
|
||||
import { ICommentService, ICommentInfo } from 'vs/workbench/contrib/comments/browser/commentService';
|
||||
import { COMMENTS_PANEL_ID, CommentsPanel, COMMENTS_PANEL_TITLE } from 'vs/workbench/contrib/comments/browser/commentsPanel';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ICommentsConfiguration } from 'vs/workbench/contrib/comments/browser/comments.contribution';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export class MainThreadDocumentCommentProvider implements modes.DocumentCommentProvider {
|
||||
private readonly _proxy: ExtHostCommentsShape;
|
||||
private readonly _handle: number;
|
||||
private readonly _features: CommentProviderFeatures;
|
||||
get startDraftLabel(): string | undefined { return this._features.startDraftLabel; }
|
||||
get deleteDraftLabel(): string | undefined { return this._features.deleteDraftLabel; }
|
||||
get finishDraftLabel(): string | undefined { return this._features.finishDraftLabel; }
|
||||
get reactionGroup(): modes.CommentReaction[] | undefined { return this._features.reactionGroup; }
|
||||
|
||||
constructor(proxy: ExtHostCommentsShape, handle: number, features: CommentProviderFeatures) {
|
||||
this._proxy = proxy;
|
||||
this._handle = handle;
|
||||
this._features = features;
|
||||
}
|
||||
|
||||
async provideDocumentComments(uri: URI, token: CancellationToken) {
|
||||
return this._proxy.$provideDocumentComments(this._handle, uri);
|
||||
}
|
||||
|
||||
async createNewCommentThread(uri: URI, range: Range, text: string, token: CancellationToken) {
|
||||
return this._proxy.$createNewCommentThread(this._handle, uri, range, text);
|
||||
}
|
||||
|
||||
async replyToCommentThread(uri: URI, range: Range, thread: modes.CommentThread, text: string, token: CancellationToken) {
|
||||
return this._proxy.$replyToCommentThread(this._handle, uri, range, thread, text);
|
||||
}
|
||||
|
||||
async editComment(uri: URI, comment: modes.Comment, text: string, token: CancellationToken) {
|
||||
return this._proxy.$editComment(this._handle, uri, comment, text);
|
||||
}
|
||||
|
||||
async deleteComment(uri: URI, comment: modes.Comment, token: CancellationToken) {
|
||||
return this._proxy.$deleteComment(this._handle, uri, comment);
|
||||
}
|
||||
|
||||
async startDraft(uri: URI, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$startDraft(this._handle, uri);
|
||||
}
|
||||
async deleteDraft(uri: URI, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$deleteDraft(this._handle, uri);
|
||||
}
|
||||
async finishDraft(uri: URI, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$finishDraft(this._handle, uri);
|
||||
}
|
||||
async addReaction(uri: URI, comment: modes.Comment, reaction: modes.CommentReaction, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$addReaction(this._handle, uri, comment, reaction);
|
||||
}
|
||||
async deleteReaction(uri: URI, comment: modes.Comment, reaction: modes.CommentReaction, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$deleteReaction(this._handle, uri, comment, reaction);
|
||||
}
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { Extensions as PanelExtensions, PanelDescriptor, PanelRegistry } from 'vs/workbench/browser/panel';
|
||||
import { ICommentInfo, ICommentService } from 'vs/workbench/contrib/comments/browser/commentService';
|
||||
import { CommentsPanel, COMMENTS_PANEL_ID, COMMENTS_PANEL_TITLE } from 'vs/workbench/contrib/comments/browser/commentsPanel';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { CommentProviderFeatures, ExtHostCommentsShape, ExtHostContext, IExtHostContext, MainContext, MainThreadCommentsShape } from '../common/extHost.protocol';
|
||||
|
||||
|
||||
// onDidChangeCommentThreads = null;
|
||||
}
|
||||
|
||||
export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
export class MainThreadCommentThread implements modes.CommentThread {
|
||||
private _input?: modes.CommentInput;
|
||||
get input(): modes.CommentInput | undefined {
|
||||
return this._input;
|
||||
@@ -133,42 +73,6 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
private _onDidChangeComments = new Emitter<modes.Comment[] | undefined>();
|
||||
get onDidChangeComments(): Event<modes.Comment[] | undefined> { return this._onDidChangeComments.event; }
|
||||
|
||||
private _acceptInputCommand: modes.Command | undefined;
|
||||
set acceptInputCommand(newCommand: modes.Command | undefined) {
|
||||
this._acceptInputCommand = newCommand;
|
||||
this._onDidChangeAcceptInputCommand.fire(this._acceptInputCommand);
|
||||
}
|
||||
|
||||
get acceptInputCommand(): modes.Command | undefined {
|
||||
return this._acceptInputCommand!;
|
||||
}
|
||||
|
||||
private _onDidChangeAcceptInputCommand = new Emitter<modes.Command | undefined>();
|
||||
get onDidChangeAcceptInputCommand(): Event<modes.Command | undefined> { return this._onDidChangeAcceptInputCommand.event; }
|
||||
|
||||
private _additionalCommands: modes.Command[] | undefined;
|
||||
set additionalCommands(newCommands: modes.Command[] | undefined) {
|
||||
this._additionalCommands = newCommands;
|
||||
this._onDidChangeAdditionalCommands.fire(this._additionalCommands);
|
||||
}
|
||||
|
||||
get additionalCommands(): modes.Command[] | undefined {
|
||||
return this._additionalCommands;
|
||||
}
|
||||
|
||||
private _onDidChangeAdditionalCommands = new Emitter<modes.Command[] | undefined>();
|
||||
get onDidChangeAdditionalCommands(): Event<modes.Command[] | undefined> { return this._onDidChangeAdditionalCommands.event; }
|
||||
|
||||
private _deleteCommand: modes.Command | undefined;
|
||||
|
||||
set deleteCommand(newCommand: modes.Command | undefined) {
|
||||
this._deleteCommand = newCommand;
|
||||
}
|
||||
|
||||
get deleteCommand(): modes.Command | undefined {
|
||||
return this._deleteCommand;
|
||||
}
|
||||
|
||||
set range(range: IRange) {
|
||||
this._range = range;
|
||||
this._onDidChangeRange.fire(this._range);
|
||||
@@ -216,24 +120,16 @@ export class MainThreadCommentThread implements modes.CommentThread2 {
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
deleteCommand: modes.Command | undefined,
|
||||
collapsibleState: modes.CommentThreadCollapsibleState) {
|
||||
this._range = range;
|
||||
this._label = label;
|
||||
this._contextValue = contextValue;
|
||||
this._comments = comments;
|
||||
this._acceptInputCommand = acceptInputCommand;
|
||||
this._additionalCommands = additionalCommands;
|
||||
this._deleteCommand = deleteCommand;
|
||||
this._collapsibleState = collapsibleState;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._isDisposed = true;
|
||||
this._onDidChangeAcceptInputCommand.dispose();
|
||||
this._onDidChangeAdditionalCommands.dispose();
|
||||
this._onDidChangeCollasibleState.dispose();
|
||||
this._onDidChangeComments.dispose();
|
||||
this._onDidChangeInput.dispose();
|
||||
@@ -307,7 +203,7 @@ export class MainThreadCommentController {
|
||||
threadId: string,
|
||||
resource: UriComponents,
|
||||
range: IRange,
|
||||
): modes.CommentThread2 {
|
||||
): modes.CommentThread {
|
||||
let thread = new MainThreadCommentThread(
|
||||
commentThreadHandle,
|
||||
this.handle,
|
||||
@@ -319,17 +215,11 @@ export class MainThreadCommentController {
|
||||
|
||||
this._threads.set(commentThreadHandle, thread);
|
||||
|
||||
// As we create comment thread from template and then restore from the newly created maint thread comment thread,
|
||||
// we postpone the update event to avoid duplication.
|
||||
// This can be actually removed once we are on the new API.
|
||||
setTimeout(() => {
|
||||
this._commentService.updateComments(this._uniqueId, {
|
||||
added: [thread],
|
||||
removed: [],
|
||||
changed: [],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
});
|
||||
}, 0);
|
||||
this._commentService.updateComments(this._uniqueId, {
|
||||
added: [thread],
|
||||
removed: [],
|
||||
changed: []
|
||||
});
|
||||
|
||||
return thread;
|
||||
}
|
||||
@@ -341,18 +231,14 @@ export class MainThreadCommentController {
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
deleteCommand: modes.Command | undefined,
|
||||
collapsibleState: modes.CommentThreadCollapsibleState): void {
|
||||
let thread = this.getKnownThread(commentThreadHandle);
|
||||
thread.batchUpdate(range, label, contextValue, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
thread.batchUpdate(range, label, contextValue, comments, collapsibleState);
|
||||
|
||||
this._commentService.updateComments(this._uniqueId, {
|
||||
added: [],
|
||||
removed: [],
|
||||
changed: [thread],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
changed: [thread]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -363,8 +249,7 @@ export class MainThreadCommentController {
|
||||
this._commentService.updateComments(this._uniqueId, {
|
||||
added: [],
|
||||
removed: [thread],
|
||||
changed: [],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
changed: []
|
||||
});
|
||||
|
||||
thread.dispose();
|
||||
@@ -397,7 +282,7 @@ export class MainThreadCommentController {
|
||||
}
|
||||
|
||||
async getDocumentComments(resource: URI, token: CancellationToken) {
|
||||
let ret: modes.CommentThread2[] = [];
|
||||
let ret: modes.CommentThread[] = [];
|
||||
for (let thread of keys(this._threads)) {
|
||||
const commentThread = this._threads.get(thread)!;
|
||||
if (commentThread.resource === resource.toString()) {
|
||||
@@ -406,26 +291,15 @@ export class MainThreadCommentController {
|
||||
}
|
||||
|
||||
let commentingRanges = await this._proxy.$provideCommentingRanges(this.handle, resource, token);
|
||||
let staticContribution = await this._proxy.$checkStaticContribution(this.handle);
|
||||
|
||||
return <ICommentInfo>{
|
||||
owner: this._uniqueId,
|
||||
label: this.label,
|
||||
threads: ret,
|
||||
commentingRanges: commentingRanges ? {
|
||||
commentingRanges: {
|
||||
resource: resource,
|
||||
ranges: commentingRanges,
|
||||
newCommentThreadCallback: staticContribution ? undefined : async (uri: UriComponents, range: IRange) => {
|
||||
let threadHandle = await this._proxy.$createNewCommentWidgetCallback(this.handle, uri, range, token);
|
||||
|
||||
if (threadHandle !== undefined) {
|
||||
return this.getKnownThread(threadHandle);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} : [],
|
||||
draftMode: modes.DraftMode.NotSupported
|
||||
ranges: commentingRanges || []
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -438,7 +312,7 @@ export class MainThreadCommentController {
|
||||
return this._features.reactionGroup;
|
||||
}
|
||||
|
||||
async toggleReaction(uri: URI, thread: modes.CommentThread2, comment: modes.Comment, reaction: modes.CommentReaction, token: CancellationToken): Promise<void> {
|
||||
async toggleReaction(uri: URI, thread: modes.CommentThread, comment: modes.Comment, reaction: modes.CommentReaction, token: CancellationToken): Promise<void> {
|
||||
return this._proxy.$toggleReaction(this._handle, thread.commentThreadHandle, uri, comment, reaction);
|
||||
}
|
||||
|
||||
@@ -477,18 +351,14 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
|
||||
private _activeCommentThread?: MainThreadCommentThread;
|
||||
private readonly _activeCommentThreadDisposables = this._register(new DisposableStore());
|
||||
private _input?: modes.CommentInput;
|
||||
|
||||
private _openPanelListener: IDisposable | null;
|
||||
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@ICommentService private readonly _commentService: ICommentService,
|
||||
@IPanelService private readonly _panelService: IPanelService,
|
||||
@ITelemetryService private readonly _telemetryService: ITelemetryService,
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@IPanelService private readonly _panelService: IPanelService
|
||||
) {
|
||||
super();
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
|
||||
@@ -504,13 +374,6 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
this._activeCommentThreadDisposables.clear();
|
||||
this._activeCommentThread = thread as MainThreadCommentThread;
|
||||
controller.activeCommentThread = this._activeCommentThread;
|
||||
|
||||
this._activeCommentThreadDisposables.add(this._activeCommentThread.onDidChangeInput(input => { // todo, dispose
|
||||
this._input = input;
|
||||
this._proxy.$onCommentWidgetInputChange(handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread!.range, this._input ? this._input.value : undefined);
|
||||
}));
|
||||
|
||||
await this._proxy.$onCommentWidgetInputChange(controller.handle, URI.parse(this._activeCommentThread!.resource), this._activeCommentThread.range, this._input ? this._input.value : undefined);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -556,7 +419,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
resource: UriComponents,
|
||||
range: IRange,
|
||||
extensionId: ExtensionIdentifier
|
||||
): modes.CommentThread2 | undefined {
|
||||
): modes.CommentThread | undefined {
|
||||
let provider = this._commentControllers.get(handle);
|
||||
|
||||
if (!provider) {
|
||||
@@ -574,9 +437,6 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
label: string,
|
||||
contextValue: string | undefined,
|
||||
comments: modes.Comment[],
|
||||
acceptInputCommand: modes.Command | undefined,
|
||||
additionalCommands: modes.Command[],
|
||||
deleteCommand: modes.Command,
|
||||
collapsibleState: modes.CommentThreadCollapsibleState): void {
|
||||
let provider = this._commentControllers.get(handle);
|
||||
|
||||
@@ -584,7 +444,7 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return provider.updateCommentThread(commentThreadHandle, threadId, resource, range, label, contextValue, comments, acceptInputCommand, additionalCommands, deleteCommand, collapsibleState);
|
||||
return provider.updateCommentThread(commentThreadHandle, threadId, resource, range, label, contextValue, comments, collapsibleState);
|
||||
}
|
||||
|
||||
$deleteCommentThread(handle: number, commentThreadHandle: number) {
|
||||
@@ -597,26 +457,6 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
return provider.deleteCommentThread(commentThreadHandle);
|
||||
}
|
||||
|
||||
$setInputValue(handle: number, input: string) {
|
||||
let provider = this._commentControllers.get(handle);
|
||||
|
||||
if (!provider) {
|
||||
return;
|
||||
}
|
||||
|
||||
provider.updateInput(input);
|
||||
}
|
||||
|
||||
$registerDocumentCommentProvider(handle: number, features: CommentProviderFeatures): void {
|
||||
this._documentProviders.set(handle, undefined);
|
||||
const handler = new MainThreadDocumentCommentProvider(this._proxy, handle, features);
|
||||
|
||||
const providerId = generateUuid();
|
||||
this._handlers.set(handle, providerId);
|
||||
|
||||
this._commentService.registerDataProvider(providerId, handler);
|
||||
}
|
||||
|
||||
private registerPanel(commentsPanelAlreadyConstructed: boolean) {
|
||||
if (!commentsPanelAlreadyConstructed) {
|
||||
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
|
||||
@@ -638,15 +478,6 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
if (!commentsPanelAlreadyConstructed && !this._openPanelListener) {
|
||||
this._openPanelListener = this._panelService.onDidPanelOpen(e => {
|
||||
if (e.panel.getId() === COMMENTS_PANEL_ID) {
|
||||
keys(this._workspaceProviders).forEach(handle => {
|
||||
this._proxy.$provideWorkspaceComments(handle).then(commentThreads => {
|
||||
if (commentThreads) {
|
||||
const providerId = this.getHandler(handle);
|
||||
this._commentService.setWorkspaceComments(providerId, commentThreads);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
keys(this._commentControllers).forEach(handle => {
|
||||
let threads = this._commentControllers.get(handle)!.getAllComments();
|
||||
|
||||
@@ -672,116 +503,12 @@ export class MainThreadComments extends Disposable implements MainThreadComments
|
||||
return this._handlers.get(handle)!;
|
||||
}
|
||||
|
||||
$registerWorkspaceCommentProvider(handle: number, extensionId: ExtensionIdentifier): void {
|
||||
this._workspaceProviders.set(handle, undefined);
|
||||
|
||||
const providerId = generateUuid();
|
||||
this._handlers.set(handle, providerId);
|
||||
|
||||
const commentsPanelAlreadyConstructed = this._panelService.getPanels().some(panel => panel.id === COMMENTS_PANEL_ID);
|
||||
if (!commentsPanelAlreadyConstructed) {
|
||||
this.registerPanel(commentsPanelAlreadyConstructed);
|
||||
}
|
||||
|
||||
const openPanel = this._configurationService.getValue<ICommentsConfiguration>('comments').openPanel;
|
||||
|
||||
if (openPanel === 'neverOpen') {
|
||||
this.registerOpenPanelListener(commentsPanelAlreadyConstructed);
|
||||
}
|
||||
|
||||
if (openPanel === 'openOnSessionStart') {
|
||||
this._panelService.openPanel(COMMENTS_PANEL_ID);
|
||||
}
|
||||
|
||||
this._proxy.$provideWorkspaceComments(handle).then(commentThreads => {
|
||||
if (commentThreads) {
|
||||
if (openPanel === 'openOnSessionStartWithComments' && commentThreads.length) {
|
||||
if (commentThreads.length) {
|
||||
this._panelService.openPanel(COMMENTS_PANEL_ID);
|
||||
} else {
|
||||
this.registerOpenPanelListener(commentsPanelAlreadyConstructed);
|
||||
}
|
||||
}
|
||||
|
||||
this._commentService.setWorkspaceComments(providerId, commentThreads);
|
||||
}
|
||||
});
|
||||
|
||||
/* __GDPR__
|
||||
"comments:registerWorkspaceCommentProvider" : {
|
||||
"extensionId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('comments:registerWorkspaceCommentProvider', {
|
||||
extensionId: extensionId.value
|
||||
});
|
||||
}
|
||||
|
||||
$unregisterDocumentCommentProvider(handle: number): void {
|
||||
this._documentProviders.delete(handle);
|
||||
const handlerId = this.getHandler(handle);
|
||||
this._commentService.unregisterDataProvider(handlerId);
|
||||
this._handlers.delete(handle);
|
||||
}
|
||||
|
||||
$unregisterWorkspaceCommentProvider(handle: number): void {
|
||||
this._workspaceProviders.delete(handle);
|
||||
if (this._workspaceProviders.size === 0) {
|
||||
Registry.as<PanelRegistry>(PanelExtensions.Panels).deregisterPanel(COMMENTS_PANEL_ID);
|
||||
|
||||
if (this._openPanelListener) {
|
||||
this._openPanelListener.dispose();
|
||||
this._openPanelListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
const handlerId = this.getHandler(handle);
|
||||
this._commentService.removeWorkspaceComments(handlerId);
|
||||
this._handlers.delete(handle);
|
||||
}
|
||||
|
||||
$onDidCommentThreadsChange(handle: number, event: modes.CommentThreadChangedEvent) {
|
||||
// notify comment service
|
||||
const providerId = this.getHandler(handle);
|
||||
this._commentService.updateComments(providerId, event);
|
||||
}
|
||||
|
||||
getVisibleEditors(): ICodeEditor[] {
|
||||
let ret: ICodeEditor[] = [];
|
||||
|
||||
this._editorService.visibleControls.forEach(control => {
|
||||
if (isCodeEditor(control.getControl())) {
|
||||
ret.push(control.getControl() as ICodeEditor);
|
||||
}
|
||||
|
||||
if (isDiffEditor(control.getControl())) {
|
||||
let diffEditor = control.getControl() as IDiffEditor;
|
||||
ret.push(diffEditor.getOriginalEditor(), diffEditor.getModifiedEditor());
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
async provideWorkspaceComments(): Promise<modes.CommentThread[]> {
|
||||
const result: modes.CommentThread[] = [];
|
||||
for (const handle of keys(this._workspaceProviders)) {
|
||||
const result = await this._proxy.$provideWorkspaceComments(handle);
|
||||
if (Array.isArray(result)) {
|
||||
result.push(...result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async provideDocumentComments(resource: URI): Promise<Array<modes.CommentInfo | null>> {
|
||||
const result: Array<modes.CommentInfo | null> = [];
|
||||
for (const handle of keys(this._documentProviders)) {
|
||||
result.push(await this._proxy.$provideDocumentComments(handle, resource));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
this._workspaceProviders.forEach(value => dispose(value));
|
||||
|
||||
@@ -3,50 +3,50 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IRemoteConsoleLog } from 'vs/base/common/console';
|
||||
import { SerializedError } from 'vs/base/common/errors';
|
||||
import { IRelativePattern } from 'vs/base/common/glob';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { TextEditorCursorStyle, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { RenderLineNumbersType, TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ISingleEditOperation, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { EndOfLineSequence, ISingleEditOperation } from 'vs/editor/common/model';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { CharacterPair, CommentRule, EnterAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { ConfigurationTarget, IConfigurationData, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import * as files from 'vs/platform/files/common/files';
|
||||
import { ResourceLabelFormatter } from 'vs/platform/label/common/label';
|
||||
import { LogLevel } from 'vs/platform/log/common/log';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { IProgressOptions, IProgressStep } from 'vs/platform/progress/common/progress';
|
||||
import * as quickInput from 'vs/platform/quickinput/common/quickInput';
|
||||
import * as search from 'vs/workbench/services/search/common/search';
|
||||
import { RemoteAuthorityResolverErrorCode, ResolvedAuthority } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import * as statusbar from 'vs/platform/statusbar/common/statusbar';
|
||||
import { ClassifiedEvent, GDPRClassification, StrictPropertyCheck } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
import { ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ThemeColor } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
|
||||
import * as tasks from 'vs/workbench/api/common/shared/tasks';
|
||||
import { ITreeItem, IRevealOptions } from 'vs/workbench/common/views';
|
||||
import { IRevealOptions, ITreeItem } from 'vs/workbench/common/views';
|
||||
import * as callHierarchy from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
|
||||
import { IAdapterDescriptor, IConfig, ITerminalSettings } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
|
||||
import { ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ExtensionActivationError } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IRPCProtocol, createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { IProgressOptions, IProgressStep } from 'vs/platform/progress/common/progress';
|
||||
import { createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId, IRPCProtocol } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import * as search from 'vs/workbench/services/search/common/search';
|
||||
import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { ResolvedAuthority, RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import * as callHierarchy from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
|
||||
import { IRelativePattern } from 'vs/base/common/glob';
|
||||
import { IRemoteConsoleLog } from 'vs/base/common/console';
|
||||
import { VSBuffer } from 'vs/base/common/buffer';
|
||||
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
|
||||
|
||||
export interface IEnvironment {
|
||||
isExtensionDevelopmentDebug: boolean;
|
||||
@@ -120,19 +120,8 @@ export interface MainThreadCommandsShape extends IDisposable {
|
||||
$getCommands(): Promise<string[]>;
|
||||
}
|
||||
|
||||
export interface CommentThreadTemplate {
|
||||
label: string;
|
||||
acceptInputCommand?: modes.Command;
|
||||
additionalCommands?: modes.Command[];
|
||||
deleteCommand?: modes.Command;
|
||||
}
|
||||
|
||||
export interface CommentProviderFeatures {
|
||||
startDraftLabel?: string;
|
||||
deleteDraftLabel?: string;
|
||||
finishDraftLabel?: string;
|
||||
reactionGroup?: modes.CommentReaction[];
|
||||
commentThreadTemplate?: CommentThreadTemplate;
|
||||
reactionHandler?: boolean;
|
||||
}
|
||||
|
||||
@@ -140,14 +129,9 @@ export interface MainThreadCommentsShape extends IDisposable {
|
||||
$registerCommentController(handle: number, id: string, label: string): void;
|
||||
$unregisterCommentController(handle: number): void;
|
||||
$updateCommentControllerFeatures(handle: number, features: CommentProviderFeatures): void;
|
||||
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, extensionId: ExtensionIdentifier): modes.CommentThread2 | undefined;
|
||||
$updateCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, label: string, contextValue: string | undefined, comments: modes.Comment[], acceptInputCommand: modes.Command | undefined, additionalCommands: modes.Command[], deleteCommand: modes.Command | undefined, collapseState: modes.CommentThreadCollapsibleState): void;
|
||||
$createCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, extensionId: ExtensionIdentifier): modes.CommentThread | undefined;
|
||||
$updateCommentThread(handle: number, commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, label: string, contextValue: string | undefined, comments: modes.Comment[], collapseState: modes.CommentThreadCollapsibleState): void;
|
||||
$deleteCommentThread(handle: number, commentThreadHandle: number): void;
|
||||
$setInputValue(handle: number, input: string): void;
|
||||
$registerDocumentCommentProvider(handle: number, features: CommentProviderFeatures): void;
|
||||
$unregisterDocumentCommentProvider(handle: number): void;
|
||||
$registerWorkspaceCommentProvider(handle: number, extensionId: ExtensionIdentifier): void;
|
||||
$unregisterWorkspaceCommentProvider(handle: number): void;
|
||||
$onDidCommentThreadsChange(handle: number, event: modes.CommentThreadChangedEvent): void;
|
||||
}
|
||||
|
||||
@@ -1290,26 +1274,12 @@ export interface ExtHostProgressShape {
|
||||
}
|
||||
|
||||
export interface ExtHostCommentsShape {
|
||||
$provideDocumentComments(handle: number, document: UriComponents): Promise<modes.CommentInfo | null>;
|
||||
$createNewCommentThread(handle: number, document: UriComponents, range: IRange, text: string): Promise<modes.CommentThread | null>;
|
||||
$createCommentThreadTemplate(commentControllerHandle: number, uriComponents: UriComponents, range: IRange): void;
|
||||
$updateCommentThreadTemplate(commentControllerHandle: number, threadHandle: number, range: IRange): Promise<void>;
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, document: UriComponents, range: IRange, input: string | undefined): Promise<number | undefined>;
|
||||
$deleteCommentThread(commentControllerHandle: number, commentThreadHandle: number): void;
|
||||
$provideCommentingRanges(commentControllerHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise<IRange[] | undefined>;
|
||||
$checkStaticContribution(commentControllerHandle: number): Promise<boolean>;
|
||||
$provideReactionGroup(commentControllerHandle: number): Promise<modes.CommentReaction[] | undefined>;
|
||||
$toggleReaction(commentControllerHandle: number, threadHandle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<void>;
|
||||
$replyToCommentThread(handle: number, document: UriComponents, range: IRange, commentThread: modes.CommentThread, text: string): Promise<modes.CommentThread | null>;
|
||||
$editComment(handle: number, document: UriComponents, comment: modes.Comment, text: string): Promise<void>;
|
||||
$deleteComment(handle: number, document: UriComponents, comment: modes.Comment): Promise<void>;
|
||||
$startDraft(handle: number, document: UriComponents): Promise<void>;
|
||||
$deleteDraft(handle: number, document: UriComponents): Promise<void>;
|
||||
$finishDraft(handle: number, document: UriComponents): Promise<void>;
|
||||
$addReaction(handle: number, document: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
|
||||
$deleteReaction(handle: number, document: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void>;
|
||||
$provideWorkspaceComments(handle: number): Promise<modes.CommentThread[] | null>;
|
||||
}
|
||||
|
||||
export interface ExtHostStorageShape {
|
||||
|
||||
@@ -4,26 +4,20 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { DisposableStore, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/common/extHostDocuments';
|
||||
import * as extHostTypeConverter from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import * as types from 'vs/workbench/api/common/extHostTypes';
|
||||
import * as vscode from 'vscode';
|
||||
import { ExtHostCommentsShape, IMainContext, MainContext, MainThreadCommentsShape, CommandDto } from './extHost.protocol';
|
||||
import { CommandsConverter, ExtHostCommands } from './extHostCommands';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { MutableDisposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
interface HandlerData<T> {
|
||||
|
||||
extensionId: ExtensionIdentifier;
|
||||
provider: T;
|
||||
}
|
||||
import { ExtHostCommentsShape, IMainContext, MainContext, MainThreadCommentsShape } from './extHost.protocol';
|
||||
import { ExtHostCommands } from './extHostCommands';
|
||||
|
||||
type ProviderHandle = number;
|
||||
|
||||
@@ -37,20 +31,15 @@ export class ExtHostComments implements ExtHostCommentsShape, IDisposable {
|
||||
|
||||
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>>();
|
||||
|
||||
private _commandDisposables = new MutableDisposable<DisposableStore>();
|
||||
|
||||
constructor(
|
||||
mainContext: IMainContext,
|
||||
private _commands: ExtHostCommands,
|
||||
commands: ExtHostCommands,
|
||||
private readonly _documents: ExtHostDocuments,
|
||||
) {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadComments);
|
||||
this._commandDisposables.value = new DisposableStore();
|
||||
|
||||
_commands.registerArgumentProcessor({
|
||||
commands.registerArgumentProcessor({
|
||||
processArgument: arg => {
|
||||
if (arg && arg.$mid === 6) {
|
||||
const commentController = this._commentControllers.get(arg.handle);
|
||||
@@ -147,7 +136,7 @@ export class ExtHostComments implements ExtHostCommentsShape, IDisposable {
|
||||
|
||||
createCommentController(extension: IExtensionDescription, id: string, label: string): vscode.CommentController {
|
||||
const handle = ExtHostComments.handlePool++;
|
||||
const commentController = new ExtHostCommentController(extension, handle, this._commands.converter, this._proxy, id, label);
|
||||
const commentController = new ExtHostCommentController(extension, handle, this._proxy, id, label);
|
||||
this._commentControllers.set(commentController.handle, commentController);
|
||||
|
||||
const commentControllers = this._commentControllersByExtension.get(ExtensionIdentifier.toKey(extension.identifier)) || [];
|
||||
@@ -177,17 +166,6 @@ export class ExtHostComments implements ExtHostCommentsShape, IDisposable {
|
||||
commentController.$updateCommentThreadTemplate(threadHandle, range);
|
||||
}
|
||||
|
||||
$onCommentWidgetInputChange(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, input: string): Promise<number | undefined> {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
if (!commentController) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
commentController.$onCommentWidgetInputChange(uriComponents, range, input);
|
||||
return Promise.resolve(commentControllerHandle);
|
||||
}
|
||||
|
||||
$deleteCommentThread(commentControllerHandle: number, commentThreadHandle: number) {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
@@ -218,7 +196,7 @@ export class ExtHostComments implements ExtHostCommentsShape, IDisposable {
|
||||
|
||||
return asPromise(() => {
|
||||
return commentController!.reactionProvider!.availableReactions;
|
||||
}).then(reactions => reactions.map(reaction => convertToReaction2(commentController.reactionProvider, reaction)));
|
||||
}).then(reactions => reactions.map(reaction => convertToReaction(commentController.reactionProvider, reaction)));
|
||||
}
|
||||
|
||||
$toggleReaction(commentControllerHandle: number, threadHandle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void> {
|
||||
@@ -250,233 +228,8 @@ export class ExtHostComments implements ExtHostCommentsShape, IDisposable {
|
||||
});
|
||||
}
|
||||
|
||||
$createNewCommentWidgetCallback(commentControllerHandle: number, uriComponents: UriComponents, range: IRange, token: CancellationToken): Promise<void> {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
dispose() {
|
||||
|
||||
if (!commentController) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (!(commentController as any).emptyCommentThreadFactory) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const document = this._documents.getDocument(URI.revive(uriComponents));
|
||||
return asPromise(() => {
|
||||
if ((commentController as any).emptyCommentThreadFactory) {
|
||||
return (commentController as any).emptyCommentThreadFactory!.createEmptyCommentThread(document, extHostTypeConverter.Range.to(range));
|
||||
}
|
||||
}).then(() => Promise.resolve());
|
||||
}
|
||||
|
||||
$checkStaticContribution(commentControllerHandle: number): Promise<boolean> {
|
||||
const commentController = this._commentControllers.get(commentControllerHandle);
|
||||
|
||||
if (!commentController) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
if (!(commentController as any).emptyCommentThreadFactory) {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
registerWorkspaceCommentProvider(
|
||||
extensionId: ExtensionIdentifier,
|
||||
provider: vscode.WorkspaceCommentProvider
|
||||
): vscode.Disposable {
|
||||
const handle = ExtHostComments.handlePool++;
|
||||
this._workspaceProviders.set(handle, {
|
||||
extensionId,
|
||||
provider
|
||||
});
|
||||
this._proxy.$registerWorkspaceCommentProvider(handle, extensionId);
|
||||
this.registerListeners(handle, extensionId, provider);
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
this._proxy.$unregisterWorkspaceCommentProvider(handle);
|
||||
this._workspaceProviders.delete(handle);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
registerDocumentCommentProvider(
|
||||
extensionId: ExtensionIdentifier,
|
||||
provider: vscode.DocumentCommentProvider
|
||||
): vscode.Disposable {
|
||||
const handle = ExtHostComments.handlePool++;
|
||||
this._documentProviders.set(handle, {
|
||||
extensionId,
|
||||
provider
|
||||
});
|
||||
this._proxy.$registerDocumentCommentProvider(handle, {
|
||||
startDraftLabel: provider.startDraftLabel,
|
||||
deleteDraftLabel: provider.deleteDraftLabel,
|
||||
finishDraftLabel: provider.finishDraftLabel,
|
||||
reactionGroup: provider.reactionGroup ? provider.reactionGroup.map(reaction => convertToReaction(provider, reaction)) : undefined
|
||||
});
|
||||
this.registerListeners(handle, extensionId, provider);
|
||||
|
||||
return {
|
||||
dispose: () => {
|
||||
this._proxy.$unregisterDocumentCommentProvider(handle);
|
||||
this._documentProviders.delete(handle);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
$createNewCommentThread(handle: number, uri: UriComponents, range: IRange, text: string): Promise<modes.CommentThread | null> {
|
||||
const data = this._documents.getDocumentData(URI.revive(uri));
|
||||
const ran = <vscode.Range>extHostTypeConverter.Range.to(range);
|
||||
|
||||
if (!data || !data.document) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.createNewCommentThread(data.document, ran, text, CancellationToken.None);
|
||||
}).then(commentThread => commentThread ? convertToCommentThread(handlerData.extensionId, handlerData.provider, commentThread, this._commands.converter, this._commandDisposables.value!) : null);
|
||||
}
|
||||
|
||||
$replyToCommentThread(handle: number, uri: UriComponents, range: IRange, thread: modes.CommentThread, text: string): Promise<modes.CommentThread | null> {
|
||||
const data = this._documents.getDocumentData(URI.revive(uri));
|
||||
const ran = <vscode.Range>extHostTypeConverter.Range.to(range);
|
||||
|
||||
if (!data || !data.document) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.replyToCommentThread(data.document, ran, convertFromCommentThread(thread), text, CancellationToken.None);
|
||||
}).then(commentThread => commentThread ? convertToCommentThread(handlerData.extensionId, handlerData.provider, commentThread, this._commands.converter, this._commandDisposables.value!) : null);
|
||||
}
|
||||
|
||||
$editComment(handle: number, uri: UriComponents, comment: modes.Comment, text: string): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.editComment) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.editComment!(document, convertFromComment(comment), text, CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$deleteComment(handle: number, uri: UriComponents, comment: modes.Comment): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.deleteComment) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.deleteComment!(document, convertFromComment(comment), CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$startDraft(handle: number, uri: UriComponents): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.startDraft) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.startDraft!(document, CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$deleteDraft(handle: number, uri: UriComponents): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.deleteDraft) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.deleteDraft!(document, CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$finishDraft(handle: number, uri: UriComponents): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.finishDraft) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.finishDraft!(document, CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$addReaction(handle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.addReaction) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.addReaction!(document, convertFromComment(comment), convertFromReaction(reaction));
|
||||
});
|
||||
}
|
||||
|
||||
$deleteReaction(handle: number, uri: UriComponents, comment: modes.Comment, reaction: modes.CommentReaction): Promise<void> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
if (!handlerData.provider.deleteReaction) {
|
||||
return Promise.reject(new Error('not implemented'));
|
||||
}
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.deleteReaction!(document, convertFromComment(comment), convertFromReaction(reaction));
|
||||
});
|
||||
}
|
||||
|
||||
$provideDocumentComments(handle: number, uri: UriComponents): Promise<modes.CommentInfo | null> {
|
||||
const document = this._documents.getDocument(URI.revive(uri));
|
||||
const handlerData = this.getDocumentProvider(handle);
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.provideDocumentComments(document, CancellationToken.None);
|
||||
}).then(commentInfo => commentInfo ? convertCommentInfo(handle, handlerData.extensionId, handlerData.provider, commentInfo, this._commands.converter, this._commandDisposables.value!) : null);
|
||||
}
|
||||
|
||||
$provideWorkspaceComments(handle: number): Promise<modes.CommentThread[] | null> {
|
||||
const handlerData = this._workspaceProviders.get(handle);
|
||||
if (!handlerData) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asPromise(() => {
|
||||
return handlerData.provider.provideWorkspaceComments(CancellationToken.None);
|
||||
}).then(comments =>
|
||||
comments.map(comment => convertToCommentThread(handlerData.extensionId, handlerData.provider, comment, this._commands.converter, this._commandDisposables.value!)
|
||||
));
|
||||
}
|
||||
|
||||
private registerListeners(handle: number, extensionId: ExtensionIdentifier, provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider) {
|
||||
provider.onDidChangeCommentThreads(event => {
|
||||
|
||||
this._proxy.$onDidCommentThreadsChange(handle, {
|
||||
changed: event.changed.map(thread => convertToCommentThread(extensionId, provider, thread, this._commands.converter, this._commandDisposables.value!)),
|
||||
added: event.added.map(thread => convertToCommentThread(extensionId, provider, thread, this._commands.converter, this._commandDisposables.value!)),
|
||||
removed: event.removed.map(thread => convertToCommentThread(extensionId, provider, thread, this._commands.converter, this._commandDisposables.value!)),
|
||||
draftMode: !!(provider as vscode.DocumentCommentProvider).startDraft && !!(provider as vscode.DocumentCommentProvider).finishDraft ? (event.inDraftMode ? modes.DraftMode.InDraft : modes.DraftMode.NotInDraft) : modes.DraftMode.NotSupported
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private getDocumentProvider(handle: number): HandlerData<vscode.DocumentCommentProvider> {
|
||||
const provider = this._documentProviders.get(handle);
|
||||
if (!provider) {
|
||||
throw new Error('unknown provider');
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._commandDisposables.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,36 +303,6 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
private _acceptInputCommand: vscode.Command;
|
||||
get acceptInputCommand(): vscode.Command {
|
||||
return this._acceptInputCommand;
|
||||
}
|
||||
|
||||
set acceptInputCommand(acceptInputCommand: vscode.Command) {
|
||||
this._acceptInputCommand = acceptInputCommand;
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
private _additionalCommands: vscode.Command[] = [];
|
||||
get additionalCommands(): vscode.Command[] {
|
||||
return this._additionalCommands;
|
||||
}
|
||||
|
||||
set additionalCommands(additionalCommands: vscode.Command[]) {
|
||||
this._additionalCommands = additionalCommands;
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
private _deleteCommand?: vscode.Command;
|
||||
get deleteComand(): vscode.Command | undefined {
|
||||
return this._deleteCommand;
|
||||
}
|
||||
|
||||
set deleteCommand(deleteCommand: vscode.Command) {
|
||||
this._deleteCommand = deleteCommand;
|
||||
this._onDidUpdateCommentThread.fire();
|
||||
}
|
||||
|
||||
private _collapseState?: vscode.CommentThreadCollapsibleState;
|
||||
|
||||
get collapsibleState(): vscode.CommentThreadCollapsibleState {
|
||||
@@ -605,7 +328,6 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
private readonly _commandsConverter: CommandsConverter,
|
||||
private _commentController: ExtHostCommentController,
|
||||
private _id: string | undefined,
|
||||
private _uri: vscode.Uri,
|
||||
@@ -642,6 +364,10 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
|
||||
@debounce(100)
|
||||
eventuallyUpdateCommentThread(): void {
|
||||
if (this._isDiposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._acceptInputDisposables.value) {
|
||||
this._acceptInputDisposables.value = new DisposableStore();
|
||||
}
|
||||
@@ -649,10 +375,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
const commentThreadRange = extHostTypeConverter.Range.from(this._range);
|
||||
const label = this.label;
|
||||
const contextValue = this.contextValue;
|
||||
const comments = this._comments.map(cmt => { return convertToModeComment2(this, this._commentController, cmt, this._commandsConverter, this._commentsMap, this._acceptInputDisposables.value!); });
|
||||
const acceptInputCommand = this._acceptInputCommand ? this._commandsConverter.toInternal(this._acceptInputCommand, this._acceptInputDisposables.value) : undefined;
|
||||
const additionalCommands = (this._additionalCommands ? this._additionalCommands.map(x => this._commandsConverter.toInternal(x, this._acceptInputDisposables.value!)) : []) as CommandDto[];
|
||||
const deleteCommand = this._deleteCommand ? this._commandsConverter.toInternal(this._deleteCommand, this._acceptInputDisposables.value) : undefined;
|
||||
const comments = this._comments.map(cmt => { return convertToModeComment(this, this._commentController, cmt, this._commentsMap); });
|
||||
const collapsibleState = convertToCollapsibleState(this._collapseState);
|
||||
|
||||
this._proxy.$updateCommentThread(
|
||||
@@ -664,15 +387,12 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
label,
|
||||
contextValue,
|
||||
comments,
|
||||
acceptInputCommand,
|
||||
additionalCommands,
|
||||
deleteCommand,
|
||||
collapsibleState
|
||||
);
|
||||
}
|
||||
|
||||
getComment(commentId: string): vscode.Comment | undefined {
|
||||
const comments = this._comments.filter(comment => (comment.commentId === commentId || comment.id === commentId));
|
||||
const comments = this._comments.filter(comment => comment.commentId === commentId);
|
||||
|
||||
if (comments && comments.length) {
|
||||
return comments[0];
|
||||
@@ -694,54 +414,13 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._isDiposed = true;
|
||||
this._acceptInputDisposables.dispose();
|
||||
this._localDisposables.forEach(disposable => disposable.dispose());
|
||||
this._proxy.$deleteCommentThread(
|
||||
this._commentController.handle,
|
||||
this.handle
|
||||
);
|
||||
this._isDiposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostCommentInputBox implements vscode.CommentInputBox {
|
||||
get resource(): vscode.Uri {
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
get range(): vscode.Range {
|
||||
return this._range;
|
||||
}
|
||||
|
||||
get value(): string {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(newInput: string) {
|
||||
this._value = newInput;
|
||||
this._onDidChangeValue.fire(this._value);
|
||||
this._proxy.$setInputValue(this.commentControllerHandle, newInput);
|
||||
}
|
||||
|
||||
private _onDidChangeValue = new Emitter<string>();
|
||||
|
||||
get onDidChangeValue(): Event<string> {
|
||||
return this._onDidChangeValue.event;
|
||||
}
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
public commentControllerHandle: number,
|
||||
private _resource: vscode.Uri,
|
||||
private _range: vscode.Range,
|
||||
private _value: string
|
||||
) {
|
||||
}
|
||||
|
||||
setInput(resource: vscode.Uri, range: vscode.Range, input: string) {
|
||||
this._resource = resource;
|
||||
this._range = range;
|
||||
this._value = input;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,16 +435,12 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
return this._label;
|
||||
}
|
||||
|
||||
public inputBox: ExtHostCommentInputBox | undefined;
|
||||
|
||||
public activeCommentingRange?: vscode.Range;
|
||||
|
||||
public get handle(): number {
|
||||
return this._handle;
|
||||
}
|
||||
|
||||
private _threads: Map<number, ExtHostCommentThread> = new Map<number, ExtHostCommentThread>();
|
||||
commentingRangeProvider?: vscode.CommentingRangeProvider & { createEmptyCommentThread: (document: vscode.TextDocument, range: types.Range) => Promise<vscode.CommentThread>; };
|
||||
commentingRangeProvider?: vscode.CommentingRangeProvider;
|
||||
|
||||
private _commentReactionProvider?: vscode.CommentReactionProvider;
|
||||
|
||||
@@ -776,7 +451,7 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
set reactionProvider(provider: vscode.CommentReactionProvider | undefined) {
|
||||
this._commentReactionProvider = provider;
|
||||
if (provider) {
|
||||
this._proxy.$updateCommentControllerFeatures(this.handle, { reactionGroup: provider.availableReactions.map(reaction => convertToReaction2(provider, reaction)) });
|
||||
this._proxy.$updateCommentControllerFeatures(this.handle, { reactionGroup: provider.availableReactions.map(reaction => convertToReaction(provider, reaction)) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,7 +470,6 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
constructor(
|
||||
private _extension: IExtensionDescription,
|
||||
private _handle: number,
|
||||
private readonly _commandsConverter: CommandsConverter,
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
private _id: string,
|
||||
private _label: string
|
||||
@@ -804,34 +478,33 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
}
|
||||
|
||||
createCommentThread(resource: vscode.Uri, range: vscode.Range, comments: vscode.Comment[]): vscode.CommentThread;
|
||||
createCommentThread(id: string, resource: vscode.Uri, range: vscode.Range, comments: vscode.Comment[]): vscode.CommentThread;
|
||||
createCommentThread(arg0: vscode.Uri | string, arg1: vscode.Uri | vscode.Range, arg2: vscode.Range | vscode.Comment[], arg3?: vscode.Comment[]): vscode.CommentThread {
|
||||
if (typeof arg0 === 'string') {
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this._commandsConverter, this, arg0, arg1 as vscode.Uri, arg2 as vscode.Range, arg3 as vscode.Comment[], this._extension.identifier);
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this, arg0, arg1 as vscode.Uri, arg2 as vscode.Range, arg3 as vscode.Comment[], this._extension.identifier);
|
||||
this._threads.set(commentThread.handle, commentThread);
|
||||
return commentThread;
|
||||
} else {
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this._commandsConverter, this, undefined, arg0 as vscode.Uri, arg1 as vscode.Range, arg2 as vscode.Comment[], this._extension.identifier);
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this, undefined, arg0 as vscode.Uri, arg1 as vscode.Range, arg2 as vscode.Comment[], this._extension.identifier);
|
||||
this._threads.set(commentThread.handle, commentThread);
|
||||
return commentThread;
|
||||
}
|
||||
}
|
||||
|
||||
$createCommentThreadTemplate(uriComponents: UriComponents, range: IRange) {
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this._commandsConverter, this, undefined, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), [], this._extension.identifier);
|
||||
$createCommentThreadTemplate(uriComponents: UriComponents, range: IRange): ExtHostCommentThread {
|
||||
const commentThread = new ExtHostCommentThread(this._proxy, this, undefined, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), [], this._extension.identifier);
|
||||
commentThread.collapsibleState = modes.CommentThreadCollapsibleState.Expanded;
|
||||
this._threads.set(commentThread.handle, commentThread);
|
||||
return commentThread;
|
||||
}
|
||||
|
||||
$updateCommentThreadTemplate(threadHandle: number, range: IRange) {
|
||||
$updateCommentThreadTemplate(threadHandle: number, range: IRange): void {
|
||||
let thread = this._threads.get(threadHandle);
|
||||
if (thread) {
|
||||
thread.range = extHostTypeConverter.Range.to(range);
|
||||
}
|
||||
}
|
||||
|
||||
$deleteCommentThread(threadHandle: number) {
|
||||
$deleteCommentThread(threadHandle: number): void {
|
||||
let thread = this._threads.get(threadHandle);
|
||||
|
||||
if (thread) {
|
||||
@@ -841,15 +514,7 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
this._threads.delete(threadHandle);
|
||||
}
|
||||
|
||||
$onCommentWidgetInputChange(uriComponents: UriComponents, range: IRange, input: string) {
|
||||
if (!this.inputBox) {
|
||||
this.inputBox = new ExtHostCommentInputBox(this._proxy, this.handle, URI.revive(uriComponents), extHostTypeConverter.Range.to(range), input);
|
||||
} else {
|
||||
this.inputBox.setInput(URI.revive(uriComponents), extHostTypeConverter.Range.to(range), input);
|
||||
}
|
||||
}
|
||||
|
||||
getCommentThread(handle: number) {
|
||||
getCommentThread(handle: number): ExtHostCommentThread | undefined {
|
||||
return this._threads.get(handle);
|
||||
}
|
||||
|
||||
@@ -862,77 +527,7 @@ class ExtHostCommentController implements vscode.CommentController {
|
||||
}
|
||||
}
|
||||
|
||||
function convertCommentInfo(owner: number, extensionId: ExtensionIdentifier, provider: vscode.DocumentCommentProvider, vscodeCommentInfo: vscode.CommentInfo, commandsConverter: CommandsConverter, disposables: DisposableStore): modes.CommentInfo {
|
||||
return {
|
||||
extensionId: extensionId.value,
|
||||
threads: vscodeCommentInfo.threads.map(x => convertToCommentThread(extensionId, provider, x, commandsConverter, disposables)),
|
||||
commentingRanges: vscodeCommentInfo.commentingRanges ? vscodeCommentInfo.commentingRanges.map(range => extHostTypeConverter.Range.from(range)) : [],
|
||||
draftMode: provider.startDraft && provider.finishDraft ? (vscodeCommentInfo.inDraftMode ? modes.DraftMode.InDraft : modes.DraftMode.NotInDraft) : modes.DraftMode.NotSupported
|
||||
};
|
||||
}
|
||||
|
||||
function convertToCommentThread(extensionId: ExtensionIdentifier, provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, vscodeCommentThread: vscode.CommentThread, commandsConverter: CommandsConverter, disposables: DisposableStore): modes.CommentThread {
|
||||
return {
|
||||
extensionId: extensionId.value,
|
||||
threadId: vscodeCommentThread.id,
|
||||
resource: vscodeCommentThread.resource.toString(),
|
||||
range: extHostTypeConverter.Range.from(vscodeCommentThread.range),
|
||||
comments: vscodeCommentThread.comments.map(comment => convertToComment(provider, comment as vscode.Comment, commandsConverter, disposables)),
|
||||
collapsibleState: vscodeCommentThread.collapsibleState
|
||||
};
|
||||
}
|
||||
|
||||
function convertFromCommentThread(commentThread: modes.CommentThread): vscode.CommentThread {
|
||||
return {
|
||||
id: commentThread.threadId!,
|
||||
threadId: commentThread.threadId!,
|
||||
uri: URI.parse(commentThread.resource!),
|
||||
resource: URI.parse(commentThread.resource!),
|
||||
range: extHostTypeConverter.Range.to(commentThread.range),
|
||||
comments: commentThread.comments ? commentThread.comments.map(convertFromComment) : [],
|
||||
collapsibleState: commentThread.collapsibleState,
|
||||
dispose: () => { }
|
||||
} as vscode.CommentThread;
|
||||
}
|
||||
|
||||
function convertFromComment(comment: modes.Comment): vscode.Comment {
|
||||
let userIconPath: URI | undefined;
|
||||
if (comment.userIconPath) {
|
||||
try {
|
||||
userIconPath = URI.parse(comment.userIconPath);
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: comment.commentId,
|
||||
commentId: comment.commentId,
|
||||
body: extHostTypeConverter.MarkdownString.to(comment.body),
|
||||
author: {
|
||||
name: comment.userName,
|
||||
iconPath: userIconPath
|
||||
},
|
||||
userName: comment.userName,
|
||||
userIconPath: userIconPath,
|
||||
canEdit: comment.canEdit,
|
||||
canDelete: comment.canDelete,
|
||||
isDraft: comment.isDraft,
|
||||
commentReactions: comment.commentReactions ? comment.commentReactions.map(reaction => {
|
||||
return {
|
||||
label: reaction.label || '',
|
||||
count: reaction.count || 0,
|
||||
iconPath: reaction.iconPath ? URI.revive(reaction.iconPath) : '',
|
||||
hasReacted: reaction.hasReacted,
|
||||
authorHasReacted: reaction.hasReacted || false
|
||||
|
||||
};
|
||||
}) : undefined,
|
||||
mode: comment.mode ? comment.mode : modes.CommentMode.Preview
|
||||
};
|
||||
}
|
||||
|
||||
function convertToModeComment2(thread: ExtHostCommentThread, commentController: ExtHostCommentController, vscodeComment: vscode.Comment, commandsConverter: CommandsConverter, commentsMap: Map<vscode.Comment, number>, disposables: DisposableStore): modes.Comment {
|
||||
function convertToModeComment(thread: ExtHostCommentThread, commentController: ExtHostCommentController, vscodeComment: vscode.Comment, commentsMap: Map<vscode.Comment, number>): modes.Comment {
|
||||
let commentUniqueId = commentsMap.get(vscodeComment)!;
|
||||
if (!commentUniqueId) {
|
||||
commentUniqueId = ++thread.commentHandle;
|
||||
@@ -940,57 +535,21 @@ function convertToModeComment2(thread: ExtHostCommentThread, commentController:
|
||||
}
|
||||
|
||||
const iconPath = vscodeComment.author && vscodeComment.author.iconPath ? vscodeComment.author.iconPath.toString() : undefined;
|
||||
const reactions = vscodeComment.reactions || vscodeComment.commentReactions;
|
||||
|
||||
return {
|
||||
commentId: vscodeComment.id || vscodeComment.commentId,
|
||||
commentId: vscodeComment.commentId,
|
||||
mode: vscodeComment.mode,
|
||||
contextValue: vscodeComment.contextValue,
|
||||
uniqueIdInThread: commentUniqueId,
|
||||
body: extHostTypeConverter.MarkdownString.from(vscodeComment.body),
|
||||
userName: vscodeComment.author ? vscodeComment.author.name : vscodeComment.userName,
|
||||
userName: vscodeComment.author.name,
|
||||
userIconPath: iconPath,
|
||||
isDraft: vscodeComment.isDraft,
|
||||
selectCommand: vscodeComment.selectCommand ? commandsConverter.toInternal(vscodeComment.selectCommand, disposables) : undefined,
|
||||
editCommand: vscodeComment.editCommand ? commandsConverter.toInternal(vscodeComment.editCommand, disposables) : undefined,
|
||||
deleteCommand: vscodeComment.deleteCommand ? commandsConverter.toInternal(vscodeComment.deleteCommand, disposables) : undefined,
|
||||
label: vscodeComment.label,
|
||||
commentReactions: reactions ? reactions.map(reaction => convertToReaction2(commentController.reactionProvider, reaction)) : undefined
|
||||
commentReactions: vscodeComment.reactions ? vscodeComment.reactions.map(reaction => convertToReaction(commentController.reactionProvider, reaction)) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
function convertToComment(provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, vscodeComment: vscode.Comment, commandsConverter: CommandsConverter, disposables: DisposableStore): modes.Comment {
|
||||
const canEdit = !!(provider as vscode.DocumentCommentProvider).editComment && vscodeComment.canEdit;
|
||||
const canDelete = !!(provider as vscode.DocumentCommentProvider).deleteComment && vscodeComment.canDelete;
|
||||
const iconPath = vscodeComment.userIconPath ? vscodeComment.userIconPath.toString() : vscodeComment.gravatar;
|
||||
|
||||
return {
|
||||
commentId: vscodeComment.commentId,
|
||||
body: extHostTypeConverter.MarkdownString.from(vscodeComment.body),
|
||||
userName: vscodeComment.userName,
|
||||
userIconPath: iconPath,
|
||||
canEdit: canEdit,
|
||||
canDelete: canDelete,
|
||||
selectCommand: vscodeComment.command ? commandsConverter.toInternal(vscodeComment.command, disposables) : undefined,
|
||||
isDraft: vscodeComment.isDraft,
|
||||
commentReactions: vscodeComment.commentReactions ? vscodeComment.commentReactions.map(reaction => convertToReaction(provider, reaction)) : undefined
|
||||
};
|
||||
}
|
||||
|
||||
function convertToReaction(provider: vscode.DocumentCommentProvider | vscode.WorkspaceCommentProvider, reaction: vscode.CommentReaction): modes.CommentReaction {
|
||||
const providerCanDeleteReaction = !!(provider as vscode.DocumentCommentProvider).deleteReaction;
|
||||
const providerCanAddReaction = !!(provider as vscode.DocumentCommentProvider).addReaction;
|
||||
|
||||
return {
|
||||
label: reaction.label,
|
||||
iconPath: reaction.iconPath ? extHostTypeConverter.pathOrURIToURI(reaction.iconPath) : undefined,
|
||||
count: reaction.count,
|
||||
hasReacted: reaction.hasReacted,
|
||||
canEdit: (reaction.hasReacted && providerCanDeleteReaction) || (!reaction.hasReacted && providerCanAddReaction)
|
||||
};
|
||||
}
|
||||
|
||||
function convertToReaction2(provider: vscode.CommentReactionProvider | undefined, reaction: vscode.CommentReaction): modes.CommentReaction {
|
||||
function convertToReaction(provider: vscode.CommentReactionProvider | undefined, reaction: vscode.CommentReaction): modes.CommentReaction {
|
||||
return {
|
||||
label: reaction.label,
|
||||
iconPath: reaction.iconPath ? extHostTypeConverter.pathOrURIToURI(reaction.iconPath) : undefined,
|
||||
|
||||
@@ -688,12 +688,6 @@ export function createApiFactory(
|
||||
registerTextSearchProvider: proposedApiFunction(extension, (scheme: string, provider: vscode.TextSearchProvider) => {
|
||||
return extHostSearch.registerTextSearchProvider(scheme, provider);
|
||||
}),
|
||||
registerDocumentCommentProvider: proposedApiFunction(extension, (provider: vscode.DocumentCommentProvider) => {
|
||||
return extHostComment.registerDocumentCommentProvider(extension.identifier, provider);
|
||||
}),
|
||||
registerWorkspaceCommentProvider: proposedApiFunction(extension, (provider: vscode.WorkspaceCommentProvider) => {
|
||||
return extHostComment.registerWorkspaceCommentProvider(extension.identifier, provider);
|
||||
}),
|
||||
registerRemoteAuthorityResolver: proposedApiFunction(extension, (authorityPrefix: string, resolver: vscode.RemoteAuthorityResolver) => {
|
||||
return extensionService.registerRemoteAuthorityResolver(authorityPrefix, resolver);
|
||||
}),
|
||||
@@ -718,7 +712,7 @@ export function createApiFactory(
|
||||
}
|
||||
};
|
||||
|
||||
const comment: typeof vscode.comment = {
|
||||
const comment: typeof vscode.comments = {
|
||||
createCommentController(id: string, label: string) {
|
||||
return extHostComment.createCommentController(extension, id, label);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user