use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeCppAutoImportHelperTest method differentDirectory_importUserHeader.
@Test
public void differentDirectory_importUserHeader() {
ProjectView projectView = projectView(directories("foo/bar", "baz"), targets("//foo/bar", "//baz"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:bar", Kind.CC_LIBRARY, sources("foo/bar/bar.cc"), sources())).addTarget(createCcTarget("//baz:baz", Kind.CC_LIBRARY, sources(""), sources("baz/test.h"))).build();
OCFile header = createFile("baz/test.h", "class SomeClass {};");
OCFile file = createFile("foo/bar/bar.cc", "SomeClass* my_class = new SomeClass();");
resolve(projectView, targetMap, file, header);
testFixture.openFileInEditor(file.getVirtualFile());
OCReferenceElement referenceElement = testFixture.findElementByText("SomeClass*", OCReferenceElement.class);
OCImportSymbolFix fix = new OCImportSymbolFix(referenceElement);
assertThat(fix.isAvailable(getProject(), testFixture.getEditor(), file)).isTrue();
assertThat(fix.getAutoImportItems()).hasSize(1);
assertThat(fix.getAutoImportItems().get(0).getTitleAndLocation().getFirst()).isEqualTo("class 'SomeClass'");
assertThat(fix.getAutoImportItems().get(0).getTitleAndLocation().getSecond()).isEqualTo("\"baz/test.h\"");
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeCppAutoImportHelperTest method sameDirectory_importUserHeader.
@Test
public void sameDirectory_importUserHeader() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:bar"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:bar", Kind.CC_LIBRARY, sources("foo/bar/bar.cc"), sources("foo/bar/test.h"))).build();
OCFile header = createFile("foo/bar/test.h", "class SomeClass {};");
OCFile file = createFile("foo/bar/bar.cc", "SomeClass* my_class = new SomeClass();");
resolve(projectView, targetMap, file, header);
testFixture.openFileInEditor(file.getVirtualFile());
OCReferenceElement referenceElement = testFixture.findElementByText("SomeClass*", OCReferenceElement.class);
OCImportSymbolFix fix = new OCImportSymbolFix(referenceElement);
assertThat(fix.isAvailable(getProject(), testFixture.getEditor(), file)).isTrue();
assertThat(fix.getAutoImportItems()).hasSize(1);
assertThat(fix.getAutoImportItems().get(0).getTitleAndLocation().getFirst()).isEqualTo("class 'SomeClass'");
assertThat(fix.getAutoImportItems().get(0).getTitleAndLocation().getSecond()).isEqualTo("\"foo/bar/test.h\"");
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method testEmptyProject.
@Test
public void testEmptyProject() {
ProjectView projectView = projectView(directories(), targets());
TargetMap targetMap = TargetMapBuilder.builder().build();
assertThatResolving(projectView, targetMap).producesNoConfigurations();
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method testSingleSourceTargetWithLibraryDependencies.
@Test
public void testSingleSourceTargetWithLibraryDependencies() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:binary"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc"))).addDependency("//bar/baz:library").addDependency("//third_party:library")).addTarget(createCcTarget("//bar/baz:library", Kind.CC_LIBRARY, ImmutableList.of(src("bar/baz/library.cc")))).addTarget(createCcTarget("//third_party:library", Kind.CC_LIBRARY, ImmutableList.of(src("third_party/library.cc")))).build();
assertThatResolving(projectView, targetMap).producesConfigurationsFor("//foo/bar:binary");
}
use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.
the class BlazeConfigurationResolverTest method firstResolve_testNotIncremental.
@Test
public void firstResolve_testNotIncremental() {
ProjectView projectView = projectView(directories("foo/bar"), targets("//foo/bar:binary"));
TargetMap targetMap = TargetMapBuilder.builder().addTarget(createCcToolchain()).addTarget(createCcTarget("//foo/bar:binary", Kind.CC_BINARY, ImmutableList.of(src("foo/bar/binary.cc")))).build();
ImmutableList<BlazeResolveConfiguration> noReusedConfigurations = ImmutableList.of();
assertThatResolving(projectView, targetMap).reusedConfigurations(noReusedConfigurations, "//foo/bar:binary");
}
Aggregations