mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Commenting Ranges API
This commit is contained in:
@@ -123,6 +123,10 @@ export interface MainThreadCommentsShape extends IDisposable {
|
||||
$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;
|
||||
$createCommentingRanges(handle: number, commentingRangesHandle: number, resource: UriComponents, ranges: IRange[], commands: modes.Command[]): void;
|
||||
$deleteCommentingRanges(handle: number, commentingRangesHandle: number): void;
|
||||
$updateCommentingRanges(handle: number, commentingRangesHandle: number, newRanges: IRange[]): void;
|
||||
$updateCommentingRangesCommands(handle: number, commentingRangesHandle: number, acceptInputCommands: modes.Command[]): void;
|
||||
$setInputValue(handle: number, commentThreadHandle: number, input: string): void;
|
||||
$updateCommentThreadCommands(handle: number, commentThreadHandle: number, acceptInputCommands: modes.Command[]): void;
|
||||
$registerDocumentCommentProvider(handle: number, features: CommentProviderFeatures): void;
|
||||
|
||||
@@ -378,11 +378,61 @@ export class ExtHostCommentWidget implements vscode.CommentWidget {
|
||||
public commentThread: ExtHostCommentThread,
|
||||
public comment: vscode.Comment | undefined,
|
||||
input: string
|
||||
) {
|
||||
) {
|
||||
this._input = input;
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtHostCommentingRanges implements vscode.CommentingRanges {
|
||||
private static _handlePool: number = 0;
|
||||
readonly handle = ExtHostCommentingRanges._handlePool++;
|
||||
|
||||
get resource(): vscode.Uri {
|
||||
return this._resource;
|
||||
}
|
||||
|
||||
get ranges(): vscode.Range[] {
|
||||
return this._ranges;
|
||||
}
|
||||
|
||||
set ranges(newRanges: vscode.Range[]) {
|
||||
this._ranges = newRanges;
|
||||
this._proxy.$updateCommentingRanges(this._commentControlHandle, this.handle, this._ranges.map(extHostTypeConverter.Range.from));
|
||||
}
|
||||
|
||||
get acceptInputCommands(): vscode.Command[] {
|
||||
return this._acceptInputCommands;
|
||||
}
|
||||
|
||||
set acceptInputCommands(replyCommands: vscode.Command[]) {
|
||||
this._acceptInputCommands = replyCommands;
|
||||
|
||||
const internals = replyCommands.map(this._commandsConverter.toInternal.bind(this._commandsConverter));
|
||||
this._proxy.$updateCommentingRangesCommands(this._commentControlHandle, this.handle, internals);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private _proxy: MainThreadCommentsShape,
|
||||
private readonly _commandsConverter: CommandsConverter,
|
||||
private _commentControlHandle: number,
|
||||
private _resource: vscode.Uri,
|
||||
private _ranges: vscode.Range[],
|
||||
private _acceptInputCommands: vscode.Command[],
|
||||
) {
|
||||
this._proxy.$createCommentingRanges(
|
||||
this._commentControlHandle,
|
||||
this.handle,
|
||||
this._resource,
|
||||
this._ranges.map(extHostTypeConverter.Range.from),
|
||||
this._acceptInputCommands.map(this._commandsConverter.toInternal.bind(this._commandsConverter))
|
||||
);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._proxy.$deleteCommentingRanges(this._commentControlHandle, this.handle);
|
||||
}
|
||||
}
|
||||
|
||||
class ExtHostCommentControl implements vscode.CommentControl {
|
||||
get id(): string {
|
||||
return this._id;
|
||||
@@ -399,6 +449,7 @@ class ExtHostCommentControl implements vscode.CommentControl {
|
||||
}
|
||||
|
||||
private _threads: Map<number, ExtHostCommentThread> = new Map<number, ExtHostCommentThread>();
|
||||
private _commentingRanges: Map<number, ExtHostCommentingRanges> = new Map<number, ExtHostCommentingRanges>();
|
||||
|
||||
constructor(
|
||||
_extension: IExtensionDescription,
|
||||
@@ -431,6 +482,12 @@ class ExtHostCommentControl implements vscode.CommentControl {
|
||||
this.widget = extHostCommentWidget;
|
||||
}
|
||||
|
||||
createCommentingRanges(resource: vscode.Uri, ranges: vscode.Range[], acceptInputCommands: vscode.Command[]): vscode.CommentingRanges {
|
||||
const commentingRange = new ExtHostCommentingRanges(this._proxy, this._commandsConverter, this.handle, resource, ranges, acceptInputCommands);
|
||||
this._commentingRanges.set(commentingRange.handle, commentingRange);
|
||||
return commentingRange;
|
||||
}
|
||||
|
||||
getCommentThread(handle: number) {
|
||||
return this._threads.get(handle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user