Aadl2Formatter.java

/**
 * Copyright (c) 2004-2025 Carnegie Mellon University and others. (see Contributors file).
 * All Rights Reserved.
 * 
 * NO WARRANTY. ALL MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR PURPOSE
 * OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT
 * MAKE ANY WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.
 * 
 * This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Created, in part, with funding and support from the United States Government. (see Acknowledgments file).
 * 
 * This program includes and/or can make use of certain third party source code, object code, documentation and other
 * files ("Third Party Software"). The Third Party Software that is used by this program is dependent upon your system
 * configuration. By using this program, You agree to comply with any and all relevant Third Party Software terms and
 * conditions contained in any such Third Party Software or separate license file distributed with such Third Party
 * Software. The parties who own the Third Party Software ("Third Party Licensors") are intended third party benefici-
 * aries to this license with respect to the terms applicable to their Third Party Software. Third Party Software li-
 * censes only apply to the Third Party Software and not any other portion of this program or this program as a whole.
 */
package org.osate.xtext.aadl2.formatting2;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.inject.ConfigurationException;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.ProvisionException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.formatting2.FormatterRequest;
import org.eclipse.xtext.formatting2.IFormattableDocument;
import org.eclipse.xtext.formatting2.IFormatter2;
import org.eclipse.xtext.formatting2.IHiddenRegionFormatter;
import org.eclipse.xtext.formatting2.ITextReplacerContext;
import org.eclipse.xtext.formatting2.internal.AbstractTextReplacer;
import org.eclipse.xtext.formatting2.regionaccess.IEObjectRegion;
import org.eclipse.xtext.formatting2.regionaccess.IHiddenRegion;
import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion;
import org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess;
import org.eclipse.xtext.formatting2.regionaccess.ITextReplacement;
import org.eclipse.xtext.formatting2.regionaccess.TextRegionAccessBuilder;
import org.eclipse.xtext.formatting2.regionaccess.internal.NodeModelBasedRegionAccess;
import org.eclipse.xtext.formatting2.regionaccess.internal.StringBasedRegionAccess;
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.resource.FileExtensionProvider;
import org.eclipse.xtext.resource.IResourceFactory;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.serializer.ISerializer;
import org.eclipse.xtext.serializer.impl.Serializer;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Pair;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.osate.aadl2.AadlBoolean;
import org.osate.aadl2.AadlInteger;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.AadlReal;
import org.osate.aadl2.AadlString;
import org.osate.aadl2.AbstractFeature;
import org.osate.aadl2.AbstractImplementation;
import org.osate.aadl2.AbstractPrototype;
import org.osate.aadl2.AbstractSubcomponent;
import org.osate.aadl2.AbstractType;
import org.osate.aadl2.AccessConnection;
import org.osate.aadl2.AccessSpecification;
import org.osate.aadl2.AnnexLibrary;
import org.osate.aadl2.AnnexSubclause;
import org.osate.aadl2.ArrayDimension;
import org.osate.aadl2.ArrayRange;
import org.osate.aadl2.BasicProperty;
import org.osate.aadl2.BasicPropertyAssociation;
import org.osate.aadl2.BehavioredImplementation;
import org.osate.aadl2.BusAccess;
import org.osate.aadl2.BusImplementation;
import org.osate.aadl2.BusPrototype;
import org.osate.aadl2.BusSubcomponent;
import org.osate.aadl2.BusType;
import org.osate.aadl2.Classifier;
import org.osate.aadl2.ClassifierFeature;
import org.osate.aadl2.ClassifierType;
import org.osate.aadl2.ClassifierValue;
import org.osate.aadl2.ComponentImplementation;
import org.osate.aadl2.ComponentImplementationReference;
import org.osate.aadl2.ComponentPrototype;
import org.osate.aadl2.ComponentPrototypeActual;
import org.osate.aadl2.ComponentPrototypeBinding;
import org.osate.aadl2.ComponentType;
import org.osate.aadl2.ComponentTypeRename;
import org.osate.aadl2.ComputedValue;
import org.osate.aadl2.ConnectedElement;
import org.osate.aadl2.Connection;
import org.osate.aadl2.ContainedNamedElement;
import org.osate.aadl2.ContainmentPathElement;
import org.osate.aadl2.DataAccess;
import org.osate.aadl2.DataImplementation;
import org.osate.aadl2.DataPort;
import org.osate.aadl2.DataPrototype;
import org.osate.aadl2.DataSubcomponent;
import org.osate.aadl2.DataType;
import org.osate.aadl2.DefaultAnnexLibrary;
import org.osate.aadl2.DefaultAnnexSubclause;
import org.osate.aadl2.DeviceImplementation;
import org.osate.aadl2.DevicePrototype;
import org.osate.aadl2.DeviceSubcomponent;
import org.osate.aadl2.DeviceType;
import org.osate.aadl2.EndToEndFlow;
import org.osate.aadl2.EndToEndFlowSegment;
import org.osate.aadl2.EnumerationLiteral;
import org.osate.aadl2.EnumerationType;
import org.osate.aadl2.EventDataPort;
import org.osate.aadl2.EventDataSource;
import org.osate.aadl2.EventPort;
import org.osate.aadl2.EventSource;
import org.osate.aadl2.Feature;
import org.osate.aadl2.FeatureConnection;
import org.osate.aadl2.FeatureGroup;
import org.osate.aadl2.FeatureGroupConnection;
import org.osate.aadl2.FeatureGroupPrototype;
import org.osate.aadl2.FeatureGroupPrototypeActual;
import org.osate.aadl2.FeatureGroupPrototypeBinding;
import org.osate.aadl2.FeatureGroupType;
import org.osate.aadl2.FeatureGroupTypeRename;
import org.osate.aadl2.FeaturePrototype;
import org.osate.aadl2.FeaturePrototypeBinding;
import org.osate.aadl2.FeaturePrototypeReference;
import org.osate.aadl2.FlowEnd;
import org.osate.aadl2.FlowImplementation;
import org.osate.aadl2.FlowSegment;
import org.osate.aadl2.FlowSpecification;
import org.osate.aadl2.GroupExtension;
import org.osate.aadl2.ImplementationExtension;
import org.osate.aadl2.IntegerLiteral;
import org.osate.aadl2.InternalFeature;
import org.osate.aadl2.ListType;
import org.osate.aadl2.ListValue;
import org.osate.aadl2.MemoryImplementation;
import org.osate.aadl2.MemoryPrototype;
import org.osate.aadl2.MemorySubcomponent;
import org.osate.aadl2.MemoryType;
import org.osate.aadl2.MetaclassReference;
import org.osate.aadl2.ModalPropertyValue;
import org.osate.aadl2.Mode;
import org.osate.aadl2.ModeBinding;
import org.osate.aadl2.ModeTransition;
import org.osate.aadl2.ModeTransitionTrigger;
import org.osate.aadl2.NamedElement;
import org.osate.aadl2.NumberType;
import org.osate.aadl2.NumericRange;
import org.osate.aadl2.Operation;
import org.osate.aadl2.PackageRename;
import org.osate.aadl2.PackageSection;
import org.osate.aadl2.Parameter;
import org.osate.aadl2.ParameterConnection;
import org.osate.aadl2.PortConnection;
import org.osate.aadl2.PortProxy;
import org.osate.aadl2.PortSpecification;
import org.osate.aadl2.PrivatePackageSection;
import org.osate.aadl2.ProcessImplementation;
import org.osate.aadl2.ProcessPrototype;
import org.osate.aadl2.ProcessSubcomponent;
import org.osate.aadl2.ProcessType;
import org.osate.aadl2.ProcessorFeature;
import org.osate.aadl2.ProcessorImplementation;
import org.osate.aadl2.ProcessorPrototype;
import org.osate.aadl2.ProcessorSubcomponent;
import org.osate.aadl2.ProcessorType;
import org.osate.aadl2.Property;
import org.osate.aadl2.PropertyAssociation;
import org.osate.aadl2.PropertyConstant;
import org.osate.aadl2.PropertyOwner;
import org.osate.aadl2.PropertySet;
import org.osate.aadl2.PropertyType;
import org.osate.aadl2.Prototype;
import org.osate.aadl2.PrototypeBinding;
import org.osate.aadl2.PublicPackageSection;
import org.osate.aadl2.RangeType;
import org.osate.aadl2.RangeValue;
import org.osate.aadl2.RealLiteral;
import org.osate.aadl2.Realization;
import org.osate.aadl2.RecordType;
import org.osate.aadl2.RecordValue;
import org.osate.aadl2.ReferenceType;
import org.osate.aadl2.ReferenceValue;
import org.osate.aadl2.StructuralFeature;
import org.osate.aadl2.Subcomponent;
import org.osate.aadl2.SubprogramAccess;
import org.osate.aadl2.SubprogramCall;
import org.osate.aadl2.SubprogramCallSequence;
import org.osate.aadl2.SubprogramGroupAccess;
import org.osate.aadl2.SubprogramGroupImplementation;
import org.osate.aadl2.SubprogramGroupPrototype;
import org.osate.aadl2.SubprogramGroupSubcomponent;
import org.osate.aadl2.SubprogramGroupType;
import org.osate.aadl2.SubprogramImplementation;
import org.osate.aadl2.SubprogramPrototype;
import org.osate.aadl2.SubprogramProxy;
import org.osate.aadl2.SubprogramSubcomponent;
import org.osate.aadl2.SubprogramType;
import org.osate.aadl2.SystemImplementation;
import org.osate.aadl2.SystemPrototype;
import org.osate.aadl2.SystemSubcomponent;
import org.osate.aadl2.SystemType;
import org.osate.aadl2.ThreadGroupImplementation;
import org.osate.aadl2.ThreadGroupPrototype;
import org.osate.aadl2.ThreadGroupSubcomponent;
import org.osate.aadl2.ThreadGroupType;
import org.osate.aadl2.ThreadImplementation;
import org.osate.aadl2.ThreadPrototype;
import org.osate.aadl2.ThreadSubcomponent;
import org.osate.aadl2.ThreadType;
import org.osate.aadl2.TypeExtension;
import org.osate.aadl2.UnitLiteral;
import org.osate.aadl2.UnitsType;
import org.osate.aadl2.VirtualBusImplementation;
import org.osate.aadl2.VirtualBusPrototype;
import org.osate.aadl2.VirtualBusSubcomponent;
import org.osate.aadl2.VirtualBusType;
import org.osate.aadl2.VirtualProcessorImplementation;
import org.osate.aadl2.VirtualProcessorPrototype;
import org.osate.aadl2.VirtualProcessorSubcomponent;
import org.osate.aadl2.VirtualProcessorType;
import org.osate.annexsupport.AnnexUtil;
import org.osate.annexsupport.ParseResultHolder;
import org.osate.xtext.aadl2.properties.formatting2.PropertiesFormatter;
import org.osate.xtext.aadl2.services.Aadl2GrammarAccess;

/**
 * @since 5.0
 */
@SuppressWarnings("all")
public class Aadl2Formatter extends PropertiesFormatter {
  @Inject
  @Extension
  private Aadl2GrammarAccess _aadl2GrammarAccess;

