Search in sources :

Example 1 with AndroidResourceModuleRegistry

use of com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method createTargetMapWithNonStandardAndroidManifestName.

private void createTargetMapWithNonStandardAndroidManifestName() {
    Label mainResourceTarget = Label.create("//com/google/example:main");
    ArtifactLocation mainManifest = artifact("com/google/example/main/WeirdManifest.xml", true);
    ArtifactLocation mainResource = artifact("com/google/example/main/res", true);
    ArtifactLocation mainBuildFile = artifact("com/google/example/main/BUILD", true);
    AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
    registry.put(module, AndroidResourceModule.builder(TargetKey.forPlainTarget(mainResourceTarget)).addResource(mainResource).build());
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(mainResourceTarget).setBuildFile(mainBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).setManifestFile(mainManifest).addResource(mainResource))).build();
    projectDataManager.setTargetMap(targetMap);
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 2 with AndroidResourceModuleRegistry

use of com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    super.initTest(applicationServices, projectServices);
    applicationServices.register(FileTypeManager.class, new MockFileTypeManager());
    projectServices.register(ProjectFileIndex.class, mock(ProjectFileIndex.class));
    projectServices.register(BuildReferenceManager.class, new MockBuildReferenceManager(project));
    projectServices.register(TransitiveDependencyMap.class, new TransitiveDependencyMap(project));
    projectServices.register(ProjectScopeBuilder.class, new ProjectScopeBuilderImpl(project));
    projectServices.register(AndroidResourceModuleRegistry.class, new AndroidResourceModuleRegistry());
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
    BlazeImportSettings settings = new BlazeImportSettings("", "", "", "", BuildSystem.Blaze);
    importSettingsManager.setImportSettings(settings);
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    createPsiClassesAndSourceToTargetMap(projectServices);
    projectDataManager = new MockBlazeProjectDataManager();
    projectServices.register(BlazeProjectDataManager.class, projectDataManager);
    ExtensionPoint<RenderErrorContributor.Provider> extensionPoint = registerExtensionPoint(ExtensionPointName.create("com.android.rendering.renderErrorContributor"), RenderErrorContributor.Provider.class);
    extensionPoint.registerExtension(new RenderErrorContributor.Provider());
    extensionPoint.registerExtension(new BlazeRenderErrorContributor.BlazeProvider());
    module = new MockModule(project, () -> {
    });
    // For the isApplicable tests.
    provider = new BlazeRenderErrorContributor.BlazeProvider();
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) RenderErrorContributor(com.android.tools.idea.rendering.RenderErrorContributor) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) MockFileTypeManager(com.intellij.openapi.fileTypes.MockFileTypeManager) TransitiveDependencyMap(com.google.idea.blaze.base.targetmaps.TransitiveDependencyMap) MockModule(com.intellij.mock.MockModule) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) ProjectScopeBuilderImpl(com.intellij.psi.search.ProjectScopeBuilderImpl)

Example 3 with AndroidResourceModuleRegistry

use of com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method createTargetMapWithGeneratedResources.

