use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-eclipse by eclipse.
the class StatemachineFormatter method format.
protected void format(State s, IFormattableDocument doc) {
// indent the state elements between the name of the state and the 'end' keyword
ISemanticRegion begin = regionFor(s).feature(STATE__NAME);
ISemanticRegion end = regionFor(s).keyword(ga.getStateAccess().getEndKeyword_4());
doc.append(begin, it -> it.newLine());
doc.interior(begin, end, it -> it.indent());
formatActions(s, doc);
for (Transition transition : s.getTransitions()) {
format(transition, doc);
}
if (isLastState(s)) {
doc.append(s, it -> it.newLine());
} else {
doc.append(s, it -> it.setNewLines(2));
}
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-eclipse by eclipse.
the class RuleEngineFormatter method _format.
@Override
protected void _format(final XBlockExpression expr, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<XBlockExpression>surround(expr, _function);
EList<XExpression> _expressions = expr.getExpressions();
for (final XExpression child : _expressions) {
{
final ISemanticRegion sem = this.textRegionExtensions.immediatelyFollowing(child).keyword(";");
if ((sem != null)) {
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.prepend(sem, _function_1);
XExpression _last = IterableExtensions.<XExpression>last(expr.getExpressions());
boolean _notEquals = (!Objects.equal(child, _last));
if (_notEquals) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(sem, _function_2);
}
} else {
XExpression _last_1 = IterableExtensions.<XExpression>last(expr.getExpressions());
boolean _notEquals_1 = (!Objects.equal(child, _last_1));
if (_notEquals_1) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.<XExpression>append(child, _function_3);
}
}
document.<XExpression>format(child);
}
}
}
Aggregations