Skip to content

Commit

Permalink
Implement Intellij-ext Critique service
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 601736812
  • Loading branch information
Googler authored and copybara-github committed Jan 26, 2024
1 parent 509c43c commit 75aa1aa
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
}
Expand Down
107 changes: 107 additions & 0 deletions ext/proto/codereview.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
5 changes: 5 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 75aa1aa

Please sign in to comment.