Search in sources :

Example 1 with AndroidBlazeRules

use of com.google.idea.blaze.java.AndroidBlazeRules 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());
    projectFileIndex = mock(ProjectFileIndex.class);
    projectServices.register(ProjectFileIndex.class, projectFileIndex);
    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());
    ExtensionPointImpl<Provider> kindProvider = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    kindProvider.registerExtension(new AndroidBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager(project);
    BlazeImportSettings settings = new BlazeImportSettings("", "", "", "", BuildSystemName.Blaze);
    importSettingsManager.setImportSettings(settings);
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    projectServices.register(JvmPsiConversionHelper.class, new JvmPsiConversionHelperImpl());
    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) Provider(com.google.idea.blaze.base.model.primitives.Kind.Provider) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) MockModule(com.intellij.mock.MockModule) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Kind(com.google.idea.blaze.base.model.primitives.Kind) JvmPsiConversionHelperImpl(com.intellij.psi.impl.JvmPsiConversionHelperImpl) ProjectScopeBuilderImpl(com.intellij.psi.search.ProjectScopeBuilderImpl)

Example 2 with AndroidBlazeRules

use of com.google.idea.blaze.java.AndroidBlazeRules in project intellij by bazelbuild.

the class BlazeAndroidWorkspaceImporterTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    BlazeExecutor blazeExecutor = new MockBlazeExecutor();
    applicationServices.register(BlazeExecutor.class, blazeExecutor);
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    MockFileOperationProvider mockFileOperationProvider = new MockFileOperationProvider();
    applicationServices.register(FileOperationProvider.class, mockFileOperationProvider);
    ExtensionPointImpl<Provider> targetKindEp = registerExtensionPoint(Provider.EP_NAME, Provider.class);
    targetKindEp.registerExtension(new AndroidBlazeRules());
    targetKindEp.registerExtension(new JavaBlazeRules());
    targetKindEp.registerExtension(new GenericBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    retentionFilterEp = registerExtensionPoint(GeneratedResourceRetentionFilter.EP_NAME, GeneratedResourceRetentionFilter.class);
    context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    registerExtensionPoint(EmptyLibraryFilterSettings.EP_NAME, EmptyLibraryFilterSettings.class);
    // For importJavaWorkspace.
    applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {

        @Nullable
        @Override
        public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
            return null;
        }
    });
    applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
    applicationServices.register(PrefetchService.class, new MockPrefetchService());
    registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
    applicationServices.register(RemoteArtifactPrefetcher.class, new MockRemoteArtifactPrefetcher());
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) GeneratedResourceRetentionFilter(com.google.idea.blaze.android.sync.importer.problems.GeneratedResourceRetentionFilter) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Kind(com.google.idea.blaze.base.model.primitives.Kind) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) MockRemoteArtifactPrefetcher(com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) Provider(com.google.idea.blaze.base.model.primitives.Kind.Provider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) Nullable(javax.annotation.Nullable)

Example 3 with AndroidBlazeRules

use of com.google.idea.blaze.java.AndroidBlazeRules in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporterTest method initTest.

