Search in sources :

Example 1 with FoldedPosition

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

the class XtendFoldingRegionProviderTest method testRichString_02.

@Test
public void testRichString_02() throws Exception {
    String content = "class Foo {\n" + "  def void xxx() {\n" + "    println('''x y''')\n" + "  }\n" + "}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Foo", content);
    assertEquals(2, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition next = iterator.next();
    assertEquals(0, next.offset);
    assertEquals(59, next.length);
    next = iterator.next();
    assertEquals(12, next.offset);
    assertEquals(46, next.length);
}
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 FoldedPosition

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

the class XtendFoldingRegionProviderTest method testFoldSetLiteral_01.

@Test
public void testFoldSetLiteral_01() throws Exception {
    String content = "class Foo {\n" + "  def xxx() {\n" + "    #{\n" + "      1,\n" + "      2\n" + "    }\n" + "  }\n" + "}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Foo", content);
    assertEquals(3, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition next = iterator.next();
    assertEquals(0, next.offset);
    assertEquals(61, next.length);
    next = iterator.next();
    assertEquals(12, next.offset);
    assertEquals(48, next.length);
    next = iterator.next();
    assertEquals(26, next.offset);
    assertEquals(30, next.length);
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Example 3 with FoldedPosition

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

the class XtendFoldingRegionProviderTest method testFoldClosure_01.

@Test
public void testFoldClosure_01() throws Exception {
    String content = "class Foo {\n" + "  def void xxx() {\n" + "    #[1,2,3].filter [\n" + "      println(it)\n" + "      it%2==0\n" + "    ]\n" + "  }\n" + "}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Foo", content);
    assertEquals(3, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition next = iterator.next();
    assertEquals(0, next.offset);
    assertEquals(96, next.length);
    next = iterator.next();
    assertEquals(12, next.offset);
    assertEquals(83, next.length);
    next = iterator.next();
    assertEquals(31, next.offset);
    assertEquals(60, next.length);
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Example 4 with FoldedPosition

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

the class XtendFoldingRegionProviderTest method testFoldRichString_01.

@Test
public void testFoldRichString_01() throws Exception {
    String content = "class Foo {\n" + "  def void xxx() {\n" + "    println('''\n" + "      x\n" + "      y\n" + "    ''')\n" + "  }\n" + "}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Foo", content);
    assertEquals(3, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition next = iterator.next();
    assertEquals(0, next.offset);
    assertEquals(77, next.length);
    next = iterator.next();
    assertEquals(12, next.offset);
    assertEquals(64, next.length);
    next = iterator.next();
    assertEquals(31, next.offset);
    assertEquals(41, next.length);
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Example 5 with FoldedPosition

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

the class XtendFoldingRegionProviderTest method testFoldListLiteral_01.

@Test
public void testFoldListLiteral_01() throws Exception {
    String content = "class Foo {\n" + "  def xxx() {\n" + "    #[\n" + "      1,\n" + "      2\n" + "    ]\n" + "  }\n" + "}";
    Collection<FoldedPosition> foldingRegions = calculateFoldingRegions("test/Foo", content);
    assertEquals(3, foldingRegions.size());
    Iterator<FoldedPosition> iterator = foldingRegions.iterator();
    FoldedPosition next = iterator.next();
    assertEquals(0, next.offset);
    assertEquals(61, next.length);
    next = iterator.next();
    assertEquals(12, next.offset);
    assertEquals(48, next.length);
    next = iterator.next();
    assertEquals(26, next.offset);
    assertEquals(30, next.length);
}
Also used : FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) DefaultFoldedPosition(org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition) Test(org.junit.Test)

Aggregations

FoldedPosition (org.eclipse.xtext.ui.editor.folding.FoldedPosition)32 Test (org.junit.Test)31 IFile (org.eclipse.core.resources.IFile)19 DefaultFoldingRegionProvider (org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider)18 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)18 AbstractEditorTest (org.eclipse.xtext.ui.testing.AbstractEditorTest)18 DefaultFoldedPosition (org.eclipse.xtext.ui.editor.folding.DefaultFoldedPosition)13 IRegion (org.eclipse.jface.text.IRegion)7 EObject (org.eclipse.emf.ecore.EObject)2 DefaultLocationInFileProvider (org.eclipse.xtext.resource.DefaultLocationInFileProvider)2 Element (org.eclipse.xtext.ui.tests.folding.Element)2 BadLocationException (org.eclipse.jface.text.BadLocationException)1