Search in sources :

Example 26 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoTestEventsHandlerTest method testTopLevelTestTargetResolves.

@Test
public void testTopLevelTestTargetResolves() {
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//:foo_test").setKind("go_test").setBuildFile(src("BUILD")).addSource(src("foo_test.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo_test.go"))).setImportPath("foo"))).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, new WorkspacePathResolverImpl(workspaceRoot), location -> workspaceRoot.fileForPath(new WorkspacePath(location.getRelativePath())), new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
    GoFile goFile = (GoFile) workspace.createPsiFile(new WorkspacePath("foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
    workspace.createFile(new WorkspacePath("BUILD"), "go_test(", "    name = 'foo_test',", "    srcs = ['foo_test.go'],", ")");
    String url = handler.suiteLocationUrl(null, "foo_test");
    Location<?> location = getLocation(url);
    assertThat(location).isNotNull();
    assertThat(location.getPsiElement()).isEqualTo(goFile);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) GoFile(com.goide.psi.GoFile) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 27 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoTestEventsHandlerTest method testFunctionLocationResolves.

@Test
public void testFunctionLocationResolves() {
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//foo/bar:foo_test").setKind("go_test").setBuildFile(src("foo/bar/BUILD")).addSource(src("foo/bar/foo_test.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/foo_test.go"))).setImportPath("google3/foo/bar/foo"))).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, new WorkspacePathResolverImpl(workspaceRoot), location -> workspaceRoot.fileForPath(new WorkspacePath(location.getRelativePath())), new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
    GoFile goFile = (GoFile) workspace.createPsiFile(new WorkspacePath("foo/bar/foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
    workspace.createFile(new WorkspacePath("foo/bar/BUILD"), "go_test(", "    name = 'foo_test',", "    srcs = ['foo_test.go'],", ")");
    GoFunctionDeclaration function = PsiUtils.findFirstChildOfClassRecursive(goFile, GoFunctionDeclaration.class);
    assertThat(function).isNotNull();
    String url = handler.testLocationUrl(null, "foo/bar/foo_test", "TestFoo", null);
    Location<?> location = getLocation(url);
    assertThat(location).isNotNull();
    assertThat(location.getPsiElement()).isEqualTo(function);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) GoFile(com.goide.psi.GoFile) GoFunctionDeclaration(com.goide.psi.GoFunctionDeclaration) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 28 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoTestEventsHandlerTest method testSuiteLocationResolvesToSingleSourceFile.

@Test
public void testSuiteLocationResolvesToSingleSourceFile() {
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//foo/bar:foo_test").setKind("go_test").setBuildFile(src("foo/bar/BUILD")).addSource(src("foo/bar/foo_test.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/foo_test.go"))).setImportPath("google3/foo/bar/foo"))).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, new WorkspacePathResolverImpl(workspaceRoot), location -> workspaceRoot.fileForPath(new WorkspacePath(location.getRelativePath())), new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
    GoFile goFile = (GoFile) workspace.createPsiFile(new WorkspacePath("foo/bar/foo_test.go"), "package foo", "import \"testing\"", "func TestFoo(t *testing.T) {}");
    workspace.createFile(new WorkspacePath("foo/bar/BUILD"), "go_test(", "    name = 'foo_test',", "    srcs = ['foo_test.go'],", ")");
    String url = handler.suiteLocationUrl(null, "foo/bar/foo_test");
    Location<?> location = getLocation(url);
    assertThat(location).isNotNull();
    assertThat(location.getPsiElement()).isEqualTo(goFile);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) GoFile(com.goide.psi.GoFile) WorkspacePathResolverImpl(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 29 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoSyncPluginTest method testGoWorkspaceTypeError.

@Test
public void testGoWorkspaceTypeError() {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.GO)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings);
    errorCollector.assertIssueContaining("Workspace type 'go' is not supported by this plugin");
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 30 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeDartSyncPluginTest method testDartLanguageAvailable.

@Test
public void testDartLanguageAvailable() {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.DART)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVA, ImmutableSet.of(LanguageClass.DART, LanguageClass.GENERIC, LanguageClass.JAVA)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Aggregations

WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)33 Test (org.junit.Test)28 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)20 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)17 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)13 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)13 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableSet (com.google.common.collect.ImmutableSet)7 WorkspaceType (com.google.idea.blaze.base.model.primitives.WorkspaceType)7 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)6 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)6 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)6 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)6 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)5 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)5 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)5 GoFile (com.goide.psi.GoFile)4 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 PrefetchService (com.google.idea.blaze.base.prefetch.PrefetchService)4