@Override
// False positive on getDeclaredPackageOfJavaFile.
@SuppressWarnings("FunctionalInterfaceClash")
protected void initTest(Container applicationServices, Container projectServices) {
    fileOperationProvider = new MockFileOperationProvider();
    applicationServices.register(FileOperationProvider.class, fileOperationProvider);
    experimentService = new MockExperimentService();
    applicationServices.register(ExperimentService.class, experimentService);
    MockRemoteArtifactPrefetcher remoteArtifactPrefetcher = new MockRemoteArtifactPrefetcher();
    applicationServices.register(RemoteArtifactPrefetcher.class, remoteArtifactPrefetcher);
    ExtensionPointImpl<Kind.Provider> ep = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    ep.registerExtension(new JavaBlazeRules());
    ep.registerExtension(new AndroidBlazeRules());
    ep.registerExtension(new GenericBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    BlazeExecutor blazeExecutor = new MockBlazeExecutor();
    applicationServices.register(BlazeExecutor.class, blazeExecutor);
    projectServices.register(BlazeImportSettingsManager.class, new BlazeImportSettingsManager(project));
    BlazeImportSettingsManager.getInstance(getProject()).setImportSettings(DUMMY_IMPORT_SETTINGS);
    // will silently fall back to FilePathJavaPackageReader
    applicationServices.register(JavaSourcePackageReader.class, new JavaSourcePackageReader() {

        @Nullable
        @Override
        public String getDeclaredPackageOfJavaFile(BlazeContext context, ArtifactLocationDecoder artifactLocationDecoder, SourceArtifact sourceArtifact) {
            return null;
        }
    });
    applicationServices.register(PackageManifestReader.class, new PackageManifestReader());
    applicationServices.register(PrefetchService.class, new MockPrefetchService());
    context = BlazeContext.create();
    context.addOutputSink(IssueOutput.class, errorCollector);
    augmenters = registerExtensionPoint(BlazeJavaSyncAugmenter.EP_NAME, BlazeJavaSyncAugmenter.class);
    registerExtensionPoint(EmptyLibraryFilterSettings.EP_NAME, EmptyLibraryFilterSettings.class);
    registerExtensionPoint(JavaLikeLanguage.EP_NAME, JavaLikeLanguage.class).registerExtension(new JavaLikeLanguage.Java());
    projectServices.register(JarCache.class, new MockJarCache(project));
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) JavaBlazeRules(com.google.idea.blaze.java.JavaBlazeRules) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) MockPrefetchService(com.google.idea.blaze.base.prefetch.MockPrefetchService) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) Kind(com.google.idea.blaze.base.model.primitives.Kind) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) JavaSourcePackageReader(com.google.idea.blaze.java.sync.source.JavaSourcePackageReader) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) JavaLikeLanguage(com.google.idea.blaze.java.sync.source.JavaLikeLanguage) PackageManifestReader(com.google.idea.blaze.java.sync.source.PackageManifestReader) GenericBlazeRules(com.google.idea.blaze.base.model.primitives.GenericBlazeRules) MockRemoteArtifactPrefetcher(com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher) SourceArtifact(com.google.idea.blaze.java.sync.source.SourceArtifact) BuildSystemProvider(com.google.idea.blaze.base.bazel.BuildSystemProvider) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) BazelBuildSystemProvider(com.google.idea.blaze.base.bazel.BazelBuildSystemProvider) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) Nullable(javax.annotation.Nullable)

Example 4 with AndroidBlazeRules

use of com.google.idea.blaze.java.AndroidBlazeRules in project intellij by bazelbuild.

the class RenderJarCacheTest method initTest.

@Before
public void initTest() throws IOException {
    errorCollector = new ErrorCollector();
    outputSink = new WritingOutputSink();
    context = BlazeContext.create();
    context.addOutputSink(PrintOutput.class, outputSink);
    workspaceRoot = new WorkspaceRoot(temporaryFolder.getRoot());
    artifactLocationDecoder = new MockArtifactLocationDecoder() {

        @Override
        public File decode(ArtifactLocation artifactLocation) {
            return new File(workspaceRoot.directory(), artifactLocation.getRelativePath());
        }
    };
    registerMockBlazeImportSettings();
    mockedArtifactCache = Mockito.mock(ArtifactCache.class);
    intellijRule.registerProjectService(RenderJarCache.class, new RenderJarCache(intellijRule.getProject(), RenderJarCache.getCacheDirForProject(intellijRule.getProject()), mockedArtifactCache));
    intellijRule.registerApplicationService(FileOperationProvider.class, new FileOperationProvider());
    intellijRule.registerApplicationService(RemoteArtifactPrefetcher.class, new DefaultPrefetcher());
    intellijRule.registerExtensionPoint(FileCache.EP_NAME, FileCache.class);
    intellijRule.registerExtension(FileCache.EP_NAME, new FileCacheAdapter());
    // Required to enable RenderJarClassFileFinder
    MockExperimentService experimentService = new MockExperimentService();
    experimentService.setExperiment(RenderResolveOutputGroupProvider.buildOnSync, true);
    intellijRule.registerApplicationService(ExperimentService.class, experimentService);
    // Setup needed for setting a projectview
    intellijRule.registerExtensionPoint(BlazeSyncPlugin.EP_NAME, BlazeSyncPlugin.class);
    intellijRule.registerExtension(BlazeSyncPlugin.EP_NAME, new BlazeJavaSyncPlugin());
    // RenderJarCache looks at targets of `Kind`s with LanguageClass.ANDROID
    // so we need to setup the framework for fetching a target's `Kind`
    intellijRule.registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    intellijRule.registerExtension(Kind.Provider.EP_NAME, new AndroidBlazeRules());
    intellijRule.registerApplicationService(ApplicationState.class, new ApplicationState());
    // registered because `RenderJarCache` uses it to filter source targets
    projectViewManager = new MockProjectViewManager();
    intellijRule.registerProjectService(ProjectViewManager.class, projectViewManager);
    intellijRule.registerApplicationService(BlazeExecutor.class, new MockBlazeExecutor());
    setupProjectData();
    setProjectView("directories:", "  com/foo/bar/baz", "  com/foo/bar/qux", "targets:", "  //com/foo/bar/baz:baz", "  //com/foo/bar/qux:quz");
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) MockProjectViewManager(com.google.idea.blaze.base.MockProjectViewManager) BlazeJavaSyncPlugin(com.google.idea.blaze.java.sync.BlazeJavaSyncPlugin) ApplicationState(com.google.idea.blaze.base.model.primitives.Kind.ApplicationState) ErrorCollector(com.google.idea.blaze.base.scope.ErrorCollector) MockArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) MockBlazeExecutor(com.google.idea.blaze.base.async.executor.MockBlazeExecutor) FileCacheAdapter(com.google.idea.blaze.android.libraries.RenderJarCache.FileCacheAdapter) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) Kind(com.google.idea.blaze.base.model.primitives.Kind) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) DefaultPrefetcher(com.google.idea.blaze.base.prefetch.DefaultPrefetcher) File(java.io.File) ArtifactCache(com.google.idea.blaze.android.filecache.ArtifactCache) Before(org.junit.Before)

