Search in sources :

Example 51 with FoldingDescriptor

use of com.intellij.lang.folding.FoldingDescriptor in project intellij by bazelbuild.

the class BuildFileFoldingBuilderTest method testFuncDefStatementsFolded.

@Test
public void testFuncDefStatementsFolded() {
    BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "# multi-line comment, not folded", "# second line of comment", "def function(arg1, arg2):", "    stmt1", "    stmt2", "", "variable = 1");
    FoldingDescriptor[] foldingRegions = getFoldingRegions(file);
    assertThat(foldingRegions).hasLength(1);
    assertThat(foldingRegions[0].getElement().getPsi()).isEqualTo(file.findFunctionInScope("function"));
}
Also used : BuildFile(com.google.idea.blaze.base.lang.buildfile.psi.BuildFile) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) FoldingDescriptor(com.intellij.lang.folding.FoldingDescriptor) Test(org.junit.Test)

Aggregations

FoldingDescriptor (com.intellij.lang.folding.FoldingDescriptor)51 TextRange (com.intellij.openapi.util.TextRange)31 ASTNode (com.intellij.lang.ASTNode)20 PsiElement (com.intellij.psi.PsiElement)16 IElementType (com.intellij.psi.tree.IElementType)12 NamedFoldingDescriptor (com.intellij.lang.folding.NamedFoldingDescriptor)8 PsiComment (com.intellij.psi.PsiComment)7 PsiWhiteSpace (com.intellij.psi.PsiWhiteSpace)7 FoldingGroup (com.intellij.openapi.editor.FoldingGroup)6 UnfairTextRange (com.intellij.openapi.util.UnfairTextRange)6 NotNull (org.jetbrains.annotations.NotNull)6 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)4 Nullable (org.jetbrains.annotations.Nullable)4 BuildFile (com.google.idea.blaze.base.lang.buildfile.psi.BuildFile)3 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)3 FoldRegion (com.intellij.openapi.editor.FoldRegion)3 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)3 Test (org.junit.Test)3 HbBlockWrapper (com.dmarcotte.handlebars.psi.HbBlockWrapper)2