use of com.android.builder.model.BuildType in project android by JetBrains.
the class MoveToDebugManifestQuickFix method apply.
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
final XmlAttribute attribute = PsiTreeUtil.getParentOfType(startElement, XmlAttribute.class);
if (attribute != null) {
XmlTag parent = attribute.getParent();
if (parent != null && parent.getName().equals(TAG_USES_PERMISSION)) {
Module module = getModule(parent);
assert MOCK_LOCATION_PERMISSION.equals(parent.getAttributeValue(ATTR_NAME, ANDROID_URI));
parent.delete();
if (module != null) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
VirtualFile mainManifest = facet.getMainIdeaSourceProvider().getManifestFile();
// TODO: b/22928250
AndroidModuleModel androidModel = AndroidModuleModel.get(facet);
if (androidModel != null && mainManifest != null && mainManifest.getParent() != null && mainManifest.getParent().getParent() != null) {
final VirtualFile src = mainManifest.getParent().getParent();
for (BuildTypeContainer container : androidModel.getAndroidProject().getBuildTypes()) {
BuildType buildType = container.getBuildType();
if (buildType.isDebuggable()) {
addManifest(module, src, buildType.getName());
return;
}
}
Messages.showErrorDialog(module.getProject(), "Did not find a debug build type", "Move Permission");
}
}
}
}
}
}
Aggregations