Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/review/node/githubPullRequestReviewerCommentsProvider.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IInteractionService } from '../../../platform/chat/common/interactionService';
7
import { ProgressLocation } from '../../../platform/notification/common/notificationService';
8
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
9
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
10
import { Uri } from '../../../vscodeTypes';
11
import { ReviewerComments, ReviewerCommentsProvider } from '../../githubPullRequest';
12
import { ReviewSession } from './doReview';
13
14
export class GitHubPullRequestReviewerCommentsProvider implements ReviewerCommentsProvider {
15
constructor(
16
@IInstantiationService private readonly instantiationService: IInstantiationService,
17
@IInteractionService private readonly interactionService: IInteractionService,
18
) { }
19
20
async provideReviewerComments(context: { repositoryRoot: string; commitMessages: string[]; patches: { patch: string; fileUri: string; previousFileUri?: string }[] }, token: CancellationToken): Promise<ReviewerComments> {
21
this.interactionService.startInteraction();
22
const reviewSession = this.instantiationService.createInstance(ReviewSession);
23
const reviewResult = await reviewSession.review(context, ProgressLocation.Notification, token);
24
const files: Uri[] = [];
25
if (reviewResult?.type === 'success') {
26
for (const comment of reviewResult.comments) {
27
files.push(comment.uri);
28
}
29
}
30
const succeeded = reviewResult?.type === 'success';
31
return { files, succeeded };
32
}
33
34
}
35