use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.
the class BlazeScalaWorkspaceImporterTest method importJava.
private BlazeJavaImportResult importJava(ProjectView projectView, TargetMap targetMap) {
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(projectView).build();
WorkspaceLanguageSettings languageSettings = new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.GENERIC, LanguageClass.SCALA, LanguageClass.JAVA));
JavaSourceFilter sourceFilter = new JavaSourceFilter(Blaze.getBuildSystemName(project), workspaceRoot, projectViewSet, targetMap);
JdepsMap jdepsMap = key -> ImmutableList.of();
ArtifactLocationDecoder decoder = new MockArtifactLocationDecoder();
return new BlazeJavaWorkspaceImporter(project, workspaceRoot, projectViewSet, languageSettings, targetMap, sourceFilter, jdepsMap, null, decoder, null).importWorkspace(context);
}
use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder 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");
}
use of com.google.idea.blaze.base.sync.workspace.MockArtifactLocationDecoder in project intellij by bazelbuild.
the class BlazeModuleSystemTest method createMockBlazeProjectData.
private BlazeProjectData createMockBlazeProjectData() {
TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel(Label.create("//foo:bar")).setKind(AndroidBlazeRules.RuleTypes.ANDROID_LIBRARY.getKind()).setBuildFile(ArtifactLocation.builder().setRelativePath("foo/BUILD").build()).build()).build();
ArtifactLocationDecoder decoder = new MockArtifactLocationDecoder() {
@Override
public File decode(ArtifactLocation artifactLocation) {
return new File("/", artifactLocation.getRelativePath());
}
};
return MockBlazeProjectDataBuilder.builder(workspaceRoot).setTargetMap(targetMap).setArtifactLocationDecoder(decoder).build();
}
Aggregations