From 72529f086bfc6b16dccb6f5438dcdf823b983023 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Mon, 14 Oct 2024 18:06:46 +0200 Subject: [PATCH 01/27] fix: pass absolute paths to the Starlark Debugger (#6888) --- .../idea/blaze/skylark/debugger/impl/SkylarkDebugProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skylark/src/com/google/idea/blaze/skylark/debugger/impl/SkylarkDebugProcess.java b/skylark/src/com/google/idea/blaze/skylark/debugger/impl/SkylarkDebugProcess.java index 86fe42eb81d..eef8ae827a2 100644 --- a/skylark/src/com/google/idea/blaze/skylark/debugger/impl/SkylarkDebugProcess.java +++ b/skylark/src/com/google/idea/blaze/skylark/debugger/impl/SkylarkDebugProcess.java @@ -32,6 +32,7 @@ import com.google.devtools.build.lib.starlarkdebugging.StarlarkDebuggingProtos.SetBreakpointsRequest; import com.google.devtools.build.lib.starlarkdebugging.StarlarkDebuggingProtos.StartDebuggingRequest; import com.google.devtools.build.lib.starlarkdebugging.StarlarkDebuggingProtos.Stepping; +import com.google.idea.blaze.base.model.primitives.WorkspaceRoot; import com.intellij.execution.ExecutionResult; import com.intellij.execution.process.ProcessAdapter; import com.intellij.execution.process.ProcessEvent; @@ -269,7 +270,7 @@ private Location convertLocation(XLineBreakpoint breakpoi // TODO(brendandouglas): handle local changes? return Location.newBuilder() .setLineNumber(breakpoint.getLine() + 1) - .setPath(breakpoint.getPresentableFilePath()) + .setPath(WorkspaceRoot.fromProject(project).absolutePathFor(breakpoint.getPresentableFilePath()).toString()) .build(); } From 711519dacb24c4d31ec1e8e966d23087aa949d50 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Mon, 14 Oct 2024 18:07:07 +0200 Subject: [PATCH 02/27] fix(querysync): affected packages calculator was broken when 'directories' contained '.' (#6885) --- .../com/google/idea/blaze/qsync/AffectedPackagesCalculator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/querysync/java/com/google/idea/blaze/qsync/AffectedPackagesCalculator.java b/querysync/java/com/google/idea/blaze/qsync/AffectedPackagesCalculator.java index 7952fa1a049..9b69bcf660a 100644 --- a/querysync/java/com/google/idea/blaze/qsync/AffectedPackagesCalculator.java +++ b/querysync/java/com/google/idea/blaze/qsync/AffectedPackagesCalculator.java @@ -235,7 +235,7 @@ public AffectedPackages getAffectedPackages() { private boolean isIncludedInProject(Path file) { for (Path includePath : projectIncludes()) { - if (file.startsWith(includePath)) { + if (file.startsWith(includePath) || includePath.toString().isEmpty()) { for (Path excludePath : projectExcludes()) { if (file.startsWith(excludePath)) { return false; From 3c0d90392173ad68d72103f29a9a4578f0d12fee Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Tue, 15 Oct 2024 08:43:22 +0200 Subject: [PATCH 03/27] doc: Document gazelle integration (#6894) --- docs/gazelle.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/gazelle.md diff --git a/docs/gazelle.md b/docs/gazelle.md new file mode 100644 index 00000000000..eda2e5d04fc --- /dev/null +++ b/docs/gazelle.md @@ -0,0 +1,25 @@ +# Using Gazelle to Keep BUILD Files Updated + +Gazelle can automatically generate and update your Bazel `BUILD` files based on the imports in your source code. To keep your `BUILD` files in sync without manual intervention, configure Gazelle to run before each sync operation. + +## Setup Instructions + +1. **Add `gazelle_target` to Your Project View File**: Include the `gazelle_target` attribute in your project view file to specify the Gazelle target to run. + + ```yaml + # Example project view file + directories: + src/ + gazelle_target: //:gazelle + ``` + +2. **Automatic Execution**: With the `gazelle_target` set, Gazelle will run automatically before every sync, updating your `BUILD` files according to your source code imports. + +## Example Project + +For a practical example, see this [Gazelle project setup](https://github.com/bazelbuild/intellij/tree/master/examples/go/with_proto). + +## Demo + +https://github.com/user-attachments/assets/b130bf56-49ec-46cc-810f-c831672e2601 + From 2f24ed2351ee9ab68250ed01ef4d1b04c87511a9 Mon Sep 17 00:00:00 2001 From: Evgenii Novozhilov Date: Tue, 15 Oct 2024 16:43:55 +0300 Subject: [PATCH 04/27] Update CLion and IntelliJ test configurations (#6856) * ci: remove google internal testconfigs they point to a very old version and we do not receive updates from google, neither google receives from us * ci: add clion configurations for os and ls our main target configurations so we'd like to test against them * ci: fix typo in intellijce test config name --- .bazelci/clion.yml | 56 +++++++++++++++++++++++++++++++++++++--- .bazelci/intellij-ue.yml | 38 --------------------------- .bazelci/intellij.yml | 40 +--------------------------- 3 files changed, 53 insertions(+), 81 deletions(-) diff --git a/.bazelci/clion.yml b/.bazelci/clion.yml index a7a81cdd087..f62e4044241 100644 --- a/.bazelci/clion.yml +++ b/.bazelci/clion.yml @@ -1,7 +1,7 @@ --- tasks: - CLion-OSS-oldest-stable: - name: CLion OSS Oldest Stable + CLion-Linux-OSS-oldest-stable: + name: CLion Linux OSS Oldest Stable platform: ubuntu2204 build_flags: - --define=ij_product=clion-oss-oldest-stable @@ -12,8 +12,8 @@ tasks: - --test_output=errors test_targets: - //:clwb_tests - CLion-OSS-latest-stable: - name: CLion OSS Latest Stable + CLion-Linux-OSS-latest-stable: + name: CLion Linux OSS Latest Stable platform: ubuntu2204 build_flags: - --define=ij_product=clion-oss-latest-stable @@ -24,6 +24,54 @@ tasks: - --test_output=errors test_targets: - //:clwb_tests + CLion-Windows-OSS-oldest-stable: + name: CLion Windows OSS Oldest Stable + platform: windows + build_flags: + - --define=ij_product=clion-oss-oldest-stable + build_targets: + - //clwb/... + test_flags: + - --define=ij_product=clion-oss-oldest-stable + - --test_output=errors + test_targets: + - //clwb:integration_tests + CLion-Windows-OSS-latest-stable: + name: CLion Windows OSS Latest Stable + platform: windows + build_flags: + - --define=ij_product=clion-oss-latest-stable + build_targets: + - //clwb/... + test_flags: + - --define=ij_product=clion-oss-latest-stable + - --test_output=errors + test_targets: + - //clwb:integration_tests + CLion-MacOS-OSS-oldest-stable: + name: CLion MacOS OSS Oldest Stable + platform: macos_arm64 + build_flags: + - --define=ij_product=clion-oss-oldest-stable + build_targets: + - //clwb/... + test_flags: + - --define=ij_product=clion-oss-oldest-stable + - --test_output=errors + test_targets: + - //:clwb_tests + CLion-MacOS-OSS-latest-stable: + name: CLion MacOS OSS Latest Stable + platform: macos_arm64 + build_flags: + - --define=ij_product=clion-oss-latest-stable + build_targets: + - //clwb/... + test_flags: + - --define=ij_product=clion-oss-latest-stable + - --test_output=errors + test_targets: + - //:clwb_tests CLion-Linux-OSS-under-dev: name: CLion Linux OSS Under Development platform: ubuntu2204 diff --git a/.bazelci/intellij-ue.yml b/.bazelci/intellij-ue.yml index 1e31418492d..c965dfb49d2 100644 --- a/.bazelci/intellij-ue.yml +++ b/.bazelci/intellij-ue.yml @@ -1,43 +1,5 @@ --- tasks: - IntelliJ-UE-internal-stable: - name: IntelliJ UE Internal Stable - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-ue-latest - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-ue-latest - - --test_output=errors - test_targets: - - //:ijwb_ue_tests - IntelliJ-UE-internal-beta: - name: IntelliJ UE Internal Beta - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-ue-beta - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-ue-beta - - --test_output=errors - test_targets: - - //:ijwb_ue_tests - IntelliJ-UE-internal-under-dev: - name: IntelliJ UE Internal Under Development - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-ue-under-dev - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-ue-under-dev - - --test_output=errors - test_targets: - - //:ijwb_ue_tests - soft_fail: - - exit_status: 1 IntelliJ-UE-OSS-oldest-stable: name: IntelliJ UE OSS Oldest Stable platform: ubuntu2204 diff --git a/.bazelci/intellij.yml b/.bazelci/intellij.yml index f669a56b450..1d826389d83 100644 --- a/.bazelci/intellij.yml +++ b/.bazelci/intellij.yml @@ -1,43 +1,5 @@ --- tasks: - IntelliJ-CE-internal-stable: - name: IntelliJ CE Internal Stable - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-latest - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-latest - - --test_output=errors - test_targets: - - //:ijwb_ce_tests - IntelliJ-CE-internal-beta: - name: IntelliJ CE Internal Beta - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-beta - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-beta - - --test_output=errors - test_targets: - - //:ijwb_ce_tests - IntelliJ-CE-internal-under-dev: - name: IntelliJ CE Internal Under Development - platform: ubuntu2204 - build_flags: - - --define=ij_product=intellij-under-dev - build_targets: - - //ijwb/... - test_flags: - - --define=ij_product=intellij-under-dev - - --test_output=errors - test_targets: - - //:ijwb_ce_tests - soft_fail: - - exit_status: 1 IntelliJ-CE-OSS-oldest-stable: name: IntelliJ CE OSS Oldest Stable platform: ubuntu2204 @@ -76,7 +38,7 @@ tasks: - //:ijwb_ce_tests soft_fail: - exit_status: 1 - IntelliJ-CE-OSS-under-dev: + IntelliJ-CE-OSS-under-dev-windows: name: IntelliJ CE OSS Under Development platform: windows build_flags: From 30b7a7a4688fd4a39817190177d2d610447e79c7 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 07:06:06 -0700 Subject: [PATCH 05/27] doc: Document the starlark debugger (#6899) * doc: Document the starlark debugger * Update starlark_debugger.md --- docs/starlark_debugger.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 docs/starlark_debugger.md diff --git a/docs/starlark_debugger.md b/docs/starlark_debugger.md new file mode 100644 index 00000000000..a8b2785c4d6 --- /dev/null +++ b/docs/starlark_debugger.md @@ -0,0 +1,24 @@ +# Debugging Starlark with the IntelliJ Plugin + +To debug Starlark, you need to create a `build` run configuration. You can do this in two ways: manually create a new configuration or reuse an existing one. + +## Method 1: Create a Run Configuration Manually + +1. Open the **Run Configurations** menu. +2. Click the `+` icon to add a new configuration. +3. Select **Bazel Command** from the list. +4. Enter the target expression in the **Target** field. +5. Set the **Bazel Command** field to `build`. + +## Method 2: Reuse an Existing Run Configuration + +1. Run the target using an existing configuration. +2. Open the **Run Configurations** editor. +3. Change the **Command** field to `build`. +4. Run the configuration again. + +**Important:** Before starting the debugger, ensure you have modified something in the Starlark file. If no changes are made, Bazel will use the analysis cache and skip executing the Starlark code. + +## Demo: Showing Both Methods +https://github.com/user-attachments/assets/959b3d53-f79b-4329-bd3b-74d328af761a + From b823456fdf5e0e737773f58ebb2ea544b0f6f2cd Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 10:50:37 -0700 Subject: [PATCH 06/27] Update querysync.md (#6898) * Update querysync.md * Update querysync.md --- docs/querysync.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/querysync.md b/docs/querysync.md index 573c7200109..aa22d435749 100644 --- a/docs/querysync.md +++ b/docs/querysync.md @@ -49,7 +49,10 @@ Before enabling Query Sync, please ensure you're using the Bazel Plugin from the 2. Go to **File** > **Import Project...** or **File** > **New** > **Project from Existing Sources...** to start the **Project Import Wizard**. 3. Select your project's root directory and click **OK**. 4. In the **Import Project from Bazel** dialog, proceed with the import process. -5. When you reach the **Project View** setup step, enable **Query Sync** by setting the attrbute `use_query_sync` to `true`. +5. When you reach the **Project View** setup step, enable **Query Sync** by setting the attribute `use_query_sync` to `true`. + ``` + use_query_sync: true + ``` 6. Complete the wizard to generate. 7. Your project is now configured to use Query Sync. From c1bfa0666a541afa449727a1d2c8eab340a326eb Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 14:35:24 -0700 Subject: [PATCH 07/27] fix: fast test not working when main class is not set (#6903) --- .../java/run/fastbuild/FastBuildTestEnvironmentCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/google/idea/blaze/java/run/fastbuild/FastBuildTestEnvironmentCreator.java b/java/src/com/google/idea/blaze/java/run/fastbuild/FastBuildTestEnvironmentCreator.java index bc49c03f38f..8eb987b95f7 100644 --- a/java/src/com/google/idea/blaze/java/run/fastbuild/FastBuildTestEnvironmentCreator.java +++ b/java/src/com/google/idea/blaze/java/run/fastbuild/FastBuildTestEnvironmentCreator.java @@ -111,7 +111,7 @@ GeneralCommandLine createCommandLine( getTestClassProperty(), FastBuildTestClassFinder.getInstance(project).getTestClass(target, targetJavaInfo)); - if (targetJavaInfo.mainClass().isPresent()) { + if (targetJavaInfo.mainClass().isPresent() && !targetJavaInfo.mainClass().get().isBlank()) { commandBuilder.setMainClass(targetJavaInfo.mainClass().get()); } else { commandBuilder.setMainClass(getTestRunner()); From 36ed4c1b5c451d7d2b314996942e32d731908a99 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 14:36:08 -0700 Subject: [PATCH 08/27] doc: Document hotswapping (#6902) * doc: Document hotswapping * Update hotswap.md --- docs/hotswap.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 docs/hotswap.md diff --git a/docs/hotswap.md b/docs/hotswap.md new file mode 100644 index 00000000000..fcecc6f50db --- /dev/null +++ b/docs/hotswap.md @@ -0,0 +1,23 @@ +# JVM Hotswapping with the Bazel Plugin in IntelliJ IDEA + +The Bazel Plugin for IntelliJ IDEA supports JVM hotswapping, allowing you to modify code during a debug session without restarting your application. + +## Steps + +1. **Start a Debugger Session** + - Run your Bazel application in debug mode. + +2. **Modify Your Code** + - Make changes to your source files while the application is running. + +3. **Compile and Reload** + - Go to **Run** > **Debugging actions** > **Compile and Reload Modified Files**. + +## Notes + +- **Supported Changes**: Edits within method bodies. +- **Unsupported Changes**: Adding methods, fields, or altering class structures may require a restart. + +## Demo +https://github.com/user-attachments/assets/a0f602d3-815b-4980-8194-3114971d2899 + From 1e071bb6b6f4094af4ed7936f22d925aded015fe Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 15:55:07 -0700 Subject: [PATCH 09/27] doc: Document fast builds (#6904) * doc: Document fast builds * Update fastbuild.md * Update fastbuild.md * Update fastbuild.md * Update fastbuild.md --- docs/fastbuild.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docs/fastbuild.md diff --git a/docs/fastbuild.md b/docs/fastbuild.md new file mode 100644 index 00000000000..9e537df53eb --- /dev/null +++ b/docs/fastbuild.md @@ -0,0 +1,31 @@ +## Fast Build + +The IntelliJ plugin for Bazel includes the **Fast Build** feature, allowing you to run tests and executables without recompiling the entire target. This feature detects which Java files have changed and compiles only those files, significantly speeding up the development process. + +## Requirements + +To enable Fast Build, you must add specific VM options to your IntelliJ configuration. +The flags are required to run Java compilation inside the IntelliJ process, so that there's +no need to spawn a separate `javac` process. +Follow these steps: + +1. Navigate to **Help** -> **Edit Custom VM Options**. +2. Add the following entries: + +```plaintext +--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +``` + +## rules_java +Please use rules_java 8.1.0 or newer + +## How to Use + +To use Fast Build, locate your test or executable in the editor. Click the gutter icon and select either **Fast Run** or **Fast Test**. + +## Demo + +https://github.com/user-attachments/assets/73b4ffbb-043a-4b96-81f8-de5fb2a2a1eb + From d8bca8766f4dbd3bc81a87773152594c582f0988 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 16:03:23 -0700 Subject: [PATCH 10/27] fix: fast sync with bazel 8 (#6901) --- .../run/fastbuild/BazelFastBuildTestEnvironmentCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/src/com/google/idea/blaze/java/run/fastbuild/BazelFastBuildTestEnvironmentCreator.java b/java/src/com/google/idea/blaze/java/run/fastbuild/BazelFastBuildTestEnvironmentCreator.java index 20be9f8c669..89da23b5709 100644 --- a/java/src/com/google/idea/blaze/java/run/fastbuild/BazelFastBuildTestEnvironmentCreator.java +++ b/java/src/com/google/idea/blaze/java/run/fastbuild/BazelFastBuildTestEnvironmentCreator.java @@ -74,7 +74,7 @@ private static boolean isDefaultLauncher(Label label) { private static File getStandardJavaBinary(String runfilesPath) { for (File file : new File(runfilesPath) - .listFiles(fn -> fn.getName().matches("rules_java~.*~toolchains~local_jdk"))) { + .listFiles(fn -> fn.getName().matches("rules_java[+~].*[+~]toolchains[+~]local_jdk"))) { if (file.isDirectory()) { return file.toPath().resolve("bin/java").toFile(); } From a1cf27c26852db022caf29deaad1cee2d555d706 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 16:15:25 -0700 Subject: [PATCH 11/27] doc: Table of contents (#6905) * doc: Table of contents * Update index.md --- docs/index.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/index.md diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000000..c8457e10de6 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,11 @@ +## How to import +The best way to become familiar with the plugin is to watch [this](https://www.youtube.com/watch?v=GV_KwWK3Qy8) video. + +## Advanced features + +- [Python code generation](python/code-generators.md) +- [Query Sync](querysync.md) +- [Starlark Debugger](starlark_debugger.md) +- [Sub-target incremental compilation](fastbuild.md) +- [Gazelle support](gazelle.md) +- [JVM HotSwap](hotswap.md) From 12a7d815450083364039dd62f3f5721e739bf68e Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 16 Oct 2024 20:15:48 -0700 Subject: [PATCH 12/27] doc: Refer to the new docpage (#6906) --- README.md | 4 ++-- .../idea/blaze/base/bazel/BazelBuildSystemProvider.java | 2 +- ijwb/src/META-INF/description.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9cb919034dc..779e07dfadf 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ how to join the discussion can be found in the [SIG charter](https://github.com/ ## Support -See the [documentation entry](https://ij.bazel.build/docs/bazel-support.html) +See the [documentation entry](https://github.com/bazelbuild/intellij/blob/master/docs/index.md) on the plugin support across JetBrains products, languages, and operating systems. @@ -54,7 +54,7 @@ We recommend watching [this video](https://www.youtube.com/watch?v=GV_KwWK3Qy8) To import an existing Bazel project, choose `Import Bazel Project`, and follow the instructions in the project import wizard. -Detailed docs are available [here](http://ij.bazel.build). +Detailed docs are available [here](https://github.com/bazelbuild/intellij/blob/master/docs/index.md). ## Known issues diff --git a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystemProvider.java b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystemProvider.java index 75c6b28f2be..bddd935c3b9 100644 --- a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystemProvider.java +++ b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystemProvider.java @@ -22,7 +22,7 @@ /** Provides the bazel build system name string. */ public class BazelBuildSystemProvider implements BuildSystemProvider { - private static final String BAZEL_DOC_SITE = "https://ij.bazel.build/docs"; + private static final String BAZEL_DOC_SITE = "https://github.com/bazelbuild/intellij/blob/master/docs/index.md"; private static final ImmutableList BUILD_FILE_NAMES = ImmutableList.of("BUILD.bazel", "BUILD"); diff --git a/ijwb/src/META-INF/description.html b/ijwb/src/META-INF/description.html index 1694774135f..f8b25c79415 100644 --- a/ijwb/src/META-INF/description.html +++ b/ijwb/src/META-INF/description.html @@ -9,4 +9,4 @@ Watch this video to familiarize yourself with the plugin's features. -Usage instructions at ij.bazel.build +Usage instructions here From 5ba2eac016f564da3190d18c55665c6e57e124dd Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Thu, 17 Oct 2024 19:38:32 +0200 Subject: [PATCH 13/27] chore(deps): update dependency rules_java to v7.12.2 (#6907) --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index cfb8fc7d79c..bd68f53909d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -9,7 +9,7 @@ bazel_dep( ) bazel_dep( name = "rules_java", - version = "7.12.1", + version = "7.12.2", ) bazel_dep( name = "rules_python", From 94b38b5fceefe0b825c7c1ebed5ae04888f36a0f Mon Sep 17 00:00:00 2001 From: Evgenii Novozhilov Date: Fri, 18 Oct 2024 11:43:36 +0300 Subject: [PATCH 14/27] Decorate tabs for BUILD files with package name (#6900) Since BUILD files all have the same name it's hard to distinguish them, so we can use EditorTabTitleProvider to write full label in the editor tab title --- base/src/META-INF/blaze-base.xml | 1 + .../editor/BazelEditorTabTitleProvider.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 base/src/com/google/idea/blaze/base/editor/BazelEditorTabTitleProvider.java diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml index 620b28d071d..0b662167bf9 100644 --- a/base/src/META-INF/blaze-base.xml +++ b/base/src/META-INF/blaze-base.xml @@ -462,6 +462,7 @@ + diff --git a/base/src/com/google/idea/blaze/base/editor/BazelEditorTabTitleProvider.java b/base/src/com/google/idea/blaze/base/editor/BazelEditorTabTitleProvider.java new file mode 100644 index 00000000000..6f6e79e117a --- /dev/null +++ b/base/src/com/google/idea/blaze/base/editor/BazelEditorTabTitleProvider.java @@ -0,0 +1,31 @@ +package com.google.idea.blaze.base.editor; + +import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile; +import com.google.idea.blaze.base.settings.Blaze; +import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class BazelEditorTabTitleProvider implements EditorTabTitleProvider { + private static boolean requiresDecoration(Project project, String fileName) { + return Blaze.getBuildSystemProvider(project).possibleBuildFileNames().contains(fileName); + } + @Override + public @Nullable String getEditorTabTitle(@NotNull Project project, + @NotNull VirtualFile virtualFile) { + var fileName = virtualFile.getName(); + if (!requiresDecoration(project, fileName)) { + return null; + } + + return BuildFile.getBuildFileString(project, virtualFile.getPath()); + } + + @Override + public @Nullable String getEditorTabTooltipText(@NotNull Project project, + @NotNull VirtualFile virtualFile) { + return EditorTabTitleProvider.super.getEditorTabTooltipText(project, virtualFile); + } +} From c1a3c5af264d468d90f19f04935487e0983f8ac5 Mon Sep 17 00:00:00 2001 From: Daniel Brauner <44034965+LeFrosch@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:48:53 +0200 Subject: [PATCH 15/27] New Sync View (#6813) Adds a new sync view that uses the build view provided by platform. Error messages received by BEP rather than parsing the command line output to increase the quality and relevance of reported errors. Currently the view is disabled by default but can be enabled in the settings. --- .bazelrc | 1 + MODULE.bazel | 2 + aswb/aswb.bazelproject | 4 + .../BlazeApkDeployInfoProtoHelper.java | 8 +- .../run/test/BlazeAndroidTestLaunchTask.java | 9 +- .../sync/BlazeNdkDependencySyncPlugin.java | 2 +- .../BlazeAndroidWorkspaceImporter.java | 4 +- .../sync/importer/BlazeImportUtil.java | 4 +- .../problems/GeneratedResourceWarnings.java | 11 +- .../sync/sdk/AndroidSdkFromProjectView.java | 6 +- base/BUILD | 7 +- base/src/META-INF/blaze-base.xml | 6 +- .../ProgressiveTaskWithProgressIndicator.java | 9 +- .../base/bazel/AbstractBuildInvoker.java | 3 +- .../blaze/base/bazel/BazelBuildSystem.java | 9 - .../blaze/base/buildview/BazelExecService.kt | 181 ++++++++++++++++ .../base/buildview/BuildViewMigration.kt | 25 +++ .../blaze/base/buildview/BuildViewScope.kt | 106 +++++++++ .../idea/blaze/base/buildview/ContextExt.kt | 26 +++ .../base/buildview/events/AbortedParser.kt | 75 +++++++ .../buildview/events/ActionCompletedParser.kt | 66 ++++++ .../base/buildview/events/BazelBuildIssue.kt | 51 +++++ .../base/buildview/events/BuildEventParser.kt | 21 ++ .../idea/blaze/base/command/BlazeCommand.java | 8 + .../CommandLineBlazeCommandRunner.java | 19 +- .../buildresult/BuildEventProtocolUtils.java | 8 +- .../buildresult/BuildEventStreamProvider.java | 7 - .../buildresult/BuildResultHelper.java | 204 ------------------ .../command/buildresult/BuildResultHelper.kt | 135 ++++++++++++ .../buildresult/BuildResultHelperBep.java | 113 ---------- .../BuildResultHelperProvider.java | 65 ------ .../command/buildresult/ParsedBepOutput.java | 9 - .../base/issueparser/BlazeIssueParser.java | 60 ++---- .../issueparser/IssueOutputLineProcessor.java | 3 +- .../ToolWindowTaskIssueOutputFilter.java | 21 +- .../logging/utils/BuildPhaseSyncStats.java | 5 - .../utils/querysync/BuildDepsStats.java | 4 - .../base/projectview/ProjectViewVerifier.java | 8 +- .../base/projectview/parser/ParseContext.java | 4 +- .../base/qsync/BazelDependencyBuilder.java | 1 - ...lBuildEventProtocolTestFinderStrategy.java | 2 +- .../blaze/base/scope/output/IssueOutput.java | 190 ---------------- .../blaze/base/scope/output/IssueOutput.kt | 133 ++++++++++++ .../blaze/base/scope/scopes/IdeaLogScope.java | 2 +- .../base/scope/scopes/ProblemsViewScope.java | 3 + .../base/scope/scopes/ToolWindowScope.java | 10 + .../base/settings/BlazeUserSettings.java | 10 + .../ui/BlazeUserSettingsConfigurable.java | 8 + .../blaze/base/sync/BlazeSyncManager.java | 27 ++- .../blaze/base/sync/BuildPhaseSyncTask.java | 50 ++--- .../blaze/base/sync/SyncPhaseCoordinator.java | 25 ++- .../base/sync/SyncProjectTargetsHelper.java | 47 ++-- .../base/sync/aspects/BlazeBuildOutputs.java | 11 +- .../aspects/BlazeIdeInterfaceAspectsImpl.java | 9 +- .../data/AspectSyncProjectDataManager.java | 2 + .../SuggestBuildShardingNotification.java | 64 +++--- .../base/ui/problems/BlazeProblemsView.java | 33 +-- .../ui/problems/BuildTasksProblemsView.java | 41 ++-- .../idea/blaze/base/util/ScopeService.kt | 25 +++ .../ui/BlazeEditProjectViewControl.java | 6 +- .../issueparser/BlazeIssueParserTest.java | 165 ++++---------- .../parser/ProjectViewParserTest.java | 8 + ...ldEventProtocolTestFinderStrategyTest.java | 50 +---- .../google/idea/blaze/base/BlazeTestCase.java | 5 + .../base/bazel/FakeBuildResultHelperBep.java | 73 ------- .../google/idea/blaze/base/io/TempFile.java | 30 +++ .../idea/blaze/base/scope/ErrorCollector.java | 6 +- .../run/BlazeCidrRunConfigurationRunner.java | 4 +- .../clwb/base/ClwbIntegrationTestCase.java | 9 + .../idea/blaze/cpp/BlazeCWorkspace.java | 2 +- .../BlazeConfigurationToolchainResolver.java | 2 +- .../idea/blaze/dart/BlazeDartSyncPlugin.java | 2 +- .../blaze/gazelle/GazelleIssueParsers.java | 7 +- .../run/BlazeGoRunConfigurationRunner.java | 4 +- .../sync/AlwaysPresentGoSyncPlugin.java | 6 +- ijwb/ijwb.bazelproject | 3 + .../FastBuildCompilerFactoryImpl.java | 19 +- .../java/fastbuild/FastBuildServiceImpl.java | 4 +- .../run/hotswap/ClassFileManifestBuilder.java | 4 +- .../sync/source/JavaSourcePackageReader.java | 2 +- .../FastBuildCompilerFactoryImplTest.java | 15 +- .../source/SourceDirectoryCalculatorTest.java | 7 + .../javascript/BlazeJavascriptSyncPlugin.java | 2 +- .../typescript/BlazeTypescriptSyncPlugin.java | 4 +- .../sync/AlwaysPresentKotlinSyncPlugin.java | 2 +- .../kotlin/sync/BlazeKotlinSyncPlugin.java | 43 ++-- .../issueparser/PyIssueParserProvider.java | 10 +- .../run/BlazePyRunConfigurationRunner.java | 4 +- .../sync/AlwaysPresentPythonSyncPlugin.java | 2 +- .../python/sync/BlazePythonSyncPlugin.java | 2 +- .../PyIssueParserProviderTest.java | 28 +-- .../GenerateDeployableJarTaskProvider.java | 4 +- .../sync/AlwaysPresentScalaSyncPlugin.java | 2 +- .../testing/BlazeTestSystemProperties.java | 20 +- third_party/kotlin/BUILD | 8 + 95 files changed, 1314 insertions(+), 1252 deletions(-) create mode 100644 base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/BuildViewMigration.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/BuildViewScope.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/ContextExt.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/events/AbortedParser.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/events/ActionCompletedParser.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/events/BazelBuildIssue.kt create mode 100644 base/src/com/google/idea/blaze/base/buildview/events/BuildEventParser.kt delete mode 100644 base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.java create mode 100644 base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.kt delete mode 100644 base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperBep.java delete mode 100644 base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperProvider.java delete mode 100644 base/src/com/google/idea/blaze/base/scope/output/IssueOutput.java create mode 100644 base/src/com/google/idea/blaze/base/scope/output/IssueOutput.kt create mode 100644 base/src/com/google/idea/blaze/base/util/ScopeService.kt delete mode 100644 base/tests/utils/unit/com/google/idea/blaze/base/bazel/FakeBuildResultHelperBep.java create mode 100644 base/tests/utils/unit/com/google/idea/blaze/base/io/TempFile.java create mode 100644 third_party/kotlin/BUILD diff --git a/.bazelrc b/.bazelrc index b433f6c936c..dc45a733ab9 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,5 @@ build --java_language_version=17 --java_runtime_version=17 +build --tool_java_language_version=17 --tool_java_runtime_version=17 # Delete test data packages, needed for bazel integration tests. Update by running the following command: # bazel run @rules_bazel_integration_test//tools:update_deleted_packages diff --git a/MODULE.bazel b/MODULE.bazel index bd68f53909d..adce232d004 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,6 +3,8 @@ module( repo_name = "intellij_with_bazel", ) +register_toolchains("//third_party/kotlin:toolchain") + bazel_dep( name = "platforms", version = "0.0.10", diff --git a/aswb/aswb.bazelproject b/aswb/aswb.bazelproject index 96d6a6a7271..015b3e045d8 100644 --- a/aswb/aswb.bazelproject +++ b/aswb/aswb.bazelproject @@ -22,3 +22,7 @@ test_sources: */testcompat/unittests* */testcompat/integrationtests* */testcompat/utils/integration* + +additional_languages: + kotlin + diff --git a/aswb/src/com/google/idea/blaze/android/run/deployinfo/BlazeApkDeployInfoProtoHelper.java b/aswb/src/com/google/idea/blaze/android/run/deployinfo/BlazeApkDeployInfoProtoHelper.java index 88c62b3ee64..f4bbf2162f2 100644 --- a/aswb/src/com/google/idea/blaze/android/run/deployinfo/BlazeApkDeployInfoProtoHelper.java +++ b/aswb/src/com/google/idea/blaze/android/run/deployinfo/BlazeApkDeployInfoProtoHelper.java @@ -17,6 +17,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.AndroidDeployInfo; import com.google.devtools.build.lib.rules.android.deployinfo.AndroidDeployInfoOuterClass.Artifact; import com.google.idea.blaze.android.manifest.ManifestParser.ParsedManifest; @@ -29,6 +30,7 @@ import com.google.idea.blaze.common.artifact.OutputArtifact; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.util.containers.ContainerUtil; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -45,7 +47,7 @@ public class BlazeApkDeployInfoProtoHelper { public AndroidDeployInfo readDeployInfoProtoForTarget( Label target, BuildResultHelper buildResultHelper, Predicate pathFilter) throws GetDeployInfoException { - ImmutableList outputArtifacts; + ImmutableSet outputArtifacts; try { outputArtifacts = buildResultHelper.getBuildArtifactsForTarget(target, pathFilter); } catch (GetArtifactsException e) { @@ -62,7 +64,7 @@ public AndroidDeployInfo readDeployInfoProtoForTarget( log.warn(outputArtifact.getRelativePath() + " -> " + outputArtifact.getRelativePath()); } log.warn("All local artifacts for " + target + ":"); - List allBuildArtifacts = + ImmutableSet allBuildArtifacts = buildResultHelper.getBuildArtifactsForTarget(target, path -> true); List allLocalFiles = LocalFileArtifact.getLocalFiles(allBuildArtifacts); for (File file : allLocalFiles) { @@ -87,7 +89,7 @@ public AndroidDeployInfo readDeployInfoProtoForTarget( .collect(Collectors.joining(", ", "[", "]"))); } - try (InputStream inputStream = outputArtifacts.get(0).getInputStream()) { + try (InputStream inputStream = ContainerUtil.getFirstItem(outputArtifacts).getInputStream()) { return AndroidDeployInfo.parseFrom(inputStream); } catch (IOException e) { throw new GetDeployInfoException(e.getMessage()); diff --git a/aswb/src/com/google/idea/blaze/android/run/test/BlazeAndroidTestLaunchTask.java b/aswb/src/com/google/idea/blaze/android/run/test/BlazeAndroidTestLaunchTask.java index d057bc54172..f505e849402 100644 --- a/aswb/src/com/google/idea/blaze/android/run/test/BlazeAndroidTestLaunchTask.java +++ b/aswb/src/com/google/idea/blaze/android/run/test/BlazeAndroidTestLaunchTask.java @@ -26,8 +26,6 @@ import com.google.idea.blaze.base.command.BlazeCommandName; import com.google.idea.blaze.base.command.BlazeFlags; import com.google.idea.blaze.base.command.buildresult.BuildResultHelper; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelper.GetArtifactsException; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelperBep; import com.google.idea.blaze.base.filecache.FileCaches; import com.google.idea.blaze.base.ideinfo.AndroidInstrumentationInfo; import com.google.idea.blaze.base.ideinfo.TargetIdeInfo; @@ -195,7 +193,7 @@ public void run(@NotNull BlazeLaunchContext launchContext) String.format("Starting %s test...\n", Blaze.buildSystemName(project))); int retVal; - try (BuildResultHelper buildResultHelper = new BuildResultHelperBep()) { + try (final var buildResultHelper = new BuildResultHelper()) { commandBuilder.addBlazeFlags(buildResultHelper.getBuildFlags()); BlazeCommand command = commandBuilder.build(); ExecutionUtils.println(console, command + "\n"); @@ -212,16 +210,13 @@ public void run(@NotNull BlazeLaunchContext launchContext) if (retVal != 0) { context.setHasError(); } else { - testResultsHolder.setTestResults( - buildResultHelper.getTestResults(Optional.empty())); + testResultsHolder.setTestResults(buildResultHelper.getTestResults()); } ListenableFuture unusedFuture = FileCaches.refresh( project, context, BlazeBuildOutputs.noOutputs(BuildResult.fromExitCode(retVal))); - } catch (GetArtifactsException e) { - LOG.error(e.getMessage()); } return !context.hasErrors(); })); diff --git a/aswb/src/com/google/idea/blaze/android/sync/BlazeNdkDependencySyncPlugin.java b/aswb/src/com/google/idea/blaze/android/sync/BlazeNdkDependencySyncPlugin.java index e945650f37d..8e323a36657 100644 --- a/aswb/src/com/google/idea/blaze/android/sync/BlazeNdkDependencySyncPlugin.java +++ b/aswb/src/com/google/idea/blaze/android/sync/BlazeNdkDependencySyncPlugin.java @@ -80,7 +80,7 @@ private static void notifyMissingPlugin(BlazeContext context, PluginNameAndId pl + "Click here to install/enable it, then restart the IDE", plugin.name); IssueOutput.error(msg) - .navigatable(PluginUtils.installOrEnablePluginNavigable(plugin.id)) + .withNavigatable(PluginUtils.installOrEnablePluginNavigable(plugin.id)) .submit(context); } } diff --git a/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeAndroidWorkspaceImporter.java b/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeAndroidWorkspaceImporter.java index 62a41bf8ba5..999a810506e 100644 --- a/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeAndroidWorkspaceImporter.java +++ b/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeAndroidWorkspaceImporter.java @@ -41,10 +41,10 @@ import com.google.idea.blaze.base.model.primitives.Label; import com.google.idea.blaze.base.scope.BlazeContext; import com.google.idea.blaze.base.scope.output.IssueOutput; -import com.google.idea.blaze.base.scope.output.IssueOutput.Category; import com.google.idea.blaze.base.scope.output.PerformanceWarning; import com.google.idea.blaze.common.Output; import com.google.idea.common.experiments.BoolExperiment; +import com.intellij.build.events.MessageEvent.Kind; import com.intellij.openapi.project.Project; import java.util.Collection; import java.util.Collections; @@ -327,7 +327,7 @@ private ImmutableList buildAndroidResourceModules( if (mergeResourcesEnabled.getValue()) { messageBuilder.append(" ").append("Merging Resources...").append("\n"); String message = messageBuilder.toString(); - context.accept(IssueOutput.issue(Category.INFORMATION, message).build()); + context.accept(IssueOutput.issue(Kind.INFO, message).build()); result.add(mergeAndroidResourceModules(androidResourceModulesWithJavaPackage)); } else { diff --git a/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeImportUtil.java b/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeImportUtil.java index 1b2ab3540f9..8e806f54bd2 100644 --- a/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeImportUtil.java +++ b/aswb/src/com/google/idea/blaze/android/sync/importer/BlazeImportUtil.java @@ -39,6 +39,7 @@ import com.google.idea.blaze.base.sync.projectview.ProjectViewTargetImportFilter; import com.google.idea.blaze.common.Output; import com.google.idea.blaze.java.sync.model.BlazeJarLibrary; +import com.intellij.build.events.MessageEvent.Kind; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import java.util.Collection; @@ -110,8 +111,7 @@ static Consumer asConsumer(BlazeContext context) { context.output(issue); if (issue instanceof IssueOutput) { IssueOutput issueOutput = (IssueOutput) issue; - if (issueOutput.getCategory() - == com.google.idea.blaze.base.scope.output.IssueOutput.Category.ERROR) { + if (issueOutput.getKind() == Kind.ERROR) { context.setHasError(); } } diff --git a/aswb/src/com/google/idea/blaze/android/sync/importer/problems/GeneratedResourceWarnings.java b/aswb/src/com/google/idea/blaze/android/sync/importer/problems/GeneratedResourceWarnings.java index 81641227959..7edd9de643c 100644 --- a/aswb/src/com/google/idea/blaze/android/sync/importer/problems/GeneratedResourceWarnings.java +++ b/aswb/src/com/google/idea/blaze/android/sync/importer/problems/GeneratedResourceWarnings.java @@ -71,9 +71,7 @@ public static void submit( + "Double-click to add to project view if needed to resolve" + " references.", interestingDirectories.size())) - .inFile(projectViewFile) - .onLine(1) - .inColumn(1) + .withFile(projectViewFile) .build()); for (Map.Entry entry : interestingDirectories.entrySet()) { context.accept( @@ -81,10 +79,7 @@ public static void submit( String.format( "Dropping generated resource directory '%s' w/ %d subdirs", entry.getKey(), entry.getValue())) - .inFile(projectViewFile) - .navigatable( - new AddGeneratedResourceDirectoryNavigatable( - project, projectViewFile, entry.getKey())) + .withFile(projectViewFile) .build()); } } @@ -98,7 +93,7 @@ public static void submit( unusedAllowlistEntries.size(), GeneratedAndroidResourcesSection.KEY.getName(), String.join("\n ", unusedAllowlistEntries))) - .inFile(projectViewFile) + .withFile(projectViewFile) .build()); } } diff --git a/aswb/src/com/google/idea/blaze/android/sync/sdk/AndroidSdkFromProjectView.java b/aswb/src/com/google/idea/blaze/android/sync/sdk/AndroidSdkFromProjectView.java index 7301a0080ab..9445ccc47c1 100644 --- a/aswb/src/com/google/idea/blaze/android/sync/sdk/AndroidSdkFromProjectView.java +++ b/aswb/src/com/google/idea/blaze/android/sync/sdk/AndroidSdkFromProjectView.java @@ -51,7 +51,7 @@ public static AndroidSdkPlatform getAndroidSdkPlatform( if (sdks.isEmpty()) { String msg = "No Android SDK configured. Please use the SDK manager to configure."; IssueOutput.error(msg) - .navigatable( + .withNavigatable( new Navigatable() { @Override public void navigate(boolean b) { @@ -87,7 +87,7 @@ public boolean canNavigateToSource() { + getAvailableTargetHashesAsList(sdks) + ". To install more android SDKs, use the SDK manager."; IssueOutput.error(msg) - .inFile(projectViewFile != null ? projectViewFile.projectViewFile : null) + .withFile(projectViewFile != null ? projectViewFile.projectViewFile : null) .submit(context); BlazeSyncManager.printAndLogError(msg, context); return null; @@ -98,7 +98,7 @@ public boolean canNavigateToSource() { ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile(); String msg = String.format(NO_SDK_ERROR_TEMPLATE, androidSdk, getAllAvailableTargetHashes()); IssueOutput.error(msg) - .inFile(projectViewFile != null ? projectViewFile.projectViewFile : null) + .withFile(projectViewFile != null ? projectViewFile.projectViewFile : null) .submit(context); BlazeSyncManager.printAndLogError(msg, context); return null; diff --git a/base/BUILD b/base/BUILD index 1c7482e41f6..8ecfe3d01b6 100644 --- a/base/BUILD +++ b/base/BUILD @@ -18,12 +18,13 @@ load( "intellij_integration_test_suite", "intellij_unit_test_suite", ) +load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") -java_library( +kt_jvm_library( name = "base", - srcs = glob(["src/**/*.java"]), - javacopts = ["-Xep:FutureReturnValueIgnored:OFF"], + srcs = glob(["src/**/*.java", "src/**/*.kt"]), resources = glob(["src/resources/**/*"]), + resource_strip_prefix = "base/src", visibility = PLUGIN_PACKAGES_VISIBILITY, deps = [ "//common/actions", diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml index 0b662167bf9..19af9de2acb 100644 --- a/base/src/META-INF/blaze-base.xml +++ b/base/src/META-INF/blaze-base.xml @@ -589,6 +589,7 @@ + @@ -615,7 +616,6 @@ - @@ -684,7 +684,9 @@ - + + + diff --git a/base/src/com/google/idea/blaze/base/async/executor/ProgressiveTaskWithProgressIndicator.java b/base/src/com/google/idea/blaze/base/async/executor/ProgressiveTaskWithProgressIndicator.java index f7b0c15f8bd..63256bd9757 100644 --- a/base/src/com/google/idea/blaze/base/async/executor/ProgressiveTaskWithProgressIndicator.java +++ b/base/src/com/google/idea/blaze/base/async/executor/ProgressiveTaskWithProgressIndicator.java @@ -20,9 +20,11 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.progress.PerformInBackgroundOption; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Progressive; +import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator; import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase; import com.intellij.openapi.progress.util.ProgressWindow; @@ -40,7 +42,8 @@ public class ProgressiveTaskWithProgressIndicator { public enum Modality { MODAL, // This task must start in the foreground and stay there. BACKGROUNDABLE, // This task will start in the foreground, but can be sent to the background. - ALWAYS_BACKGROUND // This task will start in the background and stay there. + ALWAYS_BACKGROUND, // This task will start in the background and stay there. + BUILD_VIEW // Progress of this task is tracked in the build view } @Nullable private final Project project; @@ -104,6 +107,10 @@ public void submitTaskLater(Progressive progressive) { * progress dialog. */ public ListenableFuture submitTaskWithResult(ProgressiveWithResult progressive) { + if (modality == Modality.BUILD_VIEW) { + return executor.submit(() -> progressive.compute(new EmptyProgressIndicator(ModalityState.NON_MODAL))); + } + // The progress indicator must be created on the UI thread. final ProgressWindow indicator = UIUtil.invokeAndWaitIfNeeded( diff --git a/base/src/com/google/idea/blaze/base/bazel/AbstractBuildInvoker.java b/base/src/com/google/idea/blaze/base/bazel/AbstractBuildInvoker.java index 5e76138a86c..52b9900d82c 100644 --- a/base/src/com/google/idea/blaze/base/bazel/AbstractBuildInvoker.java +++ b/base/src/com/google/idea/blaze/base/bazel/AbstractBuildInvoker.java @@ -26,7 +26,6 @@ import com.google.idea.blaze.base.command.BlazeFlags; import com.google.idea.blaze.base.command.BlazeInvocationContext; import com.google.idea.blaze.base.command.buildresult.BuildResultHelper; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelperBep; import com.google.idea.blaze.base.command.info.BlazeInfo; import com.google.idea.blaze.base.command.info.BlazeInfoProvider; import com.google.idea.blaze.base.command.info.BlazeInfoRunner; @@ -95,7 +94,7 @@ public boolean supportsParallelism() { @Override @MustBeClosed public BuildResultHelper createBuildResultHelper() { - return new BuildResultHelperBep(); + return new BuildResultHelper(); } @Override diff --git a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java index 1fa124ce963..87d78f74eb4 100644 --- a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java +++ b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java @@ -15,11 +15,8 @@ */ package com.google.idea.blaze.base.bazel; -import com.google.errorprone.annotations.MustBeClosed; import com.google.idea.blaze.base.command.BlazeCommandName; import com.google.idea.blaze.base.command.CommandLineBlazeCommandRunner; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelper; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelperBep; import com.google.idea.blaze.base.command.info.BlazeInfo; import com.google.idea.blaze.base.model.BlazeVersionData; import com.google.idea.blaze.base.model.primitives.Kind; @@ -52,12 +49,6 @@ public BazelInvoker(Project project, BlazeContext blazeContext, String path) { BazelBuildSystem.this, new CommandLineBlazeCommandRunner()); } - - @Override - @MustBeClosed - public BuildResultHelper createBuildResultHelper() { - return new BuildResultHelperBep(); - } } @Override diff --git a/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt b/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt new file mode 100644 index 00000000000..6b6c6e55d89 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/BazelExecService.kt @@ -0,0 +1,181 @@ +package com.google.idea.blaze.base.buildview + +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent +import com.google.idea.blaze.base.buildview.events.BuildEventParser +import com.google.idea.blaze.base.command.BlazeCommand +import com.google.idea.blaze.base.command.BlazeCommandName +import com.google.idea.blaze.base.command.buildresult.BuildResultHelper +import com.google.idea.blaze.base.model.primitives.WorkspaceRoot +import com.google.idea.blaze.base.scope.BlazeContext +import com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs +import com.google.idea.blaze.base.sync.aspects.BuildResult +import com.google.protobuf.CodedInputStream +import com.intellij.execution.configurations.GeneralCommandLine +import com.intellij.execution.process.OSProcessHandler +import com.intellij.execution.process.ProcessEvent +import com.intellij.execution.process.ProcessListener +import com.intellij.openapi.Disposable +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.components.Service +import com.intellij.openapi.components.service +import com.intellij.openapi.diagnostic.Logger +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Key +import com.intellij.util.io.LimitedInputStream +import com.intellij.util.ui.EDT +import kotlinx.coroutines.* +import java.io.BufferedInputStream +import java.io.FileInputStream +import kotlin.io.path.pathString + +private val LOG: Logger = Logger.getInstance(BazelExecService::class.java) + +@Service(Service.Level.PROJECT) +class BazelExecService(private val project: Project) : Disposable { + companion object { + @JvmStatic + fun instance(project: Project): BazelExecService = project.service() + } + + // #api223 use the injected scope + private val scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default) + + override fun dispose() { + scope.cancel() + } + + private fun assertNonBlocking() { + LOG.assertTrue( + !EDT.isCurrentThreadEdt(), + "action would block UI thread", + ) + LOG.assertTrue( + !ApplicationManager.getApplication().isReadAccessAllowed, + "action holds read lock, can block UI thread" + ) + } + + private fun executionScope( + ctx: BlazeContext, + block: suspend CoroutineScope.(BuildResultHelper) -> T + ): T { + return ctx.pushJob(scope) { + BuildResultHelper().use { block(it) } + } + } + + private suspend fun execute(ctx: BlazeContext, cmd: BlazeCommand): Int { + val root = cmd.effectiveWorkspaceRoot.orElseGet { WorkspaceRoot.fromProject(project).path() } + + val cmdLine = GeneralCommandLine() + .withExePath(cmd.binaryPath) + .withParameters(cmd.toArgumentList()) + .apply { setWorkDirectory(root.pathString) } // required for backwards compatability + .withRedirectErrorStream(true) + + var handler: OSProcessHandler? = null + val exitCode = try { + handler = withContext(Dispatchers.IO) { + OSProcessHandler(cmdLine) + } + + handler.addProcessListener(object : ProcessListener { + override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) { + ctx.println(event.text.trimEnd()) + } + }) + handler.startNotify() + + while (!handler.isProcessTerminated) { + delay(100) + } + + handler.exitCode ?: 1 + } finally { + handler?.destroyProcess() + } + + if (exitCode != 0) { + ctx.setHasError() + } + + return exitCode + } + + private suspend fun parseEvent(ctx: BlazeContext, stream: BufferedInputStream) { + // make sure that there are at least four bytes already available + while (stream.available() < 4) { + delay(10) + } + + // protobuf messages are delimited by size (encoded as varint32), + // read size manually to ensure the entire message is already available + val size = CodedInputStream.readRawVarint32(stream.read(), stream) + + while (stream.available() < size) { + delay(10) + } + + val eventStream = LimitedInputStream(stream, size) + val event = try { + BuildEvent.parseFrom(eventStream) + } catch (e: Exception) { + LOG.error("could not parse event", e) + + // if the message could not be parsed, make sure to skip it + if (eventStream.bytesRead < size) { + stream.skip(size.toLong() - eventStream.bytesRead) + } + + return + } + + BuildEventParser.parse(event)?.let(ctx::output) + } + + private fun CoroutineScope.parseEvents(ctx: BlazeContext, helper: BuildResultHelper): Job { + return launch(Dispatchers.IO + CoroutineName("EventParser")) { + try { + // wait for bazel to create the output file + while (!helper.outputFile.exists()) { + delay(10) + } + + FileInputStream(helper.outputFile).buffered().use { stream -> + // keep reading events while the coroutine is active, i.e. bazel is still running, + // or while the stream has data available (to ensure that all events are processed) + while (isActive || stream.available() > 0) { + parseEvent(ctx, stream) + } + } + } catch (e: CancellationException) { + throw e + } catch (e: Exception) { + LOG.error("error in event parser", e) + } + } + } + + fun build(ctx: BlazeContext, cmdBuilder: BlazeCommand.Builder): BlazeBuildOutputs { + assertNonBlocking() + LOG.assertTrue(cmdBuilder.name == BlazeCommandName.BUILD) + + return executionScope(ctx) { provider -> + cmdBuilder.addBlazeFlags(provider.getBuildFlags()) + + val parseJob = parseEvents(ctx, provider) + + val exitCode = execute(ctx, cmdBuilder.build()) + val result = BuildResult.fromExitCode(exitCode) + + parseJob.cancelAndJoin() + + if (result.status != BuildResult.Status.SUCCESS) { + BlazeBuildOutputs.noOutputs(result) + } else { + BlazeBuildOutputs.fromParsedBepOutput(result, provider.getBuildOutput()) + } + } + } +} + diff --git a/base/src/com/google/idea/blaze/base/buildview/BuildViewMigration.kt b/base/src/com/google/idea/blaze/base/buildview/BuildViewMigration.kt new file mode 100644 index 00000000000..94298024165 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/BuildViewMigration.kt @@ -0,0 +1,25 @@ +package com.google.idea.blaze.base.buildview + +import com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator +import com.google.idea.blaze.base.scope.BlazeContext +import com.google.idea.blaze.base.settings.BlazeUserSettings + +object BuildViewMigration { + @JvmStatic + val enabled + get(): Boolean = BlazeUserSettings.getInstance().useNewSyncView + + @JvmStatic + fun present(ctx: BlazeContext): Boolean { + return ctx.getScope(BuildViewScope::class.java) != null + } + + @JvmStatic + fun progressModality(): ProgressiveTaskWithProgressIndicator.Modality { + return if (enabled) { + ProgressiveTaskWithProgressIndicator.Modality.BUILD_VIEW + } else { + ProgressiveTaskWithProgressIndicator.Modality.ALWAYS_BACKGROUND + } + } +} \ No newline at end of file diff --git a/base/src/com/google/idea/blaze/base/buildview/BuildViewScope.kt b/base/src/com/google/idea/blaze/base/buildview/BuildViewScope.kt new file mode 100644 index 00000000000..41f4c741ee1 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/BuildViewScope.kt @@ -0,0 +1,106 @@ +@file:Suppress("UnstableApiUsage") + +package com.google.idea.blaze.base.buildview + +import com.google.idea.blaze.base.scope.BlazeContext +import com.google.idea.blaze.base.scope.BlazeScope +import com.google.idea.blaze.base.scope.OutputSink +import com.google.idea.blaze.base.scope.output.IssueOutput +import com.google.idea.blaze.base.scope.output.StatusOutput +import com.google.idea.blaze.common.Output +import com.google.idea.blaze.common.PrintOutput +import com.intellij.build.BuildDescriptor +import com.intellij.build.DefaultBuildDescriptor +import com.intellij.build.SyncViewManager +import com.intellij.build.progress.BuildProgress +import com.intellij.build.progress.BuildProgressDescriptor +import com.intellij.icons.AllIcons +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator +import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase +import com.intellij.openapi.project.Project +import java.util.function.Consumer + +class BuildViewScope(project: Project, private val title: String) : BlazeScope { + companion object { + @JvmStatic + fun of(ctx: BlazeContext): BuildViewScope? = ctx.getScope(BuildViewScope::class.java) + } + + private var progress = SyncViewManager.createBuildProgress(project) + private var indicator = BackgroundableProcessIndicator(project, title, "Cancel", "Cancel", true) + + override fun onScopeBegin(ctx: BlazeContext) { + progress.start(ProgressDescriptor(title, ctx)) + + indicator.addStateDelegate(object : AbstractProgressIndicatorExBase() { + override fun cancel() { + super.cancel() + ctx.setCancelled() + } + }) + indicator.start() + + addOutputSink(ctx) { + progress.output(it.text + '\n', true) + } + addOutputSink(ctx) { + progress.output(it.status + '\n', true) + } + addOutputSink(ctx) { + progress.buildIssue(it, it.kind) + } + } + + private inline fun addOutputSink(ctx: BlazeContext, consumer: Consumer) { + ctx.addOutputSink(T::class.java) { it: T -> + consumer.accept(it) + OutputSink.Propagation.Stop + } + } + + override fun onScopeEnd(ctx: BlazeContext) { + val progress = this.progress ?: return + + when { + ctx.isCancelled -> progress.cancel() + ctx.hasErrors() -> progress.fail() + else -> progress.finish() + } + + indicator.stop() + indicator.processFinish() + } + + fun startProgress(title: String): BuildProgress? { + indicator.text2 = title + return progress?.progress(title) + } +} + +private class ProgressDescriptor(private val title: String, ctx: BlazeContext) : + BuildProgressDescriptor { + private val descriptor = DefaultBuildDescriptor(Any(), title, "", System.currentTimeMillis()) + .withRestartAction(RestartAction(ctx)) + + override fun getTitle(): String = title + + override fun getBuildDescriptor(): BuildDescriptor = descriptor +} + +private class RestartAction(private val ctx: BlazeContext) : + AnAction({ "Stop" }, AllIcons.Actions.Suspend) { + override fun actionPerformed(event: AnActionEvent) { + ctx.setCancelled() + } + + override fun update(event: AnActionEvent) { + event.presentation.isEnabled = !ctx.isCancelled && !ctx.isEnding + } + + override fun getActionUpdateThread(): ActionUpdateThread { + return ActionUpdateThread.BGT + } +} diff --git a/base/src/com/google/idea/blaze/base/buildview/ContextExt.kt b/base/src/com/google/idea/blaze/base/buildview/ContextExt.kt new file mode 100644 index 00000000000..f1e2c8bead9 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/ContextExt.kt @@ -0,0 +1,26 @@ +package com.google.idea.blaze.base.buildview + +import com.google.idea.blaze.base.scope.BlazeContext +import com.google.idea.blaze.common.PrintOutput +import com.intellij.openapi.progress.runBlockingMaybeCancellable +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.async + +fun BlazeContext.println(msg: String) { + output(PrintOutput(msg)) +} + +fun BlazeContext.pushJob( + scope: CoroutineScope, + name: String = "BazelContext", + block: suspend CoroutineScope.() -> T, +): T { + val deferred = scope.async(CoroutineName(name)) { block() } + + addCancellationHandler { deferred.cancel() } + + return runBlockingMaybeCancellable { + deferred.await() + } +} \ No newline at end of file diff --git a/base/src/com/google/idea/blaze/base/buildview/events/AbortedParser.kt b/base/src/com/google/idea/blaze/base/buildview/events/AbortedParser.kt new file mode 100644 index 00000000000..f2250fc29e0 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/events/AbortedParser.kt @@ -0,0 +1,75 @@ +package com.google.idea.blaze.base.buildview.events + +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEventId +import com.google.idea.blaze.base.scope.output.IssueOutput +import com.intellij.build.events.MessageEvent + +private fun reportMissingImplementation(id: BuildEventId): T? { + LOG.error("missing implementation: $id") + return null +} + +class AbortedParser : BuildEventParser { + private fun getDescription(id: BuildEventId): String? { + return when { + id.hasUnconfiguredLabel() -> "could not find label: ${id.unconfiguredLabel.label} - make sure a label or a file with that name exists" + id.hasTargetConfigured() -> "could not configure target: ${id.targetConfigured.label}" + id.hasTargetCompleted() -> "could not complete target: ${id.targetCompleted.label}" + id.hasConfiguredLabel() -> null + else -> reportMissingImplementation(id) + } + } + + private fun getChildDescription(id: BuildEventId): String? { + return when { + id.hasUnconfiguredLabel() -> "depends on undefined label: ${id.unconfiguredLabel.label} - might not be a direct dependency" + id.hasConfiguredLabel() -> null + else -> reportMissingImplementation(id) + } + } + + private fun buildDescription(event: BuildEvent): String? { + val builder = StringBuilder() + + if (event.aborted.description.isNotBlank()) { + builder.append(event.aborted.description) + } else { + builder.append(getDescription(event.id) ?: return null) + } + builder.append("\n\n") + + for (child in event.childrenList) { + val description = getChildDescription(child) ?: return null + + builder.append(description) + builder.append("\n") + } + + return builder.toString().trimEnd() + } + + private fun getLabel(id: BuildEventId): String? { + return when { + id.hasTargetConfigured() -> id.targetConfigured.label + id.hasTargetCompleted() -> id.targetCompleted.label + id.hasUnconfiguredLabel() -> id.unconfiguredLabel.label + id.hasConfiguredLabel() -> id.configuredLabel.label + id.hasUnstructuredCommandLine() -> null + else -> reportMissingImplementation(id) + } + } + + override fun parse(event: BuildEvent): IssueOutput? { + if (!event.hasAborted()) return null + + val label = getLabel(event.id) ?: return null + val issue = BazelBuildIssue( + label = label, + title = "${event.aborted.reason}: $label", + description = buildDescription(event) ?: return null, + ) + + return IssueOutput(issue, MessageEvent.Kind.ERROR) + } +} \ No newline at end of file diff --git a/base/src/com/google/idea/blaze/base/buildview/events/ActionCompletedParser.kt b/base/src/com/google/idea/blaze/base/buildview/events/ActionCompletedParser.kt new file mode 100644 index 00000000000..f73e0affa24 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/events/ActionCompletedParser.kt @@ -0,0 +1,66 @@ +package com.google.idea.blaze.base.buildview.events + +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.* +import com.google.idea.blaze.base.scope.output.IssueOutput +import com.intellij.build.events.MessageEvent +import java.io.IOException +import java.net.URI +import java.nio.file.Files +import java.nio.file.Path + +class ActionCompletedParser : BuildEventParser { + private fun getDescription(body: ActionExecuted): String? { + if (!body.hasStderr()) { + if (body.hasFailureDetail()) { + return body.failureDetail.message + } + + return null + } + + val uri = try { + URI.create(body.stderr.uri) + } catch (e: IllegalArgumentException) { + return "Invalid output URI: ${body.stderr.uri}" + } + + return try { + Files.readString(Path.of(uri)) + } catch (e: IOException) { + "Could not read output file: ${e.message}" + } + } + + override fun parse(event: BuildEvent): IssueOutput? { + if (!event.id.hasActionCompleted()) return null + val id = event.id.actionCompleted + + val isExternal = !id.label.startsWith("//") + + if (!event.hasAction()) return null + val body = event.action + + val isWarning = !body.hasFailureDetail() + + // ignore warnings from external projects + if (isExternal && isWarning) return null + + val name = if (isWarning) { + "BUILD_WARNING" + } else { + "BUILD_FAILURE" + } + + val issue = BazelBuildIssue( + label = id.label, + title = "$name: ${id.label}", + description = getDescription(body) ?: return null, + ) + + // TODO: if this is reused for a build view, this logic needs to be adjusted + return IssueOutput( + issue, + if (isWarning) MessageEvent.Kind.INFO else MessageEvent.Kind.WARNING, + ) + } +} diff --git a/base/src/com/google/idea/blaze/base/buildview/events/BazelBuildIssue.kt b/base/src/com/google/idea/blaze/base/buildview/events/BazelBuildIssue.kt new file mode 100644 index 00000000000..2a782b16ab7 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/events/BazelBuildIssue.kt @@ -0,0 +1,51 @@ +@file:Suppress("UnstableApiUsage") + +package com.google.idea.blaze.base.buildview.events + +import com.google.idea.blaze.base.lang.buildfile.references.BuildReferenceManager +import com.google.idea.blaze.base.lang.buildfile.references.LabelUtils +import com.google.idea.blaze.base.util.pluginProjectScope +import com.intellij.build.issue.BuildIssue +import com.intellij.build.issue.BuildIssueQuickFix +import com.intellij.openapi.application.invokeLater +import com.intellij.openapi.application.readAction +import com.intellij.openapi.fileEditor.OpenFileDescriptor +import com.intellij.openapi.project.Project +import com.intellij.pom.Navigatable +import com.intellij.pom.NavigatableAdapter +import kotlinx.coroutines.launch + +data class BazelBuildIssue( + override val title: String, + override val description: String, + override val quickFixes: List = emptyList(), + val label: String? = null, +) : BuildIssue { + override fun getNavigatable(project: Project): Navigatable? { + if (label == null) return null + return LabelNavigatable(project, label) + } +} + +private class LabelNavigatable(private val project: Project, private val label: String) : NavigatableAdapter() { + override fun navigate(requestFocus: Boolean) { + pluginProjectScope(project).launch { + val descriptor = readAction { findFileAsync() } + if (descriptor != null && descriptor.canNavigate()) { + invokeLater { + descriptor.navigate(requestFocus) + } + } + } + } + + private fun findFileAsync(): OpenFileDescriptor? { + // TODO: better use `bazel query "label" --output=location` - would be way more accurate ?? + + val label = LabelUtils.createLabelFromString(null, label) ?: return null + val element = BuildReferenceManager.getInstance(project).resolveLabel(label) ?: return null + + val file = element.containingFile.virtualFile ?: return null + return OpenFileDescriptor(project, file, element.textRange.startOffset) + } +} \ No newline at end of file diff --git a/base/src/com/google/idea/blaze/base/buildview/events/BuildEventParser.kt b/base/src/com/google/idea/blaze/base/buildview/events/BuildEventParser.kt new file mode 100644 index 00000000000..4dc9b8ef89c --- /dev/null +++ b/base/src/com/google/idea/blaze/base/buildview/events/BuildEventParser.kt @@ -0,0 +1,21 @@ +package com.google.idea.blaze.base.buildview.events + +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent +import com.google.idea.blaze.base.scope.output.IssueOutput +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.extensions.ExtensionPointName + +internal val LOG = logger() + +interface BuildEventParser { + companion object { + val EP_NAME: ExtensionPointName = + ExtensionPointName.create("com.google.idea.blaze.BuildEventParser") + + fun parse(event: BuildEvent): IssueOutput? { + return EP_NAME.extensions.firstNotNullOfOrNull { it.parse(event) } + } + } + + fun parse(event: BuildEvent): IssueOutput? +} diff --git a/base/src/com/google/idea/blaze/base/command/BlazeCommand.java b/base/src/com/google/idea/blaze/base/command/BlazeCommand.java index ecfd96c7e8c..aabe390eb1b 100644 --- a/base/src/com/google/idea/blaze/base/command/BlazeCommand.java +++ b/base/src/com/google/idea/blaze/base/command/BlazeCommand.java @@ -56,6 +56,10 @@ public BlazeCommandName getName() { return name; } + public String getBinaryPath() { + return binaryPath; + } + public ImmutableList toArgumentList() { return ImmutableList.builder() .addAll(blazeStartupFlags) @@ -117,6 +121,10 @@ public Builder(String binaryPath, BlazeCommandName name, Project project) { .forEach(this::addBlazeFlags); } + public BlazeCommandName getName() { + return name; + } + private ImmutableList getArguments() { ImmutableList.Builder arguments = ImmutableList.builder(); arguments.addAll(blazeCmdlineFlags.build()); diff --git a/base/src/com/google/idea/blaze/base/command/CommandLineBlazeCommandRunner.java b/base/src/com/google/idea/blaze/base/command/CommandLineBlazeCommandRunner.java index d689fafd8cd..143dd3f253f 100644 --- a/base/src/com/google/idea/blaze/base/command/CommandLineBlazeCommandRunner.java +++ b/base/src/com/google/idea/blaze/base/command/CommandLineBlazeCommandRunner.java @@ -25,7 +25,6 @@ import com.google.idea.blaze.base.bazel.BazelExitCodeException.ThrowOption; import com.google.idea.blaze.base.command.buildresult.BuildResultHelper; import com.google.idea.blaze.base.command.buildresult.BuildResultHelper.GetArtifactsException; -import com.google.idea.blaze.base.command.buildresult.BuildResultHelperBep; import com.google.idea.blaze.base.command.buildresult.ParsedBepOutput; import com.google.idea.blaze.base.command.mod.BlazeModException; import com.google.idea.blaze.base.console.BlazeConsoleLineProcessorProvider; @@ -88,17 +87,9 @@ public BlazeBuildOutputs run( context.setHasError(); } context.output(SummaryOutput.output(SummaryOutput.Prefix.TIMESTAMP, "Build command finished. Retrieving BEP outputs ...")); - if (buildResultHelper instanceof BuildResultHelperBep) { - File outputFile = ((BuildResultHelperBep) buildResultHelper).getOutputFile(); - context.output(SummaryOutput.output(SummaryOutput.Prefix.TIMESTAMP, String.format("BEP file '%s' (%d bytes)", outputFile.getAbsolutePath(), outputFile.length()))); - } try { - Interner stringInterner = - Optional.ofNullable(context.getScope(SharedStringPoolScope.class)) - .map(SharedStringPoolScope::getStringInterner) - .orElse(null); context.output(SummaryOutput.output(SummaryOutput.Prefix.TIMESTAMP, "Parsing BEP outputs...")); - ParsedBepOutput buildOutput = buildResultHelper.getBuildOutput(stringInterner); + ParsedBepOutput buildOutput = buildResultHelper.getBuildOutput(); context.output(SummaryOutput.output(SummaryOutput.Prefix.TIMESTAMP, "Handling parsed BEP outputs...")); BlazeBuildOutputs blazeBuildOutputs = BlazeBuildOutputs.fromParsedBepOutput( buildResult, buildOutput); @@ -135,13 +126,7 @@ public BlazeTestResults runTest( return BlazeTestResults.NO_RESULTS; } context.output(PrintOutput.log("Build command finished. Retrieving BEP outputs...")); - try { - return buildResultHelper.getTestResults(Optional.empty()); - } catch (GetArtifactsException e) { - context.output(PrintOutput.log("Failed to get build outputs: " + e.getMessage())); - context.setHasError(); - return BlazeTestResults.NO_RESULTS; - } + return buildResultHelper.getTestResults(); } @Override diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventProtocolUtils.java b/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventProtocolUtils.java index 80af6c4aaf4..b3b41306792 100644 --- a/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventProtocolUtils.java +++ b/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventProtocolUtils.java @@ -28,6 +28,8 @@ public final class BuildEventProtocolUtils { // Instructs BEP to use local file paths (file://...) rather than objfs blobids. private static final String LOCAL_FILE_PATHS = "--nobuild_event_binary_file_path_conversion"; + // Instructs BEP to emit events for all actions. + private static final String PUBLISH_ALL_ACTIONS = "--build_event_publish_all_actions"; // A vm option overriding the directory used for the BEP output file. private static final String BEP_OUTPUT_FILE_VM_OVERRIDE = "bazel.bep.path"; @@ -55,7 +57,11 @@ public static File createTempOutputFile() { /** Returns a build flag instructing blaze to write build events to the given output file. */ public static ImmutableList getBuildFlags(File outputFile) { - return ImmutableList.of("--build_event_binary_file=" + outputFile.getPath(), LOCAL_FILE_PATHS); + return ImmutableList.of( + "--build_event_binary_file=" + outputFile.getPath(), + LOCAL_FILE_PATHS, + PUBLISH_ALL_ACTIONS + ); } /** diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventStreamProvider.java b/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventStreamProvider.java index 8cc55a8633c..6229c3b1ebb 100644 --- a/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventStreamProvider.java +++ b/base/src/com/google/idea/blaze/base/command/buildresult/BuildEventStreamProvider.java @@ -55,17 +55,10 @@ static BuildEventStreamProvider fromInputStream(InputStream stream) { public BuildEvent getNext() throws BuildEventStreamException { return parseNextEventFromStream(countingStream); } - - @Override - public long getBytesConsumed() { - return countingStream.getCount(); - } }; } /** Returns the next build event in the stream, or null if there are none remaining. */ @Nullable BuildEventStreamProtos.BuildEvent getNext() throws BuildEventStreamException; - - long getBytesConsumed(); } diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.java b/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.java deleted file mode 100644 index 8e7a6cc95ee..00000000000 --- a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2017 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. - */ -package com.google.idea.blaze.base.command.buildresult; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Interner; -import com.google.idea.blaze.base.model.primitives.Label; -import com.google.idea.blaze.base.run.testlogs.BlazeTestResults; -import com.google.idea.blaze.base.scope.BlazeContext; -import com.google.idea.blaze.common.artifact.OutputArtifact; -import com.google.idea.blaze.exception.BuildException; -import java.io.InputStream; -import java.util.List; -import java.util.Optional; -import java.util.function.Consumer; -import java.util.function.Predicate; - -/** Assists in getting build artifacts from a build operation. */ -public interface BuildResultHelper extends AutoCloseable { - - /** - * Returns the build flags necessary for the build result helper to work. - * - *

The user must add these flags to their build command. - */ - List getBuildFlags(); - - /** - * Parses the BEP output data and returns the corresponding {@link ParsedBepOutput}. May only be - * called once, after the build is complete. - * - *

As BEP retrieval can be memory-intensive for large projects, implementations of - * getBuildOutput may restrict parallelism for cases in which many builds are executed in parallel - * (e.g. remote builds). - */ - default ParsedBepOutput getBuildOutput() throws GetArtifactsException { - return getBuildOutput(Optional.empty()); - } - - /** - * Parses the BEP output data and returns the corresponding {@link ParsedBepOutput}. May only be - * called once, after the build is complete. - * - *

As BEP retrieval can be memory-intensive for large projects, implementations of - * getBuildOutput may restrict parallelism for cases in which many builds are executed in parallel - * (e.g. remote builds). - */ - default ParsedBepOutput getBuildOutput(Interner stringInterner) - throws GetArtifactsException { - return getBuildOutput(Optional.empty(), stringInterner); - } - - /** - * Parses the BEP output data and returns the corresponding {@link ParsedBepOutput}. May only be - * called once, after the build is complete. - * - *

As BEP retrieval can be memory-intensive for large projects, implementations of - * getBuildOutput may restrict parallelism for cases in which many builds are executed in parallel - * (e.g. remote builds). - */ - default ParsedBepOutput getBuildOutput( - Optional completionBuildId, Interner stringInterner) - throws GetArtifactsException { - return getBuildOutput(completionBuildId); - } - - /** - * Retrieves BEP build events according to given id, parses them and returns the corresponding - * {@link ParsedBepOutput}. May only be called once, after the build is complete. - * - *

As BEP retrieval can be memory-intensive for large projects, implementations of - * getBuildOutput may restrict parallelism for cases in which many builds are executed in parallel - * (e.g. remote builds). - */ - ParsedBepOutput getBuildOutput(Optional completedBuildId) throws GetArtifactsException; - - /** - * Retrieves test results, parses them and returns the corresponding {@link BlazeTestResults}. May - * only be called once, after the build is complete. - */ - BlazeTestResults getTestResults(Optional completedBuildId) throws GetArtifactsException; - - /** Deletes the local BEP output file associated with the test results */ - default void deleteTemporaryOutputFiles() {} - - /** - * Parses the BEP output data to collect all build flags used. Return all flags that pass filters - */ - BuildFlags getBlazeFlags(Optional completedBuildId) throws GetFlagsException; - - /** - * Parses the BEP output data to collect message on stdout. - * - *

This function is designed for remote build which does not have local console output. Local - * build should not use this since {@link ExternalTask} provide stdout handler. - * - * @param completedBuildId build id. - * @param stderrConsumer process stderr - * @param blazeContext blaze context may contains logging scope - * @return a list of message on stdout. - */ - default InputStream getStdout( - String completedBuildId, Consumer stderrConsumer, BlazeContext blazeContext) - throws BuildException { - return InputStream.nullInputStream(); - } - - /** - * Parses the BEP output data to collect message on stderr. - * - *

This function is designed for remote build which does not have local console output. Local - * build should not use this since {@link ExternalTask} provide stderr handler. - * - * @param completedBuildId build id. - * @return a list of message on stderr. - */ - default InputStream getStderr(String completedBuildId) throws BuildException { - return InputStream.nullInputStream(); - } - - /** - * Parses the BEP output data to collect all build flags used. Return all flags that pass filters - */ - default BuildFlags getBlazeFlags() throws GetFlagsException { - return getBlazeFlags(Optional.empty()); - } - - /** - * Returns the build result. May only be called once, after the build is complete, or no artifacts - * will be returned. - * - * @return The build artifacts from the build operation. - */ - default ImmutableList getAllOutputArtifacts(Predicate pathFilter) - throws GetArtifactsException { - return getBuildOutput().getAllOutputArtifacts(pathFilter).asList(); - } - - /** - * Returns the build artifacts, filtering out all artifacts not directly produced by the specified - * target. - * - *

May only be called once, after the build is complete, or no artifacts will be returned. - */ - default ImmutableList getBuildArtifactsForTarget( - Label target, Predicate pathFilter) throws GetArtifactsException { - return getBuildOutput().getDirectArtifactsForTarget(target, pathFilter).asList(); - } - - /** - * Returns all build artifacts belonging to the given output groups. May only be called once, - * after the build is complete, or no artifacts will be returned. - */ - default ImmutableList getArtifactsForOutputGroup( - String outputGroup, Predicate pathFilter) throws GetArtifactsException { - return getBuildOutput().getOutputGroupArtifacts(outputGroup, pathFilter); - } - - @Override - void close(); - - /** Indicates a failure to get artifact information */ - class GetArtifactsException extends BuildException { - public GetArtifactsException(Throwable cause) { - super(cause); - } - - public GetArtifactsException(String message) { - super(message); - } - - public GetArtifactsException(String message, Throwable cause) { - super(message, cause); - } - } - - /** Indicates a failure to get artifact information */ - class GetFlagsException extends Exception { - public GetFlagsException(String message, Throwable cause) { - super(message, cause); - } - - public GetFlagsException(String message) { - super(message); - } - - public GetFlagsException(Throwable cause) { - super(cause); - } - } -} diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.kt b/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.kt new file mode 100644 index 00000000000..00d7f33e81a --- /dev/null +++ b/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelper.kt @@ -0,0 +1,135 @@ +/* + * Copyright 2017 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. + */ +package com.google.idea.blaze.base.command.buildresult + +import com.google.common.collect.ImmutableList +import com.google.common.collect.ImmutableSet +import com.google.devtools.build.lib.buildeventstream.BuildEventStreamProtos.BuildEvent +import com.google.idea.blaze.base.command.buildresult.BuildEventStreamProvider.BuildEventStreamException +import com.google.idea.blaze.base.model.primitives.Label +import com.google.idea.blaze.base.run.testlogs.BlazeTestResults +import com.google.idea.blaze.common.artifact.OutputArtifact +import com.google.idea.blaze.exception.BuildException +import com.intellij.openapi.diagnostic.Logger +import java.io.BufferedInputStream +import java.io.File +import java.io.FileInputStream +import java.io.IOException +import java.util.* +import java.util.function.Predicate + +private val LOG = Logger.getInstance(BuildResultHelper::class.java) + +/** + * Build event protocol implementation to get build results. + * + * The build even protocol (BEP for short) is a proto-based protocol used by bazel to communicate + * build events. + */ +class BuildResultHelper(val outputFile: File) : AutoCloseable { + + constructor() : this(BuildEventProtocolUtils.createTempOutputFile()) + + /** + * Returns the build flags necessary for the build result helper to work. + * + *

The user must add these flags to their build command. + */ + fun getBuildFlags(): List = BuildEventProtocolUtils.getBuildFlags(outputFile) + + /** + * Parses the BEP output data and returns the corresponding {@link ParsedBepOutput}. + */ + @Throws(GetArtifactsException::class) + fun getBuildOutput(): ParsedBepOutput { + return try { + BufferedInputStream(FileInputStream(outputFile)).use(ParsedBepOutput::parseBepArtifacts) + } catch (e: IOException) { + LOG.error(e) + throw GetArtifactsException(e.message) + } catch (e: BuildEventStreamException) { + LOG.error(e) + throw GetArtifactsException(e.message) + } + } + + /** + * Parses the BEP output data and returns the corresponding {@link ParsedBepOutput}. + */ + fun getTestResults(): BlazeTestResults { + return try { + BufferedInputStream(FileInputStream(outputFile)).use(BuildEventProtocolOutputReader::parseTestResults) + } catch (e: IOException) { + LOG.warn(e) + return BlazeTestResults.NO_RESULTS + } catch (e: BuildEventStreamException) { + LOG.warn(e) + return BlazeTestResults.NO_RESULTS + } + } + + fun deleteTemporaryOutputFiles() { + outputFile.delete() + } + + @Throws(GetFlagsException::class) + fun getBlazeFlags(): BuildFlags { + return try { + BufferedInputStream(FileInputStream(outputFile)).use(BuildFlags::parseBep) + } catch (e: IOException) { + throw GetFlagsException(e) + } catch (e: BuildEventStreamException) { + throw GetFlagsException(e) + } + } + + /** + * Returns the build artifacts, filtering out all artifacts not directly produced by the specified + * target. + */ + @Throws(GetArtifactsException::class) + fun getBuildArtifactsForTarget( + target: Label, + pathFilter: Predicate, + ): ImmutableSet { + return getBuildOutput().getDirectArtifactsForTarget(target, pathFilter) + } + + /** + * Returns all build artifacts belonging to the given output groups. + */ + @Throws(GetArtifactsException::class) + fun getArtifactsForOutputGroup( + outputGroup: String, + pathFilter: Predicate, + ): ImmutableList { + return getBuildOutput().getOutputGroupArtifacts(outputGroup, pathFilter) + } + + override fun close() { + deleteTemporaryOutputFiles() + } + + class GetArtifactsException : BuildException { + constructor(cause: Throwable?) : super(cause) + + constructor(message: String?) : super(message) + + constructor(message: String?, cause: Throwable?) : super(message, cause) + } + + class GetFlagsException(cause: Throwable?) : Exception(cause) +} diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperBep.java b/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperBep.java deleted file mode 100644 index bfb24bda2f9..00000000000 --- a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperBep.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2017 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. - */ -package com.google.idea.blaze.base.command.buildresult; - -import com.google.idea.blaze.base.command.buildresult.BuildEventStreamProvider.BuildEventStreamException; -import com.google.idea.blaze.base.io.InputStreamProvider; -import com.google.idea.blaze.base.run.testlogs.BlazeTestResults; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.Optional; -import org.jetbrains.annotations.VisibleForTesting; - -/** - * Build event protocol implementation to get build results. - * - *

The build even protocol (BEP for short) is a proto-based protocol used by bazel to communicate - * build events. - */ -public class BuildResultHelperBep implements BuildResultHelper { - - private static final Logger logger = Logger.getInstance(BuildResultHelperBep.class); - private final File outputFile; - - public BuildResultHelperBep() { - outputFile = BuildEventProtocolUtils.createTempOutputFile(); - } - - @VisibleForTesting - public BuildResultHelperBep(File outputFile) { - this.outputFile = outputFile; - } - - @Override - public List getBuildFlags() { - return BuildEventProtocolUtils.getBuildFlags(outputFile); - } - - @Override - public ParsedBepOutput getBuildOutput(Optional completedBuildId) - throws GetArtifactsException { - try (InputStream inputStream = new BufferedInputStream(new FileInputStream(outputFile))) { - return ParsedBepOutput.parseBepArtifacts(inputStream); - } catch (IOException | BuildEventStreamException e) { - logger.error(e); - throw new GetArtifactsException(e.getMessage()); - } - } - - @Override - public BlazeTestResults getTestResults(Optional completedBuildId) { - try (InputStream inputStream = - new BufferedInputStream(InputStreamProvider.getInstance().forFile(outputFile))) { - return BuildEventProtocolOutputReader.parseTestResults(inputStream); - } catch (IOException | BuildEventStreamException e) { - logger.warn(e); - return BlazeTestResults.NO_RESULTS; - } - } - - @Override - public void deleteTemporaryOutputFiles() { - if (!outputFile.delete()) { - logger.warn("Could not delete BEP output file: " + outputFile); - } - } - - @Override - public BuildFlags getBlazeFlags(Optional completedBuildId) throws GetFlagsException { - try (InputStream inputStream = new BufferedInputStream(new FileInputStream(outputFile))) { - return BuildFlags.parseBep(inputStream); - } catch (IOException | BuildEventStreamException e) { - throw new GetFlagsException(e); - } - } - - @Override - public void close() { - if (!outputFile.delete()) { - logger.warn("Could not delete BEP output file: " + outputFile); - } - } - - public File getOutputFile() { - return outputFile; - } - - static class Provider implements BuildResultHelperProvider { - - @Override - public Optional doCreateForLocalBuild(Project project) { - return Optional.of(new BuildResultHelperBep()); - } - } -} diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperProvider.java b/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperProvider.java deleted file mode 100644 index f8798190f6c..00000000000 --- a/base/src/com/google/idea/blaze/base/command/buildresult/BuildResultHelperProvider.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 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. - */ -package com.google.idea.blaze.base.command.buildresult; - -import com.google.errorprone.annotations.MustBeClosed; -import com.google.idea.blaze.base.bazel.BuildSystem.BuildInvoker; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.project.Project; -import java.util.Optional; - -/** - * Determines which {@link BuildResultHelper} to use for the current project. - * - * @deprecated Use {@link BuildInvoker#createBuildResultProvider()} instead which will create a - * result helper appropriate for that build invoker. - */ -@Deprecated -public interface BuildResultHelperProvider { - - ExtensionPointName EP_NAME = - ExtensionPointName.create("com.google.idea.blaze.BuildResultHelperProvider"); - - /** - * Constructs a BuildResultHelper that supports a local BEP and artifacts. This is required - * because parts of Blaze Plugin implicitly depended on a {@link BuildResultHelper} corresponding - * to local builds. - * - * @deprecated All consumers should be migrated to use {@link - * com.google.idea.blaze.base.bazel.BuildSystem#getBuildInvoker(Project)} and {handle local or - * {@link BuildInvoker#createBuildResultProvider()}. - */ - @Deprecated - Optional doCreateForLocalBuild(Project project); - - /** - * Constructs a new build result helper for local builds. - * - * @deprecated Use {@link BuildInvoker#createBuildResultProvider()} instead which will create a - * result helper appropriate for that build invoker. - */ - @Deprecated - @MustBeClosed - static BuildResultHelper createForLocalBuild(Project project) { - for (BuildResultHelperProvider extension : EP_NAME.getExtensions()) { - Optional helper = extension.doCreateForLocalBuild(project); - if (helper.isPresent()) { - return helper.get(); - } - } - return new BuildResultHelperBep(); - } -} diff --git a/base/src/com/google/idea/blaze/base/command/buildresult/ParsedBepOutput.java b/base/src/com/google/idea/blaze/base/command/buildresult/ParsedBepOutput.java index 8919bfcf609..7027fb608d7 100644 --- a/base/src/com/google/idea/blaze/base/command/buildresult/ParsedBepOutput.java +++ b/base/src/com/google/idea/blaze/base/command/buildresult/ParsedBepOutput.java @@ -71,7 +71,6 @@ public final class ParsedBepOutput { ImmutableSetMultimap.of(), 0, BuildResult.SUCCESS, - 0, ImmutableSet.of()); private static final String WORKSPACE_ITEM_KEY_SOURCE_URI = "SOURCE_URI"; @@ -200,7 +199,6 @@ public static ParsedBepOutput parseBepArtifacts( targetToFileSets.build(), startTimeMillis, buildResult, - stream.getBytesConsumed(), targetsWithErrors.build()); } @@ -260,7 +258,6 @@ private static ImmutableMap fillInTransitiveFileSetData( final long syncStartTimeMillis; private final BuildResult buildResult; - private final long bepBytesConsumed; private final ImmutableSet