Search in sources :

Example 1 with FileCacheAdapter

use of com.google.idea.blaze.android.libraries.RenderJarCache.FileCacheAdapter 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)

Aggregations

ArtifactCache (com.google.idea.blaze.android.filecache.ArtifactCache)1 FileCacheAdapter (com.google.idea.blaze.android.libraries.RenderJarCache.FileCacheAdapter)1 MockProjectViewManager (com.google.idea.blaze.base.MockProjectViewManager)1 MockBlazeExecutor (com.google.idea.blaze.base.async.executor.MockBlazeExecutor)1 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)1 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)1 Kind (com.google.idea.blaze.base.model.primitives.Kind)1 ApplicationState (com.google.idea.blaze.base.model.primitives.Kind.ApplicationState)1 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)1 DefaultPrefetcher (com.google.idea.blaze.base.prefetch.DefaultPrefetcher)1 ErrorCollector (com.google.idea.blaze.base.scope.ErrorCollector)1 MockArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder)1 AndroidBlazeRules (com.google.idea.blaze.java.AndroidBlazeRules)1 BlazeJavaSyncPlugin (com.google.idea.blaze.java.sync.BlazeJavaSyncPlugin)1 MockExperimentService (com.google.idea.common.experiments.MockExperimentService)1 File (java.io.File)1 Before (org.junit.Before)1