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);
}
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);
}
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);
}
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");
}
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)));
}
Aggregations