Search in sources :

Example 71 with ProjectView

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\"");
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) OCReferenceElement(com.jetbrains.cidr.lang.psi.OCReferenceElement) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) OCImportSymbolFix(com.jetbrains.cidr.lang.quickfixes.OCImportSymbolFix) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 72 with ProjectView

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\"");
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) OCReferenceElement(com.jetbrains.cidr.lang.psi.OCReferenceElement) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) OCImportSymbolFix(com.jetbrains.cidr.lang.quickfixes.OCImportSymbolFix) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 73 with ProjectView

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();
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 74 with ProjectView

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");
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Example 75 with ProjectView

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");
}
Also used : ProjectView(com.google.idea.blaze.base.projectview.ProjectView) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Test(org.junit.Test)

Aggregations

ProjectView (com.google.idea.blaze.base.projectview.ProjectView)87 Test (org.junit.Test)81 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)55 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)45 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)33 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)13 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)12 File (java.io.File)12 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)9 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)8 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)7 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)6 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)5 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)5 ImmutableList (com.google.common.collect.ImmutableList)4 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)4 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)4