Skip to content

Commit

Permalink
Add Intellij-ext client for depserver
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 588484285
  • Loading branch information
Googler authored and copybara-github committed Dec 6, 2023
1 parent 8d9bd98 commit 4738875
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class IntelliJExtManager {

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

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

/**
* System property controlling the experiments service. If set to 1, forces intellij-ext binary to
* be available (regardless of ENABLED value)
Expand Down Expand Up @@ -128,6 +131,10 @@ public boolean isBuildServiceEnabled() {
return isEnabled() && BUILD_SERVICE.getValue();
}

public boolean isDepserverEnabled() {
return isEnabled() && DEPSEREVR.getValue();
}

public boolean isKytheEnabled() {
return isEnabled() && KYTHE.getValue();
}
Expand Down
1 change: 1 addition & 0 deletions ext/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ proto_library(
"build_service.proto",
"chatbotmodel.proto",
"codesearch.proto",
"depserver.proto",
"experiments.proto",
"intellijext.proto",
"issuetracker.proto",
Expand Down
64 changes: 64 additions & 0 deletions ext/proto/depserver.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto3";

package com.google.idea.blaze.ext;

option java_package = "com.google.idea.blaze.ext";
option java_multiple_files = true;
option java_outer_classname = "DependencyServiceProto";


service DepServer {
// Get all dependencies for the packages and targets in the given request
rpc Query(DependencyRequest) returns (QueryResponse) {}

// Execute a Blaze Query command using a query expression
rpc BlazeQuery(BlazeQueryRequest) returns (QueryResponse) {}
}

message TargetInfo {
string name = 1;
string kind = 2;
}

message DependencyRequest {
enum FilterType {
UNKNOWN = 0;
TESTS = 1;
LIBRARIES = 2;
BINARIES = 3;
GWT = 4;
FILES = 5;
RULES = 6;
}
bool forward = 1;
repeated string target = 2;
repeated string filter_kind = 3;
bool direct = 4;
repeated string file = 5;
repeated FilterType filter_type = 6;
repeated string response_attribute = 12;
}

message BlazeQueryRequest {
string blaze_query_expression = 1;
}

message QueryResponse {
repeated TargetInfo target = 1;
bool success = 2;
}
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 @@ -19,6 +19,7 @@
import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceBlockingStub;
import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub;
import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub;
import com.google.idea.blaze.ext.DepServerGrpc.DepServerFutureStub;
import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub;
import com.google.idea.blaze.ext.IntelliJExtGrpc.IntelliJExtBlockingStub;
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
Expand Down Expand Up @@ -96,4 +97,8 @@ public LinterFutureStub getLinterService() {
public BuildCleanerServiceFutureStub getBuildCleanerService() {
return BuildCleanerServiceGrpc.newFutureStub(channel);
}

public DepServerFutureStub getDependencyService() {
return DepServerGrpc.newFutureStub(channel);
}
}
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 @@ -20,6 +20,7 @@
import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceBlockingStub;
import com.google.idea.blaze.ext.BuildServiceGrpc.BuildServiceFutureStub;
import com.google.idea.blaze.ext.ChatBotModelGrpc.ChatBotModelBlockingStub;
import com.google.idea.blaze.ext.DepServerGrpc.DepServerFutureStub;
import com.google.idea.blaze.ext.ExperimentsServiceGrpc.ExperimentsServiceBlockingStub;
import com.google.idea.blaze.ext.IntelliJExtGrpc.IntelliJExtBlockingStub;
import com.google.idea.blaze.ext.IssueTrackerGrpc.IssueTrackerBlockingStub;
Expand Down Expand Up @@ -185,4 +186,9 @@ public BuildCleanerServiceFutureStub getBuildCleanerService() {
}
return client.getBuildCleanerService();
}

public DepServerFutureStub getDependencyService() throws IOException {
IntelliJExtBlockingStub unused = connect();
return client.getDependencyService();
}
}

0 comments on commit 4738875

Please sign in to comment.