Search in sources :

Example 81 with AndroidFacet

use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.

the class AndroidCompileUtil method findCircularDependencyOnLibraryWithSamePackage.

@Nullable
public static Module findCircularDependencyOnLibraryWithSamePackage(@NotNull AndroidFacet facet) {
    final Manifest manifest = facet.getManifest();
    final String aPackage = manifest != null ? manifest.getPackage().getValue() : null;
    if (aPackage == null) {
        return null;
    }
    for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(facet.getModule(), true)) {
        final Manifest depManifest = depFacet.getManifest();
        final String depPackage = depManifest != null ? depManifest.getPackage().getValue() : null;
        if (aPackage.equals(depPackage)) {
            final List<AndroidFacet> depDependencies = AndroidUtils.getAllAndroidDependencies(depFacet.getModule(), false);
            if (depDependencies.contains(facet)) {
                // circular dependency on library with the same package
                return depFacet.getModule();
            }
        }
    }
    return null;
}
Also used : Manifest(org.jetbrains.android.dom.manifest.Manifest) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 82 with AndroidFacet

use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.

the class AndroidApplicationArtifactType method getNewArtifactTemplates.

@NotNull
@Override
public List<? extends ArtifactTemplate> getNewArtifactTemplates(@NotNull PackagingElementResolvingContext context) {
    final List<AndroidFacet> facets = new ArrayList<AndroidFacet>();
    for (Module module : context.getModulesProvider().getModules()) {
        final FacetModel facetModel = context.getModulesProvider().getFacetModel(module);
        final AndroidFacet facet = facetModel.getFacetByType(AndroidFacet.ID);
        if (facet != null && facet.isAppProject()) {
            facets.add(facet);
        }
    }
    if (facets.size() == 0) {
        return Collections.emptyList();
    }
    return Collections.singletonList(new MyTemplate(context.getProject(), facets));
}
Also used : ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module) FacetModel(com.intellij.facet.FacetModel) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Example 83 with AndroidFacet

use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.

the class ProGuardConfigFilesPanel method getCanonicalSdkHome.

@Nullable
private String getCanonicalSdkHome() {
    final AndroidFacet facet = getFacet();
    if (facet == null) {
        return null;
    }
    final Sdk sdk = ModuleRootManager.getInstance(facet.getModule()).getSdk();
    if (sdk == null) {
        return null;
    }
    final String homePath = sdk.getHomePath();
    return homePath != null ? FileUtil.toCanonicalPath(homePath) : null;
}
Also used : Sdk(com.intellij.openapi.projectRoots.Sdk) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 84 with AndroidFacet

use of org.jetbrains.android.facet.AndroidFacet in project android by JetBrains.

the class AndroidFindStyleApplicationsAction method createFindStyleApplicationsProcessor.

public static AndroidFindStyleApplicationsProcessor createFindStyleApplicationsProcessor(XmlTag tag, MyStyleData styleData, PsiFile context) {
    final ErrorReporter errorReporter = new ProjectBasedErrorReporter(tag.getProject());
    final Style style = styleData.getStyle();
    final Map<AndroidAttributeInfo, String> attrMap = AndroidRefactoringUtil.computeAttributeMap(style, new ProjectBasedErrorReporter(tag.getProject()), AndroidBundle.message("android.find.style.applications.title"));
    if (attrMap == null || attrMap.size() == 0) {
        return null;
    }
    final AndroidFacet facet = styleData.getFacet();
    final StyleRefData parentStyleRef = AndroidRefactoringUtil.getParentStyle(style);
    PsiElement parentStyleAttrName = null;
    if (parentStyleRef != null) {
        parentStyleAttrName = resolveStyleRef(parentStyleRef, facet);
        if (parentStyleAttrName == null) {
            errorReporter.report("Cannot resolve parent style '" + parentStyleRef.getStyleName() + "'", AndroidBundle.message("android.find.style.applications.title"));
            return null;
        }
    }
    return new AndroidFindStyleApplicationsProcessor(styleData.getFacet().getModule(), attrMap, styleData.getName(), tag, styleData.getNameAttrValue(), parentStyleAttrName, context);
}
Also used : ProjectBasedErrorReporter(org.jetbrains.android.util.ProjectBasedErrorReporter) ErrorReporter(org.jetbrains.android.util.ErrorReporter) ProjectBasedErrorReporter(org.jetbrains.android.util.ProjectBasedErrorReporter) Style(org.jetbrains.android.dom.resources.Style) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) PsiElement(com.intellij.psi.PsiElement)

Example 85 with AndroidFacet

use of org.jetbrains.android.facet.AndroidFacet in project kotlin by JetBrains.

the class IntellijLintProject method addAndroidModules.

private static void addAndroidModules(Set<AndroidFacet> androidFacets, Set<Module> seen, Graph<Module> graph, Module module) {
    Iterator<Module> iterator = graph.getOut(module);
    while (iterator.hasNext()) {
        Module dep = iterator.next();
        AndroidFacet facet = AndroidFacet.getInstance(dep);
        if (facet != null) {
            androidFacets.add(facet);
        }
        if (!seen.contains(dep)) {
            seen.add(dep);
            addAndroidModules(androidFacets, seen, graph, dep);
        }
    }
}
Also used : Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

AndroidFacet (org.jetbrains.android.facet.AndroidFacet)299 Module (com.intellij.openapi.module.Module)122 VirtualFile (com.intellij.openapi.vfs.VirtualFile)73 NotNull (org.jetbrains.annotations.NotNull)61 Nullable (org.jetbrains.annotations.Nullable)51 Project (com.intellij.openapi.project.Project)39 File (java.io.File)29 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)28 PsiFile (com.intellij.psi.PsiFile)24 XmlFile (com.intellij.psi.xml.XmlFile)20 PsiElement (com.intellij.psi.PsiElement)17 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)16 XmlTag (com.intellij.psi.xml.XmlTag)16 ArrayList (java.util.ArrayList)16 Manifest (org.jetbrains.android.dom.manifest.Manifest)14 IAndroidTarget (com.android.sdklib.IAndroidTarget)13 ResourceFolderType (com.android.resources.ResourceFolderType)11 Configuration (com.android.tools.idea.configurations.Configuration)10 PsiClass (com.intellij.psi.PsiClass)10 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)10