use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-eclipse by eclipse.
the class RuleEngineFormatter method _format.
@Override
protected void _format(final XSwitchExpression expr, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.set(this.textRegionExtensions.previousHiddenRegion(expr.getSwitch()), this.textRegionExtensions.nextHiddenRegion(expr), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("switch"), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.<XExpression>format(document.<XExpression>append(expr.getSwitch(), _function_2));
EList<XCasePart> _cases = expr.getCases();
for (final XCasePart c : _cases) {
{
if (((c.getTypeGuard() != null) && (c.getCase() != null))) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_3);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(c.getCase(), _function_4);
} else {
JvmTypeReference _typeGuard = c.getTypeGuard();
boolean _tripleNotEquals = (_typeGuard != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_5);
} else {
XExpression _case = c.getCase();
boolean _tripleNotEquals_1 = (_case != null);
if (_tripleNotEquals_1) {
final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(document.<XExpression>prepend(c.getCase(), _function_6), _function_7);
}
}
}
final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(document.prepend(this.textRegionExtensions.regionFor(c).feature(XbasePackage.Literals.XCASE_PART__FALL_THROUGH), _function_8), _function_9);
document.<XExpression>format(c.getCase());
if ((Objects.equal(c, IterableExtensions.<XCasePart>last(expr.getCases())) && (expr.getDefault() == null))) {
this.formatBody(c.getThen(), true, document);
} else {
this.formatBodyParagraph(c.getThen(), document);
}
}
}
XExpression _default = expr.getDefault();
boolean _tripleNotEquals = (_default != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("default"), _function_3);
this.formatBody(expr.getDefault(), true, document);
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-eclipse by eclipse.
the class DomainmodelFormatter method _format.
protected void _format(final DomainModel domainmodel, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.setNewLines(0, 0, 1);
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.<DomainModel>append(document.<DomainModel>prepend(domainmodel, _function), _function_1);
this.format(domainmodel.getImportSection(), document);
EList<AbstractElement> _elements = domainmodel.getElements();
for (final AbstractElement element : _elements) {
this.format(element, document);
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-eclipse by eclipse.
the class DomainmodelFormatter method _format.
protected void _format(final PackageDeclaration pkg, @Extension final IFormattableDocument document) {
final ISemanticRegion open = this.textRegionExtensions.regionFor(pkg).keyword("{");
final ISemanticRegion close = this.textRegionExtensions.regionFor(pkg).keyword("}");
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.surround(this.textRegionExtensions.regionFor(pkg).feature(DomainmodelPackage.Literals.ABSTRACT_ELEMENT__NAME), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(open, _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_2);
EList<AbstractElement> _elements = pkg.getElements();
for (final AbstractElement element : _elements) {
{
document.<AbstractElement>format(element);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.setNewLines(1, 1, 2);
};
document.<AbstractElement>append(element, _function_3);
}
}
}
use of org.eclipse.xtext.formatting2.IHiddenRegionFormatter in project xtext-eclipse by eclipse.
the class DomainmodelFormatter method _format.
protected void _format(final Operation operation, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(this.textRegionExtensions.regionFor(operation).keyword("op"), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.surround(this.textRegionExtensions.regionFor(operation).keyword("("), _function_1);
boolean _isEmpty = operation.getParams().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
List<ISemanticRegion> _keywords = this.textRegionExtensions.regionFor(operation).keywords(",");
for (final ISemanticRegion comma : _keywords) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(document.prepend(comma, _function_2), _function_3);
}
EList<JvmFormalParameter> _params = operation.getParams();
for (final JvmFormalParameter params : _params) {
document.<JvmFormalParameter>format(params);
}
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.prepend(this.textRegionExtensions.regionFor(operation).keyword(")"), _function_4);
}
JvmTypeReference _type = operation.getType();
boolean _tripleNotEquals = (_type != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.append(this.textRegionExtensions.regionFor(operation).keyword(")"), _function_5);
final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.<JvmTypeReference>append(document.<JvmTypeReference>prepend(operation.getType(), _function_6), _function_7);
document.<JvmTypeReference>format(operation.getType());
} else {
final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(this.textRegionExtensions.regionFor(operation).keyword(")"), _function_8);
}
document.<XExpression>format(operation.getBody());
}
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);
}
}
Aggregations