Search in sources :

Example 6 with BlazeProjectData

use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.

the class ProjectTargetFinder method findTarget.

@Override
public Future<TargetInfo> findTarget(Project project, Label label) {
    BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    TargetInfo target = projectData != null ? findTarget(projectData.targetMap, label) : null;
    return Futures.immediateFuture(target);
}
Also used : TargetInfo(com.google.idea.blaze.base.dependencies.TargetInfo) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData)

Example 7 with BlazeProjectData

use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.

the class TestTargetHeuristicTest method doSetup.

@Before
public final void doSetup() {
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
}
Also used : BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Before(org.junit.Before)

Example 8 with BlazeProjectData

use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.

the class BlazeBuildServiceTest method initTest.

@Override
protected void initTest(Container applicationServices, Container projectServices) {
    BlazeImportSettingsManager importSettingsManager = new BlazeImportSettingsManager();
    importSettingsManager.setImportSettings(new BlazeImportSettings("", "", "", "", Blaze.BuildSystem.Blaze));
    projectServices.register(BlazeImportSettingsManager.class, importSettingsManager);
    applicationServices.register(ExperimentService.class, new MockExperimentService());
    ProjectView view = ProjectView.builder().add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//view/target:one")).add(TargetExpression.fromStringSafe("//view/target:two"))).build();
    viewSet = ProjectViewSet.builder().add(new File("view/target/.blazeproject"), view).build();
    ProjectViewManager viewManager = new MockProjectViewManager(viewSet);
    projectServices.register(ProjectViewManager.class, viewManager);
    BlazeProjectData blazeProjectData = MockBlazeProjectDataBuilder.builder(workspaceRoot).build();
    projectServices.register(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(blazeProjectData));
    applicationServices.register(BlazeBuildService.class, spy(new BlazeBuildService()));
    service = BlazeBuildService.getInstance();
    assertThat(service).isNotNull();
    // Can't mock BlazeExecutor.submitTask.
    doNothing().when(service).buildTargetExpressions(any(), any(), any(), any());
}
Also used : BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) MockExperimentService(com.google.idea.common.experiments.MockExperimentService) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager)

Example 9 with BlazeProjectData

use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.

the class FastBuildCompilerFactoryImplTest method configureTestForTargetMap.

private void configureTestForTargetMap(Map<TargetKey, TargetIdeInfo> targetMap) {
    BlazeProjectData projectData = new BlazeProjectData(0, new TargetMap(ImmutableMap.copyOf(targetMap)), null, null, null, artifact -> new File(artifact.relativePath), null, null, null);
    BlazeProjectDataManager projectDataManager = new MockBlazeProjectDataManager(projectData);
    compilerFactory = new FastBuildCompilerFactoryImpl(projectDataManager);
}
Also used : MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) File(java.io.File) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager)

Example 10 with BlazeProjectData

use of com.google.idea.blaze.base.model.BlazeProjectData in project intellij by bazelbuild.

the class PluginDevSyncTest method testRunConfigurationCreatedDuringSync.

@Test
public void testRunConfigurationCreatedDuringSync() throws Exception {
    setProjectView("directories:", "  java/com/google", "targets:", "  //java/com/google:lib", "  //java/com/google:plugin", "workspace_type: intellij_plugin");
    workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName1.java"), "package com.google;", "public class ClassWithUniqueName1 {}");
    workspace.createFile(new WorkspacePath("java/com/google/ClassWithUniqueName2.java"), "package com.google;", "public class ClassWithUniqueName2 {}");
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:lib").setKind("java_library").addSource(sourceRoot("java/com/google/ClassWithUniqueName1.java")).addSource(sourceRoot("java/com/google/ClassWithUniqueName2.java"))).addTarget(TargetIdeInfo.builder().setBuildFile(sourceRoot("java/com/google/BUILD")).setLabel("//java/com/google:plugin").setKind("intellij_plugin_debug_target")).build();
    setTargetMap(targetMap);
    runBlazeSync(new BlazeSyncParams.Builder("Sync", SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
    errorCollector.assertNoIssues();
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(getProject()).getBlazeProjectData();
    assertThat(blazeProjectData).isNotNull();
    assertThat(blazeProjectData.targetMap).isEqualTo(targetMap);
    assertThat(blazeProjectData.workspaceLanguageSettings.getWorkspaceType()).isEqualTo(WorkspaceType.INTELLIJ_PLUGIN);
    List<RunConfiguration> runConfigs = RunManager.getInstance(getProject()).getAllConfigurationsList();
    assertThat(runConfigs).hasSize(1);
    assertThat(runConfigs.get(0)).isInstanceOf(BlazeIntellijPluginConfiguration.class);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) Test(org.junit.Test)

Aggregations

BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)82 File (java.io.File)31 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)28 Nullable (javax.annotation.Nullable)24 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)23 Test (org.junit.Test)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)17 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)17 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)15 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)13 WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)13 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)13 Project (com.intellij.openapi.project.Project)13 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)11 ImmutableList (com.google.common.collect.ImmutableList)10 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)10 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)8 List (java.util.List)8 BlazeProjectDataManager (com.google.idea.blaze.base.sync.data.BlazeProjectDataManager)7