private void createTargetMapWithGeneratedResources() {
    Label mainResourcesTarget = Label.create("//com/google/example:main");
    Label dependencyGeneratedResourceTarget = Label.create("//com/google/example:generated");
    Label dependencySourceResourceTarget = Label.create("//com/google/example:source");
    Label transitiveGeneratedResourcesTarget = Label.create("//com/google/example/transitive:generated");
    Label transitiveSourceResourceTarget = Label.create("//com/google/example/transitive:source");
    Label unrelatedGeneratedResourceTarget = Label.create("//com/google/unrelated:generated");
    Label unrelatedSourceResourceTarget = Label.create("//com/google/unrelated:source");
    ArtifactLocation mainGeneratedResource = artifact("com/google/example/main/generated/res", false);
    ArtifactLocation mainSourceResource = artifact("com/google/example/main/source/res", true);
    ArtifactLocation dependencyGeneratedResource = artifact("com/google/example/dependency/generated/res", false);
    ArtifactLocation dependencySourceResource = artifact("com/google/example/dependency/source/res", true);
    ArtifactLocation transitiveGeneratedResourceOne = artifact("com/google/example/transitive/generated/one/res", false);
    ArtifactLocation transitiveGeneratedResourceTwo = artifact("com/google/example/transitive/generated/two/res", false);
    ArtifactLocation transitiveSourceResource = artifact("com/google/example/transitive/source/res", true);
    ArtifactLocation unrelatedGeneratedResource = artifact("com/google/unrelated/generated/res", false);
    ArtifactLocation unrelatedSourceResource = artifact("com/google/unrelated/source/res", true);
    ArtifactLocation mainBuildFile = artifact("com/google/example/main/BUILD", true);
    ArtifactLocation dependencyBuildFile = artifact("com/google/example/dependency/BUILD", true);
    ArtifactLocation transitiveBuildFile = artifact("com/google/example/transitive/BUILD", true);
    ArtifactLocation unrelatedBuildFile = artifact("com/google/unrelated/BUILD", true);
    AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
    registry.put(module, AndroidResourceModule.builder(TargetKey.forPlainTarget(mainResourcesTarget)).addResource(mainSourceResource).addTransitiveResourceDependency(dependencyGeneratedResourceTarget).addTransitiveResource(dependencyGeneratedResource).addTransitiveResourceDependency(dependencySourceResourceTarget).addTransitiveResource(dependencySourceResource).addTransitiveResourceDependency(transitiveGeneratedResourcesTarget).addTransitiveResource(transitiveGeneratedResourceOne).addTransitiveResource(transitiveGeneratedResourceTwo).addTransitiveResourceDependency(transitiveSourceResourceTarget).addTransitiveResource(transitiveSourceResource).build());
    // Not using these, but they should be in the registry.
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(dependencyGeneratedResourceTarget)).addTransitiveResourceDependency(transitiveSourceResourceTarget).addTransitiveResource(transitiveSourceResource).build());
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(dependencySourceResourceTarget)).addResource(dependencySourceResource).addTransitiveResourceDependency(transitiveGeneratedResourcesTarget).addTransitiveResource(transitiveGeneratedResourceOne).addTransitiveResource(transitiveGeneratedResourceTwo).build());
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(transitiveGeneratedResourcesTarget)).build());
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(transitiveSourceResourceTarget)).addResource(transitiveSourceResource).build());
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(unrelatedGeneratedResourceTarget)).build());
    registry.put(mock(Module.class), AndroidResourceModule.builder(TargetKey.forPlainTarget(unrelatedSourceResourceTarget)).addResource(unrelatedSourceResource).build());
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(mainResourcesTarget).setBuildFile(mainBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(mainGeneratedResource).addResource(mainSourceResource)).addDependency(dependencyGeneratedResourceTarget).addDependency(dependencySourceResourceTarget)).addTarget(TargetIdeInfo.builder().setLabel(dependencyGeneratedResourceTarget).setBuildFile(dependencyBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(dependencyGeneratedResource)).addDependency(transitiveSourceResourceTarget)).addTarget(TargetIdeInfo.builder().setLabel(dependencySourceResourceTarget).setBuildFile(dependencyBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(dependencySourceResource)).addDependency(transitiveGeneratedResourcesTarget)).addTarget(TargetIdeInfo.builder().setLabel(transitiveGeneratedResourcesTarget).setBuildFile(transitiveBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(transitiveGeneratedResourceOne).addResource(transitiveGeneratedResourceTwo))).addTarget(TargetIdeInfo.builder().setLabel(transitiveSourceResourceTarget).setBuildFile(transitiveBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(transitiveSourceResource))).addTarget(TargetIdeInfo.builder().setLabel(unrelatedGeneratedResourceTarget).setBuildFile(unrelatedBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(unrelatedGeneratedResource))).addTarget(TargetIdeInfo.builder().setLabel(unrelatedSourceResourceTarget).setBuildFile(unrelatedBuildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).addResource(unrelatedSourceResource))).build();
    projectDataManager.setTargetMap(targetMap);
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) MockModule(com.intellij.mock.MockModule) Module(com.intellij.openapi.module.Module) AndroidResourceModule(com.google.idea.blaze.android.sync.model.AndroidResourceModule) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 4 with AndroidResourceModuleRegistry

