diff --git a/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java b/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java index 06f2e2fa669..055562fa877 100644 --- a/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java +++ b/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java @@ -57,6 +57,9 @@ public class IntelliJExtManager { private static final BoolExperiment FINDINGS_SERVICE = new BoolExperiment("use.intellij.ext.findingsservice", false); + private static final BoolExperiment CRITIQUE_SERVICE = + new BoolExperiment("use.intellij.ext.critiqueservice", false); + private static final BoolExperiment CODESEARCH = new BoolExperiment("use.intellij.ext.codesearch", false); @@ -168,6 +171,10 @@ public boolean isFindingsServiceEnabled() { return isEnabled() && FINDINGS_SERVICE.getValue(); } + public boolean isCritiqueServiceEnabled() { + return isEnabled() && CRITIQUE_SERVICE.getValue(); + } + public boolean isCodeSearchEnabled() { return isEnabled() && CODESEARCH.getValue(); } diff --git a/ext/proto/codereview.proto b/ext/proto/codereview.proto index 36386a243b9..b7a2d4c5795 100644 --- a/ext/proto/codereview.proto +++ b/ext/proto/codereview.proto @@ -59,7 +59,114 @@ message ListFindingsResponse { } } +message PublishCommentsRequest { + int64 cl_number = 1; +} +message PublishCommentsResponse {} +message UpdateCommentRequest { + int64 cl_number = 1; + string comment_id = 2; + string message = 3; + bool resolved = 4; +} +message UpdateCommentResponse {} +message DeleteCommentRequest { + int64 cl_number = 1; + string comment_id = 2; +} +message DeleteCommentResponse {} + +enum ReplyAction { + REPLY_ACTION_UNKNOWN = 0; + REPLY_ACTION_NEW = 1; + REPLY_ACTION_RESOLVE = 2; + REPLY_ACTION_REOPEN = 3; + REPLY_ACTION_STICKY_LGTM = 4; +} + +message PostReplyRequest { + int64 cl_number = 1; + string comment_id = 2; + string message = 3; + ReplyAction action = 4; +} + +message PostReplyResponse { + string reply_id = 1; +} + +message UpdateReplyRequest { + int64 cl_number = 1; + string comment_id = 2; + string reply_id = 3; + string message = 4; + ReplyAction action = 5; +} + +message UpdateReplyResponse {} + +message DeleteReplyRequest { + int64 cl_number = 1; + string comment_id = 2; + string reply_id = 3; +} + +message DeleteReplyResponse {} + service FindingsService { // Runs lint checks and returns findings. rpc ListFindings(ListFindingsRequest) returns (stream ListFindingsResponse) {} } + +message GetCommentsRequest { + int64 cl_number = 1; +} + +message GetCommentsResponse { + repeated Comment comments = 1; + + message Comment { + string id = 1; + int64 timestamp_seconds = 2; + bool published = 3; + CodeReview.Location location = 4; + optional string context_text = 5; + string author = 6; + string message = 7; + bool is_active = 8; + repeated Approval approvals = 9; + repeated Reply replies = 10; + } + + message Approval { + string type = 1; + bool approve = 2; + string display_name = 3; + } + + message Reply { + string id = 1; + string author = 2; + bool published = 3; + int64 timestamp_seconds = 4; + string message = 5; + } +} + +service CritiqueService { + // Fetches Critique comments on the given CL and returns them. + rpc GetComments(GetCommentsRequest) returns (GetCommentsResponse) {} + // Publishes any pending comments. + rpc PublishComments(PublishCommentsRequest) + returns (PublishCommentsResponse) {} + // Updates the comment. + rpc UpdateComment(UpdateCommentRequest) returns (UpdateCommentResponse) {} + // Deletes the comment. + rpc DeleteComment(DeleteCommentRequest) returns (DeleteCommentResponse) {} + // Adds a reply to the given comment. + rpc PostReply(PostReplyRequest) returns (PostReplyResponse) {} + // Updates the given reply. + rpc UpdateReply(UpdateReplyRequest) returns (UpdateReplyResponse) {} + // Delete the reply. + rpc DeleteReply(DeleteReplyRequest) returns (DeleteReplyResponse) {} +} diff --git a/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java b/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java index 1bbaf29b699..36d587c68e2 100644 --- a/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java +++ b/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java @@ -20,6 +20,7 @@ import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub; import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub; import com.google.idea.blaze.ext.CodeSearchGrpc.CodeSearchFutureStub; +import com.google.idea.blaze.ext.CritiqueServiceGrpc.CritiqueServiceBlockingStub; import com.google.idea.blaze.ext.DepServerGrpc.DepServerFutureStub; import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub; import com.google.idea.blaze.ext.FileApiGrpc.FileApiFutureStub; @@ -117,6 +118,10 @@ public FindingsServiceBlockingStub getFindingsService() { return FindingsServiceGrpc.newBlockingStub(channel); } + public CritiqueServiceBlockingStub getCritiqueService() { + return CritiqueServiceGrpc.newBlockingStub(channel); + } + public BuildCleanerServiceFutureStub getBuildCleanerService() { return BuildCleanerServiceGrpc.newFutureStub(channel); } diff --git a/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java b/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java index 5e8c770e420..7e4f139ca46 100644 --- a/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java +++ b/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java @@ -21,6 +21,7 @@ import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub; import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub; import com.google.idea.blaze.ext.CodeSearchGrpc.CodeSearchFutureStub; +import com.google.idea.blaze.ext.CritiqueServiceGrpc.CritiqueServiceBlockingStub; import com.google.idea.blaze.ext.DepServerGrpc.DepServerFutureStub; import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub; import com.google.idea.blaze.ext.FileApiGrpc.FileApiFutureStub; @@ -202,6 +203,11 @@ public FindingsServiceBlockingStub getFindingsService() throws IOException { return client.getFindingsService(); } + public CritiqueServiceBlockingStub getCritiqueService() throws IOException { + IntelliJExtBlockingStub unused = connect(); + return client.getCritiqueService(); + } + public CodeSearchFutureStub getCodeSearchService() throws IOException { IntelliJExtBlockingStub unused = connect(); return client.getCodeSearchService();