Search in sources :

Example 11 with AndroidModel

use of com.android.tools.idea.model.AndroidModel in project android by JetBrains.

the class ModuleClassLoader method loadClassFromModule.

@Nullable
private Class<?> loadClassFromModule(Module module, String name) {
    if (module.isDisposed()) {
        return null;
    }
    final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module);
    if (extension == null) {
        return null;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("loadClassFromModule(%s, %s)", anonymize(module), anonymizeClassName(name)));
    }
    VirtualFile vOutFolder = extension.getCompilerOutputPath();
    VirtualFile classFile = null;
    if (vOutFolder == null) {
        AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet != null && facet.requiresAndroidModel()) {
            AndroidModel androidModel = facet.getAndroidModel();
            if (androidModel != null) {
                classFile = androidModel.getClassJarProvider().findModuleClassFile(name, module);
            }
        }
    } else {
        classFile = ClassJarProvider.findClassFileInPath(vOutFolder, name);
    }
    if (classFile != null) {
        return loadClassFile(name, classFile);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("  Class not found");
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidModel(com.android.tools.idea.model.AndroidModel) CompilerModuleExtension(com.intellij.openapi.roots.CompilerModuleExtension) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with AndroidModel

use of com.android.tools.idea.model.AndroidModel in project android by JetBrains.

the class UniqueParameterTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    loadProject(PROJECT_WITH_APPAND_LIB);
    assertNotNull(myAndroidFacet);
    AndroidModel androidModel = AndroidModuleModel.get(myAndroidFacet);
    assertNotNull(androidModel);
    // Set up modules
    for (Module m : ModuleManager.getInstance(getProject()).getModules()) {
        if (m.getName().equals("app")) {
            myAppModule = m;
            break;
        }
    }
    assertNotNull(myAppModule);
    myAppFacet = AndroidFacet.getInstance(myAppModule);
    assertNotNull(myAppFacet);
    addLatestAndroidSdk(myAppModule);
    assertNotNull(AndroidPlatform.getInstance(myAppModule));
    assertNotNull(myAppFacet.getAndroidModel());
    // TODO: b/23032990
    ProductFlavorContainer paidFlavor = AndroidModuleModel.get(myAppFacet).findProductFlavor("paid");
    assertNotNull(paidFlavor);
    myPaidSourceProvider = paidFlavor.getSourceProvider();
    assertNotNull(myPaidSourceProvider);
    myMainSourceProvider = myAppFacet.getMainSourceProvider();
    assertNotNull(myMainSourceProvider);
    TemplateMetadata mockMetadata = Mockito.mock(TemplateMetadata.class);
    Element elem = new IIOMetadataNode();
    elem.setAttribute(ATTR_TYPE, Parameter.Type.STRING.toString());
    elem.setAttribute(ATTR_ID, "testParam");
    elem.setAttribute(ATTR_DEFAULT, "");
    elem.setAttribute(ATTR_SUGGEST, null);
    elem.setAttribute(ATTR_NAME, "Test Param");
    elem.setAttribute(ATTR_HELP, "This is a test parameter");
    elem.setAttribute(ATTR_CONSTRAINTS, "");
    myParameter = new Parameter(mockMetadata, elem);
}
Also used : ProductFlavorContainer(com.android.builder.model.ProductFlavorContainer) AndroidModel(com.android.tools.idea.model.AndroidModel) Element(org.w3c.dom.Element) Module(com.intellij.openapi.module.Module) IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Aggregations

AndroidModel (com.android.tools.idea.model.AndroidModel)12 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)7 File (java.io.File)6 SourceProvider (com.android.builder.model.SourceProvider)3 Module (com.intellij.openapi.module.Module)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 ArrayList (java.util.ArrayList)2 ProductFlavorContainer (com.android.builder.model.ProductFlavorContainer)1 AndroidVersion (com.android.sdklib.AndroidVersion)1 AndroidGradleModel (com.android.tools.idea.gradle.AndroidGradleModel)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 AppResourceRepository (com.android.tools.idea.res.AppResourceRepository)1 FileResourceRepository (com.android.tools.idea.res.FileResourceRepository)1 ResourceClassRegistry (com.android.tools.idea.res.ResourceClassRegistry)1 Project (com.intellij.openapi.project.Project)1 CompilerModuleExtension (com.intellij.openapi.roots.CompilerModuleExtension)1 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)1