Skip to content

Commit

Permalink
Import Android Studio 2023.2.1 Canary 4 (2023.2.1.4)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 565774266
  • Loading branch information
Googler authored and copybara-github committed Sep 20, 2023
1 parent 60b46f3 commit ac5c231
Show file tree
Hide file tree
Showing 10 changed files with 341 additions and 57 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ http_archive(

http_archive(
name = "rules_java",
sha256 = "7b0d9ba216c821ee8697dedc0f9d0a705959ace462a3885fe9ba0347ba950111",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.5.1/rules_java-6.5.1.tar.gz",
],
sha256 = "7b0d9ba216c821ee8697dedc0f9d0a705959ace462a3885fe9ba0347ba950111",
)

# LICENSE: Common Public License 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2016 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.resources;

import com.android.tools.idea.projectsystem.LightResourceClassService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.common.experiments.FeatureRolloutExperiment;
import com.intellij.openapi.module.Module;
import com.intellij.psi.PsiClass;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/** Implementation of {@link LightResourceClassService} set up at Blaze sync time. */
public abstract class BlazeLightResourceClassServiceBase implements LightResourceClassService {

@VisibleForTesting
public static final FeatureRolloutExperiment workspaceResourcesFeature =
new FeatureRolloutExperiment("aswb.workspace.light.class.enabled");

Map<String, BlazeRClass> rClasses = Maps.newHashMap();
Map<Module, BlazeRClass> rClassesByModule = Maps.newHashMap();
final Set<BlazeRClass> allRClasses = Sets.newHashSet();

@Override
public Collection<? extends PsiClass> getLightRClassesAccessibleFromModule(
Module module, boolean includeTest) {
if (workspaceResourcesFeature.isEnabled()
&& module.getName().equals(BlazeDataStorage.WORKSPACE_MODULE_NAME)) {
// Returns all the packages in resource modules, and all the workspace packages that
// have previously been asked for. All `res/` directories in our project should belong to a
// resource module. For java sources, IntelliJ will ask for explicit resource package by
// calling `getLightRClasses` at which point we can create the package. This is not completely
// correct and the autocomplete will be slightly off when initial `R` is typed in the editor,
// but this workaround is being used to mitigate issues (b/136685602) while resources
// are re-worked.
return allRClasses;
} else {
return rClasses.values();
}
}

@Override
public Collection<? extends PsiClass> getLightRClassesDefinedByModule(
Module module, boolean includeTestClasses) {
BlazeRClass rClass = rClassesByModule.get(module);
return rClass == null ? ImmutableSet.of() : ImmutableSet.of(rClass);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2016 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.resources;

import com.android.tools.idea.projectsystem.LightResourceClassService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.common.experiments.FeatureRolloutExperiment;
import com.intellij.openapi.module.Module;
import com.intellij.psi.PsiClass;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/** Implementation of {@link LightResourceClassService} set up at Blaze sync time. */
public abstract class BlazeLightResourceClassServiceBase implements LightResourceClassService {

@VisibleForTesting
public static final FeatureRolloutExperiment workspaceResourcesFeature =
new FeatureRolloutExperiment("aswb.workspace.light.class.enabled");

Map<String, BlazeRClass> rClasses = Maps.newHashMap();
Map<Module, BlazeRClass> rClassesByModule = Maps.newHashMap();
final Set<BlazeRClass> allRClasses = Sets.newHashSet();

@Override
public Collection<? extends PsiClass> getLightRClassesAccessibleFromModule(
Module module, boolean includeTest) {
if (workspaceResourcesFeature.isEnabled()
&& module.getName().equals(BlazeDataStorage.WORKSPACE_MODULE_NAME)) {
// Returns all the packages in resource modules, and all the workspace packages that
// have previously been asked for. All `res/` directories in our project should belong to a
// resource module. For java sources, IntelliJ will ask for explicit resource package by
// calling `getLightRClasses` at which point we can create the package. This is not completely
// correct and the autocomplete will be slightly off when initial `R` is typed in the editor,
// but this workaround is being used to mitigate issues (b/136685602) while resources
// are re-worked.
return allRClasses;
} else {
return rClasses.values();
}
}

@Override
public Collection<? extends PsiClass> getLightRClassesDefinedByModule(
Module module, boolean includeTestClasses) {
BlazeRClass rClass = rClassesByModule.get(module);
return rClass == null ? ImmutableSet.of() : ImmutableSet.of(rClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@

import com.android.ddmlib.Client;
import com.android.ddmlib.ClientData;
import com.android.tools.ndk.run.editor.AutoAndroidDebuggerState;
import com.intellij.execution.ExecutionException;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebugSession;
import org.jetbrains.annotations.NotNull;

/** Shim for #api212 compat. */
public class BlazeAutoAndroidDebugger extends BlazeAutoAndroidDebuggerBase {

@Override
public XDebugSession attachToClient(
Project project, Client client, AutoAndroidDebuggerState state) throws ExecutionException {
public XDebugSession getExistingDebugSession(@NotNull Project project, @NotNull Client client) {
if (isNativeProject(project)) {
log.info("Project has native development enabled. Attaching native debugger.");
return nativeDebugger.attachToClient(project, client, state);
log.info("Project has native development enabled");
return nativeDebugger.getExistingDebugSession(project, client);
} else {
return super.attachToClient(project, client, state);
return super.getExistingDebugSession(project, client);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
*/
package com.google.idea.blaze.android.cppimpl.debug;

import com.android.ddmlib.Client;
import com.android.tools.ndk.run.editor.NativeAndroidDebugger;
import com.android.tools.ndk.run.editor.NativeAndroidDebuggerState;
import com.google.idea.blaze.base.model.BlazeProjectData;
import com.google.idea.blaze.base.model.primitives.LanguageClass;
import com.google.idea.blaze.base.settings.Blaze;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.intellij.execution.ExecutionException;
import com.intellij.openapi.project.Project;
import com.intellij.xdebugger.XDebugProcessStarter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Extension of {@link NativeAndroidDebugger} with the following key differences compared to {@link
Expand Down Expand Up @@ -56,4 +62,17 @@ public boolean supportsProject(Project project) {
return blazeProjectData != null
&& blazeProjectData.getWorkspaceLanguageSettings().isLanguageActive(LanguageClass.C);
}

@Override
public XDebugProcessStarter getDebugProcessStarterForExistingProcess(
@NotNull Project project,
@NotNull Client client,
@Nullable String applicationId,
@Nullable NativeAndroidDebuggerState state)
throws ExecutionException {
if (state != null) {
BlazeNativeDebuggerStateSourceMapping.addSourceMapping(project, state);
}
return super.getDebugProcessStarterForExistingProcess(project, client, applicationId, state);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* 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.cppimpl.debug;

import com.android.tools.ndk.run.editor.NativeAndroidDebuggerState;
import com.google.common.collect.ImmutableList;
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

/** Maps source directory when attaching to a process */
public class BlazeNativeDebuggerStateSourceMapping {
public static void addSourceMapping(
@NotNull Project project, @NotNull NativeAndroidDebuggerState state) {
// Source code is always relative to the workspace root in a blaze project.
String workingDirPath = WorkspaceRoot.fromProject(project).directory().getPath();
state.setWorkingDir(workingDirPath);

// Remote built binaries may use /proc/self/cwd to represent the working directory
// so we manually map /proc/self/cwd to the workspace root. We used to use
// `plugin.symbol-file.dwarf.comp-dir-symlink-paths = "/proc/self/cwd"`
// to automatically resolve this but it's no longer supported in newer versions of
// LLDB.
String sourceMapToWorkspaceRootCommand =
"settings append target.source-map /proc/self/cwd " + workingDirPath;
ImmutableList<String> startupCommands =
ImmutableList.<String>builder()
.addAll(state.getUserStartupCommands())
.add(sourceMapToWorkspaceRootCommand)
.build();
state.setUserStartupCommands(startupCommands);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2016 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.resources;

import com.android.tools.idea.projectsystem.LightResourceClassService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.common.experiments.FeatureRolloutExperiment;
import com.intellij.openapi.module.Module;
import com.intellij.psi.PsiClass;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/** Implementation of {@link LightResourceClassService} set up at Blaze sync time. */
public abstract class BlazeLightResourceClassServiceBase implements LightResourceClassService {

@VisibleForTesting
public static final FeatureRolloutExperiment workspaceResourcesFeature =
new FeatureRolloutExperiment("aswb.workspace.light.class.enabled");

Map<String, BlazeRClass> rClasses = Maps.newHashMap();
Map<Module, BlazeRClass> rClassesByModule = Maps.newHashMap();
final Set<BlazeRClass> allRClasses = Sets.newHashSet();

@Override
public Collection<? extends PsiClass> getLightRClassesAccessibleFromModule(Module module) {
if (workspaceResourcesFeature.isEnabled()
&& module.getName().equals(BlazeDataStorage.WORKSPACE_MODULE_NAME)) {
// Returns all the packages in resource modules, and all the workspace packages that
// have previously been asked for. All `res/` directories in our project should belong to a
// resource module. For java sources, IntelliJ will ask for explicit resource package by
// calling `getLightRClasses` at which point we can create the package. This is not completely
// correct and the autocomplete will be slightly off when initial `R` is typed in the editor,
// but this workaround is being used to mitigate issues (b/136685602) while resources
// are re-worked.
return allRClasses;
} else {
return rClasses.values();
}
}

@Override
public Collection<? extends PsiClass> getLightRClassesDefinedByModule(Module module) {
BlazeRClass rClass = rClassesByModule.get(module);
return rClass == null ? ImmutableSet.of() : ImmutableSet.of(rClass);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,20 @@
*/
package com.google.idea.blaze.android.run.runner;

import static com.android.tools.idea.run.tasks.AbstractDeployTask.getAppToInstall;

import com.android.ddmlib.IDevice;
import com.android.tools.deployer.ApkParser;
import com.android.tools.deployer.Deployer;
import com.android.tools.deployer.DeployerException;
import com.android.tools.deployer.model.Apk;
import com.android.tools.deployer.model.App;
import com.android.tools.idea.execution.common.ApplicationDeployer;
import com.android.tools.idea.execution.common.DeployOptions;
import com.android.tools.idea.log.LogWrapper;
import com.android.tools.idea.run.ApkFileUnit;
import com.android.tools.idea.run.ApkInfo;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;

/** Deploys mobile install application. */
public class MobileInstallApplicationDeployer implements ApplicationDeployer {
final Logger log = Logger.getInstance(this.getClass());

public MobileInstallApplicationDeployer() {}

Expand All @@ -45,15 +38,8 @@ public Deployer.Result fullDeploy(
@NotNull IDevice device,
@NotNull ApkInfo apkInfo,
@NotNull DeployOptions deployOptions,
ProgressIndicator indicator)
throws DeployerException {
final List<String> apkPaths =
apkInfo.getFiles().stream()
.map(ApkFileUnit::getApkPath)
.map(Path::toString)
.collect(Collectors.toList());
final List<Apk> apks = new ApkParser().parsePaths(apkPaths);
App app = new App(apkInfo.getApplicationId(), apks, device, new LogWrapper(log));
ProgressIndicator indicator) {
App app = getAppToInstall(apkInfo);
return new Deployer.Result(false, false, false, app);
}

Expand All @@ -63,8 +49,7 @@ public Deployer.Result applyChangesDeploy(
@NotNull IDevice device,
@NotNull ApkInfo app,
@NotNull DeployOptions deployOptions,
ProgressIndicator indicator)
throws DeployerException {
ProgressIndicator indicator) {
throw new RuntimeException("Apply changes is not supported for mobile-install");
}

Expand Down
Loading

0 comments on commit ac5c231

Please sign in to comment.