org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtendFoldingRegionProviderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: XtendFoldingRegionProviderTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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());
}
 
Example #3
Source File: AbstractFoldingTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Verifies that FoldedPositions are valid.
 * If the assertion fails that is probably due to an ITextRegion.EMPTY_REGION being provided for the object's significant text region.
 */
@BugTest("ACF-2605")
public void testFoldedPositions() {
  Collection<FoldedPosition> foldingRegions = getXtextTestUtil().get(IFoldingRegionProvider.class).getFoldingRegions(getDocument());
  for (DefaultFoldedPosition foldedPosition : Iterables.filter(foldingRegions, DefaultFoldedPosition.class)) {
    try {
      Assert.assertFalse("Illegal significant region for FoldedPosition " + foldedPosition, foldedPosition.computeCaptionOffset(getDocument()) < 0);
      /* If the above assertion fails that is probably due to an ITextRegion.EMPTY_REGION being provided for the object's significant text region. */
    } catch (BadLocationException e) {
      fail("Bad location for FoldedPosition: " + e.getMessage());
    }
  }
}