  protected void _format(final PropertySet propertySet, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.<PropertySet>surround(propertySet, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertySet).keyword(this._aadl2GrammarAccess.getPropertySetAccess().getSetKeyword_1()), _function_1);
    final ISemanticRegion isKeyword = this.textRegionExtensions.regionFor(propertySet).keyword(this._aadl2GrammarAccess.getPropertySetAccess().getIsKeyword_3());
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(document.prepend(isKeyword, _function_2), _function_3);
    final ISemanticRegion endKeyword = this.textRegionExtensions.regionFor(propertySet).keyword(this._aadl2GrammarAccess.getPropertySetAccess().getEndKeyword_7());
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(isKeyword, endKeyword, _function_4);
    final List<ISemanticRegion> withSemicolons = this.textRegionExtensions.regionFor(propertySet).keywords(this._aadl2GrammarAccess.getPropertySetAccess().getSemicolonKeyword_4_3());
    boolean _isEmpty = withSemicolons.isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
      final Consumer<ISemanticRegion> _function_5 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
        };
        document.append(it, _function_6);
      };
      this.textRegionExtensions.regionFor(propertySet).keywords(this._aadl2GrammarAccess.getPropertySetAccess().getWithKeyword_4_0()).forEach(_function_5);
      final Consumer<ISemanticRegion> _function_6 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
        };
        document.append(document.prepend(it, _function_7), _function_8);
      };
      this.textRegionExtensions.regionFor(propertySet).keywords(this._aadl2GrammarAccess.getPropertySetAccess().getCommaKeyword_4_2_0()).forEach(_function_6);
      int _size = withSemicolons.size();
      int _minus = (_size - 1);
      final Consumer<ISemanticRegion> _function_7 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
          it_1.setNewLines(1);
        };
        document.append(document.prepend(it, _function_8), _function_9);
      };
      IterableExtensions.<ISemanticRegion>take(withSemicolons, _minus).forEach(_function_7);
      int _xifexpression = (int) 0;
      if ((((propertySet.getOwnedPropertyTypes().isEmpty() && 
        propertySet.getOwnedProperties().isEmpty()) && 
        propertySet.getOwnedPropertyConstants().isEmpty()) && 
        propertySet.getOwnedAnnexSubclauses().isEmpty())) {
        _xifexpression = 1;
      } else {
        _xifexpression = 2;
      }
      final int newLineCount = _xifexpression;
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(newLineCount);
      };
      document.append(document.prepend(IterableExtensions.<ISemanticRegion>last(withSemicolons), _function_8), _function_9);
    }
    final Consumer<PropertyType> _function_10 = (PropertyType it) -> {
      this.format(it, document);
    };
    propertySet.getOwnedPropertyTypes().forEach(_function_10);
    final Consumer<Property> _function_11 = (Property it) -> {
      this.format(it, document);
    };
    propertySet.getOwnedProperties().forEach(_function_11);
    final Consumer<PropertyConstant> _function_12 = (PropertyConstant it) -> {
      this.format(it, document);
    };
    propertySet.getOwnedPropertyConstants().forEach(_function_12);
    final Consumer<AnnexSubclause> _function_13 = (AnnexSubclause it) -> {
      this.format(it, document);
    };
    propertySet.getOwnedAnnexSubclauses().forEach(_function_13);
    final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(endKeyword, _function_14);
    final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(propertySet).keyword(this._aadl2GrammarAccess.getPropertySetAccess().getSemicolonKeyword_9()), _function_15);
  }

  protected void _format(final AadlBoolean aadlBoolean, @Extension final IFormattableDocument document) {
    String _name = aadlBoolean.getName();
    boolean _tripleNotEquals = (_name != null);
    if (_tripleNotEquals) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<AadlBoolean>conditionalAppend(aadlBoolean, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlBoolean).keyword(this._aadl2GrammarAccess.getBooleanTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlBoolean).keyword(this._aadl2GrammarAccess.getBooleanTypeAccess().getAadlbooleanKeyword_3()), _function_3), _function_4);
    }
  }

  protected void _format(final AadlString aadlString, @Extension final IFormattableDocument document) {
    String _name = aadlString.getName();
    boolean _tripleNotEquals = (_name != null);
    if (_tripleNotEquals) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<AadlString>conditionalAppend(aadlString, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlString).keyword(this._aadl2GrammarAccess.getStringTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlString).keyword(this._aadl2GrammarAccess.getStringTypeAccess().getAadlstringKeyword_3()), _function_3), _function_4);
    }
  }

  protected void _format(final EnumerationType enumerationType, @Extension final IFormattableDocument document) {
    String _name = enumerationType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getUnnamedEnumerationTypeAccess().getEnumerationKeyword_0()), _function);
      this.formatEnumerationTypeCommon(document, this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getUnnamedEnumerationTypeAccess().getLeftParenthesisKeyword_1()), 
        this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getUnnamedEnumerationTypeAccess().getRightParenthesisKeyword_4()), 
        this.textRegionExtensions.regionFor(enumerationType).keywords(this._aadl2GrammarAccess.getUnnamedEnumerationTypeAccess().getCommaKeyword_3_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<EnumerationType>conditionalAppend(enumerationType, document, _function_1);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getEnumerationTypeAccess().getColonKeyword_1()), _function_2), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getEnumerationTypeAccess().getEnumerationKeyword_3()), _function_4);
      this.formatEnumerationTypeCommon(document, this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getEnumerationTypeAccess().getLeftParenthesisKeyword_4()), 
        this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getEnumerationTypeAccess().getRightParenthesisKeyword_7()), 
        this.textRegionExtensions.regionFor(enumerationType).keywords(this._aadl2GrammarAccess.getEnumerationTypeAccess().getCommaKeyword_6_0()));
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(enumerationType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_5);
    }
  }

  private ISemanticRegion formatEnumerationTypeCommon(@Extension final IFormattableDocument document, final ISemanticRegion leftParenthesis, final ISemanticRegion rightParenthesis, final Iterable<ISemanticRegion> commas) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(leftParenthesis, _function_1);
      final Consumer<ISemanticRegion> _function_2 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_3), _function_4);
      };
      commas.forEach(_function_2);
      ISemanticRegion _xifexpression = null;
      if ((rightParenthesis != null)) {
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_3);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_4);
        }
        _xifexpression = _xifexpression_1;
      }
      _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
  }

  protected void _format(final UnitsType unitsType, @Extension final IFormattableDocument document) {
    String _name = unitsType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnnamedUnitsTypeAccess().getUnitsKeyword_0()), _function);
      this.formatUnitsTypeCommon(unitsType, document, this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnnamedUnitsTypeAccess().getLeftParenthesisKeyword_1()), 
        this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnnamedUnitsTypeAccess().getRightParenthesisKeyword_4()), this.textRegionExtensions.regionFor(unitsType).keywords(this._aadl2GrammarAccess.getUnnamedUnitsTypeAccess().getCommaKeyword_3_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<UnitsType>conditionalAppend(unitsType, document, _function_1);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnitsTypeAccess().getColonKeyword_1()), _function_2), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnitsTypeAccess().getUnitsKeyword_3()), _function_4);
      this.formatUnitsTypeCommon(unitsType, document, this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnitsTypeAccess().getLeftParenthesisKeyword_4()), 
        this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getUnitsTypeAccess().getRightParenthesisKeyword_7()), this.textRegionExtensions.regionFor(unitsType).keywords(this._aadl2GrammarAccess.getUnitsTypeAccess().getCommaKeyword_6_0()));
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(unitsType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_5);
    }
  }

  private ISemanticRegion formatUnitsTypeCommon(final UnitsType unitsType, @Extension final IFormattableDocument document, final ISemanticRegion leftParenthesis, final ISemanticRegion rightParenthesis, final Iterable<ISemanticRegion> commas) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(leftParenthesis, _function_1);
      final Consumer<EnumerationLiteral> _function_2 = (EnumerationLiteral it) -> {
        this.format(it, document);
      };
      unitsType.getOwnedLiterals().forEach(_function_2);
      final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_4), _function_5);
      };
      commas.forEach(_function_3);
      ISemanticRegion _xifexpression = null;
      if ((rightParenthesis != null)) {
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_4);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_5);
        }
        _xifexpression = _xifexpression_1;
      }
      _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
  }

  protected void _format(final UnitLiteral unitLiteral, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(unitLiteral).keyword(this._aadl2GrammarAccess.getUnitLiteralConversionAccess().getEqualsSignGreaterThanSignKeyword_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(unitLiteral).ruleCall(this._aadl2GrammarAccess.getUnitLiteralConversionAccess().getSTARParserRuleCall_3()), _function_1);
  }

  protected void _format(final AadlReal aadlReal, @Extension final IFormattableDocument document) {
    String _name = aadlReal.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      this.formatAadlRealCommon(aadlReal, document, this.textRegionExtensions.regionFor(aadlReal).keyword(this._aadl2GrammarAccess.getUnnamedRealTypeAccess().getUnitsKeyword_3_1_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<AadlReal>conditionalAppend(aadlReal, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlReal).keyword(this._aadl2GrammarAccess.getRealTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(aadlReal).keyword(this._aadl2GrammarAccess.getRealTypeAccess().getAadlrealKeyword_3()), _function_3);
      this.formatAadlRealCommon(aadlReal, document, this.textRegionExtensions.regionFor(aadlReal).keyword(this._aadl2GrammarAccess.getRealTypeAccess().getUnitsKeyword_5_1_0()));
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(aadlReal).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_4);
    }
  }

  private ISemanticRegion formatAadlRealCommon(final AadlReal aadlReal, @Extension final IFormattableDocument document, final ISemanticRegion unitsKeyword) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<NumericRange>prepend(aadlReal.getRange(), _function);
      this.format(aadlReal.getRange(), document);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<UnitsType>prepend(aadlReal.getOwnedUnitsType(), _function_1);
      this.format(aadlReal.getOwnedUnitsType(), document);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      _xblockexpression = document.surround(unitsKeyword, _function_2);
    }
    return _xblockexpression;
  }

  protected void _format(final NumericRange numericRange, @Extension final IFormattableDocument document) {
    this.format(numericRange.getLowerBound(), document);
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(numericRange).keyword(this._aadl2GrammarAccess.getIntegerRangeAccess().getFullStopFullStopKeyword_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(numericRange).keyword(this._aadl2GrammarAccess.getRealRangeAccess().getFullStopFullStopKeyword_1()), _function_1);
    this.format(numericRange.getUpperBound(), document);
  }

  protected void _format(final AadlInteger aadlInteger, @Extension final IFormattableDocument document) {
    String _name = aadlInteger.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      this.formatAadlIntegerCommon(aadlInteger, document, this.textRegionExtensions.regionFor(aadlInteger).keyword(this._aadl2GrammarAccess.getUnnamedIntegerTypeAccess().getUnitsKeyword_3_1_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<AadlInteger>conditionalAppend(aadlInteger, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(aadlInteger).keyword(this._aadl2GrammarAccess.getIntegerTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(aadlInteger).keyword(this._aadl2GrammarAccess.getIntegerTypeAccess().getAadlintegerKeyword_3()), _function_3);
      this.formatAadlIntegerCommon(aadlInteger, document, this.textRegionExtensions.regionFor(aadlInteger).keyword(this._aadl2GrammarAccess.getIntegerTypeAccess().getUnitsKeyword_5_1_0()));
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(aadlInteger).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_4);
    }
  }

  private ISemanticRegion formatAadlIntegerCommon(final AadlInteger aadlInteger, @Extension final IFormattableDocument document, final ISemanticRegion unitsKeyword) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<NumericRange>prepend(aadlInteger.getRange(), _function);
      this.format(aadlInteger.getRange(), document);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<UnitsType>prepend(aadlInteger.getOwnedUnitsType(), _function_1);
      this.format(aadlInteger.getOwnedUnitsType(), document);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      _xblockexpression = document.surround(unitsKeyword, _function_2);
    }
    return _xblockexpression;
  }

  protected void _format(final RangeType rangeType, @Extension final IFormattableDocument document) {
    String _name = rangeType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(this.textRegionExtensions.regionFor(rangeType).keyword(this._aadl2GrammarAccess.getRangeOfKeywordsAccess().getRangeKeyword_0()), _function);
      this.formatRangeTypeCommon(rangeType, document, this.textRegionExtensions.regionFor(rangeType).assignment(this._aadl2GrammarAccess.getUnnamedRangeTypeAccess().getReferencedNumberTypeAssignment_2_1()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<RangeType>conditionalAppend(rangeType, document, _function_1);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(rangeType).keyword(this._aadl2GrammarAccess.getRangeTypeAccess().getColonKeyword_1()), _function_2), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(rangeType).keyword(this._aadl2GrammarAccess.getRangeOfKeywordsAccess().getRangeKeyword_0()), _function_4);
      this.formatRangeTypeCommon(rangeType, document, this.textRegionExtensions.regionFor(rangeType).assignment(this._aadl2GrammarAccess.getRangeTypeAccess().getReferencedNumberTypeAssignment_4_1()));
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(rangeType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_5);
    }
  }

  private ISemanticRegion formatRangeTypeCommon(final RangeType rangeType, @Extension final IFormattableDocument document, final ISemanticRegion referencedNumberType) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<NumberType>prepend(rangeType.getOwnedNumberType(), _function);
      this.format(rangeType.getOwnedNumberType(), document);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      _xblockexpression = document.prepend(referencedNumberType, _function_1);
    }
    return _xblockexpression;
  }

  protected void _format(final ClassifierType classifierType, @Extension final IFormattableDocument document) {
    String _name = classifierType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      this.formatClassifierTypeCommon(classifierType, document, this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getUnnamedClassifierTypeAccess().getLeftParenthesisKeyword_2_0()), 
        this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getUnnamedClassifierTypeAccess().getRightParenthesisKeyword_2_3()), 
        this.textRegionExtensions.regionFor(classifierType).keywords(this._aadl2GrammarAccess.getUnnamedClassifierTypeAccess().getCommaKeyword_2_2_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<ClassifierType>conditionalAppend(classifierType, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getClassifierTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getClassifierTypeAccess().getClassifierKeyword_3()), _function_3);
      this.formatClassifierTypeCommon(classifierType, document, this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getClassifierTypeAccess().getLeftParenthesisKeyword_4_0()), 
        this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getClassifierTypeAccess().getRightParenthesisKeyword_4_3()), 
        this.textRegionExtensions.regionFor(classifierType).keywords(this._aadl2GrammarAccess.getClassifierTypeAccess().getCommaKeyword_4_2_0()));
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(classifierType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_4);
    }
  }

  private ISemanticRegion formatClassifierTypeCommon(final ClassifierType classifierType, @Extension final IFormattableDocument document, final ISemanticRegion leftParenthesis, final ISemanticRegion rightParenthesis, final Iterable<ISemanticRegion> commas) {
    ISemanticRegion _xifexpression = null;
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      ISemanticRegion _xblockexpression = null;
      {
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
          it.setNewLines(0, 0, 1);
          it.autowrap();
        };
        document.append(document.prepend(leftParenthesis, _function_1), _function_2);
        final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
            it_1.noSpace();
          };
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
            it_1.oneSpace();
            it_1.setNewLines(0, 0, 1);
            it_1.autowrap();
          };
          document.append(document.prepend(it, _function_4), _function_5);
        };
        commas.forEach(_function_3);
        final Consumer<MetaclassReference> _function_4 = (MetaclassReference it) -> {
          this.format(it, document);
        };
        classifierType.getClassifierReferences().forEach(_function_4);
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_5);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_6);
        }
        _xblockexpression = _xifexpression_1;
      }
      _xifexpression = _xblockexpression;
    }
    return _xifexpression;
  }

  protected void _format(final MetaclassReference metaclassReference, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(metaclassReference).assignment(this._aadl2GrammarAccess.getQMReferenceAccess().getAnnexNameAssignment_0_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(metaclassReference).ruleCall(this._aadl2GrammarAccess.getQMReferenceAccess().getSTARParserRuleCall_0_3()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.append(this.textRegionExtensions.regionFor(metaclassReference).ruleCall(this._aadl2GrammarAccess.getQMReferenceAccess().getSTARParserRuleCall_0_4()), _function_2);
    final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
      };
      document.prepend(it, _function_4);
    };
    IterableExtensions.<ISemanticRegion>tail(this.textRegionExtensions.regionFor(metaclassReference).assignments(this._aadl2GrammarAccess.getQMReferenceAccess().getMetaclassNameAssignment_1())).forEach(_function_3);
  }

  protected void _format(final ReferenceType referenceType, @Extension final IFormattableDocument document) {
    String _name = referenceType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      this.formatReferenceTypeCommon(referenceType, document, this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getUnnamedReferenceTypeAccess().getLeftParenthesisKeyword_2_0()), 
        this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getUnnamedReferenceTypeAccess().getRightParenthesisKeyword_2_3()), 
        this.textRegionExtensions.regionFor(referenceType).keywords(this._aadl2GrammarAccess.getUnnamedReferenceTypeAccess().getCommaKeyword_2_2_0()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<ReferenceType>conditionalAppend(referenceType, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getReferenceTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getReferenceTypeAccess().getReferenceKeyword_3()), _function_3);
      this.formatReferenceTypeCommon(referenceType, document, this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getReferenceTypeAccess().getLeftParenthesisKeyword_4_0()), 
        this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getReferenceTypeAccess().getRightParenthesisKeyword_4_3()), 
        this.textRegionExtensions.regionFor(referenceType).keywords(this._aadl2GrammarAccess.getReferenceTypeAccess().getCommaKeyword_4_2_0()));
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(referenceType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_4);
    }
  }

  private ISemanticRegion formatReferenceTypeCommon(final ReferenceType referenceType, @Extension final IFormattableDocument document, final ISemanticRegion leftParenthesis, final ISemanticRegion rightParenthesis, final Iterable<ISemanticRegion> commas) {
    ISemanticRegion _xifexpression = null;
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      ISemanticRegion _xblockexpression = null;
      {
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
          it.setNewLines(0, 0, 1);
          it.autowrap();
        };
        document.append(document.prepend(leftParenthesis, _function_1), _function_2);
        final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
            it_1.noSpace();
          };
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
            it_1.oneSpace();
            it_1.setNewLines(0, 0, 1);
            it_1.autowrap();
          };
          document.append(document.prepend(it, _function_4), _function_5);
        };
        commas.forEach(_function_3);
        final Consumer<MetaclassReference> _function_4 = (MetaclassReference it) -> {
          this.format(it, document);
        };
        referenceType.getNamedElementReferences().forEach(_function_4);
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_5);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_6);
        }
        _xblockexpression = _xifexpression_1;
      }
      _xifexpression = _xblockexpression;
    }
    return _xifexpression;
  }

  protected void _format(final RecordType recordType, @Extension final IFormattableDocument document) {
    String _name = recordType.getName();
    boolean _tripleEquals = (_name == null);
    if (_tripleEquals) {
      this.formatRecordTypeCommon(recordType, document, this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getUnnamedRecordTypeAccess().getLeftParenthesisKeyword_1()), 
        this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getUnnamedRecordTypeAccess().getRightParenthesisKeyword_3()));
    } else {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<RecordType>conditionalAppend(recordType, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getRecordTypeAccess().getColonKeyword_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getRecordTypeAccess().getTypeKeyword_2()), _function_3);
      this.formatRecordTypeCommon(recordType, document, this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getRecordTypeAccess().getLeftParenthesisKeyword_4()), 
        this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getRecordTypeAccess().getRightParenthesisKeyword_6()));
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(recordType).keyword(this._aadl2GrammarAccess.getPropertyTypeAccess().getSemicolonKeyword_1()), _function_4);
    }
  }

  private ISemanticRegion formatRecordTypeCommon(final RecordType recordType, @Extension final IFormattableDocument document, final ISemanticRegion leftParenthesis, final ISemanticRegion rightParenthesis) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_1), _function_2);
      final Consumer<BasicProperty> _function_3 = (BasicProperty it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.<BasicProperty>prepend(it, _function_4);
      };
      IterableExtensions.<BasicProperty>tail(recordType.getOwnedFields()).forEach(_function_3);
      final Consumer<BasicProperty> _function_4 = (BasicProperty it) -> {
        this.format(it, document);
      };
      recordType.getOwnedFields().forEach(_function_4);
      ISemanticRegion _xifexpression = null;
      if ((rightParenthesis != null)) {
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_5);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightParenthesis, _function_6);
        }
        _xifexpression = _xifexpression_1;
      }
      _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
  }

  protected void _format(final BasicProperty basicProperty, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(basicProperty).keyword(this._aadl2GrammarAccess.getRecordFieldAccess().getColonKeyword_1()), _function), _function_1);
    this.format(basicProperty.getOwnedPropertyType(), document);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(basicProperty).keyword(this._aadl2GrammarAccess.getRecordFieldAccess().getSemicolonKeyword_3()), _function_2);
  }

  protected void _format(final ListType listType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(listType).keyword(this._aadl2GrammarAccess.getListOfKeywordsAccess().getOfKeyword_1()), _function);
    this.format(listType.getOwnedElementType(), document);
  }

  protected void _format(final PropertyConstant propertyConstant, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<PropertyConstant>conditionalAppend(propertyConstant, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(propertyConstant).keyword(this._aadl2GrammarAccess.getPropertyConstantAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(propertyConstant).keyword(this._aadl2GrammarAccess.getPropertyConstantAccess().getConstantKeyword_2()), _function_3);
    this.format(propertyConstant.getOwnedPropertyType(), document);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertyConstant).keyword(this._aadl2GrammarAccess.getPropertyConstantAccess().getEqualsSignGreaterThanSignKeyword_4()), _function_4);
    this.format(propertyConstant.getConstantValue(), document);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(propertyConstant).keyword(this._aadl2GrammarAccess.getPropertyConstantAccess().getSemicolonKeyword_6()), _function_5);
  }

  protected void _format(final Property property, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<Property>conditionalAppend(property, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getInheritInheritKeyword_2_0()), _function_3);
    this.format(property.getOwnedPropertyType(), document);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getEqualsSignGreaterThanSignKeyword_4_0()), _function_4);
    this.format(property.getDefaultValue(), document);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getAppliesToKeywordsAccess().getAppliesKeyword_0()), _function_5);
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getLeftParenthesisKeyword_6());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(property).keyword(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getRightParenthesisKeyword_8());
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
      it.setNewLines(0, 0, 1);
      it.autowrap();
    };
    document.append(document.prepend(leftParenthesis, _function_7), _function_8);
    final Consumer<ISemanticRegion> _function_9 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
        it_1.setNewLines(0, 0, 1);
        it_1.autowrap();
      };
      document.append(document.prepend(it, _function_10), _function_11);
    };
    this.textRegionExtensions.regionFor(property).keywords(this._aadl2GrammarAccess.getPropertyDefinitionAccess().getCommaKeyword_7_0_1_0()).forEach(_function_9);
    final Consumer<PropertyOwner> _function_10 = (PropertyOwner it) -> {
      this.format(it, document);
    };
    property.getAppliesTos().forEach(_function_10);
    if ((rightParenthesis != null)) {
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.append(document.prepend(rightParenthesis, _function_11), _function_12);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.surround(rightParenthesis, _function_13);
      }
    }
  }

  protected void _format(final AadlPackage aadlPackage, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.<AadlPackage>surround(aadlPackage, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(aadlPackage).assignment(this._aadl2GrammarAccess.getAadlPackageAccess().getNameAssignment_1()), _function_1), _function_2);
    this.format(aadlPackage.getOwnedPublicSection(), document);
    this.format(aadlPackage.getOwnedPrivateSection(), document);
    final ISemanticRegion propertiesKeyword = this.textRegionExtensions.regionFor(aadlPackage).keyword(this._aadl2GrammarAccess.getAadlPackageAccess().getPropertiesKeyword_3_0());
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(propertiesKeyword, _function_3);
    final ISemanticRegion endKeyword = this.textRegionExtensions.regionFor(aadlPackage).keyword(this._aadl2GrammarAccess.getAadlPackageAccess().getEndKeyword_4());
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(propertiesKeyword, endKeyword, _function_4);
    final Consumer<PropertyAssociation> _function_5 = (PropertyAssociation it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
        it_1.setNewLines(1, 1, 2);
      };
      document.<PropertyAssociation>append(it, _function_6);
      this.format(it, document);
    };
    aadlPackage.getOwnedPropertyAssociations().forEach(_function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(aadlPackage).keyword(this._aadl2GrammarAccess.getAadlPackageAccess().getSemicolonKeyword_3_1_1_1()), _function_6), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(endKeyword, _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(aadlPackage).keyword(this._aadl2GrammarAccess.getAadlPackageAccess().getSemicolonKeyword_6()), _function_9);
  }

  protected void _format(final PropertyAssociation propertyAssociation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertyAssociation).keyword("=>"), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertyAssociation).keyword("+=>"), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(propertyAssociation).keyword("constant"), _function_2);
    final Consumer<ModalPropertyValue> _function_3 = (ModalPropertyValue it) -> {
      this.format(it, document);
    };
    propertyAssociation.getOwnedValues().forEach(_function_3);
    final Consumer<ISemanticRegion> _function_4 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
      };
      document.append(document.prepend(it, _function_5), _function_6);
    };
    this.textRegionExtensions.regionFor(propertyAssociation).keywords(",").forEach(_function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertyAssociation).keyword(this._aadl2GrammarAccess.getAppliesToKeywordsAccess().getAppliesKeyword_0()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(propertyAssociation).keyword(this._aadl2GrammarAccess.getAppliesToKeywordsAccess().getToKeyword_1()), _function_6);
    final Consumer<ContainedNamedElement> _function_7 = (ContainedNamedElement it) -> {
      this.format(it, document);
    };
    propertyAssociation.getAppliesTos().forEach(_function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(propertyAssociation).keyword("in"), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(propertyAssociation).keyword("("), _function_9), _function_10);
    final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(propertyAssociation).keyword(")"), _function_11);
    final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(propertyAssociation).keyword(";"), _function_12);
  }

  protected void _format(final PublicPackageSection publicPackageSection, @Extension final IFormattableDocument document) {
    this.formatPackageSectionCommon(publicPackageSection, document, 
      this.textRegionExtensions.regionFor(publicPackageSection).keyword(this._aadl2GrammarAccess.getPublicPackageSectionAccess().getPublicKeyword_1()), 
      this.textRegionExtensions.regionFor(publicPackageSection).keywords(this._aadl2GrammarAccess.getPublicPackageSectionAccess().getWithKeyword_2_0_0()), 
      this.textRegionExtensions.regionFor(publicPackageSection).keywords(this._aadl2GrammarAccess.getPublicPackageSectionAccess().getCommaKeyword_2_0_2_0()), 
      this.textRegionExtensions.regionFor(publicPackageSection).keywords(this._aadl2GrammarAccess.getPublicPackageSectionAccess().getSemicolonKeyword_2_0_3()));
  }

  protected void _format(final PrivatePackageSection privatePackageSection, @Extension final IFormattableDocument document) {
    this.formatPackageSectionCommon(privatePackageSection, document, 
      this.textRegionExtensions.regionFor(privatePackageSection).keyword(this._aadl2GrammarAccess.getPrivatePackageSectionAccess().getPrivateKeyword_1()), 
      this.textRegionExtensions.regionFor(privatePackageSection).keywords(this._aadl2GrammarAccess.getPrivatePackageSectionAccess().getWithKeyword_2_0_0()), 
      this.textRegionExtensions.regionFor(privatePackageSection).keywords(this._aadl2GrammarAccess.getPrivatePackageSectionAccess().getCommaKeyword_2_0_2_0()), 
      this.textRegionExtensions.regionFor(privatePackageSection).keywords(this._aadl2GrammarAccess.getPrivatePackageSectionAccess().getSemicolonKeyword_2_0_3()));
  }

  private void formatPackageSectionCommon(final PackageSection packageSection, @Extension final IFormattableDocument document, final ISemanticRegion visibilityKeyword, final Iterable<ISemanticRegion> withs, final Iterable<ISemanticRegion> commas, final Iterable<ISemanticRegion> semicolons) {
    if (((!packageSection.eContents().isEmpty()) || (!packageSection.getImportedUnits().isEmpty()))) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<PackageSection>interior(packageSection, _function);
    }
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(visibilityKeyword, _function_1);
    final Consumer<ISemanticRegion> _function_2 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
      };
      document.append(it, _function_3);
    };
    withs.forEach(_function_2);
    final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
      };
      document.append(document.prepend(it, _function_4), _function_5);
    };
    commas.forEach(_function_3);
    final Consumer<ISemanticRegion> _function_4 = (ISemanticRegion it) -> {
      int _switchResult = (int) 0;
      ISemanticRegion _nextSemanticRegion = it.getNextSemanticRegion();
      EObject _semanticElement = null;
      if (_nextSemanticRegion!=null) {
        _semanticElement=_nextSemanticRegion.getSemanticElement();
      }
      final EObject nextElement = _semanticElement;
      boolean _matched = false;
      if (nextElement instanceof Classifier) {
        _matched=true;
      }
      if (!_matched) {
        if (nextElement instanceof AnnexLibrary) {
          _matched=true;
        }
      }
      if (!_matched) {
        if (nextElement instanceof PackageSection) {
          boolean _notEquals = (!Objects.equal(nextElement, packageSection));
          if (_notEquals) {
            _matched=true;
          }
        }
      }
      if (_matched) {
        _switchResult = 2;
      }
      if (!_matched) {
        _switchResult = 1;
      }
      final int newLineCount = _switchResult;
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
        it_1.setNewLines(newLineCount);
      };
      document.append(document.prepend(it, _function_5), _function_6);
    };
    semicolons.forEach(_function_4);
    final Consumer<PackageRename> _function_5 = (PackageRename it) -> {
      this.format(it, document);
    };
    packageSection.getOwnedPackageRenames().forEach(_function_5);
    final Consumer<FeatureGroupTypeRename> _function_6 = (FeatureGroupTypeRename it) -> {
      this.format(it, document);
    };
    packageSection.getOwnedFeatureGroupTypeRenames().forEach(_function_6);
    final Consumer<ComponentTypeRename> _function_7 = (ComponentTypeRename it) -> {
      this.format(it, document);
    };
    packageSection.getOwnedComponentTypeRenames().forEach(_function_7);
    final Consumer<Classifier> _function_8 = (Classifier it) -> {
      this.format(it, document);
    };
    packageSection.getOwnedClassifiers().forEach(_function_8);
    final Consumer<AnnexLibrary> _function_9 = (AnnexLibrary it) -> {
      this.format(it, document);
    };
    packageSection.getOwnedAnnexLibraries().forEach(_function_9);
  }

  protected void _format(final PackageRename packageRename, @Extension final IFormattableDocument document) {
    int _switchResult = (int) 0;
    IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(packageRename);
    ISemanticRegion _nextSemanticRegion = null;
    if (_regionForEObject!=null) {
      _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
    }
    EObject _semanticElement = null;
    if (_nextSemanticRegion!=null) {
      _semanticElement=_nextSemanticRegion.getSemanticElement();
    }
    boolean _matched = false;
    if (_semanticElement instanceof Classifier) {
      _matched=true;
    }
    if (!_matched) {
      if (_semanticElement instanceof AnnexLibrary) {
        _matched=true;
      }
    }
    if (!_matched) {
      if (_semanticElement instanceof PackageSection) {
        _matched=true;
      }
    }
    if (_matched) {
      _switchResult = 2;
    }
    if (!_matched) {
      _switchResult = 1;
    }
    final int newLineCount = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(newLineCount);
    };
    this.<PackageRename>conditionalAppend(packageRename, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getPackageRenameAccess().getRenamesKeyword_1()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getPackageRenameAccess().getPackageKeyword_2()), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getPackageRenameAccess().getColonColonKeyword_4_0()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getPackageRenameAccess().getSemicolonKeyword_5()), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getRenameAllAccess().getRenamesKeyword_0()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getRenameAllAccess().getColonColonKeyword_2()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(packageRename).keyword(this._aadl2GrammarAccess.getRenameAllAccess().getSemicolonKeyword_4()), _function_7);
  }

  protected void _format(final FeatureGroupTypeRename featureGroupTypeRename, @Extension final IFormattableDocument document) {
    int _switchResult = (int) 0;
    IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(featureGroupTypeRename);
    ISemanticRegion _nextSemanticRegion = null;
    if (_regionForEObject!=null) {
      _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
    }
    EObject _semanticElement = null;
    if (_nextSemanticRegion!=null) {
      _semanticElement=_nextSemanticRegion.getSemanticElement();
    }
    boolean _matched = false;
    if (_semanticElement instanceof Classifier) {
      _matched=true;
    }
    if (!_matched) {
      if (_semanticElement instanceof AnnexLibrary) {
        _matched=true;
      }
    }
    if (!_matched) {
      if (_semanticElement instanceof PackageSection) {
        _matched=true;
      }
    }
    if (_matched) {
      _switchResult = 2;
    }
    if (!_matched) {
      _switchResult = 1;
    }
    final int newLineCount = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(newLineCount);
    };
    this.<FeatureGroupTypeRename>conditionalAppend(featureGroupTypeRename, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroupTypeRename).assignment(this._aadl2GrammarAccess.getFGTRenameAccess().getNameAssignment_0()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroupTypeRename).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getFeatureKeyword_0()), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroupTypeRename).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getGroupKeyword_1()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featureGroupTypeRename).keyword(this._aadl2GrammarAccess.getFGTRenameAccess().getSemicolonKeyword_4()), _function_4);
  }

  protected void _format(final ComponentTypeRename componentTypeRename, @Extension final IFormattableDocument document) {
    int _switchResult = (int) 0;
    IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(componentTypeRename);
    ISemanticRegion _nextSemanticRegion = null;
    if (_regionForEObject!=null) {
      _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
    }
    EObject _semanticElement = null;
    if (_nextSemanticRegion!=null) {
      _semanticElement=_nextSemanticRegion.getSemanticElement();
    }
    boolean _matched = false;
    if (_semanticElement instanceof Classifier) {
      _matched=true;
    }
    if (!_matched) {
      if (_semanticElement instanceof AnnexLibrary) {
        _matched=true;
      }
    }
    if (!_matched) {
      if (_semanticElement instanceof PackageSection) {
        _matched=true;
      }
    }
    if (_matched) {
      _switchResult = 2;
    }
    if (!_matched) {
      _switchResult = 1;
    }
    final int newLineCount = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(newLineCount);
    };
    this.<ComponentTypeRename>conditionalAppend(componentTypeRename, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(componentTypeRename).assignment(this._aadl2GrammarAccess.getCTRenameAccess().getNameAssignment_0()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(componentTypeRename).assignment(this._aadl2GrammarAccess.getCTRenameAccess().getCategoryAssignment_2()), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(componentTypeRename).keyword(this._aadl2GrammarAccess.getCTRenameAccess().getSemicolonKeyword_4()), _function_3);
  }

  protected void _format(final DefaultAnnexLibrary defaultAnnexLibrary, @Extension final IFormattableDocument document) {
    int _switchResult = (int) 0;
    IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(defaultAnnexLibrary);
    ISemanticRegion _nextSemanticRegion = null;
    if (_regionForEObject!=null) {
      _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
    }
    EObject _semanticElement = null;
    if (_nextSemanticRegion!=null) {
      _semanticElement=_nextSemanticRegion.getSemanticElement();
    }
    boolean _matched = false;
    if (_semanticElement instanceof Classifier) {
      _matched=true;
    }
    if (!_matched) {
      if (_semanticElement instanceof AnnexLibrary) {
        _matched=true;
      }
    }
    if (!_matched) {
      if (_semanticElement instanceof PackageSection) {
        _matched=true;
      }
    }
    if (_matched) {
      _switchResult = 2;
    }
    if (!_matched) {
      _switchResult = 1;
    }
    final int newLineCount = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(newLineCount, newLineCount, 2);
    };
    this.<DefaultAnnexLibrary>conditionalAppend(defaultAnnexLibrary, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(defaultAnnexLibrary).assignment(this._aadl2GrammarAccess.getDefaultAnnexLibraryAccess().getNameAssignment_1()), _function_1);
    final AnnexLibrary parsedLibrary = defaultAnnexLibrary.getParsedAnnexLibrary();
    final ISemanticRegion sourceTextRegion = this.textRegionExtensions.regionFor(defaultAnnexLibrary).assignment(this._aadl2GrammarAccess.getDefaultAnnexLibraryAccess().getSourceTextAssignment_2());
    this.formatAnnexText(parsedLibrary, defaultAnnexLibrary.getName(), sourceTextRegion, 1, document);
    final Procedure0 _function_2 = () -> {
      defaultAnnexLibrary.setParsedAnnexLibrary(parsedLibrary);
    };
    Aadl2Formatter.performModification(defaultAnnexLibrary, _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(defaultAnnexLibrary).keyword(this._aadl2GrammarAccess.getDefaultAnnexLibraryAccess().getSemicolonKeyword_3()), _function_3);
  }

  protected void _format(final AbstractType abstractType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(abstractType).keyword(this._aadl2GrammarAccess.getAbstractTypeAccess().getAbstractKeyword_0()), _function);
    this.formatComponentTypeCommon(abstractType, document, this.textRegionExtensions.regionFor(abstractType).assignment(this._aadl2GrammarAccess.getAbstractTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final SystemType systemType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(systemType).keyword(this._aadl2GrammarAccess.getSystemTypeAccess().getSystemKeyword_0()), _function);
    this.formatComponentTypeCommon(systemType, document, this.textRegionExtensions.regionFor(systemType).assignment(this._aadl2GrammarAccess.getSystemTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final ProcessType processType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(processType).keyword(this._aadl2GrammarAccess.getProcessTypeAccess().getProcessKeyword_0()), _function);
    this.formatComponentTypeCommon(processType, document, this.textRegionExtensions.regionFor(processType).assignment(this._aadl2GrammarAccess.getProcessTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final ThreadGroupType threadGroupType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(threadGroupType).keyword(this._aadl2GrammarAccess.getThreadGroupKeywordsAccess().getGroupKeyword_1()), _function);
    this.formatComponentTypeCommon(threadGroupType, document, this.textRegionExtensions.regionFor(threadGroupType).assignment(this._aadl2GrammarAccess.getThreadGroupTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final ThreadType threadType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(threadType).keyword(this._aadl2GrammarAccess.getThreadTypeAccess().getThreadKeyword_0()), _function);
    this.formatComponentTypeCommon(threadType, document, this.textRegionExtensions.regionFor(threadType).assignment(this._aadl2GrammarAccess.getThreadTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final SubprogramType subprogramType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramType).keyword(this._aadl2GrammarAccess.getSubprogramTypeAccess().getSubprogramKeyword_0()), _function);
    this.formatComponentTypeCommon(subprogramType, document, this.textRegionExtensions.regionFor(subprogramType).assignment(this._aadl2GrammarAccess.getSubprogramTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final SubprogramGroupType subprogramGroupType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramGroupType).keyword(this._aadl2GrammarAccess.getSubprogramGroupKeywordsAccess().getGroupKeyword_1()), _function);
    this.formatComponentTypeCommon(subprogramGroupType, document, 
      this.textRegionExtensions.regionFor(subprogramGroupType).assignment(this._aadl2GrammarAccess.getSubprogramGroupTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final ProcessorType processorType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(processorType).keyword(this._aadl2GrammarAccess.getProcessorTypeAccess().getProcessorKeyword_0()), _function);
    this.formatComponentTypeCommon(processorType, document, this.textRegionExtensions.regionFor(processorType).assignment(this._aadl2GrammarAccess.getProcessorTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final DeviceType deviceType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(deviceType).keyword(this._aadl2GrammarAccess.getDeviceTypeAccess().getDeviceKeyword_0()), _function);
    this.formatComponentTypeCommon(deviceType, document, this.textRegionExtensions.regionFor(deviceType).assignment(this._aadl2GrammarAccess.getDeviceTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final MemoryType memoryType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(memoryType).keyword(this._aadl2GrammarAccess.getMemoryTypeAccess().getMemoryKeyword_0()), _function);
    this.formatComponentTypeCommon(memoryType, document, this.textRegionExtensions.regionFor(memoryType).assignment(this._aadl2GrammarAccess.getMemoryTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final BusType busType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(busType).keyword(this._aadl2GrammarAccess.getBusTypeAccess().getBusKeyword_0()), _function);
    this.formatComponentTypeCommon(busType, document, this.textRegionExtensions.regionFor(busType).assignment(this._aadl2GrammarAccess.getBusTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final VirtualBusType virtualBusType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(virtualBusType).keyword(this._aadl2GrammarAccess.getVirtualBusKeywordsAccess().getBusKeyword_1()), _function);
    this.formatComponentTypeCommon(virtualBusType, document, this.textRegionExtensions.regionFor(virtualBusType).assignment(this._aadl2GrammarAccess.getVirtualBusTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final VirtualProcessorType virtualProcessorType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(virtualProcessorType).keyword(this._aadl2GrammarAccess.getVirtualProcessorKeywordsAccess().getProcessorKeyword_1()), _function);
    this.formatComponentTypeCommon(virtualProcessorType, document, 
      this.textRegionExtensions.regionFor(virtualProcessorType).assignment(this._aadl2GrammarAccess.getVirtualProcessorTypeAccess().getNameAssignment_1()));
  }

  protected void _format(final DataType dataType, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataType).keyword(this._aadl2GrammarAccess.getDataTypeAccess().getDataKeyword_0()), _function);
    this.formatComponentTypeCommon(dataType, document, this.textRegionExtensions.regionFor(dataType).assignment(this._aadl2GrammarAccess.getDataTypeAccess().getNameAssignment_1()));
  }

  private ISemanticRegion formatComponentTypeCommon(final ComponentType componentType, @Extension final IFormattableDocument document, final ISemanticRegion nameAssignment) {
    ISemanticRegion _xblockexpression = null;
    {
      int _switchResult = (int) 0;
      IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(componentType);
      ISemanticRegion _nextSemanticRegion = null;
      if (_regionForEObject!=null) {
        _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
      }
      EObject _semanticElement = null;
      if (_nextSemanticRegion!=null) {
        _semanticElement=_nextSemanticRegion.getSemanticElement();
      }
      boolean _matched = false;
      if (_semanticElement instanceof Classifier) {
        _matched=true;
      }
      if (!_matched) {
        if (_semanticElement instanceof AnnexLibrary) {
          _matched=true;
        }
      }
      if (!_matched) {
        if (_semanticElement instanceof PackageSection) {
          _matched=true;
        }
      }
      if (_matched) {
        _switchResult = 2;
      }
      if (!_matched) {
        _switchResult = 1;
      }
      final int newLineCount = _switchResult;
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(newLineCount, newLineCount, 2);
      };
      this.<ComponentType>conditionalAppend(componentType, document, _function);
      final ISemanticRegion endKeyword = this.textRegionExtensions.regionFor(componentType).keyword("end");
      TypeExtension _ownedExtension = componentType.getOwnedExtension();
      boolean _tripleEquals = (_ownedExtension == null);
      if (_tripleEquals) {
        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(nameAssignment, _function_1);
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(nameAssignment, endKeyword, _function_2);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        document.append(nameAssignment, _function_3);
        this.format(componentType.getOwnedExtension(), document);
        boolean _isEmpty = componentType.getOwnedPrototypeBindings().isEmpty();
        if (_isEmpty) {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1, 1, 2);
          };
          document.<TypeExtension>append(componentType.getOwnedExtension(), _function_4);
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.indent();
          };
          document.<ISemanticRegion, ISemanticRegion>interior(IterableExtensions.<ISemanticRegion>last(this.textRegionExtensions.allSemanticRegions(componentType.getOwnedExtension())), endKeyword, _function_5);
        } else {
          final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(componentType).keyword("(");
          final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(componentType).keyword(")");
          final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
            it.indent();
          };
          document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_6);
          final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
            it.oneSpace();
          };
          final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
            it.setNewLines(0, 0, 1);
            it.autowrap();
          };
          document.append(document.prepend(leftParenthesis, _function_7), _function_8);
          final Consumer<ISemanticRegion> _function_9 = (ISemanticRegion it) -> {
            final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it_1) -> {
              it_1.noSpace();
            };
            final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
              it_1.oneSpace();
              it_1.setNewLines(0, 0, 1);
              it_1.autowrap();
            };
            document.append(document.prepend(it, _function_10), _function_11);
          };
          this.textRegionExtensions.regionFor(componentType).keywords(",").forEach(_function_9);
          final Consumer<PrototypeBinding> _function_10 = (PrototypeBinding it) -> {
            this.format(it, document);
          };
          componentType.getOwnedPrototypeBindings().forEach(_function_10);
          if ((rightParenthesis != null)) {
            boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
            if (_isMultiline) {
              final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1);
              };
              final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1, 1, 2);
              };
              document.append(document.prepend(rightParenthesis, _function_11), _function_12);
            } else {
              final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
                it.noSpace();
              };
              final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1, 1, 2);
              };
              document.append(document.prepend(rightParenthesis, _function_13), _function_14);
            }
            final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
              it.indent();
            };
            document.<ISemanticRegion, ISemanticRegion>interior(rightParenthesis, endKeyword, _function_15);
          }
        }
      }
      final ISemanticRegion prototypesKeyword = this.textRegionExtensions.regionFor(componentType).keyword("prototypes");
      final ISemanticRegion featuresKeyword = this.textRegionExtensions.regionFor(componentType).keyword("features");
      final ISemanticRegion flowsKeyword = this.textRegionExtensions.regionFor(componentType).keyword("flows");
      final ISemanticRegion requiresKeyword = this.textRegionExtensions.regionFor(componentType).keyword("requires");
      final ISemanticRegion modesKeyword = this.textRegionExtensions.regionFor(componentType).keyword("modes");
      final ISemanticRegion propertiesKeyword = this.textRegionExtensions.regionFor(componentType).keyword("properties");
      final ISemanticRegion annexRegion = IterableExtensions.<ISemanticRegion>head(this.textRegionExtensions.semanticRegions(IterableExtensions.<AnnexSubclause>head(componentType.getOwnedAnnexSubclauses())));
      if ((prototypesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_16 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(prototypesKeyword, _function_16);
        ISemanticRegion _elvis = null;
        ISemanticRegion _elvis_1 = null;
        ISemanticRegion _elvis_2 = null;
        ISemanticRegion _elvis_3 = null;
        ISemanticRegion _elvis_4 = null;
        ISemanticRegion _elvis_5 = null;
        if (featuresKeyword != null) {
          _elvis_5 = featuresKeyword;
        } else {
          _elvis_5 = flowsKeyword;
        }
        if (_elvis_5 != null) {
          _elvis_4 = _elvis_5;
        } else {
          _elvis_4 = requiresKeyword;
        }
        if (_elvis_4 != null) {
          _elvis_3 = _elvis_4;
        } else {
          _elvis_3 = modesKeyword;
        }
        if (_elvis_3 != null) {
          _elvis_2 = _elvis_3;
        } else {
          _elvis_2 = propertiesKeyword;
        }
        if (_elvis_2 != null) {
          _elvis_1 = _elvis_2;
        } else {
          _elvis_1 = annexRegion;
        }
        if (_elvis_1 != null) {
          _elvis = _elvis_1;
        } else {
          _elvis = endKeyword;
        }
        final ISemanticRegion endMarker = _elvis;
        final Procedure1<IHiddenRegionFormatter> _function_17 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(prototypesKeyword, endMarker, _function_17);
      }
      if ((featuresKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_18 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(featuresKeyword, _function_18);
        ISemanticRegion _elvis_6 = null;
        ISemanticRegion _elvis_7 = null;
        ISemanticRegion _elvis_8 = null;
        ISemanticRegion _elvis_9 = null;
        ISemanticRegion _elvis_10 = null;
        if (flowsKeyword != null) {
          _elvis_10 = flowsKeyword;
        } else {
          _elvis_10 = requiresKeyword;
        }
        if (_elvis_10 != null) {
          _elvis_9 = _elvis_10;
        } else {
          _elvis_9 = modesKeyword;
        }
        if (_elvis_9 != null) {
          _elvis_8 = _elvis_9;
        } else {
          _elvis_8 = propertiesKeyword;
        }
        if (_elvis_8 != null) {
          _elvis_7 = _elvis_8;
        } else {
          _elvis_7 = annexRegion;
        }
        if (_elvis_7 != null) {
          _elvis_6 = _elvis_7;
        } else {
          _elvis_6 = endKeyword;
        }
        final ISemanticRegion endMarker_1 = _elvis_6;
        final Procedure1<IHiddenRegionFormatter> _function_19 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(featuresKeyword, endMarker_1, _function_19);
      }
      if ((flowsKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_20 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(flowsKeyword, _function_20);
        ISemanticRegion _elvis_11 = null;
        ISemanticRegion _elvis_12 = null;
        ISemanticRegion _elvis_13 = null;
        ISemanticRegion _elvis_14 = null;
        if (requiresKeyword != null) {
          _elvis_14 = requiresKeyword;
        } else {
          _elvis_14 = modesKeyword;
        }
        if (_elvis_14 != null) {
          _elvis_13 = _elvis_14;
        } else {
          _elvis_13 = propertiesKeyword;
        }
        if (_elvis_13 != null) {
          _elvis_12 = _elvis_13;
        } else {
          _elvis_12 = annexRegion;
        }
        if (_elvis_12 != null) {
          _elvis_11 = _elvis_12;
        } else {
          _elvis_11 = endKeyword;
        }
        final ISemanticRegion endMarker_2 = _elvis_11;
        final Procedure1<IHiddenRegionFormatter> _function_21 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(flowsKeyword, endMarker_2, _function_21);
      }
      if ((modesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_22 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(modesKeyword, _function_22);
        ISemanticRegion _elvis_15 = null;
        ISemanticRegion _elvis_16 = null;
        if (propertiesKeyword != null) {
          _elvis_16 = propertiesKeyword;
        } else {
          _elvis_16 = annexRegion;
        }
        if (_elvis_16 != null) {
          _elvis_15 = _elvis_16;
        } else {
          _elvis_15 = endKeyword;
        }
        final ISemanticRegion endMarker_3 = _elvis_15;
        final Procedure1<IHiddenRegionFormatter> _function_23 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(modesKeyword, endMarker_3, _function_23);
      }
      if ((propertiesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_24 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(propertiesKeyword, _function_24);
        ISemanticRegion _elvis_17 = null;
        if (annexRegion != null) {
          _elvis_17 = annexRegion;
        } else {
          _elvis_17 = endKeyword;
        }
        final ISemanticRegion endMarker_4 = _elvis_17;
        final Procedure1<IHiddenRegionFormatter> _function_25 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(propertiesKeyword, endMarker_4, _function_25);
      }
      final Procedure1<IHiddenRegionFormatter> _function_26 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(requiresKeyword, _function_26);
      final Consumer<ISemanticRegion> _function_27 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_28 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        document.append(it, _function_28);
      };
      this.textRegionExtensions.regionFor(componentType).keywords("none").forEach(_function_27);
      final List<ISemanticRegion> semicolons = this.textRegionExtensions.regionFor(componentType).keywords(";");
      int _size = semicolons.size();
      boolean _greaterThan = (_size > 1);
      if (_greaterThan) {
        int _size_1 = semicolons.size();
        int _minus = (_size_1 - 1);
        final Consumer<ISemanticRegion> _function_28 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_29 = (IHiddenRegionFormatter it_1) -> {
            it_1.setNewLines(1, 1, 2);
          };
          document.append(it, _function_29);
        };
        IterableExtensions.<ISemanticRegion>take(semicolons, _minus).forEach(_function_28);
      }
      EList<Prototype> _ownedPrototypes = componentType.getOwnedPrototypes();
      EList<Feature> _ownedFeatures = componentType.getOwnedFeatures();
      Iterable<StructuralFeature> _plus = Iterables.<StructuralFeature>concat(_ownedPrototypes, _ownedFeatures);
      EList<FlowSpecification> _ownedFlowSpecifications = componentType.getOwnedFlowSpecifications();
      Iterable<StructuralFeature> _plus_1 = Iterables.<StructuralFeature>concat(_plus, _ownedFlowSpecifications);
      EList<Mode> _ownedModes = componentType.getOwnedModes();
      Iterable<ClassifierFeature> _plus_2 = Iterables.<ClassifierFeature>concat(_plus_1, _ownedModes);
      EList<ModeTransition> _ownedModeTransitions = componentType.getOwnedModeTransitions();
      Iterable<ClassifierFeature> _plus_3 = Iterables.<ClassifierFeature>concat(_plus_2, _ownedModeTransitions);
      EList<AnnexSubclause> _ownedAnnexSubclauses = componentType.getOwnedAnnexSubclauses();
      final Consumer<NamedElement> _function_29 = (NamedElement it) -> {
        this.format(it, document);
      };
      Iterables.<NamedElement>concat(_plus_3, _ownedAnnexSubclauses).forEach(_function_29);
      final Consumer<PropertyAssociation> _function_30 = (PropertyAssociation it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_31 = (IHiddenRegionFormatter it_1) -> {
          it_1.setNewLines(1, 1, 2);
        };
        document.<PropertyAssociation>append(it, _function_31);
        this.format(it, document);
      };
      componentType.getOwnedPropertyAssociations().forEach(_function_30);
      final Procedure1<IHiddenRegionFormatter> _function_31 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(endKeyword, _function_31);
      final Procedure1<IHiddenRegionFormatter> _function_32 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      _xblockexpression = document.prepend(IterableExtensions.<ISemanticRegion>last(semicolons), _function_32);
    }
    return _xblockexpression;
  }

  protected void _format(final TypeExtension typeExtension, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(typeExtension).keyword(this._aadl2GrammarAccess.getTypeExtensionAccess().getExtendsKeyword_0()), _function);
  }

  protected void _format(final FeatureGroupPrototypeBinding featureGroupPrototypeBinding, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroupPrototypeBinding).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeBindingAccess().getEqualsSignGreaterThanSignKeyword_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroupPrototypeBinding).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getGroupKeyword_1()), _function_1);
    this.format(featureGroupPrototypeBinding.getActual(), document);
  }

  protected void _format(final FeatureGroupPrototypeActual featureGroupPrototypeActual, @Extension final IFormattableDocument document) {
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(featureGroupPrototypeActual).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeActualAccess().getLeftParenthesisKeyword_1_0());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(featureGroupPrototypeActual).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeActualAccess().getRightParenthesisKeyword_1_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_1), _function_2);
      final Consumer<ISemanticRegion> _function_3 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_4), _function_5);
      };
      this.textRegionExtensions.regionFor(featureGroupPrototypeActual).keywords(this._aadl2GrammarAccess.getFeatureGroupPrototypeActualAccess().getCommaKeyword_1_2_0()).forEach(_function_3);
      final Consumer<PrototypeBinding> _function_4 = (PrototypeBinding it) -> {
        this.format(it, document);
      };
      featureGroupPrototypeActual.getBindings().forEach(_function_4);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_5);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_6);
      }
    }
  }

  protected void _format(final FeaturePrototypeBinding featurePrototypeBinding, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featurePrototypeBinding).keyword(this._aadl2GrammarAccess.getFeaturePrototypeBindingAccess().getEqualsSignGreaterThanSignKeyword_1()), _function);
    this.format(featurePrototypeBinding.getActual(), document);
  }

  protected void _format(final PortSpecification portSpecification, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(portSpecification).keyword(this._aadl2GrammarAccess.getPortSpecificationAccess().getInInKeyword_0_0_0_0()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(portSpecification).keyword(this._aadl2GrammarAccess.getPortSpecificationAccess().getOutOutKeyword_0_0_1_0()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(portSpecification).keyword(this._aadl2GrammarAccess.getPortSpecificationAccess().getOutOutKeyword_0_1_0()), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(portSpecification).keyword(this._aadl2GrammarAccess.getPortSpecificationAccess().getPortKeyword_2()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(portSpecification).assignment(this._aadl2GrammarAccess.getPortSpecificationAccess().getClassifierAssignment_3()), _function_4);
  }

  protected void _format(final AccessSpecification accessSpecification, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(accessSpecification).assignment(this._aadl2GrammarAccess.getAccessSpecificationAccess().getCategoryAssignment_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(accessSpecification).assignment(this._aadl2GrammarAccess.getAccessSpecificationAccess().getClassifierAssignment_3()), _function_1);
  }

  protected void _format(final FeaturePrototypeReference featurePrototypeReference, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featurePrototypeReference).keyword(this._aadl2GrammarAccess.getFeaturePrototypeReferenceAccess().getInInKeyword_0_0_0()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featurePrototypeReference).keyword(this._aadl2GrammarAccess.getFeaturePrototypeReferenceAccess().getOutOutKeyword_0_1_0()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featurePrototypeReference).keyword(this._aadl2GrammarAccess.getFeaturePrototypeReferenceAccess().getFeatureKeyword_1()), _function_2);
  }

  protected void _format(final ComponentPrototypeBinding componentPrototypeBinding, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(componentPrototypeBinding).keyword(this._aadl2GrammarAccess.getComponentPrototypeBindingAccess().getEqualsSignGreaterThanSignKeyword_1()), _function);
    final Consumer<ComponentPrototypeActual> _function_1 = (ComponentPrototypeActual it) -> {
      this.format(it, document);
    };
    componentPrototypeBinding.getActuals().forEach(_function_1);
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(componentPrototypeBinding).keyword(this._aadl2GrammarAccess.getComponentPrototypeBindingAccess().getLeftParenthesisKeyword_2_1_0());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(componentPrototypeBinding).keyword(this._aadl2GrammarAccess.getComponentPrototypeBindingAccess().getRightParenthesisKeyword_2_1_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(leftParenthesis, _function_3);
      final Consumer<ISemanticRegion> _function_4 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_5), _function_6);
      };
      this.textRegionExtensions.regionFor(componentPrototypeBinding).keywords(this._aadl2GrammarAccess.getComponentPrototypeBindingAccess().getCommaKeyword_2_1_2_0()).forEach(_function_4);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_5);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_6);
      }
    }
  }

  protected void _format(final ComponentPrototypeActual componentPrototypeActual, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(componentPrototypeActual).assignment(this._aadl2GrammarAccess.getComponentReferenceAccess().getCategoryAssignment_0()), _function);
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(componentPrototypeActual).keyword(this._aadl2GrammarAccess.getComponentReferenceAccess().getLeftParenthesisKeyword_2_0());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(componentPrototypeActual).keyword(this._aadl2GrammarAccess.getComponentReferenceAccess().getRightParenthesisKeyword_2_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_1);
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_2), _function_3);
      final Consumer<ISemanticRegion> _function_4 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_5), _function_6);
      };
      this.textRegionExtensions.regionFor(componentPrototypeActual).keywords(this._aadl2GrammarAccess.getComponentReferenceAccess().getCommaKeyword_2_2_0()).forEach(_function_4);
      final Consumer<PrototypeBinding> _function_5 = (PrototypeBinding it) -> {
        this.format(it, document);
      };
      componentPrototypeActual.getBindings().forEach(_function_5);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_6);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_7);
      }
    }
  }

  protected void _format(final DataPort dataPort, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<DataPort>conditionalAppend(dataPort, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getColonKeyword_1_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getColonKeyword_1_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getInInKeyword_2_0_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getOutOutKeyword_2_0_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getOutOutKeyword_2_1_0()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortKeywordsAccess().getDataKeyword_0()), _function_9);
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(dataPort).assignment(this._aadl2GrammarAccess.getDataPortAccess().getDataFeatureClassifierAssignment_4()), _function_10);
    final Consumer<ArrayDimension> _function_11 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_12);
      this.format(it, document);
    };
    dataPort.getArrayDimensions().forEach(_function_11);
    this.formatCurlyProperties(dataPort, document, this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getLeftCurlyBracketKeyword_6_0()), 
      this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getRightCurlyBracketKeyword_6_2()));
    final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(dataPort).keyword(this._aadl2GrammarAccess.getDataPortAccess().getSemicolonKeyword_7()), _function_12);
  }

  protected void _format(final ArrayDimension arrayDimension, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.append(this.textRegionExtensions.regionFor(arrayDimension).keyword(this._aadl2GrammarAccess.getArrayDimensionAccess().getLeftSquareBracketKeyword_1()), _function);
    this.format(arrayDimension.getSize(), document);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(arrayDimension).keyword(this._aadl2GrammarAccess.getArrayDimensionAccess().getRightSquareBracketKeyword_3()), _function_1);
  }

  protected void _format(final EventDataPort eventDataPort, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<EventDataPort>conditionalAppend(eventDataPort, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getColonKeyword_1_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getColonKeyword_1_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getInInKeyword_2_0_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getOutOutKeyword_2_0_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getOutOutKeyword_2_1_0()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortKeywordsAccess().getDataKeyword_1()), _function_9);
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventDataPort).assignment(this._aadl2GrammarAccess.getEventDataPortAccess().getDataFeatureClassifierAssignment_4()), _function_10);
    final Consumer<ArrayDimension> _function_11 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_12);
      this.format(it, document);
    };
    eventDataPort.getArrayDimensions().forEach(_function_11);
    this.formatCurlyProperties(eventDataPort, document, this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getLeftCurlyBracketKeyword_6_0()), 
      this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getRightCurlyBracketKeyword_6_2()));
    final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventDataPort).keyword(this._aadl2GrammarAccess.getEventDataPortAccess().getSemicolonKeyword_7()), _function_12);
  }

  protected void _format(final EventPort eventPort, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<EventPort>conditionalAppend(eventPort, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getColonKeyword_1_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getColonKeyword_1_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getInInKeyword_2_0_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getOutOutKeyword_2_0_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getOutOutKeyword_2_1_0()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortKeywordsAccess().getEventKeyword_0()), _function_9);
    final Consumer<ArrayDimension> _function_10 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_11);
      this.format(it, document);
    };
    eventPort.getArrayDimensions().forEach(_function_10);
    this.formatCurlyProperties(eventPort, document, this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventPort).keyword(this._aadl2GrammarAccess.getEventPortAccess().getSemicolonKeyword_6()), _function_11);
  }

  protected void _format(final FeatureGroup featureGroup, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<FeatureGroup>conditionalAppend(featureGroup, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getInInKeyword_1_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getOutOutKeyword_1_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getFeatureKeyword_0()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getInverseOfKeywordsAccess().getInverseKeyword_0()), _function_9);
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featureGroup).assignment(this._aadl2GrammarAccess.getFeatureGroupAccess().getFeatureTypeAssignment_3_1()), _function_10);
    final Consumer<ArrayDimension> _function_11 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_12);
      this.format(it, document);
    };
    featureGroup.getArrayDimensions().forEach(_function_11);
    this.formatCurlyProperties(featureGroup, document, this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featureGroup).keyword(this._aadl2GrammarAccess.getFeatureGroupAccess().getSemicolonKeyword_6()), _function_12);
  }

  protected void _format(final ContainedNamedElement containedNamedElement, @Extension final IFormattableDocument document) {
    this.format(containedNamedElement.getPath(), document);
  }

  protected void _format(final Parameter parameter, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<Parameter>conditionalAppend(parameter, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getInInKeyword_1_0_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getOutOutKeyword_1_0_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getOutOutKeyword_1_1_0()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(parameter).assignment(this._aadl2GrammarAccess.getParameterAccess().getDataFeatureClassifierAssignment_3()), _function_9);
    final Consumer<ArrayDimension> _function_10 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_11);
      this.format(it, document);
    };
    parameter.getArrayDimensions().forEach(_function_10);
    this.formatCurlyProperties(parameter, document, this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(parameter).keyword(this._aadl2GrammarAccess.getParameterAccess().getSemicolonKeyword_6()), _function_11);
  }

  protected void _format(final SubprogramAccess subprogramAccess, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<SubprogramAccess>conditionalAppend(subprogramAccess, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessKeywordsAccess().getSubprogramKeyword_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramAccess).assignment(this._aadl2GrammarAccess.getSubprogramAccessAccess().getSubprogramFeatureClassifierAssignment_3()), _function_7);
    final Consumer<ArrayDimension> _function_8 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_9);
      this.format(it, document);
    };
    subprogramAccess.getArrayDimensions().forEach(_function_8);
    this.formatCurlyProperties(subprogramAccess, document, this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramAccess).keyword(this._aadl2GrammarAccess.getSubprogramAccessAccess().getSemicolonKeyword_6()), _function_9);
  }

  protected void _format(final SubprogramGroupAccess subprogramGroupAccess, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<SubprogramGroupAccess>conditionalAppend(subprogramGroupAccess, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessKeywordsAccess().getSubprogramKeyword_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessKeywordsAccess().getGroupKeyword_1()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramGroupAccess).assignment(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getSubprogramGroupFeatureClassifierAssignment_3()), _function_8);
    final Consumer<ArrayDimension> _function_9 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_10);
      this.format(it, document);
    };
    subprogramGroupAccess.getArrayDimensions().forEach(_function_9);
    this.formatCurlyProperties(subprogramGroupAccess, document, 
      this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramGroupAccess).keyword(this._aadl2GrammarAccess.getSubprogramGroupAccessAccess().getSemicolonKeyword_6()), _function_10);
  }

  protected void _format(final BusAccess busAccess, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<BusAccess>conditionalAppend(busAccess, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getVirtualVirtualKeyword_2_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessKeywordsAccess().getBusKeyword_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(busAccess).assignment(this._aadl2GrammarAccess.getBusAccessAccess().getBusFeatureClassifierAssignment_4()), _function_8);
    final Consumer<ArrayDimension> _function_9 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_10);
      this.format(it, document);
    };
    busAccess.getArrayDimensions().forEach(_function_9);
    this.formatCurlyProperties(busAccess, document, this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getLeftCurlyBracketKeyword_6_0()), 
      this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getRightCurlyBracketKeyword_6_2()));
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(busAccess).keyword(this._aadl2GrammarAccess.getBusAccessAccess().getSemicolonKeyword_7()), _function_10);
  }

  protected void _format(final DataAccess dataAccess, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<DataAccess>conditionalAppend(dataAccess, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessKeywordsAccess().getDataKeyword_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(dataAccess).assignment(this._aadl2GrammarAccess.getDataAccessAccess().getDataFeatureClassifierAssignment_3()), _function_7);
    final Consumer<ArrayDimension> _function_8 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_9);
      this.format(it, document);
    };
    dataAccess.getArrayDimensions().forEach(_function_8);
    this.formatCurlyProperties(dataAccess, document, this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(dataAccess).keyword(this._aadl2GrammarAccess.getDataAccessAccess().getSemicolonKeyword_6()), _function_9);
  }

  protected void _format(final AbstractFeature abstractFeature, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<AbstractFeature>conditionalAppend(abstractFeature, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getInInKeyword_1_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getOutOutKeyword_1_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(abstractFeature).assignment(this._aadl2GrammarAccess.getAbstractFeatureAccess().getFeaturePrototypeAssignment_2_0_1()), _function_8);
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(abstractFeature).assignment(this._aadl2GrammarAccess.getAbstractFeatureAccess().getAbstractFeatureClassifierAssignment_2_1_1()), _function_9);
    final Consumer<ArrayDimension> _function_10 = (ArrayDimension it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.<ArrayDimension>prepend(it, _function_11);
      this.format(it, document);
    };
    abstractFeature.getArrayDimensions().forEach(_function_10);
    this.formatCurlyProperties(abstractFeature, document, this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(abstractFeature).keyword(this._aadl2GrammarAccess.getAbstractFeatureAccess().getSemicolonKeyword_5()), _function_11);
  }

  protected void _format(final Mode mode, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<Mode>conditionalAppend(mode, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(mode).keyword(this._aadl2GrammarAccess.getModeAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(mode).keyword(this._aadl2GrammarAccess.getModeAccess().getInitialInitialKeyword_2_0()), _function_3);
    this.formatCurlyProperties(mode, document, this.textRegionExtensions.regionFor(mode).keyword(this._aadl2GrammarAccess.getModeAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(mode).keyword(this._aadl2GrammarAccess.getModeAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(mode).keyword(this._aadl2GrammarAccess.getModeAccess().getSemicolonKeyword_5()), _function_4);
  }

  protected void _format(final ModeTransition modeTransition, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<ModeTransition>conditionalAppend(modeTransition, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getColonKeyword_0_1()), _function_1), _function_2);
    final ISemanticRegion leftMarker = this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getHyphenMinusLeftSquareBracketKeyword_2());
    final ISemanticRegion rightMarker = this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getRightSquareBracketHyphenMinusGreaterThanSignKeyword_5());
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(leftMarker, rightMarker, _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
      it.setNewLines(0, 0, 1);
      it.autowrap();
    };
    document.append(document.prepend(leftMarker, _function_4), _function_5);
    final Consumer<ModeTransitionTrigger> _function_6 = (ModeTransitionTrigger it) -> {
      this.format(it, document);
    };
    modeTransition.getOwnedTriggers().forEach(_function_6);
    final Consumer<ISemanticRegion> _function_7 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
        it_1.setNewLines(0, 0, 1);
        it_1.autowrap();
      };
      document.append(document.prepend(it, _function_8), _function_9);
    };
    this.textRegionExtensions.regionFor(modeTransition).keywords(this._aadl2GrammarAccess.getModeTransitionAccess().getCommaKeyword_4_0()).forEach(_function_7);
    IHiddenRegion _previousHiddenRegion = null;
    if (rightMarker!=null) {
      _previousHiddenRegion=rightMarker.getPreviousHiddenRegion();
    }
    final IHiddenRegion previousHidden = _previousHiddenRegion;
    if (((previousHidden != null) && previousHidden.isMultiline())) {
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1);
      };
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(rightMarker, _function_8), _function_9);
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(rightMarker, _function_10), _function_11);
    }
    this.formatCurlyProperties(modeTransition, document, this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getLeftCurlyBracketKeyword_7_0()), 
      this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getRightCurlyBracketKeyword_7_2()));
    final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(modeTransition).keyword(this._aadl2GrammarAccess.getModeTransitionAccess().getSemicolonKeyword_8()), _function_12);
  }

  private ISemanticRegion formatCurlyProperties(final NamedElement namedElement, @Extension final IFormattableDocument document, final ISemanticRegion leftCurly, final ISemanticRegion rightCurly) {
    ISemanticRegion _xifexpression = null;
    if (((leftCurly != null) && (rightCurly != null))) {
      ISemanticRegion _xblockexpression = null;
      {
        final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(leftCurly, rightCurly, _function);
        final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
          it.setNewLines(0, 0, 1);
          it.autowrap();
        };
        document.append(document.prepend(leftCurly, _function_1), _function_2);
        final Consumer<PropertyAssociation> _function_3 = (PropertyAssociation it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it_1) -> {
            it_1.oneSpace();
            it_1.setNewLines(0, 0, 1);
            it_1.autowrap();
          };
          document.<PropertyAssociation>prepend(it, _function_4);
        };
        IterableExtensions.<PropertyAssociation>tail(namedElement.getOwnedPropertyAssociations()).forEach(_function_3);
        final Consumer<PropertyAssociation> _function_4 = (PropertyAssociation it) -> {
          this.format(it, document);
        };
        namedElement.getOwnedPropertyAssociations().forEach(_function_4);
        ISemanticRegion _xifexpression_1 = null;
        boolean _isMultiline = rightCurly.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          _xifexpression_1 = document.prepend(rightCurly, _function_5);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          _xifexpression_1 = document.prepend(rightCurly, _function_6);
        }
        _xblockexpression = _xifexpression_1;
      }
      _xifexpression = _xblockexpression;
    }
    return _xifexpression;
  }

  protected void _format(final ModeTransitionTrigger modeTransitionTrigger, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(modeTransitionTrigger).keyword(this._aadl2GrammarAccess.getTriggerAccess().getFullStopKeyword_0_0_1()), _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(modeTransitionTrigger).keyword(this._aadl2GrammarAccess.getTriggerAccess().getFullStopKeyword_1_1()), _function_1);
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(modeTransitionTrigger).keyword(this._aadl2GrammarAccess.getTriggerAccess().getFullStopKeyword_2_1()), _function_2);
  }

  protected void _format(final FeatureGroupPrototype featureGroupPrototype, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<FeatureGroupPrototype>conditionalAppend(featureGroupPrototype, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getFeatureKeyword_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featureGroupPrototype).assignment(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getConstrainingFeatureGroupTypeAssignment_2()), _function_7);
    this.formatCurlyProperties(featureGroupPrototype, document, 
      this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getLeftCurlyBracketKeyword_3_0()), 
      this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getRightCurlyBracketKeyword_3_2()));
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featureGroupPrototype).keyword(this._aadl2GrammarAccess.getFeatureGroupPrototypeAccess().getSemicolonKeyword_4()), _function_8);
  }

  protected void _format(final FeaturePrototype featurePrototype, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<FeaturePrototype>conditionalAppend(featurePrototype, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getColonKeyword_0_1_1()), _function_3), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_5);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getInInKeyword_1_0_0()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getOutOutKeyword_1_1_0()), _function_7);
    final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featurePrototype).assignment(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getConstrainingClassifierAssignment_3()), _function_8);
    this.formatCurlyProperties(featurePrototype, document, this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(featurePrototype).keyword(this._aadl2GrammarAccess.getFeaturePrototypeAccess().getSemicolonKeyword_5()), _function_9);
  }

  private ISemanticRegion formatComponentPrototypeCommon(final ComponentPrototype componentPrototype, @Extension final IFormattableDocument document, final ISemanticRegion constrainingClassifierAssignment) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<ComponentPrototype>conditionalAppend(componentPrototype, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(componentPrototype).keyword(":"), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(componentPrototype).keyword("to"), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(constrainingClassifierAssignment, _function_4);
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(componentPrototype).keyword("["), _function_5);
      this.formatCurlyProperties(componentPrototype, document, this.textRegionExtensions.regionFor(componentPrototype).keyword("{"), 
        this.textRegionExtensions.regionFor(componentPrototype).keyword("}"));
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      _xblockexpression = document.prepend(this.textRegionExtensions.regionFor(componentPrototype).keyword(";"), _function_6);
    }
    return _xblockexpression;
  }

  protected void _format(final AbstractPrototype abstractPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(abstractPrototype, document, 
      this.textRegionExtensions.regionFor(abstractPrototype).assignment(this._aadl2GrammarAccess.getAbstractPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final BusPrototype busPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(busPrototype, document, 
      this.textRegionExtensions.regionFor(busPrototype).assignment(this._aadl2GrammarAccess.getBusPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final DataPrototype dataPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(dataPrototype, document, 
      this.textRegionExtensions.regionFor(dataPrototype).assignment(this._aadl2GrammarAccess.getDataPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final DevicePrototype devicePrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(devicePrototype, document, 
      this.textRegionExtensions.regionFor(devicePrototype).assignment(this._aadl2GrammarAccess.getDevicePrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final MemoryPrototype memoryPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(memoryPrototype, document, 
      this.textRegionExtensions.regionFor(memoryPrototype).assignment(this._aadl2GrammarAccess.getMemoryPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final ProcessPrototype processPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(processPrototype, document, 
      this.textRegionExtensions.regionFor(processPrototype).assignment(this._aadl2GrammarAccess.getProcessPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final ProcessorPrototype processorPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(processorPrototype, document, 
      this.textRegionExtensions.regionFor(processorPrototype).assignment(this._aadl2GrammarAccess.getProcessorPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final SubprogramPrototype subprogramPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(subprogramPrototype, document, 
      this.textRegionExtensions.regionFor(subprogramPrototype).assignment(this._aadl2GrammarAccess.getSubprogramPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final SubprogramGroupPrototype subprogramGroupPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(subprogramGroupPrototype, document, 
      this.textRegionExtensions.regionFor(subprogramGroupPrototype).assignment(this._aadl2GrammarAccess.getSubprogramGroupPrototypeAccess().getConstrainingClassifierAssignment_2()));
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramGroupPrototype).keyword(this._aadl2GrammarAccess.getSubprogramGroupKeywordsAccess().getSubprogramKeyword_0()), _function);
  }

  protected void _format(final SystemPrototype systemPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(systemPrototype, document, 
      this.textRegionExtensions.regionFor(systemPrototype).assignment(this._aadl2GrammarAccess.getSystemPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final ThreadPrototype threadPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(threadPrototype, document, 
      this.textRegionExtensions.regionFor(threadPrototype).assignment(this._aadl2GrammarAccess.getThreadPrototypeAccess().getConstrainingClassifierAssignment_2()));
  }

  protected void _format(final ThreadGroupPrototype threadGroupPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(threadGroupPrototype, document, 
      this.textRegionExtensions.regionFor(threadGroupPrototype).assignment(this._aadl2GrammarAccess.getThreadGroupPrototypeAccess().getConstrainingClassifierAssignment_2()));
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(threadGroupPrototype).keyword(this._aadl2GrammarAccess.getThreadGroupKeywordsAccess().getThreadKeyword_0()), _function);
  }

  protected void _format(final VirtualBusPrototype virtualBusPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(virtualBusPrototype, document, 
      this.textRegionExtensions.regionFor(virtualBusPrototype).assignment(this._aadl2GrammarAccess.getVirtualBusPrototypeAccess().getConstrainingClassifierAssignment_2()));
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(virtualBusPrototype).keyword(this._aadl2GrammarAccess.getVirtualBusKeywordsAccess().getVirtualKeyword_0()), _function);
  }

  protected void _format(final VirtualProcessorPrototype virtualProcessorPrototype, @Extension final IFormattableDocument document) {
    this.formatComponentPrototypeCommon(virtualProcessorPrototype, document, 
      this.textRegionExtensions.regionFor(virtualProcessorPrototype).assignment(this._aadl2GrammarAccess.getVirtualProcessorPrototypeAccess().getConstrainingClassifierAssignment_2()));
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(virtualProcessorPrototype).keyword(this._aadl2GrammarAccess.getVirtualProcessorKeywordsAccess().getVirtualKeyword_0()), _function);
  }

  protected void _format(final DefaultAnnexSubclause defaultAnnexSubclause, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<DefaultAnnexSubclause>conditionalAppend(defaultAnnexSubclause, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(defaultAnnexSubclause).assignment(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getNameAssignment_1()), _function_1);
    final AnnexSubclause parsedSubclause = defaultAnnexSubclause.getParsedAnnexSubclause();
    final ISemanticRegion sourceTextRegion = this.textRegionExtensions.regionFor(defaultAnnexSubclause).assignment(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getSourceTextAssignment_2());
    this.formatAnnexText(parsedSubclause, defaultAnnexSubclause.getName(), sourceTextRegion, 2, document);
    final Procedure0 _function_2 = () -> {
      defaultAnnexSubclause.setParsedAnnexSubclause(parsedSubclause);
    };
    Aadl2Formatter.performModification(defaultAnnexSubclause, _function_2);
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(defaultAnnexSubclause).keyword(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getLeftParenthesisKeyword_3_1());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(defaultAnnexSubclause).keyword(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getRightParenthesisKeyword_3_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(defaultAnnexSubclause).keyword(this._aadl2GrammarAccess.getInModesKeywordsAccess().getInKeyword_0()), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_4);
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_5), _function_6);
      final Consumer<ISemanticRegion> _function_7 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_8), _function_9);
      };
      this.textRegionExtensions.regionFor(defaultAnnexSubclause).keywords(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getCommaKeyword_3_2_1_0()).forEach(_function_7);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_8);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_9);
      }
    }
    final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(defaultAnnexSubclause).keyword(this._aadl2GrammarAccess.getDefaultAnnexSubclauseAccess().getSemicolonKeyword_4()), _function_10);
  }

  protected void _format(final FeatureGroupType featureGroupType, @Extension final IFormattableDocument document) {
    int _switchResult = (int) 0;
    IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(featureGroupType);
    ISemanticRegion _nextSemanticRegion = null;
    if (_regionForEObject!=null) {
      _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
    }
    EObject _semanticElement = null;
    if (_nextSemanticRegion!=null) {
      _semanticElement=_nextSemanticRegion.getSemanticElement();
    }
    boolean _matched = false;
    if (_semanticElement instanceof Classifier) {
      _matched=true;
    }
    if (!_matched) {
      if (_semanticElement instanceof AnnexLibrary) {
        _matched=true;
      }
    }
    if (!_matched) {
      if (_semanticElement instanceof PackageSection) {
        _matched=true;
      }
    }
    if (_matched) {
      _switchResult = 2;
    }
    if (!_matched) {
      _switchResult = 1;
    }
    final int newLineCount = _switchResult;
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(newLineCount, newLineCount, 2);
    };
    this.<FeatureGroupType>conditionalAppend(featureGroupType, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupKeywordsAccess().getGroupKeyword_1()), _function_1);
    final ISemanticRegion endKeyword = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getEndKeyword_8());
    final ISemanticRegion nameAssignment = this.textRegionExtensions.regionFor(featureGroupType).assignment(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getNameAssignment_1());
    GroupExtension _ownedExtension = featureGroupType.getOwnedExtension();
    boolean _tripleEquals = (_ownedExtension == null);
    if (_tripleEquals) {
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      document.append(nameAssignment, _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(nameAssignment, endKeyword, _function_3);
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(nameAssignment, _function_4);
      this.format(featureGroupType.getOwnedExtension(), document);
      boolean _isEmpty = featureGroupType.getOwnedPrototypeBindings().isEmpty();
      if (_isEmpty) {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.<GroupExtension>append(featureGroupType.getOwnedExtension(), _function_5);
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(IterableExtensions.<ISemanticRegion>last(this.textRegionExtensions.allSemanticRegions(featureGroupType.getOwnedExtension())), endKeyword, _function_6);
      } else {
        final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getLeftParenthesisKeyword_2_1_0());
        final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getRightParenthesisKeyword_2_1_3());
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_7);
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
          it.setNewLines(0, 0, 1);
          it.autowrap();
        };
        document.append(document.prepend(leftParenthesis, _function_8), _function_9);
        final Consumer<ISemanticRegion> _function_10 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
            it_1.noSpace();
          };
          final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
            it_1.oneSpace();
            it_1.setNewLines(0, 0, 1);
            it_1.autowrap();
          };
          document.append(document.prepend(it, _function_11), _function_12);
        };
        this.textRegionExtensions.regionFor(featureGroupType).keywords(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getCommaKeyword_2_1_2_0()).forEach(_function_10);
        final Consumer<PrototypeBinding> _function_11 = (PrototypeBinding it) -> {
          this.format(it, document);
        };
        featureGroupType.getOwnedPrototypeBindings().forEach(_function_11);
        if ((rightParenthesis != null)) {
          boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
          if (_isMultiline) {
            final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
              it.setNewLines(1);
            };
            final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
              it.setNewLines(1, 1, 2);
            };
            document.append(document.prepend(rightParenthesis, _function_12), _function_13);
          } else {
            final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
              it.noSpace();
            };
            final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
              it.setNewLines(1, 1, 2);
            };
            document.append(document.prepend(rightParenthesis, _function_14), _function_15);
          }
          final Procedure1<IHiddenRegionFormatter> _function_16 = (IHiddenRegionFormatter it) -> {
            it.indent();
          };
          document.<ISemanticRegion, ISemanticRegion>interior(rightParenthesis, endKeyword, _function_16);
        }
      }
    }
    final ISemanticRegion prototypesKeyword = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getPrototypesKeyword_3_0());
    final ISemanticRegion featuresKeyword = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getFeaturesKeyword_4_0());
    final ISemanticRegion inverseKeyword = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getInverseOfKeywordsAccess().getInverseKeyword_0());
    final ISemanticRegion inverseAssignment = this.textRegionExtensions.regionFor(featureGroupType).assignment(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getInverseAssignment_5_1());
    final ISemanticRegion propertiesKeyword = this.textRegionExtensions.regionFor(featureGroupType).keyword(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getPropertiesKeyword_6_0());
    final ISemanticRegion annexRegion = IterableExtensions.<ISemanticRegion>head(this.textRegionExtensions.semanticRegions(IterableExtensions.<AnnexSubclause>head(featureGroupType.getOwnedAnnexSubclauses())));
    if ((prototypesKeyword != null)) {
      final Procedure1<IHiddenRegionFormatter> _function_17 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      document.append(prototypesKeyword, _function_17);
      ISemanticRegion _elvis = null;
      ISemanticRegion _elvis_1 = null;
      ISemanticRegion _elvis_2 = null;
      ISemanticRegion _elvis_3 = null;
      if (featuresKeyword != null) {
        _elvis_3 = featuresKeyword;
      } else {
        _elvis_3 = inverseKeyword;
      }
      if (_elvis_3 != null) {
        _elvis_2 = _elvis_3;
      } else {
        _elvis_2 = propertiesKeyword;
      }
      if (_elvis_2 != null) {
        _elvis_1 = _elvis_2;
      } else {
        _elvis_1 = annexRegion;
      }
      if (_elvis_1 != null) {
        _elvis = _elvis_1;
      } else {
        _elvis = endKeyword;
      }
      final ISemanticRegion endMarker = _elvis;
      final Procedure1<IHiddenRegionFormatter> _function_18 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(prototypesKeyword, endMarker, _function_18);
    }
    if ((featuresKeyword != null)) {
      final Procedure1<IHiddenRegionFormatter> _function_19 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      document.append(featuresKeyword, _function_19);
      ISemanticRegion _elvis_4 = null;
      ISemanticRegion _elvis_5 = null;
      ISemanticRegion _elvis_6 = null;
      if (inverseKeyword != null) {
        _elvis_6 = inverseKeyword;
      } else {
        _elvis_6 = propertiesKeyword;
      }
      if (_elvis_6 != null) {
        _elvis_5 = _elvis_6;
      } else {
        _elvis_5 = annexRegion;
      }
      if (_elvis_5 != null) {
        _elvis_4 = _elvis_5;
      } else {
        _elvis_4 = endKeyword;
      }
      final ISemanticRegion endMarker_1 = _elvis_4;
      final Procedure1<IHiddenRegionFormatter> _function_20 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(featuresKeyword, endMarker_1, _function_20);
    }
    if ((propertiesKeyword != null)) {
      final Procedure1<IHiddenRegionFormatter> _function_21 = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      document.append(propertiesKeyword, _function_21);
      ISemanticRegion _elvis_7 = null;
      if (annexRegion != null) {
        _elvis_7 = annexRegion;
      } else {
        _elvis_7 = endKeyword;
      }
      final ISemanticRegion endMarker_2 = _elvis_7;
      final Procedure1<IHiddenRegionFormatter> _function_22 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(propertiesKeyword, endMarker_2, _function_22);
    }
    final Consumer<ISemanticRegion> _function_23 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_24 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.append(it, _function_24);
    };
    this.textRegionExtensions.regionFor(featureGroupType).keywords(this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getNoPrototypesNoneKeyword_3_1_0_0_0(), 
      this._aadl2GrammarAccess.getFeatureGroupTypeAccess().getNoPropertiesNoneKeyword_6_1_1_0_0()).forEach(_function_23);
    final List<ISemanticRegion> semicolons = this.textRegionExtensions.regionFor(featureGroupType).keywords(";");
    int _size = semicolons.size();
    boolean _greaterThan = (_size > 1);
    if (_greaterThan) {
      int _size_1 = semicolons.size();
      int _minus = (_size_1 - 1);
      final Consumer<ISemanticRegion> _function_24 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_25 = (IHiddenRegionFormatter it_1) -> {
          it_1.setNewLines(1, 1, 2);
        };
        document.append(it, _function_25);
      };
      IterableExtensions.<ISemanticRegion>take(semicolons, _minus).forEach(_function_24);
    }
    EList<Prototype> _ownedPrototypes = featureGroupType.getOwnedPrototypes();
    EList<Feature> _ownedFeatures = featureGroupType.getOwnedFeatures();
    Iterable<StructuralFeature> _plus = Iterables.<StructuralFeature>concat(_ownedPrototypes, _ownedFeatures);
    EList<AnnexSubclause> _ownedAnnexSubclauses = featureGroupType.getOwnedAnnexSubclauses();
    final Consumer<NamedElement> _function_25 = (NamedElement it) -> {
      this.format(it, document);
    };
    Iterables.<NamedElement>concat(_plus, _ownedAnnexSubclauses).forEach(_function_25);
    final Procedure1<IHiddenRegionFormatter> _function_26 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(inverseKeyword, _function_26);
    final Procedure1<IHiddenRegionFormatter> _function_27 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_28 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(document.prepend(inverseAssignment, _function_27), _function_28);
    final Consumer<PropertyAssociation> _function_29 = (PropertyAssociation it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_30 = (IHiddenRegionFormatter it_1) -> {
        it_1.setNewLines(1, 1, 2);
      };
      document.<PropertyAssociation>append(it, _function_30);
      this.format(it, document);
    };
    featureGroupType.getOwnedPropertyAssociations().forEach(_function_29);
    final Procedure1<IHiddenRegionFormatter> _function_30 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(endKeyword, _function_30);
    final Procedure1<IHiddenRegionFormatter> _function_31 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(IterableExtensions.<ISemanticRegion>last(semicolons), _function_31);
  }

  protected void _format(final GroupExtension groupExtension, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(groupExtension).keyword(this._aadl2GrammarAccess.getGroupExtensionAccess().getExtendsKeyword_0()), _function);
  }

  private ISemanticRegion formatComponentImplementationCommon(final ComponentImplementation componentImplementation, @Extension final IFormattableDocument document, final ISemanticRegion nameAssignment) {
    ISemanticRegion _xblockexpression = null;
    {
      int _switchResult = (int) 0;
      IEObjectRegion _regionForEObject = this.textRegionExtensions.regionForEObject(componentImplementation);
      ISemanticRegion _nextSemanticRegion = null;
      if (_regionForEObject!=null) {
        _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
      }
      EObject _semanticElement = null;
      if (_nextSemanticRegion!=null) {
        _semanticElement=_nextSemanticRegion.getSemanticElement();
      }
      boolean _matched = false;
      if (_semanticElement instanceof Classifier) {
        _matched=true;
      }
      if (!_matched) {
        if (_semanticElement instanceof AnnexLibrary) {
          _matched=true;
        }
      }
      if (!_matched) {
        if (_semanticElement instanceof PackageSection) {
          _matched=true;
        }
      }
      if (_matched) {
        _switchResult = 2;
      }
      if (!_matched) {
        _switchResult = 1;
      }
      final int newLineCount = _switchResult;
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(newLineCount, newLineCount, 2);
      };
      this.<ComponentImplementation>conditionalAppend(componentImplementation, document, _function);
      final ISemanticRegion endKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("end");
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.<Realization>append(document.<Realization>prepend(componentImplementation.getOwnedRealization(), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      document.prepend(nameAssignment, _function_3);
      if (((componentImplementation.getOwnedExtension() == null) && componentImplementation.getOwnedPrototypeBindings().isEmpty())) {
        final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(nameAssignment, _function_4);
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(nameAssignment, endKeyword, _function_5);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        document.append(nameAssignment, _function_6);
        this.format(componentImplementation.getOwnedExtension(), document);
        boolean _isEmpty = componentImplementation.getOwnedPrototypeBindings().isEmpty();
        if (_isEmpty) {
          final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1, 1, 2);
          };
          document.<ImplementationExtension>append(componentImplementation.getOwnedExtension(), _function_7);
          final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
            it.indent();
          };
          document.<ISemanticRegion, ISemanticRegion>interior(IterableExtensions.<ISemanticRegion>last(this.textRegionExtensions.allSemanticRegions(componentImplementation.getOwnedExtension())), endKeyword, _function_8);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
            it.oneSpace();
          };
          document.<ImplementationExtension>append(componentImplementation.getOwnedExtension(), _function_9);
          final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(componentImplementation).keyword("(");
          final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(componentImplementation).keyword(")");
          final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
            it.indent();
          };
          document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_10);
          final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
            it.setNewLines(0, 0, 1);
            it.autowrap();
          };
          document.append(leftParenthesis, _function_11);
          final Consumer<ISemanticRegion> _function_12 = (ISemanticRegion it) -> {
            final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it_1) -> {
              it_1.noSpace();
            };
            final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it_1) -> {
              it_1.oneSpace();
              it_1.setNewLines(0, 0, 1);
              it_1.autowrap();
            };
            document.append(document.prepend(it, _function_13), _function_14);
          };
          this.textRegionExtensions.regionFor(componentImplementation).keywords(",").forEach(_function_12);
          final Consumer<PrototypeBinding> _function_13 = (PrototypeBinding it) -> {
            this.format(it, document);
          };
          componentImplementation.getOwnedPrototypeBindings().forEach(_function_13);
          if ((rightParenthesis != null)) {
            boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
            if (_isMultiline) {
              final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1);
              };
              final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1, 1, 2);
              };
              document.append(document.prepend(rightParenthesis, _function_14), _function_15);
            } else {
              final Procedure1<IHiddenRegionFormatter> _function_16 = (IHiddenRegionFormatter it) -> {
                it.noSpace();
              };
              final Procedure1<IHiddenRegionFormatter> _function_17 = (IHiddenRegionFormatter it) -> {
                it.setNewLines(1, 1, 2);
              };
              document.append(document.prepend(rightParenthesis, _function_16), _function_17);
            }
            final Procedure1<IHiddenRegionFormatter> _function_18 = (IHiddenRegionFormatter it) -> {
              it.indent();
            };
            document.<ISemanticRegion, ISemanticRegion>interior(rightParenthesis, endKeyword, _function_18);
          }
        }
      }
      final ISemanticRegion prototypesKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("prototypes");
      final ISemanticRegion subcomponentsKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("subcomponents");
      final ISemanticRegion internalKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword(this._aadl2GrammarAccess.getInternalFeaturesKeywordsAccess().getInternalKeyword_0());
      final ISemanticRegion internalFeaturesKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword(this._aadl2GrammarAccess.getInternalFeaturesKeywordsAccess().getFeaturesKeyword_1());
      final ISemanticRegion processorKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword(this._aadl2GrammarAccess.getProcessorFeaturesKeywordsAccess().getProcessorKeyword_0());
      final ISemanticRegion processorFeaturesKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword(this._aadl2GrammarAccess.getProcessorFeaturesKeywordsAccess().getFeaturesKeyword_1());
      final ISemanticRegion callsKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("calls");
      final ISemanticRegion connectionsKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("connections");
      final ISemanticRegion flowsKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("flows");
      final ISemanticRegion modesKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("modes");
      final ISemanticRegion propertiesKeyword = this.textRegionExtensions.regionFor(componentImplementation).keyword("properties");
      final ISemanticRegion annexRegion = IterableExtensions.<ISemanticRegion>head(this.textRegionExtensions.semanticRegions(IterableExtensions.<AnnexSubclause>head(componentImplementation.getOwnedAnnexSubclauses())));
      if ((prototypesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_19 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(prototypesKeyword, _function_19);
        ISemanticRegion _elvis = null;
        ISemanticRegion _elvis_1 = null;
        ISemanticRegion _elvis_2 = null;
        ISemanticRegion _elvis_3 = null;
        ISemanticRegion _elvis_4 = null;
        ISemanticRegion _elvis_5 = null;
        ISemanticRegion _elvis_6 = null;
        ISemanticRegion _elvis_7 = null;
        ISemanticRegion _elvis_8 = null;
        if (subcomponentsKeyword != null) {
          _elvis_8 = subcomponentsKeyword;
        } else {
          _elvis_8 = internalKeyword;
        }
        if (_elvis_8 != null) {
          _elvis_7 = _elvis_8;
        } else {
          _elvis_7 = processorKeyword;
        }
        if (_elvis_7 != null) {
          _elvis_6 = _elvis_7;
        } else {
          _elvis_6 = callsKeyword;
        }
        if (_elvis_6 != null) {
          _elvis_5 = _elvis_6;
        } else {
          _elvis_5 = connectionsKeyword;
        }
        if (_elvis_5 != null) {
          _elvis_4 = _elvis_5;
        } else {
          _elvis_4 = flowsKeyword;
        }
        if (_elvis_4 != null) {
          _elvis_3 = _elvis_4;
        } else {
          _elvis_3 = modesKeyword;
        }
        if (_elvis_3 != null) {
          _elvis_2 = _elvis_3;
        } else {
          _elvis_2 = propertiesKeyword;
        }
        if (_elvis_2 != null) {
          _elvis_1 = _elvis_2;
        } else {
          _elvis_1 = annexRegion;
        }
        if (_elvis_1 != null) {
          _elvis = _elvis_1;
        } else {
          _elvis = endKeyword;
        }
        final ISemanticRegion endMarker = _elvis;
        final Procedure1<IHiddenRegionFormatter> _function_20 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(prototypesKeyword, endMarker, _function_20);
      }
      if ((subcomponentsKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_21 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(subcomponentsKeyword, _function_21);
        ISemanticRegion _elvis_9 = null;
        ISemanticRegion _elvis_10 = null;
        ISemanticRegion _elvis_11 = null;
        ISemanticRegion _elvis_12 = null;
        ISemanticRegion _elvis_13 = null;
        ISemanticRegion _elvis_14 = null;
        ISemanticRegion _elvis_15 = null;
        ISemanticRegion _elvis_16 = null;
        if (internalKeyword != null) {
          _elvis_16 = internalKeyword;
        } else {
          _elvis_16 = processorKeyword;
        }
        if (_elvis_16 != null) {
          _elvis_15 = _elvis_16;
        } else {
          _elvis_15 = callsKeyword;
        }
        if (_elvis_15 != null) {
          _elvis_14 = _elvis_15;
        } else {
          _elvis_14 = connectionsKeyword;
        }
        if (_elvis_14 != null) {
          _elvis_13 = _elvis_14;
        } else {
          _elvis_13 = flowsKeyword;
        }
        if (_elvis_13 != null) {
          _elvis_12 = _elvis_13;
        } else {
          _elvis_12 = modesKeyword;
        }
        if (_elvis_12 != null) {
          _elvis_11 = _elvis_12;
        } else {
          _elvis_11 = propertiesKeyword;
        }
        if (_elvis_11 != null) {
          _elvis_10 = _elvis_11;
        } else {
          _elvis_10 = annexRegion;
        }
        if (_elvis_10 != null) {
          _elvis_9 = _elvis_10;
        } else {
          _elvis_9 = endKeyword;
        }
        final ISemanticRegion endMarker_1 = _elvis_9;
        final Procedure1<IHiddenRegionFormatter> _function_22 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(subcomponentsKeyword, endMarker_1, _function_22);
      }
      if ((internalFeaturesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_23 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(internalFeaturesKeyword, _function_23);
        ISemanticRegion _elvis_17 = null;
        ISemanticRegion _elvis_18 = null;
        ISemanticRegion _elvis_19 = null;
        ISemanticRegion _elvis_20 = null;
        ISemanticRegion _elvis_21 = null;
        ISemanticRegion _elvis_22 = null;
        ISemanticRegion _elvis_23 = null;
        if (processorKeyword != null) {
          _elvis_23 = processorKeyword;
        } else {
          _elvis_23 = callsKeyword;
        }
        if (_elvis_23 != null) {
          _elvis_22 = _elvis_23;
        } else {
          _elvis_22 = connectionsKeyword;
        }
        if (_elvis_22 != null) {
          _elvis_21 = _elvis_22;
        } else {
          _elvis_21 = flowsKeyword;
        }
        if (_elvis_21 != null) {
          _elvis_20 = _elvis_21;
        } else {
          _elvis_20 = modesKeyword;
        }
        if (_elvis_20 != null) {
          _elvis_19 = _elvis_20;
        } else {
          _elvis_19 = propertiesKeyword;
        }
        if (_elvis_19 != null) {
          _elvis_18 = _elvis_19;
        } else {
          _elvis_18 = annexRegion;
        }
        if (_elvis_18 != null) {
          _elvis_17 = _elvis_18;
        } else {
          _elvis_17 = endKeyword;
        }
        final ISemanticRegion endMarker_2 = _elvis_17;
        final Procedure1<IHiddenRegionFormatter> _function_24 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(internalFeaturesKeyword, endMarker_2, _function_24);
      }
      if ((processorFeaturesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_25 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(processorFeaturesKeyword, _function_25);
        ISemanticRegion _elvis_24 = null;
        ISemanticRegion _elvis_25 = null;
        ISemanticRegion _elvis_26 = null;
        ISemanticRegion _elvis_27 = null;
        ISemanticRegion _elvis_28 = null;
        ISemanticRegion _elvis_29 = null;
        if (callsKeyword != null) {
          _elvis_29 = callsKeyword;
        } else {
          _elvis_29 = connectionsKeyword;
        }
        if (_elvis_29 != null) {
          _elvis_28 = _elvis_29;
        } else {
          _elvis_28 = flowsKeyword;
        }
        if (_elvis_28 != null) {
          _elvis_27 = _elvis_28;
        } else {
          _elvis_27 = modesKeyword;
        }
        if (_elvis_27 != null) {
          _elvis_26 = _elvis_27;
        } else {
          _elvis_26 = propertiesKeyword;
        }
        if (_elvis_26 != null) {
          _elvis_25 = _elvis_26;
        } else {
          _elvis_25 = annexRegion;
        }
        if (_elvis_25 != null) {
          _elvis_24 = _elvis_25;
        } else {
          _elvis_24 = endKeyword;
        }
        final ISemanticRegion endMarker_3 = _elvis_24;
        final Procedure1<IHiddenRegionFormatter> _function_26 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(processorFeaturesKeyword, endMarker_3, _function_26);
      }
      if ((callsKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_27 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(callsKeyword, _function_27);
        ISemanticRegion _elvis_30 = null;
        ISemanticRegion _elvis_31 = null;
        ISemanticRegion _elvis_32 = null;
        ISemanticRegion _elvis_33 = null;
        ISemanticRegion _elvis_34 = null;
        if (connectionsKeyword != null) {
          _elvis_34 = connectionsKeyword;
        } else {
          _elvis_34 = flowsKeyword;
        }
        if (_elvis_34 != null) {
          _elvis_33 = _elvis_34;
        } else {
          _elvis_33 = modesKeyword;
        }
        if (_elvis_33 != null) {
          _elvis_32 = _elvis_33;
        } else {
          _elvis_32 = propertiesKeyword;
        }
        if (_elvis_32 != null) {
          _elvis_31 = _elvis_32;
        } else {
          _elvis_31 = annexRegion;
        }
        if (_elvis_31 != null) {
          _elvis_30 = _elvis_31;
        } else {
          _elvis_30 = endKeyword;
        }
        final ISemanticRegion endMarker_4 = _elvis_30;
        final Procedure1<IHiddenRegionFormatter> _function_28 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(callsKeyword, endMarker_4, _function_28);
      }
      if ((connectionsKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_29 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(connectionsKeyword, _function_29);
        ISemanticRegion _elvis_35 = null;
        ISemanticRegion _elvis_36 = null;
        ISemanticRegion _elvis_37 = null;
        ISemanticRegion _elvis_38 = null;
        if (flowsKeyword != null) {
          _elvis_38 = flowsKeyword;
        } else {
          _elvis_38 = modesKeyword;
        }
        if (_elvis_38 != null) {
          _elvis_37 = _elvis_38;
        } else {
          _elvis_37 = propertiesKeyword;
        }
        if (_elvis_37 != null) {
          _elvis_36 = _elvis_37;
        } else {
          _elvis_36 = annexRegion;
        }
        if (_elvis_36 != null) {
          _elvis_35 = _elvis_36;
        } else {
          _elvis_35 = endKeyword;
        }
        final ISemanticRegion endMarker_5 = _elvis_35;
        final Procedure1<IHiddenRegionFormatter> _function_30 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(connectionsKeyword, endMarker_5, _function_30);
      }
      if ((flowsKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_31 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(flowsKeyword, _function_31);
        ISemanticRegion _elvis_39 = null;
        ISemanticRegion _elvis_40 = null;
        ISemanticRegion _elvis_41 = null;
        if (modesKeyword != null) {
          _elvis_41 = modesKeyword;
        } else {
          _elvis_41 = propertiesKeyword;
        }
        if (_elvis_41 != null) {
          _elvis_40 = _elvis_41;
        } else {
          _elvis_40 = annexRegion;
        }
        if (_elvis_40 != null) {
          _elvis_39 = _elvis_40;
        } else {
          _elvis_39 = endKeyword;
        }
        final ISemanticRegion endMarker_6 = _elvis_39;
        final Procedure1<IHiddenRegionFormatter> _function_32 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(flowsKeyword, endMarker_6, _function_32);
      }
      if ((modesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_33 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(modesKeyword, _function_33);
        ISemanticRegion _elvis_42 = null;
        ISemanticRegion _elvis_43 = null;
        if (propertiesKeyword != null) {
          _elvis_43 = propertiesKeyword;
        } else {
          _elvis_43 = annexRegion;
        }
        if (_elvis_43 != null) {
          _elvis_42 = _elvis_43;
        } else {
          _elvis_42 = endKeyword;
        }
        final ISemanticRegion endMarker_7 = _elvis_42;
        final Procedure1<IHiddenRegionFormatter> _function_34 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(modesKeyword, endMarker_7, _function_34);
      }
      if ((propertiesKeyword != null)) {
        final Procedure1<IHiddenRegionFormatter> _function_35 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1, 1, 2);
        };
        document.append(propertiesKeyword, _function_35);
        ISemanticRegion _elvis_44 = null;
        if (annexRegion != null) {
          _elvis_44 = annexRegion;
        } else {
          _elvis_44 = endKeyword;
        }
        final ISemanticRegion endMarker_8 = _elvis_44;
        final Procedure1<IHiddenRegionFormatter> _function_36 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(propertiesKeyword, endMarker_8, _function_36);
      }
      final Procedure1<IHiddenRegionFormatter> _function_37 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(internalKeyword, _function_37);
      final Procedure1<IHiddenRegionFormatter> _function_38 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(processorKeyword, _function_38);
      final Consumer<ISemanticRegion> _function_39 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_40 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        document.append(it, _function_40);
      };
      this.textRegionExtensions.regionFor(componentImplementation).keywords("none").forEach(_function_39);
      final List<ISemanticRegion> semicolons = this.textRegionExtensions.regionFor(componentImplementation).keywords(";");
      int _size = semicolons.size();
      boolean _greaterThan = (_size > 1);
      if (_greaterThan) {
        int _size_1 = semicolons.size();
        int _minus = (_size_1 - 1);
        final Consumer<ISemanticRegion> _function_40 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_41 = (IHiddenRegionFormatter it_1) -> {
            it_1.setNewLines(1, 1, 2);
          };
          document.append(it, _function_41);
        };
        IterableExtensions.<ISemanticRegion>take(semicolons, _minus).forEach(_function_40);
      }
      EList<Prototype> _ownedPrototypes = componentImplementation.getOwnedPrototypes();
      EList<Subcomponent> _ownedSubcomponents = componentImplementation.getOwnedSubcomponents();
      Iterable<StructuralFeature> _plus = Iterables.<StructuralFeature>concat(_ownedPrototypes, _ownedSubcomponents);
      EList<InternalFeature> _ownedInternalFeatures = componentImplementation.getOwnedInternalFeatures();
      Iterable<StructuralFeature> _plus_1 = Iterables.<StructuralFeature>concat(_plus, _ownedInternalFeatures);
      EList<ProcessorFeature> _ownedProcessorFeatures = componentImplementation.getOwnedProcessorFeatures();
      Iterable<StructuralFeature> _plus_2 = Iterables.<StructuralFeature>concat(_plus_1, _ownedProcessorFeatures);
      EList<Connection> _ownedConnections = componentImplementation.getOwnedConnections();
      Iterable<StructuralFeature> _plus_3 = Iterables.<StructuralFeature>concat(_plus_2, _ownedConnections);
      EList<FlowImplementation> _ownedFlowImplementations = componentImplementation.getOwnedFlowImplementations();
      Iterable<ClassifierFeature> _plus_4 = Iterables.<ClassifierFeature>concat(_plus_3, _ownedFlowImplementations);
      EList<EndToEndFlow> _ownedEndToEndFlows = componentImplementation.getOwnedEndToEndFlows();
      Iterable<ClassifierFeature> _plus_5 = Iterables.<ClassifierFeature>concat(_plus_4, _ownedEndToEndFlows);
      EList<Mode> _ownedModes = componentImplementation.getOwnedModes();
      Iterable<ClassifierFeature> _plus_6 = Iterables.<ClassifierFeature>concat(_plus_5, _ownedModes);
      EList<ModeTransition> _ownedModeTransitions = componentImplementation.getOwnedModeTransitions();
      Iterable<ClassifierFeature> _plus_7 = Iterables.<ClassifierFeature>concat(_plus_6, _ownedModeTransitions);
      EList<AnnexSubclause> _ownedAnnexSubclauses = componentImplementation.getOwnedAnnexSubclauses();
      final Consumer<NamedElement> _function_41 = (NamedElement it) -> {
        this.format(it, document);
      };
      Iterables.<NamedElement>concat(_plus_7, _ownedAnnexSubclauses).forEach(_function_41);
      final Consumer<PropertyAssociation> _function_42 = (PropertyAssociation it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_43 = (IHiddenRegionFormatter it_1) -> {
          it_1.setNewLines(1, 1, 2);
        };
        document.<PropertyAssociation>append(it, _function_43);
        this.format(it, document);
      };
      componentImplementation.getOwnedPropertyAssociations().forEach(_function_42);
      final Procedure1<IHiddenRegionFormatter> _function_43 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(endKeyword, _function_43);
      final Procedure1<IHiddenRegionFormatter> _function_44 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      _xblockexpression = document.prepend(IterableExtensions.<ISemanticRegion>last(semicolons), _function_44);
    }
    return _xblockexpression;
  }

  private ISemanticRegion formatBehavioredImplementationCommon(final BehavioredImplementation behavioredImplementation, @Extension final IFormattableDocument document, final ISemanticRegion nameAssignment) {
    ISemanticRegion _xblockexpression = null;
    {
      final Consumer<SubprogramCallSequence> _function = (SubprogramCallSequence it) -> {
        this.format(it, document);
      };
      behavioredImplementation.getOwnedSubprogramCallSequences().forEach(_function);
      _xblockexpression = this.formatComponentImplementationCommon(behavioredImplementation, document, nameAssignment);
    }
    return _xblockexpression;
  }

  protected void _format(final AbstractImplementation abstractImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(abstractImplementation).keyword(this._aadl2GrammarAccess.getAbstractImplementationKeywordsAccess().getAbstractKeyword_0()), _function);
    this.formatBehavioredImplementationCommon(abstractImplementation, document, 
      this.textRegionExtensions.regionFor(abstractImplementation).assignment(this._aadl2GrammarAccess.getAbstractImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final ThreadImplementation threadImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(threadImplementation).keyword(this._aadl2GrammarAccess.getThreadImplementationKeywordsAccess().getThreadKeyword_0()), _function);
    this.formatBehavioredImplementationCommon(threadImplementation, document, 
      this.textRegionExtensions.regionFor(threadImplementation).assignment(this._aadl2GrammarAccess.getThreadImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final SubprogramImplementation subprogramImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramImplementation).keyword(this._aadl2GrammarAccess.getSubprogramImplementationKeywordsAccess().getSubprogramKeyword_0()), _function);
    this.formatBehavioredImplementationCommon(subprogramImplementation, document, 
      this.textRegionExtensions.regionFor(subprogramImplementation).assignment(this._aadl2GrammarAccess.getSubprogramImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final SystemImplementation systemImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(systemImplementation).keyword(this._aadl2GrammarAccess.getSystemImplementationKeywordsAccess().getSystemKeyword_0()), _function);
    this.formatComponentImplementationCommon(systemImplementation, document, 
      this.textRegionExtensions.regionFor(systemImplementation).assignment(this._aadl2GrammarAccess.getSystemImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final ProcessImplementation processImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(processImplementation).keyword(this._aadl2GrammarAccess.getProcessImplementationKeywordsAccess().getProcessKeyword_0()), _function);
    this.formatComponentImplementationCommon(processImplementation, document, 
      this.textRegionExtensions.regionFor(processImplementation).assignment(this._aadl2GrammarAccess.getProcessImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final ThreadGroupImplementation threadGroupImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(threadGroupImplementation).keyword(this._aadl2GrammarAccess.getThreadGroupImplementationKeywordsAccess().getGroupKeyword_1()), _function);
    this.formatComponentImplementationCommon(threadGroupImplementation, document, 
      this.textRegionExtensions.regionFor(threadGroupImplementation).assignment(this._aadl2GrammarAccess.getThreadGroupImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final SubprogramGroupImplementation subprogramGroupImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramGroupImplementation).keyword(this._aadl2GrammarAccess.getSubprogramGroupImplementationKeywordsAccess().getGroupKeyword_1()), _function);
    this.formatComponentImplementationCommon(subprogramGroupImplementation, document, 
      this.textRegionExtensions.regionFor(subprogramGroupImplementation).assignment(this._aadl2GrammarAccess.getSubprogramGroupImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final ProcessorImplementation processorImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(processorImplementation).keyword(this._aadl2GrammarAccess.getProcessorImplementationKeywordsAccess().getProcessorKeyword_0()), _function);
    this.formatComponentImplementationCommon(processorImplementation, document, 
      this.textRegionExtensions.regionFor(processorImplementation).assignment(this._aadl2GrammarAccess.getProcessorImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final VirtualProcessorImplementation virtualProcessorImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(virtualProcessorImplementation).keyword(this._aadl2GrammarAccess.getVirtualProcessorImplementationKeywordsAccess().getProcessorKeyword_1()), _function);
    this.formatComponentImplementationCommon(virtualProcessorImplementation, document, 
      this.textRegionExtensions.regionFor(virtualProcessorImplementation).assignment(this._aadl2GrammarAccess.getVirtualProcessorImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final DeviceImplementation deviceImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(deviceImplementation).keyword(this._aadl2GrammarAccess.getDeviceImplementationKeywordsAccess().getDeviceKeyword_0()), _function);
    this.formatComponentImplementationCommon(deviceImplementation, document, 
      this.textRegionExtensions.regionFor(deviceImplementation).assignment(this._aadl2GrammarAccess.getDeviceImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final MemoryImplementation memoryImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(memoryImplementation).keyword(this._aadl2GrammarAccess.getMemoryImplementationKeywordsAccess().getMemoryKeyword_0()), _function);
    this.formatComponentImplementationCommon(memoryImplementation, document, 
      this.textRegionExtensions.regionFor(memoryImplementation).assignment(this._aadl2GrammarAccess.getMemoryImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final BusImplementation busImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(busImplementation).keyword(this._aadl2GrammarAccess.getBusImplementationKeywordsAccess().getBusKeyword_0()), _function);
    this.formatComponentImplementationCommon(busImplementation, document, 
      this.textRegionExtensions.regionFor(busImplementation).assignment(this._aadl2GrammarAccess.getBusImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final VirtualBusImplementation virtualBusImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(virtualBusImplementation).keyword(this._aadl2GrammarAccess.getVirtualBusImplementationKeywordsAccess().getBusKeyword_1()), _function);
    this.formatComponentImplementationCommon(virtualBusImplementation, document, 
      this.textRegionExtensions.regionFor(virtualBusImplementation).assignment(this._aadl2GrammarAccess.getVirtualBusImplementationAccess().getNameAssignment_3()));
  }

  protected void _format(final DataImplementation dataImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(dataImplementation).keyword(this._aadl2GrammarAccess.getDataImplementationKeywordsAccess().getDataKeyword_0()), _function);
    this.formatComponentImplementationCommon(dataImplementation, document, 
      this.textRegionExtensions.regionFor(dataImplementation).assignment(this._aadl2GrammarAccess.getDataImplementationAccess().getNameAssignment_4()));
  }

  protected void _format(final ImplementationExtension implementationExtension, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(implementationExtension).keyword(this._aadl2GrammarAccess.getImplementationExtensionAccess().getExtendsKeyword_0()), _function);
  }

  protected void _format(final EventSource eventSource, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<EventSource>conditionalAppend(eventSource, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventSource).keyword(this._aadl2GrammarAccess.getEventSourceAccess().getColonKeyword_1()), _function_1), _function_2);
    this.formatCurlyProperties(eventSource, document, 
      this.textRegionExtensions.regionFor(eventSource).keyword(this._aadl2GrammarAccess.getEventSourceAccess().getLeftCurlyBracketKeyword_3_0()), 
      this.textRegionExtensions.regionFor(eventSource).keyword(this._aadl2GrammarAccess.getEventSourceAccess().getRightCurlyBracketKeyword_3_2()));
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventSource).keyword(this._aadl2GrammarAccess.getEventSourceAccess().getSemicolonKeyword_4()), _function_3);
  }

  protected void _format(final EventDataSource eventDataSource, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<EventDataSource>conditionalAppend(eventDataSource, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(eventDataSource).keyword(this._aadl2GrammarAccess.getEventDataSourceAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(eventDataSource).keyword(this._aadl2GrammarAccess.getEventDataKeywordsAccess().getEventKeyword_0()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventDataSource).assignment(this._aadl2GrammarAccess.getEventDataSourceAccess().getDataClassifierAssignment_3()), _function_4);
    this.formatCurlyProperties(eventDataSource, document, 
      this.textRegionExtensions.regionFor(eventDataSource).keyword(this._aadl2GrammarAccess.getEventDataSourceAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(eventDataSource).keyword(this._aadl2GrammarAccess.getEventDataSourceAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(eventDataSource).keyword(this._aadl2GrammarAccess.getEventDataSourceAccess().getSemicolonKeyword_5()), _function_5);
  }

  protected void _format(final PortProxy portProxy, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<PortProxy>conditionalAppend(portProxy, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(portProxy).keyword(this._aadl2GrammarAccess.getPortProxyAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(portProxy).assignment(this._aadl2GrammarAccess.getPortProxyAccess().getDataClassifierAssignment_3()), _function_3);
    this.formatCurlyProperties(portProxy, document, 
      this.textRegionExtensions.regionFor(portProxy).keyword(this._aadl2GrammarAccess.getPortProxyAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(portProxy).keyword(this._aadl2GrammarAccess.getPortProxyAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(portProxy).keyword(this._aadl2GrammarAccess.getPortProxyAccess().getSemicolonKeyword_5()), _function_4);
  }

  protected void _format(final SubprogramProxy subprogramProxy, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<SubprogramProxy>conditionalAppend(subprogramProxy, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramProxy).keyword(this._aadl2GrammarAccess.getSubprogramProxyAccess().getColonKeyword_1()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramProxy).assignment(this._aadl2GrammarAccess.getSubprogramProxyAccess().getSubprogramClassifierAssignment_3()), _function_3);
    this.formatCurlyProperties(subprogramProxy, document, 
      this.textRegionExtensions.regionFor(subprogramProxy).keyword(this._aadl2GrammarAccess.getSubprogramProxyAccess().getLeftCurlyBracketKeyword_4_0()), 
      this.textRegionExtensions.regionFor(subprogramProxy).keyword(this._aadl2GrammarAccess.getSubprogramProxyAccess().getRightCurlyBracketKeyword_4_2()));
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramProxy).keyword(this._aadl2GrammarAccess.getSubprogramProxyAccess().getSemicolonKeyword_5()), _function_4);
  }

  protected void _format(final SubprogramCallSequence subprogramCallSequence, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<SubprogramCallSequence>conditionalAppend(subprogramCallSequence, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getColonKeyword_1()), _function_1), _function_2);
    final ISemanticRegion leftCurly = this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getLeftCurlyBracketKeyword_2());
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    document.append(leftCurly, _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.indent();
    };
    document.<ISemanticRegion, ISemanticRegion>interior(leftCurly, this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getRightCurlyBracketKeyword_4()), _function_4);
    final Consumer<SubprogramCall> _function_5 = (SubprogramCall it) -> {
      this.format(it, document);
    };
    subprogramCallSequence.getOwnedSubprogramCalls().forEach(_function_5);
    this.formatCurlyProperties(subprogramCallSequence, document, 
      this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getRightCurlyBracketKeyword_5_2()));
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getLeftParenthesisKeyword_6_1());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getRightParenthesisKeyword_6_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getInModesKeywordsAccess().getInKeyword_0()), _function_6);
      final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_7);
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_8), _function_9);
      final Consumer<ISemanticRegion> _function_10 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_11), _function_12);
      };
      this.textRegionExtensions.regionFor(subprogramCallSequence).keywords(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getCommaKeyword_6_2_1_0()).forEach(_function_10);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_11);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_12);
      }
    }
    final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramCallSequence).keyword(this._aadl2GrammarAccess.getSubprogramCallSequenceAccess().getSemicolonKeyword_7()), _function_13);
  }

  protected void _format(final SubprogramCall subprogramCall, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<SubprogramCall>conditionalAppend(subprogramCall, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getColonKeyword_2()), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getSubprogramKeyword_3()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getFullStopKeyword_4_0_1()), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getFullStopKeyword_4_2_1()), _function_5);
    this.formatCurlyProperties(subprogramCall, document, 
      this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getLeftCurlyBracketKeyword_5_0()), 
      this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getRightCurlyBracketKeyword_5_2()));
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(subprogramCall).keyword(this._aadl2GrammarAccess.getSubprogramCallAccess().getSemicolonKeyword_6()), _function_6);
  }

  private ISemanticRegion formatSubcomponentCommon(final Subcomponent subcomponent, @Extension final IFormattableDocument document, final ISemanticRegion subcomponentTypeAssignment) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<Subcomponent>conditionalAppend(subcomponent, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(subcomponent).keyword(":"), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(subcomponent).keyword("to"), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(subcomponentTypeAssignment, _function_4);
      final Consumer<Pair<ISemanticRegion, ISemanticRegion>> _function_5 = (Pair<ISemanticRegion, ISemanticRegion> it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
          it_1.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(it.getKey(), it.getValue(), _function_6);
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it.getKey(), _function_7), _function_8);
        boolean _isMultiline = it.getValue().getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
            it_1.setNewLines(1);
          };
          document.prepend(it.getValue(), _function_9);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it_1) -> {
            it_1.noSpace();
          };
          document.prepend(it.getValue(), _function_10);
        }
      };
      this.textRegionExtensions.regionFor(subcomponent).keywordPairs("(", ")").forEach(_function_5);
      final Consumer<ISemanticRegion> _function_6 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_7), _function_8);
      };
      this.textRegionExtensions.regionFor(subcomponent).keywords(",").forEach(_function_6);
      final Consumer<PrototypeBinding> _function_7 = (PrototypeBinding it) -> {
        this.format(it, document);
      };
      subcomponent.getOwnedPrototypeBindings().forEach(_function_7);
      final Consumer<ArrayDimension> _function_8 = (ArrayDimension it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        document.<ArrayDimension>prepend(it, _function_9);
        this.format(it, document);
      };
      subcomponent.getArrayDimensions().forEach(_function_8);
      final Consumer<ComponentImplementationReference> _function_9 = (ComponentImplementationReference it) -> {
        this.format(it, document);
      };
      subcomponent.getImplementationReferences().forEach(_function_9);
      this.formatCurlyProperties(subcomponent, document, this.textRegionExtensions.regionFor(subcomponent).keyword("{"), this.textRegionExtensions.regionFor(subcomponent).keyword("}"));
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(subcomponent).keyword("in"), _function_10);
      final Consumer<ModeBinding> _function_11 = (ModeBinding it) -> {
        this.format(it, document);
      };
      subcomponent.getOwnedModeBindings().forEach(_function_11);
      final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      _xblockexpression = document.prepend(this.textRegionExtensions.regionFor(subcomponent).keyword(";"), _function_12);
    }
    return _xblockexpression;
  }

  protected void _format(final AbstractSubcomponent abstractSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(abstractSubcomponent, document, 
      this.textRegionExtensions.regionFor(abstractSubcomponent).assignment(this._aadl2GrammarAccess.getAbstractSubcomponentAccess().getAbstractSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final SystemSubcomponent systemSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(systemSubcomponent, document, 
      this.textRegionExtensions.regionFor(systemSubcomponent).assignment(this._aadl2GrammarAccess.getSystemSubcomponentAccess().getSystemSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final ProcessSubcomponent processSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(processSubcomponent, document, 
      this.textRegionExtensions.regionFor(processSubcomponent).assignment(this._aadl2GrammarAccess.getProcessSubcomponentAccess().getProcessSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final ThreadGroupSubcomponent threadGroupSubcomponent, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(threadGroupSubcomponent).keyword(this._aadl2GrammarAccess.getThreadGroupKeywordsAccess().getThreadKeyword_0()), _function);
    this.formatSubcomponentCommon(threadGroupSubcomponent, document, 
      this.textRegionExtensions.regionFor(threadGroupSubcomponent).assignment(this._aadl2GrammarAccess.getThreadGroupSubcomponentAccess().getThreadGroupSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final ThreadSubcomponent threadSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(threadSubcomponent, document, 
      this.textRegionExtensions.regionFor(threadSubcomponent).assignment(this._aadl2GrammarAccess.getThreadSubcomponentAccess().getThreadSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final SubprogramSubcomponent subprogramSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(subprogramSubcomponent, document, 
      this.textRegionExtensions.regionFor(subprogramSubcomponent).assignment(this._aadl2GrammarAccess.getSubprogramSubcomponentAccess().getSubprogramSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final SubprogramGroupSubcomponent subprogramGroupSubcomponent, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(subprogramGroupSubcomponent).keyword(this._aadl2GrammarAccess.getSubprogramGroupKeywordsAccess().getSubprogramKeyword_0()), _function);
    this.formatSubcomponentCommon(subprogramGroupSubcomponent, document, 
      this.textRegionExtensions.regionFor(subprogramGroupSubcomponent).assignment(this._aadl2GrammarAccess.getSubprogramGroupSubcomponentAccess().getSubprogramGroupSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final ProcessorSubcomponent processorSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(processorSubcomponent, document, 
      this.textRegionExtensions.regionFor(processorSubcomponent).assignment(this._aadl2GrammarAccess.getProcessorSubcomponentAccess().getProcessorSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final VirtualProcessorSubcomponent virtualProcessorSubcomponent, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(virtualProcessorSubcomponent).keyword(this._aadl2GrammarAccess.getVirtualProcessorKeywordsAccess().getVirtualKeyword_0()), _function);
    this.formatSubcomponentCommon(virtualProcessorSubcomponent, document, 
      this.textRegionExtensions.regionFor(virtualProcessorSubcomponent).assignment(this._aadl2GrammarAccess.getVirtualProcessorSubcomponentAccess().getVirtualProcessorSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final DeviceSubcomponent deviceSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(deviceSubcomponent, document, 
      this.textRegionExtensions.regionFor(deviceSubcomponent).assignment(this._aadl2GrammarAccess.getDeviceSubcomponentAccess().getDeviceSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final MemorySubcomponent memorySubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(memorySubcomponent, document, 
      this.textRegionExtensions.regionFor(memorySubcomponent).assignment(this._aadl2GrammarAccess.getMemorySubcomponentAccess().getMemorySubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final BusSubcomponent busSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(busSubcomponent, document, 
      this.textRegionExtensions.regionFor(busSubcomponent).assignment(this._aadl2GrammarAccess.getBusSubcomponentAccess().getBusSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final VirtualBusSubcomponent virtualBusSubcomponent, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(virtualBusSubcomponent).keyword(this._aadl2GrammarAccess.getVirtualBusKeywordsAccess().getVirtualKeyword_0()), _function);
    this.formatSubcomponentCommon(virtualBusSubcomponent, document, 
      this.textRegionExtensions.regionFor(virtualBusSubcomponent).assignment(this._aadl2GrammarAccess.getVirtualBusSubcomponentAccess().getVirtualBusSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final DataSubcomponent dataSubcomponent, @Extension final IFormattableDocument document) {
    this.formatSubcomponentCommon(dataSubcomponent, document, 
      this.textRegionExtensions.regionFor(dataSubcomponent).assignment(this._aadl2GrammarAccess.getDataSubcomponentAccess().getDataSubcomponentTypeAssignment_2_0()));
  }

  protected void _format(final ComponentImplementationReference componentImplementationReference, @Extension final IFormattableDocument document) {
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(componentImplementationReference).keyword(this._aadl2GrammarAccess.getComponentImplementationReferenceAccess().getLeftParenthesisKeyword_2_0());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(componentImplementationReference).keyword(this._aadl2GrammarAccess.getComponentImplementationReferenceAccess().getRightParenthesisKeyword_2_3());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_1), _function_2);
      final Consumer<PrototypeBinding> _function_3 = (PrototypeBinding it) -> {
        this.format(it, document);
      };
      componentImplementationReference.getOwnedPrototypeBindings().forEach(_function_3);
      final Consumer<ISemanticRegion> _function_4 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_5), _function_6);
      };
      this.textRegionExtensions.regionFor(componentImplementationReference).keywords(this._aadl2GrammarAccess.getComponentImplementationReferenceAccess().getCommaKeyword_2_2_0()).forEach(_function_4);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_5);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_6);
      }
    }
  }

  protected void _format(final ModeBinding modeBinding, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(modeBinding).keyword(this._aadl2GrammarAccess.getModeRefAccess().getEqualsSignGreaterThanSignKeyword_1_0()), _function);
  }

  private ISemanticRegion formatConnectionCommon(final Connection connection, @Extension final IFormattableDocument document) {
    ISemanticRegion _xblockexpression = null;
    {
      final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
        it.setNewLines(1, 1, 2);
      };
      this.<Connection>conditionalAppend(connection, document, _function);
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(connection).keyword(":"), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(connection).keyword("to"), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<ConnectedElement>surround(connection.getSource(), _function_4);
      this.format(connection.getSource(), document);
      final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.<ConnectedElement>prepend(connection.getDestination(), _function_5);
      this.format(connection.getDestination(), document);
      this.formatCurlyProperties(connection, document, this.textRegionExtensions.regionFor(connection).keyword("{"), this.textRegionExtensions.regionFor(connection).keyword("}"));
      final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(connection).keyword("(");
      final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(connection).keyword(")");
      if (((leftParenthesis != null) && (rightParenthesis != null))) {
        final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        document.surround(this.textRegionExtensions.regionFor(connection).keyword("in"), _function_6);
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
          it.indent();
        };
        document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_7);
        final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
          it.oneSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
          it.setNewLines(0, 0, 1);
          it.autowrap();
        };
        document.append(document.prepend(leftParenthesis, _function_8), _function_9);
        final Consumer<ISemanticRegion> _function_10 = (ISemanticRegion it) -> {
          final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it_1) -> {
            it_1.noSpace();
          };
          final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it_1) -> {
            it_1.oneSpace();
            it_1.setNewLines(0, 0, 1);
            it_1.autowrap();
          };
          document.append(document.prepend(it, _function_11), _function_12);
        };
        this.textRegionExtensions.regionFor(connection).keywords(",").forEach(_function_10);
        boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
        if (_isMultiline) {
          final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
            it.setNewLines(1);
          };
          document.prepend(rightParenthesis, _function_11);
        } else {
          final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
            it.noSpace();
          };
          document.prepend(rightParenthesis, _function_12);
        }
      }
      final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      _xblockexpression = document.prepend(this.textRegionExtensions.regionFor(connection).keyword(";"), _function_13);
    }
    return _xblockexpression;
  }

  protected void _format(final PortConnection portConnection, @Extension final IFormattableDocument document) {
    this.formatConnectionCommon(portConnection, document);
  }

  protected void _format(final AccessConnection accessConnection, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(accessConnection).keyword("access"), _function);
    this.formatConnectionCommon(accessConnection, document);
  }

  protected void _format(final FeatureGroupConnection featureGroupConnection, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(featureGroupConnection).keyword("feature"), _function);
    this.formatConnectionCommon(featureGroupConnection, document);
  }

  protected void _format(final FeatureConnection featureConnection, @Extension final IFormattableDocument document) {
    this.formatConnectionCommon(featureConnection, document);
  }

  protected void _format(final ParameterConnection parameterConnection, @Extension final IFormattableDocument document) {
    this.formatConnectionCommon(parameterConnection, document);
  }

  protected void _format(final ConnectedElement connectedElement, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(connectedElement).keyword("."), _function);
  }

  protected void _format(final FlowSpecification flowSpecification, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<FlowSpecification>conditionalAppend(flowSpecification, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(flowSpecification).keyword(":"), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(flowSpecification).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(this.textRegionExtensions.regionFor(flowSpecification).keyword("flow"), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.<FlowEnd>prepend(flowSpecification.getInEnd(), _function_5);
    this.format(flowSpecification.getInEnd(), document);
    final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(flowSpecification).keyword(this._aadl2GrammarAccess.getFlowPathSpecAccess().getHyphenMinusGreaterThanSignKeyword_5()), _function_6);
    final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.<FlowEnd>prepend(flowSpecification.getOutEnd(), _function_7);
    this.format(flowSpecification.getOutEnd(), document);
    this.formatCurlyProperties(flowSpecification, document, this.textRegionExtensions.regionFor(flowSpecification).keyword("{"), this.textRegionExtensions.regionFor(flowSpecification).keyword("}"));
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(flowSpecification).keyword("(");
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(flowSpecification).keyword(")");
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(flowSpecification).keyword("in"), _function_8);
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_9), _function_10);
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_11);
      final Consumer<ISemanticRegion> _function_12 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_13), _function_14);
      };
      this.textRegionExtensions.regionFor(flowSpecification).keywords(",").forEach(_function_12);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_13);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_14);
      }
    }
    final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(flowSpecification).keyword(";"), _function_15);
  }

  protected void _format(final FlowEnd flowEnd, @Extension final IFormattableDocument document) {
    final Consumer<ISemanticRegion> _function = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it_1) -> {
        it_1.noSpace();
      };
      document.surround(it, _function_1);
    };
    this.textRegionExtensions.regionFor(flowEnd).keywords(this._aadl2GrammarAccess.getFlowEndAccess().getFullStopKeyword_1_1()).forEach(_function);
  }

  protected void _format(final FlowImplementation flowImplementation, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<FlowImplementation>conditionalAppend(flowImplementation, document, _function);
    final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.append(document.prepend(this.textRegionExtensions.regionFor(flowImplementation).keyword(":"), _function_1), _function_2);
    final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(flowImplementation).assignment(this._aadl2GrammarAccess.getFlowSourceImplAccess().getKindAssignment_3()), _function_3);
    final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(flowImplementation).assignment(this._aadl2GrammarAccess.getFlowSinkImplAccess().getKindAssignment_3()), _function_4);
    final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
      it.oneSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(flowImplementation).assignment(this._aadl2GrammarAccess.getFlowPathImplAccess().getKindAssignment_3()), _function_5);
    final Consumer<ISemanticRegion> _function_6 = (ISemanticRegion it) -> {
      final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it_1) -> {
        it_1.oneSpace();
      };
      document.surround(it, _function_7);
    };
    this.textRegionExtensions.regionFor(flowImplementation).keywords("->").forEach(_function_6);
    final Consumer<FlowSegment> _function_7 = (FlowSegment it) -> {
      this.format(it, document);
    };
    flowImplementation.getOwnedFlowSegments().forEach(_function_7);
    this.formatCurlyProperties(flowImplementation, document, this.textRegionExtensions.regionFor(flowImplementation).keyword("{"), this.textRegionExtensions.regionFor(flowImplementation).keyword("}"));
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(flowImplementation).keyword("(");
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(flowImplementation).keyword(")");
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(flowImplementation).keyword("in"), _function_8);
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_9);
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_10), _function_11);
      final Consumer<ISemanticRegion> _function_12 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_13), _function_14);
      };
      this.textRegionExtensions.regionFor(flowImplementation).keywords(",").forEach(_function_12);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_13);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_14);
      }
    }
    final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(flowImplementation).keyword(";"), _function_15);
  }

  protected void _format(final FlowSegment flowSegment, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(flowSegment).keyword(this._aadl2GrammarAccess.getSubcomponentFlowAccess().getFullStopKeyword_0_1()), _function);
  }

  protected void _format(final EndToEndFlow endToEndFlow, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.setNewLines(1, 1, 2);
    };
    this.<EndToEndFlow>conditionalAppend(endToEndFlow, document, _function);
    EndToEndFlow _refined = endToEndFlow.getRefined();
    boolean _tripleEquals = (_refined == null);
    if (_tripleEquals) {
      final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getColonKeyword_0_0_1()), _function_1), _function_2);
      final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowKeywordsAccess().getToKeyword_1()), _function_3);
      final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowKeywordsAccess().getFlowKeyword_3()), _function_4);
      final Consumer<EndToEndFlowSegment> _function_5 = (EndToEndFlowSegment it) -> {
        this.format(it, document);
      };
      endToEndFlow.getOwnedEndToEndFlowSegments().forEach(_function_5);
      final Consumer<ISemanticRegion> _function_6 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
        };
        document.surround(it, _function_7);
      };
      this.textRegionExtensions.regionFor(endToEndFlow).keywords("->").forEach(_function_6);
    } else {
      final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.append(document.prepend(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getColonKeyword_0_1_1()), _function_7), _function_8);
      final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getRefinedToKeywordsAccess().getToKeyword_1()), _function_9);
      final Procedure1<IHiddenRegionFormatter> _function_10 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowKeywordsAccess().getToKeyword_1()), _function_10);
      final Procedure1<IHiddenRegionFormatter> _function_11 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.prepend(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowKeywordsAccess().getFlowKeyword_3()), _function_11);
    }
    this.formatCurlyProperties(endToEndFlow, document, 
      this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getLeftCurlyBracketKeyword_1_0()), 
      this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getRightCurlyBracketKeyword_1_2()));
    final ISemanticRegion leftParenthesis = this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getLeftParenthesisKeyword_2_1());
    final ISemanticRegion rightParenthesis = this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getRightParenthesisKeyword_2_4());
    if (((leftParenthesis != null) && (rightParenthesis != null))) {
      final Procedure1<IHiddenRegionFormatter> _function_12 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      document.surround(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getInModesKeywordsAccess().getInKeyword_0()), _function_12);
      final Procedure1<IHiddenRegionFormatter> _function_13 = (IHiddenRegionFormatter it) -> {
        it.indent();
      };
      document.<ISemanticRegion, ISemanticRegion>interior(leftParenthesis, rightParenthesis, _function_13);
      final Procedure1<IHiddenRegionFormatter> _function_14 = (IHiddenRegionFormatter it) -> {
        it.oneSpace();
      };
      final Procedure1<IHiddenRegionFormatter> _function_15 = (IHiddenRegionFormatter it) -> {
        it.noSpace();
        it.setNewLines(0, 0, 1);
        it.autowrap();
      };
      document.append(document.prepend(leftParenthesis, _function_14), _function_15);
      final Consumer<ISemanticRegion> _function_16 = (ISemanticRegion it) -> {
        final Procedure1<IHiddenRegionFormatter> _function_17 = (IHiddenRegionFormatter it_1) -> {
          it_1.noSpace();
        };
        final Procedure1<IHiddenRegionFormatter> _function_18 = (IHiddenRegionFormatter it_1) -> {
          it_1.oneSpace();
          it_1.setNewLines(0, 0, 1);
          it_1.autowrap();
        };
        document.append(document.prepend(it, _function_17), _function_18);
      };
      this.textRegionExtensions.regionFor(endToEndFlow).keywords(this._aadl2GrammarAccess.getEndToEndFlowAccess().getCommaKeyword_2_3_0()).forEach(_function_16);
      boolean _isMultiline = rightParenthesis.getPreviousHiddenRegion().isMultiline();
      if (_isMultiline) {
        final Procedure1<IHiddenRegionFormatter> _function_17 = (IHiddenRegionFormatter it) -> {
          it.setNewLines(1);
        };
        document.prepend(rightParenthesis, _function_17);
      } else {
        final Procedure1<IHiddenRegionFormatter> _function_18 = (IHiddenRegionFormatter it) -> {
          it.noSpace();
        };
        document.prepend(rightParenthesis, _function_18);
      }
    }
    final Procedure1<IHiddenRegionFormatter> _function_19 = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.prepend(this.textRegionExtensions.regionFor(endToEndFlow).keyword(this._aadl2GrammarAccess.getEndToEndFlowAccess().getSemicolonKeyword_3()), _function_19);
  }

  protected void _format(final EndToEndFlowSegment endToEndFlowSegment, @Extension final IFormattableDocument document) {
    final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
      it.noSpace();
    };
    document.surround(this.textRegionExtensions.regionFor(endToEndFlowSegment).keyword(this._aadl2GrammarAccess.getETESubcomponentFlowAccess().getFullStopKeyword_0_1()), _function);
  }

  /**
   * Appends if there is another semantic region after {@code appendAfter}.
   */
  private <T extends EObject> T conditionalAppend(final T appendAfter, @Extension final IFormattableDocument document, final Procedure1<? super IHiddenRegionFormatter> initializer) {
    T _xblockexpression = null;
    {
      IEObjectRegion _regionForEObject = null;
      if (appendAfter!=null) {
        _regionForEObject=this.textRegionExtensions.regionForEObject(appendAfter);
      }
      ISemanticRegion _nextSemanticRegion = null;
      if (_regionForEObject!=null) {
        _nextSemanticRegion=_regionForEObject.getNextSemanticRegion();
      }
      boolean _tripleNotEquals = (_nextSemanticRegion != null);
      if (_tripleNotEquals) {
        document.<T>append(appendAfter, initializer);
      }
      _xblockexpression = appendAfter;
    }
    return _xblockexpression;
  }

  /**
   * The process for formatting an annex is as follows:
   * 1. Place the annex object into its own resource. This causes the annex text to effectively exist isolated and
   *    independent of the surrounding core text.
   * 2. Inject the annex formatter and format the annex text.
   * 3. Replace the annex text in the aadl file with the formatted annex text.
   * 
   * The specifics of setting up the FormatterRequest for the annex formatter are different based upon how the core
   * formatter was invoked. If the user invoked formatting on a text file, then the node model is available which is
   * then used to setup the FormatterRequest. If formatting was invoked as a part of serialization, then the node
   * model is not be available and the serializer is used to setup the FormatterRequest.
   * 
   * We need to setup an XtextResource with the AnnexLibrary or AnnexSubclause as the root object. If the
   * FormatterRequest is based on the node model, then the XtextResource also needs the IParseResult attached as well.
   * This is necessary because the annex formatter takes a resource as a parameter and then it formats the
   * AnnexLibrary or AnnexSubclause contained as a top level element of the resource.
   * 
   * For figuring out how to invoke the formatter such that a String is returned, I looked at
   * FormatterTestHelper to learn how to do that. The method of most interest is
   * assertFormatted(FormatterTestRequest).
   * 
   * It was not obvious how to replace an ISemanticRegion with a given String. It is not enough to simply
   * call ISemanticRegion.replaceWith(String). This must be wrapped in an ITextReplacer which is then
   * added to the document. See https://www.eclipse.org/forums/index.php/t/1093069/
   * 
   * Since the annex object is placed into its resource, it is removed from its existing resource. The caller of this
   * method is responsible for re-attaching the annex object to the DefaultAnnexLibrary or DefaultAnnexSubclause.
   * 
   * @param annexObject The AnnexLibrary or AnnexSubclause to format.
   * @param sourceTextRegion The ISemanticRegion for the sourceText assignment of the DefaultAnnexLibrary
   *        or DefaultAnnexSubclause.
   * @param indentationLevel Indentation level of the DefaultAnnexLibrary or DefaultAnnexSubclause. The
   *        closing "**}" is placed at indentationLevel. All lines of the formatted annex text are placed
   *        at indentationLevel + 1.
   * @param document The document passed to the format method.
   */
  private void formatAnnexText(final NamedElement annexObject, final String annexName, final ISemanticRegion sourceTextRegion, final int indentationLevel, final IFormattableDocument document) {
    if (((annexObject != null) && (sourceTextRegion != null))) {
      try {
        this.unsafeFormatAnnexText(annexObject, annexName, sourceTextRegion, indentationLevel, document);
      } catch (final Throwable _t) {
        if (_t instanceof ConfigurationException) {
        } else if (_t instanceof ProvisionException) {
        } else {
          throw Exceptions.sneakyThrow(_t);
        }
      }
    }
  }

  private void unsafeFormatAnnexText(final NamedElement annexObject, final String annexName, final ISemanticRegion sourceTextRegion, final int indentationLevel, final IFormattableDocument document) {
    ITextRegionAccess _textRegionAccess = this.getTextRegionAccess();
    if ((_textRegionAccess instanceof NodeModelBasedRegionAccess)) {
      final IParseResult annexParseResult = ParseResultHolder.Factory.INSTANCE.adapt(annexObject).getParseResult();
      if ((annexParseResult != null)) {
        final Injector annexInjector = AnnexUtil.getInjector(annexParseResult);
        IFormatter2 _instance = null;
        if (annexInjector!=null) {
          _instance=annexInjector.<IFormatter2>getInstance(IFormatter2.class);
        }
        final IFormatter2 annexFormatter = _instance;
        if ((annexFormatter != null)) {
          final XtextResource fakeResource = Aadl2Formatter.setupAnnexResource(annexInjector, annexObject);
          fakeResource.setParseResult(annexParseResult);
          final FormatterRequest request = annexInjector.<FormatterRequest>getInstance(FormatterRequest.class);
          final TextRegionAccessBuilder accessBuilder = annexInjector.<TextRegionAccessBuilder>getProvider(TextRegionAccessBuilder.class).get();
          request.setTextRegionAccess(accessBuilder.forNodeModel(fakeResource).create());
          Aadl2Formatter.invokeAnnexFormatter(annexFormatter, request, sourceTextRegion, indentationLevel, document);
        }
      }
    } else {
      ITextRegionAccess _textRegionAccess_1 = this.getTextRegionAccess();
      if ((_textRegionAccess_1 instanceof StringBasedRegionAccess)) {
        final Injector annexInjector_1 = AnnexUtil.getInjector(annexName);
        IFormatter2 _instance_1 = null;
        if (annexInjector_1!=null) {
          _instance_1=annexInjector_1.<IFormatter2>getInstance(IFormatter2.class);
        }
        final IFormatter2 annexFormatter_1 = _instance_1;
        if ((annexFormatter_1 != null)) {
          try {
            Aadl2Formatter.setupAnnexResource(annexInjector_1, annexObject);
            final FormatterRequest request_1 = annexInjector_1.<FormatterRequest>getInstance(FormatterRequest.class);
            ISerializer _instance_2 = annexInjector_1.<ISerializer>getInstance(ISerializer.class);
            final Serializer serializer = ((Serializer) _instance_2);
            request_1.setTextRegionAccess(serializer.serializeToRegions(annexObject));
            Aadl2Formatter.invokeAnnexFormatter(annexFormatter_1, request_1, sourceTextRegion, indentationLevel, document);
          } catch (final Throwable _t) {
            if (_t instanceof NullPointerException) {
            } else {
              throw Exceptions.sneakyThrow(_t);
            }
          }
        }
      }
    }
  }

  private static XtextResource setupAnnexResource(final Injector annexInjector, final NamedElement annexObject) {
    XtextResource _xblockexpression = null;
    {
      final IResourceFactory resourceFactory = annexInjector.<IResourceFactory>getInstance(IResourceFactory.class);
      final String annexExtension = annexInjector.<FileExtensionProvider>getInstance(FileExtensionProvider.class).getPrimaryFileExtension();
      final URI fakeURI = URI.createURI(("__synthetic." + annexExtension));
      Resource _createResource = resourceFactory.createResource(fakeURI);
      final XtextResource fakeResource = ((XtextResource) _createResource);
      final Procedure0 _function = () -> {
        EList<EObject> _contents = fakeResource.getContents();
        _contents.add(annexObject);
      };
      Aadl2Formatter.performModification(annexObject, _function);
      _xblockexpression = fakeResource;
    }
    return _xblockexpression;
  }

  private static void invokeAnnexFormatter(final IFormatter2 annexFormatter, final FormatterRequest request, final ISemanticRegion sourceTextRegion, final int indentationLevel, final IFormattableDocument document) {
    final List<ITextReplacement> replacements = annexFormatter.format(request);
    final String formatted = request.getTextRegionAccess().getRewriter().renderToString(replacements);
    document.addReplacer(new AbstractTextReplacer(document, sourceTextRegion) {
      @Override
      public ITextReplacerContext createReplacements(final ITextReplacerContext context) {
        ITextReplacerContext _xblockexpression = null;
        {
          final String annexIndentation = context.getIndentationString((indentationLevel + 1));
          final StringConcatenation indented = new StringConcatenation();
          indented.append(formatted, annexIndentation);
          StringConcatenation _builder = new StringConcatenation();
          _builder.append("{**");
          _builder.newLine();
          _builder.append(annexIndentation);
          _builder.append(indented);
          _builder.newLineIfNotEmpty();
          String _indentationString = context.getIndentationString(indentationLevel);
          _builder.append(_indentationString);
          _builder.append("**}");
          final String newText = _builder.toString();
          String _text = sourceTextRegion.getText();
          boolean _notEquals = (!Objects.equal(newText, _text));
          if (_notEquals) {
            context.addReplacement(this.getRegion().replaceWith(newText));
          }
          _xblockexpression = context;
        }
        return _xblockexpression;
      }
    });
  }

  private static void performModification(final EObject semanticObject, final Procedure0 runnable) {
    Resource _eResource = null;
    if (semanticObject!=null) {
      _eResource=semanticObject.eResource();
    }
    ResourceSet _resourceSet = null;
    if (_eResource!=null) {
      _resourceSet=_eResource.getResourceSet();
    }
    final ResourceSet resourceSet = _resourceSet;
    TransactionalEditingDomain _xifexpression = null;
    if ((resourceSet != null)) {
      _xifexpression = TransactionalEditingDomain.Factory.INSTANCE.getEditingDomain(resourceSet);
    }
    final TransactionalEditingDomain domain = _xifexpression;
    if ((domain == null)) {
      runnable.apply();
    } else {
      CommandStack _commandStack = domain.getCommandStack();
      _commandStack.execute(new RecordingCommand(domain) {
        @Override
        protected void doExecute() {
          runnable.apply();
        }
      });
    }
  }

  public void format(final Object abstractImplementation, final IFormattableDocument document) {
    if (abstractImplementation instanceof AbstractImplementation) {
      _format((AbstractImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataPort) {
      _format((DataPort)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EventDataPort) {
      _format((EventDataPort)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EventPort) {
      _format((EventPort)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramImplementation) {
      _format((SubprogramImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadImplementation) {
      _format((ThreadImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AadlInteger) {
      _format((AadlInteger)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AadlReal) {
      _format((AadlReal)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AbstractFeature) {
      _format((AbstractFeature)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AbstractPrototype) {
      _format((AbstractPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AbstractType) {
      _format((AbstractType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BusAccess) {
      _format((BusAccess)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BusImplementation) {
      _format((BusImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BusPrototype) {
      _format((BusPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BusType) {
      _format((BusType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataAccess) {
      _format((DataAccess)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataImplementation) {
      _format((DataImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataPrototype) {
      _format((DataPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataType) {
      _format((DataType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DeviceImplementation) {
      _format((DeviceImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DevicePrototype) {
      _format((DevicePrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DeviceType) {
      _format((DeviceType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroup) {
      _format((FeatureGroup)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof MemoryImplementation) {
      _format((MemoryImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof MemoryPrototype) {
      _format((MemoryPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof MemoryType) {
      _format((MemoryType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof Parameter) {
      _format((Parameter)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessImplementation) {
      _format((ProcessImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessPrototype) {
      _format((ProcessPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessType) {
      _format((ProcessType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessorImplementation) {
      _format((ProcessorImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessorPrototype) {
      _format((ProcessorPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessorType) {
      _format((ProcessorType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramAccess) {
      _format((SubprogramAccess)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramGroupAccess) {
      _format((SubprogramGroupAccess)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramGroupImplementation) {
      _format((SubprogramGroupImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramGroupPrototype) {
      _format((SubprogramGroupPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramGroupType) {
      _format((SubprogramGroupType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramPrototype) {
      _format((SubprogramPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramType) {
      _format((SubprogramType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SystemImplementation) {
      _format((SystemImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SystemPrototype) {
      _format((SystemPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SystemType) {
      _format((SystemType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadGroupImplementation) {
      _format((ThreadGroupImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadGroupPrototype) {
      _format((ThreadGroupPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadGroupType) {
      _format((ThreadGroupType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadPrototype) {
      _format((ThreadPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadType) {
      _format((ThreadType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof UnitsType) {
      _format((UnitsType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualBusImplementation) {
      _format((VirtualBusImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualBusPrototype) {
      _format((VirtualBusPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualBusType) {
      _format((VirtualBusType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualProcessorImplementation) {
      _format((VirtualProcessorImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualProcessorPrototype) {
      _format((VirtualProcessorPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualProcessorType) {
      _format((VirtualProcessorType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AadlBoolean) {
      _format((AadlBoolean)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AadlString) {
      _format((AadlString)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AbstractSubcomponent) {
      _format((AbstractSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AccessConnection) {
      _format((AccessConnection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BusSubcomponent) {
      _format((BusSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ClassifierType) {
      _format((ClassifierType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DataSubcomponent) {
      _format((DataSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DeviceSubcomponent) {
      _format((DeviceSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EndToEndFlow) {
      _format((EndToEndFlow)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EnumerationType) {
      _format((EnumerationType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EventDataSource) {
      _format((EventDataSource)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EventSource) {
      _format((EventSource)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureConnection) {
      _format((FeatureConnection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupConnection) {
      _format((FeatureGroupConnection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupPrototype) {
      _format((FeatureGroupPrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeaturePrototype) {
      _format((FeaturePrototype)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FlowSpecification) {
      _format((FlowSpecification)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof MemorySubcomponent) {
      _format((MemorySubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ParameterConnection) {
      _format((ParameterConnection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PortConnection) {
      _format((PortConnection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PortProxy) {
      _format((PortProxy)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessSubcomponent) {
      _format((ProcessSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ProcessorSubcomponent) {
      _format((ProcessorSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof RangeType) {
      _format((RangeType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof RecordType) {
      _format((RecordType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ReferenceType) {
      _format((ReferenceType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramGroupSubcomponent) {
      _format((SubprogramGroupSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramProxy) {
      _format((SubprogramProxy)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramSubcomponent) {
      _format((SubprogramSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SystemSubcomponent) {
      _format((SystemSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadGroupSubcomponent) {
      _format((ThreadGroupSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ThreadSubcomponent) {
      _format((ThreadSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualBusSubcomponent) {
      _format((VirtualBusSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof VirtualProcessorSubcomponent) {
      _format((VirtualProcessorSubcomponent)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DefaultAnnexSubclause) {
      _format((DefaultAnnexSubclause)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupType) {
      _format((FeatureGroupType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FlowImplementation) {
      _format((FlowImplementation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof GroupExtension) {
      _format((GroupExtension)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ImplementationExtension) {
      _format((ImplementationExtension)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof IntegerLiteral) {
      _format((IntegerLiteral)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ListType) {
      _format((ListType)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof Mode) {
      _format((Mode)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ModeTransition) {
      _format((ModeTransition)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PrivatePackageSection) {
      _format((PrivatePackageSection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof Property) {
      _format((Property)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PublicPackageSection) {
      _format((PublicPackageSection)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof RealLiteral) {
      _format((RealLiteral)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramCall) {
      _format((SubprogramCall)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof SubprogramCallSequence) {
      _format((SubprogramCallSequence)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof TypeExtension) {
      _format((TypeExtension)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AadlPackage) {
      _format((AadlPackage)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof AccessSpecification) {
      _format((AccessSpecification)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BasicProperty) {
      _format((BasicProperty)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ClassifierValue) {
      _format((ClassifierValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ComputedValue) {
      _format((ComputedValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof DefaultAnnexLibrary) {
      _format((DefaultAnnexLibrary)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupPrototypeActual) {
      _format((FeatureGroupPrototypeActual)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeaturePrototypeReference) {
      _format((FeaturePrototypeReference)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ModalPropertyValue) {
      _format((ModalPropertyValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PortSpecification) {
      _format((PortSpecification)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PropertyConstant) {
      _format((PropertyConstant)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PropertySet) {
      _format((PropertySet)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof RangeValue) {
      _format((RangeValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof RecordValue) {
      _format((RecordValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ReferenceValue) {
      _format((ReferenceValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof UnitLiteral) {
      _format((UnitLiteral)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ComponentPrototypeActual) {
      _format((ComponentPrototypeActual)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ComponentPrototypeBinding) {
      _format((ComponentPrototypeBinding)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ComponentTypeRename) {
      _format((ComponentTypeRename)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupPrototypeBinding) {
      _format((FeatureGroupPrototypeBinding)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeatureGroupTypeRename) {
      _format((FeatureGroupTypeRename)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FeaturePrototypeBinding) {
      _format((FeaturePrototypeBinding)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ListValue) {
      _format((ListValue)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof MetaclassReference) {
      _format((MetaclassReference)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof Operation) {
      _format((Operation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PackageRename) {
      _format((PackageRename)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof XtextResource) {
      _format((XtextResource)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ArrayDimension) {
      _format((ArrayDimension)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ArrayRange) {
      _format((ArrayRange)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof BasicPropertyAssociation) {
      _format((BasicPropertyAssociation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ComponentImplementationReference) {
      _format((ComponentImplementationReference)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ConnectedElement) {
      _format((ConnectedElement)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ContainedNamedElement) {
      _format((ContainedNamedElement)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ContainmentPathElement) {
      _format((ContainmentPathElement)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EndToEndFlowSegment) {
      _format((EndToEndFlowSegment)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FlowEnd) {
      _format((FlowEnd)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof FlowSegment) {
      _format((FlowSegment)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ModeBinding) {
      _format((ModeBinding)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof ModeTransitionTrigger) {
      _format((ModeTransitionTrigger)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof NumericRange) {
      _format((NumericRange)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof PropertyAssociation) {
      _format((PropertyAssociation)abstractImplementation, document);
      return;
    } else if (abstractImplementation instanceof EObject) {
      _format((EObject)abstractImplementation, document);
      return;
    } else if (abstractImplementation == null) {
      _format((Void)null, document);
      return;
    } else if (abstractImplementation != null) {
      _format(abstractImplementation, document);
      return;
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.<Object>asList(abstractImplementation, document).toString());
    }
  }
}