use of org.eclipse.xtext.ui.tests.folding.Element 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.tests.folding.Element in project xtext-eclipse by eclipse.
the class FoldingTestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == FoldingPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case FoldingPackage.ELEMENT:
sequence_Element(context, (Element) semanticObject);
return;
case FoldingPackage.FOLDING_MODEL:
sequence_FoldingModel(context, (FoldingModel) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.ui.tests.folding.Element in project xtext-eclipse by eclipse.
the class DefaultFoldingRegionProviderTest method testIsHandled.
@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());
}
Aggregations