use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method parsePrivateIncludeOther.
@Test
public void parsePrivateIncludeOther() {
OCFile file = createFile("private.h", "// IWYU pragma: private, include \"f/public.h\"", "#include \"private_details.h\"");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.privatePragma.isPresent()).isTrue();
PrivatePragma privatePragma = pragmas.privatePragma.get();
assertThat(privatePragma.includeOther.isPresent()).isTrue();
assertThat(privatePragma.includeOther.get()).isEqualTo(IncludePath.create("f/public.h", Delimiters.QUOTES));
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method withWhiteSpace_parsePrivateIncludeOther.
@Test
public void withWhiteSpace_parsePrivateIncludeOther() {
OCFile file = createFile("private.h", "// IWYU pragma:private,include\"f/public.h\" ", "#include \"private_details.h\"");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.privatePragma.isPresent()).isTrue();
PrivatePragma privatePragma = pragmas.privatePragma.get();
assertThat(privatePragma.includeOther.isPresent()).isTrue();
assertThat(privatePragma.includeOther.get()).isEqualTo(IncludePath.create("f/public.h", Delimiters.QUOTES));
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method parseExport.
@Test
public void parseExport() {
OCFile file = createFile("public/foo.h", "/** Stuff */", "#include <private/memory> // IWYU pragma: export", "#include <vector>", "", "#include \"private/foo1.h\" // IWYU pragma: export", "#include \"private/foo2.h\"", "#include \"private/foo3.h\" // IWYU pragma: export", "", "void doFoo(Foo* f);");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.exports).containsExactly(ExportPragma.create(IncludePath.create("private/memory", Delimiters.ANGLE_BRACKETS)), ExportPragma.create(IncludePath.create("private/foo1.h", Delimiters.QUOTES)), ExportPragma.create(IncludePath.create("private/foo3.h", Delimiters.QUOTES)));
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method duplicate_parseKeep.
@Test
public void duplicate_parseKeep() {
// Probably need to disambiguate the PSI nodes somewhere (last one shouldn't be kept?)
OCFile file = createFile("bar.cc", "#include \"f/foo1.h\" // IWYU pragma: keep", "#include \"f/foo1.h\" // IWYU pragma: keep", "#include \"f/foo1.h\"");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
assertThat(pragmas.keeps).containsExactly(KeepPragma.create(IncludePath.create("f/foo1.h", Delimiters.QUOTES)));
}
use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.
the class IwyuPragmasTest method sortOfCommentViaIfdef_parsePrivate.
@Test
public void sortOfCommentViaIfdef_parsePrivate() {
OCFile file = createFile("bar.cc", "#include <memory>", "#if 0", "IWYU pragma: private", "#endif");
IwyuPragmas pragmas = IwyuPragmas.parse(file);
// We don't really support this, but #ifdef'ed out things may be parsed as PsiComment,
// so at least make sure we don't assert. Answer could go either way.
assertThat(pragmas.privatePragma.isPresent()).isTrue();
PrivatePragma privatePragma = pragmas.privatePragma.get();
assertThat(privatePragma.includeOther.isPresent()).isFalse();
}
Aggregations