use of com.jetbrains.cidr.lang.psi.OCFile 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.jetbrains.cidr.lang.psi.OCFile 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.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class BlazeCppIntegrationTestCase method createFile.
protected OCFile createFile(String relativePath, String... contentLines) {
PsiFile file = workspace.createPsiFile(new WorkspacePath(relativePath), contentLines);
assertThat(file).isInstanceOf(OCFile.class);
return (OCFile) file;
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method parseAssociatedAngle.
@Test
public void parseAssociatedAngle() {
OCFile file = createFile("implementation.cc", "#include <some/interface.h> // IWYU pragma: associated", "", "#include \"other_stuff.h\"");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.associatedHeader.isPresent()).isTrue();
assertThat(pragmas.associatedHeader.get()).isEqualTo(IncludePath.create("some/interface.h", Delimiters.ANGLE_BRACKETS));
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method incompletePath_parse.
@Test
public void incompletePath_parse() {
OCFile file = createFile("bar.cc", "#include <memory>", "#include <vecto");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.keeps).isEmpty();
}
Aggregations