Search in sources :

Example 21 with OCFile

use of com.jetbrains.cidr.lang.psi.OCFile 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 22 with OCFile

use of com.jetbrains.cidr.lang.psi.OCFile 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)

Example 23 with OCFile

use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.

the class IwyuPragmasTest method incompletePragma_parseKeep.

@Test
public void incompletePragma_parseKeep() {
    OCFile file = createFile("bar.cc", "#include \"f/foo1.h\" // IWYU pragma: kee", "#include \"f/foo2.h\" // IWYU pragma: keep");
    IwyuPragmas pragmas = IwyuPragmas.parse(file);
    assertThat(pragmas.keeps).containsExactly(KeepPragma.create(IncludePath.create("f/foo2.h", Delimiters.QUOTES)));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) Test(org.junit.Test)

Example 24 with OCFile

use of com.jetbrains.cidr.lang.psi.OCFile 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 25 with OCFile

use of com.jetbrains.cidr.lang.psi.OCFile in project intellij by bazelbuild.

the class IwyuPragmasTest method multipleRanges_parseExportBeginEnd.

@Test
public void multipleRanges_parseExportBeginEnd() {
    OCFile file = createFile("public/foo.h", "/** Stuff */", "// IWYU pragma: begin_exports", "#include <private/memory>", "#include \"private/foo1.h\"", "#include \"private/foo2.h\"", "// IWYU pragma: end_exports", "#include \"private/foo3.h\"", "#include \"private/foo4.h\"", "   // IWYU pragma: begin_exports", "#include \"private/foo5.h\"", "   // IWYU pragma: end_exports", "#include \"private/foo6.h\"", "", "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/foo2.h", Delimiters.QUOTES)), ExportPragma.create(IncludePath.create("private/foo5.h", Delimiters.QUOTES)));
}
Also used : OCFile(com.jetbrains.cidr.lang.psi.OCFile) Test(org.junit.Test)

Aggregations

OCFile (com.jetbrains.cidr.lang.psi.OCFile)35 Test (org.junit.Test)28 PrivatePragma (com.google.idea.blaze.cpp.includes.IwyuPragmas.PrivatePragma)8 PsiFile (com.intellij.psi.PsiFile)5 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)3 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)3 Project (com.intellij.openapi.project.Project)3 OCReferenceElement (com.jetbrains.cidr.lang.psi.OCReferenceElement)3 OCImportSymbolFix (com.jetbrains.cidr.lang.quickfixes.OCImportSymbolFix)3 ImmutableList (com.google.common.collect.ImmutableList)2 GotoRelatedItem (com.intellij.navigation.GotoRelatedItem)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 List (java.util.List)2 Nullable (javax.annotation.Nullable)2 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)1 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)1 PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)1 Couple (com.intellij.openapi.util.Couple)1