Search in sources :

Example 1 with DefaultFoldedPosition

use of org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition in project xtext-xtend by eclipse.

the class XtendFoldingRegionProviderTest method testFoldCopyrightHeader2.

@Test
public void testFoldCopyrightHeader2() throws Exception {
    String content = "package test\n/**\n * \n * Hello Copyright\n * \n */\nimport java.util.List\nimport java.util.Set\nclass Bar{}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Bar", content);
    assertEquals(2, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition first = iterator.next();
    assertEquals(48, first.getOffset());
    assertEquals(43, first.length);
    assertTrue(((DefaultFoldedPosition) first).isInitiallyFolded());
    FoldedPosition second = iterator.next();
    assertEquals(13, second.getOffset());
    assertEquals(35, second.length);
    assertFalse(((DefaultFoldedPosition) second).isInitiallyFolded());
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Example 2 with DefaultFoldedPosition

use of org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition in project xtext-xtend by eclipse.

the class XtendFoldingRegionProviderTest method testFoldCopyrightHeader.

@Test
public void testFoldCopyrightHeader() throws Exception {
    String content = "/**\n * \n * Hello Copyright\n * \n */\npackage test\nimport java.util.List\nimport java.util.Set\nclass Bar{}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Bar", content);
    assertEquals(2, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition first = iterator.next();
    assertEquals(48, first.getOffset());
    assertEquals(43, first.length);
    assertTrue(((DefaultFoldedPosition) first).isInitiallyFolded());
    FoldedPosition second = iterator.next();
    assertEquals(0, second.getOffset());
    assertEquals(35, second.length);
    assertTrue(((DefaultFoldedPosition) second).isInitiallyFolded());
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Aggregations

DefaultFoldedPosition (org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition)2 FoldedPosition (org.eclipse.xtext.ui.editor.folding.FoldedPosition)2 Test (org.junit.Test)2