Search in sources :

Example 1 with AndroidFacet

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

the class PostProjectBuildTasksExecutorTest method addAndroidModelToFacet.

private static void addAndroidModelToFacet(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    assert facet != null;
    facet.setAndroidModel(androidModel);
}
Also used : AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 2 with AndroidFacet

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

the class GradleRenderErrorContributorTest method setUpAndroidFacetWithGradleModelWithIssue.

private void setUpAndroidFacetWithGradleModelWithIssue() {
    ApplicationManager.getApplication().runWriteAction(() -> {
        FacetManager.getInstance(myModule).addFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
    });
    AndroidFacet facet = AndroidFacet.getInstance(myModule);
    assertThat(facet).isNotNull();
    File root = Projects.getBaseDirPath(myProject);
    AndroidProjectStub androidProject = TestProjects.createBasicProject();
    // The problematic plugin version.
    // https://code.google.com/p/android/issues/detail?id=170841
    androidProject.setModelVersion("1.2.2");
    AndroidModuleModel model = new AndroidModuleModel(androidProject.getName(), root, androidProject, "debug");
    facet.setAndroidModel(model);
    model = AndroidModuleModel.get(myModule);
    assertThat(model).isNotNull();
    assertThat(model.getFeatures().isLayoutRenderingIssuePresent()).isTrue();
}
Also used : AndroidProjectStub(com.android.tools.idea.gradle.stubs.android.AndroidProjectStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) File(java.io.File) MockPsiFile(com.intellij.mock.MockPsiFile) PsiFile(com.intellij.psi.PsiFile) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 3 with AndroidFacet

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

the class ConflictSetTest method createFacet.

@NotNull
private static AndroidFacet createFacet(@NotNull FacetManager facetManager, int projectType) {
    AndroidFacet facet = facetManager.createFacet(AndroidFacet.getFacetType(), AndroidFacet.NAME, null);
    JpsAndroidModuleProperties facetState = facet.getProperties();
    facetState.ALLOW_USER_CONFIGURATION = false;
    facetState.PROJECT_TYPE = projectType;
    return facet;
}
Also used : JpsAndroidModuleProperties(org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with AndroidFacet

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

the class NlComponent method getIds.

/**
   * Looks up the existing set of id's reachable from the given module
   */
public static Collection<String> getIds(@NotNull NlModel model) {
    AndroidFacet facet = model.getFacet();
    AppResourceRepository resources = AppResourceRepository.getAppResources(facet, true);
    Collection<String> ids = resources.getItemsOfType(ResourceType.ID);
    Set<String> pendingIds = model.getPendingIds();
    if (!pendingIds.isEmpty()) {
        List<String> all = Lists.newArrayListWithCapacity(pendingIds.size() + ids.size());
        all.addAll(ids);
        all.addAll(pendingIds);
        ids = all;
    }
    return ids;
}
Also used : AppResourceRepository(com.android.tools.idea.res.AppResourceRepository) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 5 with AndroidFacet

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

the class NlProperties method getProperties.

@NotNull
public Table<String, String, NlPropertyItem> getProperties(@NotNull List<NlComponent> components) {
    AndroidFacet facet = getFacet(components);
    if (facet == null) {
        return ImmutableTable.of();
    }
    GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(facet.getModule().getProject());
    return getProperties(facet, components, dependencyManager);
}
Also used : GradleDependencyManager(com.android.tools.idea.gradle.dependencies.GradleDependencyManager) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AndroidFacet (org.jetbrains.android.facet.AndroidFacet)318 Module (com.intellij.openapi.module.Module)131 VirtualFile (com.intellij.openapi.vfs.VirtualFile)78 NotNull (org.jetbrains.annotations.NotNull)63 Nullable (org.jetbrains.annotations.Nullable)53 Project (com.intellij.openapi.project.Project)43 File (java.io.File)34 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)29 PsiFile (com.intellij.psi.PsiFile)24 XmlFile (com.intellij.psi.xml.XmlFile)20 PsiElement (com.intellij.psi.PsiElement)17 ArrayList (java.util.ArrayList)17 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)16 XmlTag (com.intellij.psi.xml.XmlTag)16 Manifest (org.jetbrains.android.dom.manifest.Manifest)14 IAndroidTarget (com.android.sdklib.IAndroidTarget)13 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)12 ResourceFolderType (com.android.resources.ResourceFolderType)11 PsiClass (com.intellij.psi.PsiClass)11 Configuration (com.android.tools.idea.configurations.Configuration)10