Search in sources :

Example 26 with FoldedPosition

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

the class DefaultFoldingRegionProviderTest method testGetFoldingRegionsWithMutltipleMlComment.

@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());
}
Also used : IFile(org.eclipse.core.resources.IFile) DefaultFoldingRegionProvider(org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider) FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 27 with FoldedPosition

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

the class DefaultFoldingRegionProviderTest method testGetFoldingRegions3.

@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());
}
Also used : IFile(org.eclipse.core.resources.IFile) DefaultFoldingRegionProvider(org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider) FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 28 with FoldedPosition

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

the class DefaultFoldingRegionProviderTest method testGetFoldingRegionsWithMlCommentInSameLine.

@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());
}
Also used : IFile(org.eclipse.core.resources.IFile) DefaultFoldingRegionProvider(org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider) FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 29 with FoldedPosition

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

the class DefaultFoldingRegionProviderTest method testGetFoldingRegions1.

@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());
}
Also used : IFile(org.eclipse.core.resources.IFile) DefaultFoldingRegionProvider(org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider) FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

Example 30 with FoldedPosition

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

the class DefaultFoldingRegionProviderTest method testGetFoldingRegionsWithMlCommentBetween.

@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());
}
Also used : IFile(org.eclipse.core.resources.IFile) DefaultFoldingRegionProvider(org.eclipse.xtext.ui.editor.folding.DefaultFoldingRegionProvider) FoldedPosition(org.eclipse.xtext.ui.editor.folding.FoldedPosition) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) Test(org.junit.Test) AbstractEditorTest(org.eclipse.xtext.ui.testing.AbstractEditorTest)

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