Search in sources :

Example 1 with PrivatePragma

use of com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma 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));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) PrivatePragma(com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma) Test(org.junit.Test)

Example 2 with PrivatePragma

use of com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma 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));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) PrivatePragma(com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma) Test(org.junit.Test)

Example 3 with PrivatePragma

use of com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma 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();
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) PrivatePragma(com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma) Test(org.junit.Test)

Example 4 with PrivatePragma

use of com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma in project intellij by bazelbuild.

the class IwyuPragmasTest method parsePrivateIncludeOtherAngle.

@Test
public void parsePrivateIncludeOtherAngle() {
    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.ANGLE_BRACKETS));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) PrivatePragma(com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma) Test(org.junit.Test)

Example 5 with PrivatePragma

use of com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma in project intellij by bazelbuild.

the class IwyuPragmasTest method parsePrivateIncludeOtherNoQuotes.

@Test
public void parsePrivateIncludeOtherNoQuotes() {
    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.NONE));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) PrivatePragma(com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma) Test(org.junit.Test)

Aggregations

PrivatePragma (com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma)8 OCFile (com.jetbrains.cidr.lang.psi.OCFile)8 Test (org.junit.Test)8