use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendConstructor func, @Extension final IFormattableDocument format) {
this.formatAnnotations(func, format, XbaseFormatterPreferenceKeys.newLineAfterConstructorAnnotations);
this.formatModifiers(func, format);
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(this.textRegionExtensions.regionFor(func).keyword("new"), _function);
boolean _isEmpty = func.getTypeParameters().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(this.textRegionExtensions.regionFor(func).keyword("<"), _function_1);
EList<JvmTypeParameter> _typeParameters = func.getTypeParameters();
for (final JvmTypeParameter arg : _typeParameters) {
{
format.<JvmTypeParameter>format(arg);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.append(format.prepend(this.textRegionExtensions.immediatelyFollowing(arg).keyword(","), _function_2), _function_3);
}
}
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.surround(this.textRegionExtensions.regionFor(func).keyword(">"), _function_2);
}
final ISemanticRegion open = this.textRegionExtensions.regionFor(func).keyword("(");
final ISemanticRegion close = this.textRegionExtensions.regionFor(func).keyword(")");
format.append(close, XbaseFormatterPreferenceKeys.bracesInNewLine);
this.formatCommaSeparatedList(func.getParameters(), open, close, format);
format.<XExpression>format(func.getExpression());
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-xtend by eclipse.
the class XtendFormatter method _format.
protected void _format(final XtendFile xtendFile, @Extension final IFormattableDocument format) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.<XtendFile>prepend(xtendFile, _function);
final ISemanticRegion pkg = this.textRegionExtensions.regionFor(xtendFile).feature(XtendPackage.Literals.XTEND_FILE__PACKAGE);
if ((pkg != null)) {
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
format.prepend(pkg, _function_1);
final ISemanticRegion pkgSemicolon = pkg.immediatelyFollowing().keyword(";");
if ((pkgSemicolon != null)) {
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
format.append(pkg, _function_2);
format.append(pkgSemicolon, XtendFormatterPreferenceKeys.blankLinesAfterPackageDecl);
} else {
format.append(pkg, XtendFormatterPreferenceKeys.blankLinesAfterPackageDecl);
}
}
XImportSection _importSection = xtendFile.getImportSection();
if (_importSection != null) {
format.<XImportSection>format(_importSection);
}
EList<XtendTypeDeclaration> _xtendTypes = xtendFile.getXtendTypes();
for (final XtendTypeDeclaration clazz : _xtendTypes) {
{
format.<XtendTypeDeclaration>format(clazz);
XtendTypeDeclaration _last = IterableExtensions.<XtendTypeDeclaration>last(xtendFile.getXtendTypes());
boolean _notEquals = (!Objects.equal(clazz, _last));
if (_notEquals) {
format.<XtendTypeDeclaration>append(clazz, XtendFormatterPreferenceKeys.blankLinesBetweenClasses);
}
}
}
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
format.<XtendFile>append(xtendFile, _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 Entity entity, @Extension final IFormattableDocument document) {
final ISemanticRegion open = this.textRegionExtensions.regionFor(entity).keyword("{");
final ISemanticRegion close = this.textRegionExtensions.regionFor(entity).keyword("}");
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.surround(this.textRegionExtensions.regionFor(entity).feature(DomainmodelPackage.Literals.ABSTRACT_ELEMENT__NAME), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.<JvmParameterizedTypeReference>surround(entity.getSuperType(), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(open, _function_2);
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_3);
this.format(entity.getSuperType(), document);
EList<Feature> _features = entity.getFeatures();
for (final Feature feature : _features) {
{
document.<Feature>format(feature);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.setNewLines(1, 1, 2);
};
document.<Feature>append(feature, _function_4);
}
}
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-eclipse by eclipse.
the class StatemachineFormatter method formatEvents.
protected void formatEvents(Statemachine sm, IFormattableDocument doc) {
// indent the event definitions between the 'events' keyword and the 'end'
// keyword
ISemanticRegion begin = regionFor(sm).keyword("events");
ISemanticRegion end = regionFor(sm).keyword(ga.getStatemachineAccess().getEndKeyword_1_2());
doc.append(begin, it -> it.newLine());
doc.interior(begin, end, it -> it.indent());
for (Event event : sm.getEvents()) {
format(event, doc);
}
if (hasResetEvents(sm) || hasCommands(sm) || hasStates(sm)) {
doc.append(end, it -> it.setNewLines(2));
}
}
use of org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion in project xtext-eclipse by eclipse.
the class StatemachineFormatter method formatResetEvents.
protected void formatResetEvents(Statemachine sm, IFormattableDocument doc) {
// indent the event references between the 'resetEvents' keyword and the 'end'
// keyword
ISemanticRegion begin = regionFor(sm).keyword("resetEvents");
ISemanticRegion end = regionFor(sm).keyword(ga.getStatemachineAccess().getEndKeyword_2_2());
doc.append(begin, it -> it.newLine());
doc.interior(begin, end, it -> it.indent());
// format each event reference
doc.append(regionFor(sm).assignment(ga.getStatemachineAccess().getResetEventsAssignment_2_1()), it -> it.newLine());
doc.prepend(end, it -> it.newLine());
if (hasCommands(sm) || hasStates(sm)) {
doc.append(end, it -> it.setNewLines(2));
}
}
Aggregations