use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion 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.regionaccess.ISemanticRegion 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.regionaccess.ISemanticRegion 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.regionaccess.ISemanticRegion in project xtext-core by eclipse.
the class RegionAccessBuilderTest method assertToStringDoesNotCrash.
private void assertToStringDoesNotCrash(final ITextRegionAccess access) {
IHiddenRegion _previousHiddenRegion = access.regionForRootEObject().getPreviousHiddenRegion();
ISequentialRegion current = ((ISequentialRegion) _previousHiddenRegion);
while ((current != null)) {
{
Assert.assertNotNull(current.toString());
boolean _matched = false;
if (current instanceof IHiddenRegion) {
_matched = true;
current = ((IHiddenRegion) current).getNextSemanticRegion();
}
if (!_matched) {
if (current instanceof ISemanticRegion) {
_matched = true;
Assert.assertNotNull(((ISemanticRegion) current).getEObjectRegion().toString());
current = ((ISemanticRegion) current).getNextHiddenRegion();
}
}
}
}
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendEnum enumeration, @Extension final IFormattableDocument format) {
this.formatAnnotations(enumeration, format, XbaseFormatterPreferenceKeys.newLineAfterClassAnnotations);
this.formatModifiers(enumeration, format);
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(this.textRegionExtensions.regionFor(enumeration).keyword("enum"), _function);
final ISemanticRegion open = this.textRegionExtensions.regionFor(enumeration).keyword("{");
final ISemanticRegion close = this.textRegionExtensions.regionFor(enumeration).keyword("}");
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.indent();
};
format.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_1);
format.prepend(open, XbaseFormatterPreferenceKeys.bracesInNewLine);
boolean _isEmpty = enumeration.getMembers().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
format.append(open, XtendFormatterPreferenceKeys.blankLinesBeforeFirstMember);
int _size = enumeration.getMembers().size();
int _minus = (_size - 1);
IntegerRange _upTo = new IntegerRange(0, _minus);
for (final Integer i : _upTo) {
{
final XtendMember current = enumeration.getMembers().get((i).intValue());
format.<XtendMember>format(current);
int _size_1 = enumeration.getMembers().size();
int _minus_1 = (_size_1 - 1);
boolean _lessThan = ((i).intValue() < _minus_1);
if (_lessThan) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(current).keyword(","), _function_2), XtendFormatterPreferenceKeys.blankLinesBetweenEnumLiterals);
} else {
format.<XtendMember>append(current, XtendFormatterPreferenceKeys.blankLinesAfterLastMember);
}
}
}
} else {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
format.append(open, _function_2);
}
}
Aggregations