use of org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testShouldProcessContent.
@SuppressWarnings("deprecation")
@Test
public void testShouldProcessContent() throws Exception {
IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \n" + "element bar \n" + "end \n" + "end");
IXtextDocument document = openFileAndReturnDocument(iFile);
DefaultFoldingRegionProvider reg = new DefaultFoldingRegionProvider(new DefaultLocationInFileProvider()) {
@Override
protected boolean shouldProcessContent(EObject object) {
if (object instanceof Element) {
return !"foo".equals(((Element) object).getName());
}
return super.shouldProcessContent(object);
}
};
Collection<FoldedPosition> regions = reg.getFoldingRegions(document);
assertEquals(1, regions.size());
assertEquals(0, regions.iterator().next().getOffset());
}
use of org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testGetFoldingRegionsWithMlCommentStart.
@Test
public void testGetFoldingRegionsWithMlCommentStart() throws Exception {
IFile iFile = createFile("foo/bar.foldingtestlanguage", "/**\n*/\n element foo \nelement bar end \nelement baz end end");
IXtextDocument document = openFileAndReturnDocument(iFile);
DefaultFoldingRegionProvider reg = createFoldingRegionProvider();
Collection<FoldedPosition> regions = reg.getFoldingRegions(document);
assertEquals(2, regions.size());
}
use of org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testSignificantPartOfMlComment_01.
@Test
public void testSignificantPartOfMlComment_01() throws Exception {
IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n/**\n *\n */\n element foo end");
IXtextDocument document = openFileAndReturnDocument(iFile);
DefaultFoldingRegionProvider reg = createFoldingRegionProvider();
Collection<FoldedPosition> regions = reg.getFoldingRegions(document);
assertEquals(1, regions.size());
FoldedPosition position = Iterables.getOnlyElement(regions);
assertEquals(1, position.getOffset());
assertEquals("/**\n *\n */\n".length(), position.getLength());
assertEquals(0, position.computeCaptionOffset(document));
IRegion[] projectionRegions = position.computeProjectionRegions(document);
assertEquals(1, projectionRegions.length);
assertEquals("\n/**\n".length(), projectionRegions[0].getOffset());
assertEquals(" *\n */\n".length(), projectionRegions[0].getLength());
}
use of org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testGetFoldingRegionsWithMlCommentEnd.
@Test
public void testGetFoldingRegionsWithMlCommentEnd() throws Exception {
IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \nelement bar end \nelement baz end end\n/**\n*/");
IXtextDocument document = openFileAndReturnDocument(iFile);
DefaultFoldingRegionProvider reg = createFoldingRegionProvider();
Collection<FoldedPosition> regions = reg.getFoldingRegions(document);
assertEquals(2, regions.size());
}
use of org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testGetFoldingRegions0.
@Test
public void testGetFoldingRegions0() throws Exception {
IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo element bar end element baz end end");
IXtextDocument document = openFileAndReturnDocument(iFile);
DefaultFoldingRegionProvider reg = createFoldingRegionProvider();
Collection<FoldedPosition> regions = reg.getFoldingRegions(document);
assertEquals(0, regions.size());
}
Aggregations