use of com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry in project intellij by bazelbuild.

the class BlazeRenderErrorContributorTest method createTargetMapWithMissingClassDependency.

private void createTargetMapWithMissingClassDependency() {
    Label parentTarget = Label.create("//com/google/example:app");
    Label independentLibraryTarget = Label.create("//com/google/example/independent:library");
    Label independentLibrary2Target = Label.create("//com/google/example/independent:library2");
    Label dependentLibraryTarget = Label.create("//com/google/example/dependent:library");
    Label resourcesTarget = Label.create("//com/google/example:resources");
    ArtifactLocation manifest = artifact("com/google/example/AndroidManifest.xml", true);
    ArtifactLocation resources = artifact("com/google/example/res", true);
    ArtifactLocation buildFile = artifact("com/google/example/BUILD", true);
    AndroidResourceModuleRegistry registry = AndroidResourceModuleRegistry.getInstance(project);
    registry.put(module, AndroidResourceModule.builder(TargetKey.forPlainTarget(resourcesTarget)).addResource(resources).build());
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(parentTarget).setBuildFile(buildFile).addDependency(independentLibraryTarget).addDependency(resourcesTarget)).addTarget(TargetIdeInfo.builder().setLabel(independentLibraryTarget).setBuildFile(buildFile).setJavaInfo(JavaIdeInfo.builder()).addDependency(independentLibrary2Target)).addTarget(TargetIdeInfo.builder().setLabel(independentLibrary2Target).setBuildFile(buildFile).setJavaInfo(JavaIdeInfo.builder())).addTarget(TargetIdeInfo.builder().setLabel(resourcesTarget).setBuildFile(buildFile).setAndroidInfo(AndroidIdeInfo.builder().setGenerateResourceClass(true).setManifestFile(manifest).addResource(resources)).addDependency(dependentLibraryTarget)).addTarget(TargetIdeInfo.builder().setLabel(dependentLibraryTarget).setBuildFile(buildFile).setJavaInfo(JavaIdeInfo.builder())).build();
    projectDataManager.setTargetMap(targetMap);
}
Also used : Label(com.google.idea.blaze.base.model.primitives.Label) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry) SourceToTargetMap(com.google.idea.blaze.base.targetmaps.SourceToTargetMap) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap)

Example 5 with AndroidResourceModuleRegistry

use of com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry in project intellij by bazelbuild.

the class AndroidResourceModuleRegistryTest method initTest.

@Override
protected void initTest(@NotNull Container applicationServices, @NotNull Container projectServices) {
    super.initTest(applicationServices, projectServices);
    projectServices.register(AndroidResourceModuleRegistry.class, new AndroidResourceModuleRegistry());
    registry = AndroidResourceModuleRegistry.getInstance(getProject());
}
Also used : AndroidResourceModuleRegistry(com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry)

Aggregations

AndroidResourceModuleRegistry (com.google.idea.blaze.android.sync.model.AndroidResourceModuleRegistry)13 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)6 Label (com.google.idea.blaze.base.model.primitives.Label)6 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)5 AndroidResourceModule (com.google.idea.blaze.android.sync.model.AndroidResourceModule)4 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)4 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)4 Module (com.intellij.openapi.module.Module)4 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)3 SourceToTargetMap (com.google.idea.blaze.base.targetmaps.SourceToTargetMap)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 ImmutableList (com.google.common.collect.ImmutableList)2 LightResourceClassService (com.google.idea.blaze.android.resources.LightResourceClassService)2 AndroidIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidIdeInfo)2 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)2 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)2 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)2 MockModule (com.intellij.mock.MockModule)2 SourceProvider (com.android.builder.model.SourceProvider)1