Search in sources :

Example 6 with PrivatePragma

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

the class IwyuPragmasTest method parsePrivate.

@Test
public void parsePrivate() {
    OCFile file = createFile("private.h", "// Stuff", "// IWYU pragma: private", "#include \"private_details.h\"");
    IwyuPragmas pragmas = IwyuPragmas.parse(file);
    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 7 with PrivatePragma

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

the class IwyuPragmasTest method hasMultipleOtherOrder_parsePrivate.

@Test
public void hasMultipleOtherOrder_parsePrivate() {
    // Like hasMultiple_parsePrivate, but with order swapped
    OCFile file = createFile("private.h", "// Stuff", "// IWYU pragma: private, include \"public.h\"", "// IWYU pragma: private", "#include \"private_details.h\"");
    IwyuPragmas pragmas = IwyuPragmas.parse(file);
    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 8 with PrivatePragma

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

the class IwyuPragmasTest method hasMultiple_parsePrivate.

@Test
public void hasMultiple_parsePrivate() {
    // We shouldn't have multiple private pragmas, but we just take the last one.
    // An alternative might be to take the most descriptive one (when there is a unique
    // most descriptive one).
    OCFile file = createFile("private.h", "// Stuff", "// IWYU pragma: private", "// IWYU pragma: private, include \"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("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)

Aggregations

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