Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Sync View #6813

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions aswb/aswb.bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ test_sources:
*/testcompat/unittests*
*/testcompat/integrationtests*
*/testcompat/utils/integration*

additional_languages:
kotlin

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -45,7 +47,7 @@ public class BlazeApkDeployInfoProtoHelper {
public AndroidDeployInfo readDeployInfoProtoForTarget(
Label target, BuildResultHelper buildResultHelper, Predicate<String> pathFilter)
throws GetDeployInfoException {
ImmutableList<OutputArtifact> outputArtifacts;
ImmutableSet<OutputArtifact> outputArtifacts;
try {
outputArtifacts = buildResultHelper.getBuildArtifactsForTarget(target, pathFilter);
} catch (GetArtifactsException e) {
Expand All @@ -62,7 +64,7 @@ public AndroidDeployInfo readDeployInfoProtoForTarget(
log.warn(outputArtifact.getRelativePath() + " -> " + outputArtifact.getRelativePath());
}
log.warn("All local artifacts for " + target + ":");
List<OutputArtifact> allBuildArtifacts =
ImmutableSet<OutputArtifact> allBuildArtifacts =
buildResultHelper.getBuildArtifactsForTarget(target, path -> true);
List<File> allLocalFiles = LocalFileArtifact.getLocalFiles(allBuildArtifacts);
for (File file : allLocalFiles) {
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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<Void> unusedFuture =
FileCaches.refresh(
project,
context,
BlazeBuildOutputs.noOutputs(BuildResult.fromExitCode(retVal)));
} catch (GetArtifactsException e) {
LOG.error(e.getMessage());
}
return !context.hasErrors();
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -327,7 +327,7 @@ private ImmutableList<AndroidResourceModule> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,8 +111,7 @@ static Consumer<Output> 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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,15 @@ 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<ArtifactLocation, Integer> entry : interestingDirectories.entrySet()) {
context.accept(
IssueOutput.warn(
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());
}
}
Expand All @@ -98,7 +93,7 @@ public static void submit(
unusedAllowlistEntries.size(),
GeneratedAndroidResourcesSection.KEY.getName(),
String.join("\n ", unusedAllowlistEntries)))
.inFile(projectViewFile)
.withFile(projectViewFile)
.build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,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",
Expand Down
9 changes: 7 additions & 2 deletions base/src/META-INF/blaze-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@
<registryKey defaultValue="true"
description="Causes the plugin to read external workspace data, enabling features such as code completion for external targets. This may incur the cost of an additional 'bazel mod' call, which could cause issues with older versions or setups."
key="bazel.read.external.workspace.data"/>
<registryKey defaultValue="true"
description="Enables the new sync view"
key="bazel.new.sync.view"/>
<editorNotificationProvider implementation="com.google.idea.blaze.base.wizard2.BazelNotificationProvider"/>
</extensions>

Expand Down Expand Up @@ -587,6 +590,7 @@
<extensionPoint qualifiedName="com.google.idea.blaze.OutputGroupsProvider" interface="com.google.idea.blaze.base.sync.aspects.strategy.OutputGroupsProvider"/>
<extensionPoint qualifiedName="com.google.idea.blaze.ExperimentLoader" interface="com.google.idea.common.experiments.ExperimentLoader"/>
<extensionPoint qualifiedName="com.google.idea.blaze.EmptyLibraryFilterSettings" interface="com.google.idea.blaze.java.sync.importer.emptylibrary.EmptyLibraryFilterSettings" />
<extensionPoint qualifiedName="com.google.idea.blaze.BuildEventParser" interface="com.google.idea.blaze.base.buildview.events.BuildEventParser" />
</extensionPoints>

<extensions defaultExtensionNs="com.google.idea.blaze">
Expand All @@ -612,7 +616,6 @@
<VcsHandler implementation="com.google.idea.blaze.base.vcs.FallbackBlazeVcsHandlerProvider" order="last" id="fallback"/>
<BuildSystemProvider implementation="com.google.idea.blaze.base.bazel.BazelBuildSystemProvider" id="BazelBuildSystemProvider" order="last"/>
<BuildifierBinaryProvider implementation="com.google.idea.blaze.base.buildmodifier.DefaultBuildifierBinaryProvider"/>
<BuildResultHelperProvider order="last" implementation="com.google.idea.blaze.base.command.buildresult.BuildResultHelperBep$Provider"/>
<BlazeCommandRunConfigurationHandlerProvider implementation="com.google.idea.blaze.base.run.confighandler.PendingTargetRunConfigurationHandlerProvider"/>
<BlazeCommandRunConfigurationHandlerProvider implementation="com.google.idea.blaze.base.run.confighandler.BlazeCommandGenericRunConfigurationHandlerProvider" order="last"/>
<AttributeSpecificStringLiteralReferenceProvider implementation="com.google.idea.blaze.base.lang.buildfile.references.VisibilityReferenceProvider"/>
Expand Down Expand Up @@ -680,7 +683,9 @@
<ExperimentLoader implementation="com.google.idea.common.experiments.SystemPropertyExperimentLoader" order="first" id="SystemPropertyExperimentLoader"/>
<ExperimentLoader implementation="com.google.idea.common.experiments.UserOverridesExperimentLoader" order="after SystemPropertyExperimentLoader" id="UserOverridesExperimentLoader"/>
<ExperimentLoader implementation="com.google.idea.common.experiments.DefaultValuesExperimentLoader" order="last" id="DefaultValuesExperimentLoader"/>
<BlazeGuard implementation="com.google.idea.blaze.base.execution.TrustedProjectGuard"/>
<BlazeGuard implementation="com.google.idea.blaze.base.execution.TrustedProjectGuard"/>
<BuildEventParser implementation="com.google.idea.blaze.base.buildview.events.AbortedParser"/>
<BuildEventParser implementation="com.google.idea.blaze.base.buildview.events.ActionCompletedParser"/>
</extensions>

<extensions defaultExtensionNs="com.google.idea.blaze.qsync">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.google.idea.blaze.base.async.executor

import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.TaskInfo
import com.intellij.openapi.wm.ex.ProgressIndicatorEx

object ProgressIndicatorStub : ProgressIndicatorEx {
override fun start() { }

override fun stop() { }

override fun isRunning(): Boolean { return false }

override fun cancel() { }

override fun isCanceled(): Boolean { return false }

override fun setText(p0: String?) { }

override fun getText(): String { return "" }

override fun setText2(p0: String?) { }

override fun getText2(): String { return "" }

override fun getFraction(): Double { return 0.0 }

override fun setFraction(p0: Double) { }

override fun pushState() { }

override fun popState() { }

override fun isModal(): Boolean { return false }

override fun getModalityState(): ModalityState { return ModalityState.NON_MODAL /* required for backwards compatability */ }

override fun setModalityProgress(p0: ProgressIndicator?) { }

override fun isIndeterminate(): Boolean { return false; }

override fun setIndeterminate(p0: Boolean) { }

override fun checkCanceled() { }

override fun isPopupWasShown(): Boolean { return false; }

override fun isShowing(): Boolean { return false; }

override fun addStateDelegate(p0: ProgressIndicatorEx) { }

override fun finish(p0: TaskInfo) { }

override fun isFinished(p0: TaskInfo): Boolean { return false; }

override fun wasStarted(): Boolean { return false; }

override fun processFinish() { }

override fun initStateFrom(p0: ProgressIndicator) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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;
Expand Down Expand Up @@ -104,6 +105,10 @@ public void submitTaskLater(Progressive progressive) {
* progress dialog.
*/
public <T> ListenableFuture<T> submitTaskWithResult(ProgressiveWithResult<T> progressive) {
if (modality == Modality.BUILD_VIEW) {
return executor.submit(() -> progressive.compute(ProgressIndicatorStub.INSTANCE));
}

// The progress indicator must be created on the UI thread.
final ProgressWindow indicator =
UIUtil.invokeAndWaitIfNeeded(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +94,7 @@ public boolean supportsParallelism() {
@Override
@MustBeClosed
public BuildResultHelper createBuildResultHelper() {
return new BuildResultHelperBep();
return new BuildResultHelper();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading