use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendClass clazz, @Extension final IFormattableDocument format) {
this.formatAnnotations(clazz, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
this.formatModifiers(clazz, format);
this.formatTypeParameters(clazz, clazz.getTypeParameters(), format);
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(this.textRegionExtensions.regionFor(clazz).keyword("class"), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.surround(this.textRegionExtensions.regionFor(clazz).keyword("extends"), _function_1);
format.<JvmTypeReference>format(clazz.getExtends());
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.surround(this.textRegionExtensions.regionFor(clazz).keyword("implements"), _function_2);
EList<JvmTypeReference> _implements = clazz.getImplements();
for (final JvmTypeReference imp : _implements) {
{
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(imp).keyword(","), _function_3), _function_4);
format.<JvmTypeReference>format(imp);
}
}
this.formatBody(clazz, format);
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FileAwareTestLanguageFormatter method _format.
protected void _format(final PackageDeclaration pkg, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.setNewLines(2);
};
document.append(this.textRegionExtensions.regionFor(pkg).feature(FileAwarePackage.Literals.PACKAGE_DECLARATION__NAME), _function);
EList<Import> _imports = pkg.getImports();
for (final Import imp : _imports) {
{
document.<Import>format(imp);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
int _xifexpression = (int) 0;
Import _last = IterableExtensions.<Import>last(pkg.getImports());
boolean _tripleEquals = (imp == _last);
if (_tripleEquals) {
_xifexpression = 2;
} else {
_xifexpression = 1;
}
it.setNewLines(_xifexpression);
};
document.<Import>append(imp, _function_1);
}
}
EList<Element> _contents = pkg.getContents();
for (final Element element : _contents) {
document.<Element>format(element);
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class PartialSerializationTestLanguageFormatter method _format.
protected void _format(final Node obj, @Extension final IFormattableDocument document) {
List<ISemanticRegion> _keywords = this.textRegionExtensions.regionFor(obj).keywords(";");
for (final ISemanticRegion r : _keywords) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(document.prepend(r, _function), _function_1);
}
EList<Node> _children = obj.getChildren();
for (final Node child : _children) {
document.<Node>format(child);
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FormattableDocument method set.
@Override
public Pair<IHiddenRegion, IHiddenRegion> set(IHiddenRegion first, IHiddenRegion second, Procedure1<? super IHiddenRegionFormatter> init) {
if (first != null && second != null) {
AbstractFormatter2 formatter = getFormatter();
IHiddenRegionFormatting f1 = formatter.createHiddenRegionFormatting();
IHiddenRegionFormatting f2 = formatter.createHiddenRegionFormatting();
init.apply(formatter.createHiddenRegionFormatter(f1, f2));
ITextReplacer replacer1 = formatter.createHiddenRegionReplacer(first, f1);
ITextReplacer replacer2 = formatter.createHiddenRegionReplacer(second, f2);
addReplacer(replacer1);
addReplacer(replacer2);
}
return Pair.of(first, second);
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-core by eclipse.
the class FormattableDocument method append.
@Override
public <T extends EObject> T append(T owner, Procedure1<? super IHiddenRegionFormatter> after) {
if (owner != null) {
IEObjectRegion region = getTextRegionAccess().regionForEObject(owner);
if (region != null) {
IHiddenRegion gap = region.getNextHiddenRegion();
set(gap, after);
}
}
return owner;
}
Aggregations