org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider.
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: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Test public void testIsHandled() 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 isHandled(EObject object) { if (object instanceof Element) { return !"foo".equals(((Element) object).getName()); } return super.isHandled(object); } }; Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); assertEquals("element foo \n".length(), regions.iterator().next().getOffset()); }
Example #2
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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()); }
Example #3
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfModel_03() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n" + "element\n" + " foo end\n"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); FoldedPosition position = Iterables.getOnlyElement(regions); assertEquals("\n".length(), position.getOffset()); assertEquals("element\n foo end\n".length(), position.getLength()); assertEquals("element\n ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(1, projectionRegions.length); assertEquals("\n".length(), projectionRegions[0].getOffset()); assertEquals("element\n".length(), projectionRegions[0].getLength()); }
Example #4
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfModel_02() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n" + "element\n" + " foo\n" + "end\n"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); FoldedPosition position = Iterables.getOnlyElement(regions); assertEquals("\n".length(), position.getOffset()); assertEquals("element\n foo\nend\n".length(), position.getLength()); assertEquals("element\n ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(2, projectionRegions.length); assertEquals("\n".length(), projectionRegions[0].getOffset()); assertEquals("element\n".length(), projectionRegions[0].getLength()); assertEquals("\nelement\n foo\n".length(), projectionRegions[1].getOffset()); assertEquals("end\n".length(), projectionRegions[1].getLength()); }
Example #5
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfModel_01() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n" + "element foo\n" + "end\n"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); FoldedPosition position = Iterables.getOnlyElement(regions); assertEquals("\n".length(), position.getOffset()); assertEquals("element foo\nend\n".length(), position.getLength()); assertEquals("element ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(1, projectionRegions.length); assertEquals("\nelement foo\n".length(), projectionRegions[0].getOffset()); assertEquals("end\n".length(), projectionRegions[0].getLength()); }
Example #6
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfMlComment_04() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n/**\n *\n * foo */\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 * foo */\n".length(), position.getLength()); assertEquals("/**\n *\n * ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(1, projectionRegions.length); assertEquals("\n".length(), projectionRegions[0].getOffset()); assertEquals("/**\n *\n".length(), projectionRegions[0].getLength()); }
Example #7
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfMlComment_03() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n/**\n *\n * foo\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 * foo\n *\n */\n".length(), position.getLength()); assertEquals("/**\n *\n * ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(2, projectionRegions.length); assertEquals("\n".length(), projectionRegions[0].getOffset()); assertEquals("/**\n *\n".length(), projectionRegions[0].getLength()); assertEquals("\n/**\n *\n * foo\n".length(), projectionRegions[1].getOffset()); assertEquals(" *\n */\n".length(), projectionRegions[1].getLength()); }
Example #8
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testSignificantPartOfMlComment_02() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "\n/** foo\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("/** foo\n *\n */\n".length(), position.getLength()); assertEquals("/** ".length(), position.computeCaptionOffset(document)); IRegion[] projectionRegions = position.computeProjectionRegions(document); assertEquals(1, projectionRegions.length); assertEquals("\n/** foo\n".length(), projectionRegions[0].getOffset()); assertEquals(" *\n */\n".length(), projectionRegions[0].getLength()); }
Example #9
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@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()); }
Example #10
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegionsWithMutltipleMlComment() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "/**\n*/\n element foo \nelement bar \n/**\n*/\n end \nelement \n/**\n*/\n baz end \n/**\n*/\n end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(7, regions.size()); }
Example #11
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #12
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegionsWithMlCommentBetween() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \nelement bar \n /**\n*/ \n end \nelement baz end end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(3, regions.size()); }
Example #13
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #14
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example #15
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegionsWithMlCommentInSameLine() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "/* */\n element foo \nelement bar end \nelement baz end end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); }
Example #16
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegions3() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \nelement \nbar end \nelement baz \nend end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(3, regions.size()); }
Example #17
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegions2() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \nelement bar \nend \nelement baz end end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(2, regions.size()); }
Example #18
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetFoldingRegions1() throws Exception { IFile iFile = createFile("foo/bar.foldingtestlanguage", "element foo \nelement bar end \nelement baz end end"); IXtextDocument document = openFileAndReturnDocument(iFile); DefaultFoldingRegionProvider reg = createFoldingRegionProvider(); Collection<FoldedPosition> regions = reg.getFoldingRegions(document); assertEquals(1, regions.size()); }
Example #19
Source File: DefaultFoldingRegionProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@SuppressWarnings("deprecation") protected DefaultFoldingRegionProvider createFoldingRegionProvider() { return new DefaultFoldingRegionProvider(new DefaultLocationInFileProvider()); }