Skip to content

Commit

Permalink
Add IntellijExt Piper service client
Browse files Browse the repository at this point in the history
Add the new intellij-ext piper service api client that interacts with the intellij-ext's gRPC binary containing golang service for piper.

PiperOrigin-RevId: 601245191
  • Loading branch information
Googler authored and copybara-github committed Jan 24, 2024
1 parent 961b965 commit 5e355d3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class IntelliJExtManager {
private static final BoolExperiment CHATBOT =
new BoolExperiment("use.intellij.ext.chatbot", false);

private static final BoolExperiment PIPER = new BoolExperiment("use.intellij.ext.piper", false);

public static IntelliJExtManager getInstance() {
return ApplicationManager.getApplication().getService(IntelliJExtManager.class);
}
Expand Down Expand Up @@ -200,4 +202,8 @@ public boolean isChatBotEnabled() {
public boolean isBuildCleanerEnabled() {
return isEnabled() && BUILD_CLEANER.getValue();
}

public boolean isPiperEnabled() {
return isEnabled() && PIPER.getValue();
}
}
12 changes: 9 additions & 3 deletions ext/proto/piper.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ service PiperService {
// Get workspaces
rpc GetWorkspaces(GetWorkspacesRequest)
returns (stream GetWorkspacesResponse) {}

// Creates or updates a Piper workspace.
rpc UpdateWorkspace(UpdateWorkspaceRequest)
returns (UpdateWorkspaceResponse) {}

// Retrieves a list of changes
rpc GetChanges(GetChangesRequest) returns (stream GetChangesResponse) {}
rpc GetChanges(GetChangesRequest)
returns (stream.com.google.idea.blaze.ext.GetChangesResponse) {}

// Resolves conflicts in a Piper workspace after sync or integrate.
rpc ResolveConflicts(ResolveConflictsRequest)
returns (stream ResolveConflictsResponse) {}

// Read the content of a depot or workspace file.
rpc ReadFiles(ReadFilesRequest) returns (stream ReadFilesResponse) {}

// Update the state and type of files that are open in a Piper workspace.
rpc UpdateFileStates(UpdateFileStatesRequest)
returns (stream UpdateFileStatesResponse) {}
Expand Down Expand Up @@ -115,7 +121,7 @@ message GetChangesRequest {

message GetChangesResponse {
PiperStatus piper_status = 1;
repeated Change change = 2;
Change change = 2;
}

message Change {
Expand Down Expand Up @@ -190,7 +196,7 @@ message ResolveConflictsRequest {

message ConflictPath {
string path = 1;
string conflict_ids = 2;
repeated string conflict_ids = 2;
}

message ResolveConflictsResponse {
Expand Down
10 changes: 10 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
import com.google.idea.blaze.ext.KytheGrpc.KytheFutureStub;
import com.google.idea.blaze.ext.LinterGrpc.LinterFutureStub;
import com.google.idea.blaze.ext.PiperServiceGrpc.PiperServiceBlockingStub;
import com.google.idea.blaze.ext.PiperServiceGrpc.PiperServiceFutureStub;
import io.grpc.ManagedChannel;
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.ChannelOption;
Expand Down Expand Up @@ -126,4 +128,12 @@ public DepServerFutureStub getDependencyService() {
public CodeSearchFutureStub getCodeSearchService() {
return CodeSearchGrpc.newFutureStub(channel);
}

public PiperServiceFutureStub getPiperService() {
return PiperServiceGrpc.newFutureStub(channel);
}

public PiperServiceBlockingStub getPiperServiceBlocking() {
return PiperServiceGrpc.newBlockingStub(channel);
}
}
16 changes: 16 additions & 0 deletions ext/src/com/google/idea/blaze/ext/IntelliJExtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
import com.google.idea.blaze.ext.KytheGrpc.KytheFutureStub;
import com.google.idea.blaze.ext.LinterGrpc.LinterFutureStub;
import com.google.idea.blaze.ext.PiperServiceGrpc.PiperServiceBlockingStub;
import com.google.idea.blaze.ext.PiperServiceGrpc.PiperServiceFutureStub;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -223,4 +225,18 @@ public DepServerFutureStub getDependencyService() throws IOException {
IntelliJExtBlockingStub unused = connect();
return client.getDependencyService();
}

public PiperServiceFutureStub getPiperService() {
try {
IntelliJExtBlockingStub unused = connect();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return client.getPiperService();
}

public PiperServiceBlockingStub getPiperServiceBlocking() throws IOException {
IntelliJExtBlockingStub unused = connect();
return client.getPiperServiceBlocking();
}
}

0 comments on commit 5e355d3

Please sign in to comment.