From 47388753b08bf6e890e76464ae47d3b5416bc4a4 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 6 Dec 2023 11:06:52 -0800 Subject: [PATCH] Add Intellij-ext client for depserver PiperOrigin-RevId: 588484285 --- .../blaze/base/ext/IntelliJExtManager.java | 7 ++ ext/proto/BUILD | 1 + ext/proto/depserver.proto | 64 +++++++++++++++++++ .../idea/blaze/ext/IntelliJExtClient.java | 5 ++ .../idea/blaze/ext/IntelliJExtService.java | 6 ++ 5 files changed, 83 insertions(+) create mode 100644 ext/proto/depserver.proto 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 8292e686f1c..4ff72e93e34 100644 --- a/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java +++ b/base/src/com/google/idea/blaze/base/ext/IntelliJExtManager.java @@ -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) @@ -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(); } diff --git a/ext/proto/BUILD b/ext/proto/BUILD index 5f9e17398f8..bd81e7f53b5 100644 --- a/ext/proto/BUILD +++ b/ext/proto/BUILD @@ -8,6 +8,7 @@ proto_library( "build_service.proto", "chatbotmodel.proto", "codesearch.proto", + "depserver.proto", "experiments.proto", "intellijext.proto", "issuetracker.proto", diff --git a/ext/proto/depserver.proto b/ext/proto/depserver.proto new file mode 100644 index 00000000000..0dc047a0562 --- /dev/null +++ b/ext/proto/depserver.proto @@ -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; +} diff --git a/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java b/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java index b23534ad9fb..970700a9062 100644 --- a/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java +++ b/ext/src/com/google/idea/blaze/ext/IntelliJExtClient.java @@ -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; @@ -96,4 +97,8 @@ public LinterFutureStub getLinterService() { public BuildCleanerServiceFutureStub getBuildCleanerService() { return BuildCleanerServiceGrpc.newFutureStub(channel); } + + public DepServerFutureStub getDependencyService() { + return DepServerGrpc.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 66c3bf22bbe..8777720c5f2 100644 --- a/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java +++ b/ext/src/com/google/idea/blaze/ext/IntelliJExtService.java @@ -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; @@ -185,4 +186,9 @@ public BuildCleanerServiceFutureStub getBuildCleanerService() { } return client.getBuildCleanerService(); } + + public DepServerFutureStub getDependencyService() throws IOException { + IntelliJExtBlockingStub unused = connect(); + return client.getDependencyService(); + } }