Example 5 with AndroidBlazeRules

use of com.google.idea.blaze.java.AndroidBlazeRules in project intellij by bazelbuild.

the class BlazeModuleSystemTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    ExtensionPointImpl<Provider> kindProvider = registerExtensionPoint(Kind.Provider.EP_NAME, Kind.Provider.class);
    kindProvider.registerExtension(new AndroidBlazeRules());
    applicationServices.register(Kind.ApplicationState.class, new Kind.ApplicationState());
    module = new MockModule(project, () -> {
    });
    // For the 'blaze.class.file.finder.name' experiment.
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    // For Blaze.isBlazeProject.
    mockBlazeImportSettings(projectServices);
    createMocksForAddDependency(applicationServices, projectServices);
    service = new BlazeProjectSystem(project);
}
Also used : MockExperimentService(com.google.idea.common.experiments.MockExperimentService) AndroidBlazeRules(com.google.idea.blaze.java.AndroidBlazeRules) MockModule(com.intellij.mock.MockModule) Kind(com.google.idea.blaze.base.model.primitives.Kind) VirtualFileSystemProvider(com.google.idea.blaze.base.io.VirtualFileSystemProvider) Provider(com.google.idea.blaze.base.model.primitives.Kind.Provider)

Aggregations

Kind (com.google.idea.blaze.base.model.primitives.Kind)6 AndroidBlazeRules (com.google.idea.blaze.java.AndroidBlazeRules)6 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)5 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)4 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)3 Provider (com.google.idea.blaze.base.model.primitives.Kind.Provider)3 BlazeImportSettingsManager (com.google.idea.blaze.base.settings.BlazeImportSettingsManager)3 MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)3 BlazeExecutor (com.google.idea.blaze.base.async.executor.BlazeExecutor)2 BazelBuildSystemProvider (com.google.idea.blaze.base.bazel.BazelBuildSystemProvider)2 BuildSystemProvider (com.google.idea.blaze.base.bazel.BuildSystemProvider)2 GenericBlazeRules (com.google.idea.blaze.base.model.primitives.GenericBlazeRules)2 MockPrefetchService (com.google.idea.blaze.base.prefetch.MockPrefetchService)2 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)2 MockRemoteArtifactPrefetcher (com.google.idea.blaze.base.sync.MockRemoteArtifactPrefetcher)2 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)2 JavaBlazeRules (com.google.idea.blaze.java.JavaBlazeRules)2 JavaLikeLanguage (com.google.idea.blaze.java.sync.source.JavaLikeLanguage)2 JavaSourcePackageReader (com.google.idea.blaze.java.sync.source.JavaSourcePackageReader)2 PackageManifestReader (com.google.idea.blaze.java.sync.source.PackageManifestReader)2