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;
}
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);
}
Aggregations