Skip to content

Commit

Permalink
Prepare IconManagerCompat for asdev update
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 556759207
  • Loading branch information
Googler authored and copybara-github committed Aug 14, 2023
1 parent 69872d9 commit 742c455
Show file tree
Hide file tree
Showing 21 changed files with 326 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.android.run.testrecorder;

import com.android.annotations.Nullable;
import com.android.ddmlib.IDevice;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner;
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.intellij.execution.runners.ExecutionEnvironment;
import java.util.List;

/** Compat class for implementing TestRecorderBlazeCommandRunConfigurationProxy. */
public class TestRecorderBlazeCommandRunConfigurationProxy
extends TestRecorderBlazeCommandRunConfigurationProxyBase {

public TestRecorderBlazeCommandRunConfigurationProxy(
BlazeCommandRunConfiguration baseConfiguration) {
super(baseConfiguration);
}

@Override
@Nullable
public List<ListenableFuture<IDevice>> getDeviceFutures(ExecutionEnvironment environment) {
return environment
.getCopyableUserData(BlazeAndroidRunConfigurationRunner.DEVICE_SESSION_KEY)
.deviceFutures
.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.android.run.testrecorder;

import com.android.annotations.Nullable;
import com.android.ddmlib.IDevice;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner;
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.intellij.execution.runners.ExecutionEnvironment;
import java.util.List;

/** Compat class for implementing TestRecorderBlazeCommandRunConfigurationProxy. */
public class TestRecorderBlazeCommandRunConfigurationProxy
extends TestRecorderBlazeCommandRunConfigurationProxyBase {

public TestRecorderBlazeCommandRunConfigurationProxy(
BlazeCommandRunConfiguration baseConfiguration) {
super(baseConfiguration);
}

@Override
@Nullable
public List<ListenableFuture<IDevice>> getDeviceFutures(ExecutionEnvironment environment) {
return environment
.getCopyableUserData(BlazeAndroidRunConfigurationRunner.DEVICE_SESSION_KEY)
.deviceFutures
.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.android.run.testrecorder;

import com.android.annotations.Nullable;
import com.android.ddmlib.IDevice;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner;
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.intellij.execution.runners.ExecutionEnvironment;
import java.util.List;

/** Compat class for implementing TestRecorderBlazeCommandRunConfigurationProxy. */
public class TestRecorderBlazeCommandRunConfigurationProxy
extends TestRecorderBlazeCommandRunConfigurationProxyBase {

public TestRecorderBlazeCommandRunConfigurationProxy(
BlazeCommandRunConfiguration baseConfiguration) {
super(baseConfiguration);
}

@Override
@Nullable
public List<ListenableFuture<IDevice>> getDeviceFutures(ExecutionEnvironment environment) {
return environment
.getCopyableUserData(BlazeAndroidRunConfigurationRunner.DEVICE_SESSION_KEY)
.deviceFutures
.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.blaze.android.run.testrecorder;

import com.android.annotations.Nullable;
import com.android.ddmlib.IDevice;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner;
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.intellij.execution.runners.ExecutionEnvironment;
import java.util.List;

/** Compat class for implementing TestRecorderBlazeCommandRunConfigurationProxy. */
public class TestRecorderBlazeCommandRunConfigurationProxy
extends TestRecorderBlazeCommandRunConfigurationProxyBase {

public TestRecorderBlazeCommandRunConfigurationProxy(
BlazeCommandRunConfiguration baseConfiguration) {
super(baseConfiguration);
}

@Override
@Nullable
public List<ListenableFuture<IDevice>> getDeviceFutures(ExecutionEnvironment environment) {
return environment
.getCopyableUserData(BlazeAndroidRunConfigurationRunner.DEVICE_SESSION_KEY)
.deviceFutures
.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,23 @@
*/
package com.google.idea.blaze.android.run.testrecorder;

import com.android.annotations.Nullable;
import com.android.ddmlib.IDevice;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.gct.testrecorder.run.TestRecorderRunConfigurationProxy;
import com.google.idea.blaze.android.run.binary.BlazeAndroidBinaryRunConfigurationHandler;
import com.google.idea.blaze.android.run.binary.BlazeAndroidBinaryRunConfigurationState;
import com.google.idea.blaze.android.run.runner.BlazeAndroidRunConfigurationRunner;
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.blaze.base.sync.projectstructure.ModuleFinder;
import com.intellij.execution.configurations.LocatableConfigurationBase;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.module.Module;
import java.util.List;

/** {@link TestRecorderRunConfigurationProxy} for blaze. */
public class TestRecorderBlazeCommandRunConfigurationProxy
public abstract class TestRecorderBlazeCommandRunConfigurationProxyBase
implements TestRecorderRunConfigurationProxy {

private final BlazeCommandRunConfiguration myBaseConfiguration;
private final BlazeAndroidBinaryRunConfigurationHandler myBaseConfigurationHandler;

public TestRecorderBlazeCommandRunConfigurationProxy(
public TestRecorderBlazeCommandRunConfigurationProxyBase(
BlazeCommandRunConfiguration baseConfiguration) {
myBaseConfiguration = baseConfiguration;
myBaseConfigurationHandler =
Expand Down Expand Up @@ -74,13 +68,4 @@ public String getLaunchActivityClass() {

return "";
}

@Nullable
@Override
public List<ListenableFuture<IDevice>> getDeviceFutures(ExecutionEnvironment environment) {
return environment
.getCopyableUserData(BlazeAndroidRunConfigurationRunner.DEVICE_SESSION_KEY)
.deviceFutures
.get();
}
}
1 change: 1 addition & 0 deletions base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ java_library(
"//intellij_platform_sdk:plugin_api_for_tests",
"//intellij_platform_sdk:test_libs",
"//proto:proto_deps",
"//sdkcompat",
"//shared:vcs",
"//testing:lib",
"@bazel_tools//tools/java/runfiles",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.sdkcompat.ui.icons.IconManagerCompat;
import com.google.idea.testing.FunctionalHeadlessDataManager;
import com.intellij.execution.Location;
import com.intellij.execution.PsiLocation;
Expand All @@ -40,8 +41,6 @@
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.MapDataContext;
import com.intellij.testFramework.ServiceContainerUtil;
import com.intellij.ui.CoreIconManager;
import com.intellij.ui.IconManager;
import java.util.Arrays;
import javax.annotation.Nullable;
import org.junit.After;
Expand Down Expand Up @@ -71,15 +70,14 @@ public final void doSetup() throws Throwable {

// IntelliJ will use a dummy icon manager that returns the same exact icon.
// This will cause uniqueness issues for gutter icons.
IconManager.activate(new CoreIconManager());
IconManagerCompat.activateCoreIconManager();
}

@After
public final void doTeardown() {
ServiceContainerUtil.registerServiceInstance(
ApplicationManager.getApplication(), DataManager.class, defaultDataManager);

IconManager.deactivate();
IconManagerCompat.deactivate();
}

protected PsiFile createAndIndexFile(WorkspacePath path, String... contents) throws Throwable {
Expand Down
1 change: 1 addition & 0 deletions sdkcompat/asdev/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/psi/**",
"com/google/idea/sdkcompat/python/**",
"com/google/idea/sdkcompat/ui/icons/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.ui.icons;

import com.intellij.ui.CoreIconManager;
import com.intellij.ui.IconManager;

/** Compat class for IconManager. */
public class IconManagerCompat {

private IconManagerCompat() {}

public static void activateCoreIconManager() throws Throwable {
IconManager.activate(new CoreIconManager());
}

public static void deactivate() {
IconManager.deactivate();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v222/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ java_library(
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/psi/**",
"com/google/idea/sdkcompat/python/**",
"com/google/idea/sdkcompat/ui/icons/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.ui.icons;

import com.intellij.ui.CoreIconManager;
import com.intellij.ui.IconManager;

/** Compat class for IconManager. */
public class IconManagerCompat {

private IconManagerCompat() {}

public static void activateCoreIconManager() throws Throwable {
IconManager.activate(new CoreIconManager());
}

public static void deactivate() {
IconManager.deactivate();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v223/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/psi/**",
"com/google/idea/sdkcompat/python/**",
"com/google/idea/sdkcompat/ui/icons/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2023 The Bazel Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.idea.sdkcompat.ui.icons;

import com.intellij.ui.CoreIconManager;
import com.intellij.ui.IconManager;

/** Compat class for IconManager. */
public class IconManagerCompat {

private IconManagerCompat() {}

public static void activateCoreIconManager() throws Throwable {
IconManager.activate(new CoreIconManager());
}

public static void deactivate() {
IconManager.deactivate();
}
}
1 change: 1 addition & 0 deletions sdkcompat/v231/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ java_library(
"com/google/idea/sdkcompat/platform/**",
"com/google/idea/sdkcompat/psi/**",
"com/google/idea/sdkcompat/python/**",
"com/google/idea/sdkcompat/ui/icons/**",
"com/google/idea/sdkcompat/vcs/**",
]) + select_for_ide(
android_studio = glob([
Expand Down
Loading

0 comments on commit 742c455

Please sign in to comment.