Java Code Examples for org.eclipse.xtext.ui.editor.folding.FoldedPosition#computeProjectionRegions()
The following examples show how to use
org.eclipse.xtext.ui.editor.folding.FoldedPosition#computeProjectionRegions() .
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 |
@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 2
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 3
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 4
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 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 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 7
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()); }