ErrorModelScopeProvider.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.errormodel.scoping;

import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.resource.EObjectDescription;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.impl.SimpleScope;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;
import org.eclipse.xtext.xbase.lib.MapExtensions;
import org.osate.aadl2.BasicProperty;
import org.osate.aadl2.BasicPropertyAssociation;
import org.osate.aadl2.Classifier;
import org.osate.aadl2.ComponentClassifier;
import org.osate.aadl2.ComponentImplementation;
import org.osate.aadl2.ContainmentPathElement;
import org.osate.aadl2.DefaultAnnexSubclause;
import org.osate.aadl2.DirectionType;
import org.osate.aadl2.Element;
import org.osate.aadl2.EnumerationType;
import org.osate.aadl2.Feature;
import org.osate.aadl2.FeatureGroup;
import org.osate.aadl2.FeatureGroupType;
import org.osate.aadl2.InternalFeature;
import org.osate.aadl2.NamedElement;
import org.osate.aadl2.Property;
import org.osate.aadl2.PropertyType;
import org.osate.aadl2.RecordType;
import org.osate.aadl2.ReferenceValue;
import org.osate.aadl2.Subcomponent;
import org.osate.aadl2.modelsupport.util.AadlUtil;
import org.osate.xtext.aadl2.errormodel.errorModel.CompositeState;
import org.osate.xtext.aadl2.errormodel.errorModel.ConditionExpression;
import org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path;
import org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement;
import org.osate.xtext.aadl2.errormodel.errorModel.EMV2PropertyAssociation;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorEvent;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorStateMachine;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorTransition;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorDetection;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelLibrary;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelPackage;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorType;
import org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes;
import org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference;
import org.osate.xtext.aadl2.errormodel.errorModel.OutgoingPropagationCondition;
import org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath;
import org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint;
import org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorBehaviorState;
import org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorEventOrPropagation;
import org.osate.xtext.aadl2.errormodel.errorModel.QualifiedErrorPropagation;
import org.osate.xtext.aadl2.errormodel.errorModel.QualifiedPropagationPoint;
import org.osate.xtext.aadl2.errormodel.errorModel.ReportingPortReference;
import org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet;
import org.osate.xtext.aadl2.errormodel.errorModel.TypeSet;
import org.osate.xtext.aadl2.errormodel.errorModel.TypeToken;
import org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet;
import org.osate.xtext.aadl2.errormodel.serializer.ErrorModelCrossReferenceSerializer;
import org.osate.xtext.aadl2.errormodel.util.EMV2Util;
import org.osate.xtext.aadl2.errormodel.util.ErrorModelUtil;
import org.osate.xtext.aadl2.properties.scoping.PropertiesScopeProvider;

/**
 * This class contains custom scoping description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping
 * on how and when to use it
 */
@SuppressWarnings("all")
public class ErrorModelScopeProvider extends PropertiesScopeProvider {
  @Inject
  private IQualifiedNameConverter qualifiedNameConverter;

  @Override
  public IScope scope_NamedValue_namedValue(final Element context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      IScope scope = this.delegateGetScope(context, reference);
      PropertyType propertyType = null;
      BasicPropertyAssociation _containerOfType = EcoreUtil2.<BasicPropertyAssociation>getContainerOfType(context, BasicPropertyAssociation.class);
      BasicProperty _property = null;
      if (_containerOfType!=null) {
        _property=_containerOfType.getProperty();
      }
      PropertyType _propertyType = null;
      if (_property!=null) {
        _propertyType=_property.getPropertyType();
      }
      propertyType = _propertyType;
      if ((propertyType == null)) {
        EMV2PropertyAssociation _containerOfType_1 = EcoreUtil2.<EMV2PropertyAssociation>getContainerOfType(context, EMV2PropertyAssociation.class);
        Property _property_1 = null;
        if (_containerOfType_1!=null) {
          _property_1=_containerOfType_1.getProperty();
        }
        PropertyType _propertyType_1 = null;
        if (_property_1!=null) {
          _propertyType_1=_property_1.getPropertyType();
        }
        propertyType = _propertyType_1;
      }
      propertyType = AadlUtil.getBasePropertyType(propertyType);
      if ((propertyType instanceof EnumerationType)) {
        scope = PropertiesScopeProvider.scopeFor(((EnumerationType)propertyType).getOwnedLiterals(), scope);
      }
      _xblockexpression = scope;
    }
    return _xblockexpression;
  }

  @Override
  public IScope scope_BasicPropertyAssociation_property(final Element context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      final BasicPropertyAssociation parentBpa = EcoreUtil2.<BasicPropertyAssociation>getContainerOfType(context.eContainer(), BasicPropertyAssociation.class);
      BasicProperty _xifexpression = null;
      if ((parentBpa != null)) {
        _xifexpression = parentBpa.getProperty();
      } else {
        _xifexpression = EcoreUtil2.<EMV2PropertyAssociation>getContainerOfType(context, EMV2PropertyAssociation.class).getProperty();
      }
      final BasicProperty property = _xifexpression;
      IScope _switchResult = null;
      PropertyType _propertyType = property.getPropertyType();
      PropertyType _basePropertyType = null;
      if (_propertyType!=null) {
        _basePropertyType=AadlUtil.getBasePropertyType(_propertyType);
      }
      final PropertyType baseType = _basePropertyType;
      boolean _matched = false;
      if (baseType instanceof RecordType) {
        _matched=true;
        _switchResult = PropertiesScopeProvider.scopeFor(((RecordType)baseType).getOwnedFields());
      }
      if (!_matched) {
        _switchResult = IScope.NULLSCOPE;
      }
      _xblockexpression = _switchResult;
    }
    return _xblockexpression;
  }

  @Override
  public IScope scope_ModalElement_inMode(final Element context, final EReference reference) {
    return IScope.NULLSCOPE;
  }

  public IScope scope_NumberValue_unit(final EObject context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      final BasicPropertyAssociation parentBpa = EcoreUtil2.<BasicPropertyAssociation>getContainerOfType(context, BasicPropertyAssociation.class);
      BasicProperty _xifexpression = null;
      if ((parentBpa != null)) {
        _xifexpression = parentBpa.getProperty();
      } else {
        _xifexpression = EcoreUtil2.<EMV2PropertyAssociation>getContainerOfType(context, EMV2PropertyAssociation.class).getProperty();
      }
      final BasicProperty property = _xifexpression;
      _xblockexpression = PropertiesScopeProvider.createUnitLiteralsScopeFromPropertyType(property.getPropertyType());
    }
    return _xblockexpression;
  }

  public IScope scope_ContainmentPathElement_namedElement(final ContainmentPathElement context, final EReference reference) {
    IScope _switchResult = null;
    EObject _eContainer = context.eContainer();
    final EObject parent = _eContainer;
    boolean _matched = false;
    if (parent instanceof EMV2Path) {
      _matched=true;
      IScope _elvis = null;
      ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parent, ComponentImplementation.class);
      EList<Subcomponent> _allSubcomponents = null;
      if (_containerOfType!=null) {
        _allSubcomponents=_containerOfType.getAllSubcomponents();
      }
      Iterable<Subcomponent> _filterRefined = null;
      if (_allSubcomponents!=null) {
        _filterRefined=PropertiesScopeProvider.<Subcomponent>filterRefined(_allSubcomponents);
      }
      SimpleScope _scopeFor = null;
      if (_filterRefined!=null) {
        _scopeFor=PropertiesScopeProvider.scopeFor(_filterRefined);
      }
      if (_scopeFor != null) {
        _elvis = _scopeFor;
      } else {
        _elvis = IScope.NULLSCOPE;
      }
      _switchResult = _elvis;
    }
    if (!_matched) {
      if (parent instanceof ContainmentPathElement) {
        _matched=true;
        IScope _switchResult_1 = null;
        NamedElement _namedElement = ((ContainmentPathElement)parent).getNamedElement();
        final NamedElement previous = _namedElement;
        boolean _matched_1 = false;
        if (previous instanceof Subcomponent) {
          boolean _eIsProxy = ((Subcomponent)previous).eIsProxy();
          boolean _not = (!_eIsProxy);
          if (_not) {
            _matched_1=true;
            IScope _switchResult_2 = null;
            ComponentClassifier _allClassifier = ((Subcomponent)previous).getAllClassifier();
            final ComponentClassifier classifier = _allClassifier;
            boolean _matched_2 = false;
            if (classifier instanceof ComponentImplementation) {
              _matched_2=true;
              _switchResult_2 = PropertiesScopeProvider.scopeFor(PropertiesScopeProvider.<Subcomponent>filterRefined(((ComponentImplementation)classifier).getAllSubcomponents()));
            }
            if (!_matched_2) {
              _switchResult_2 = IScope.NULLSCOPE;
            }
            _switchResult_1 = _switchResult_2;
          }
        }
        if (!_matched_1) {
          _switchResult_1 = IScope.NULLSCOPE;
        }
        _switchResult = _switchResult_1;
      }
    }
    if (!_matched) {
      if (parent instanceof ReferenceValue) {
        _matched=true;
        SimpleScope _xblockexpression = null;
        {
          Iterable<Subcomponent> _elvis = null;
          ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parent, ComponentImplementation.class);
          EList<Subcomponent> _allSubcomponents = null;
          if (_containerOfType!=null) {
            _allSubcomponents=_containerOfType.getAllSubcomponents();
          }
          Iterable<Subcomponent> _filterRefined = null;
          if (_allSubcomponents!=null) {
            _filterRefined=PropertiesScopeProvider.<Subcomponent>filterRefined(_allSubcomponents);
          }
          if (_filterRefined != null) {
            _elvis = _filterRefined;
          } else {
            List<Subcomponent> _emptyList = CollectionLiterals.<Subcomponent>emptyList();
            _elvis = _emptyList;
          }
          final Iterable<Subcomponent> subcomponents = _elvis;
          Iterable<ErrorType> _elvis_1 = null;
          ErrorModelSubclause _containerOfType_1 = EcoreUtil2.<ErrorModelSubclause>getContainerOfType(parent, ErrorModelSubclause.class);
          EList<ErrorModelLibrary> _useTypes = null;
          if (_containerOfType_1!=null) {
            _useTypes=_containerOfType_1.getUseTypes();
          }
          List<EList<ErrorType>> _map = null;
          if (_useTypes!=null) {
            final Function1<ErrorModelLibrary, EList<ErrorType>> _function = (ErrorModelLibrary it) -> {
              return it.getTypes();
            };
            _map=ListExtensions.<ErrorModelLibrary, EList<ErrorType>>map(_useTypes, _function);
          }
          Iterable<ErrorType> _flatten = null;
          if (_map!=null) {
            _flatten=Iterables.<ErrorType>concat(_map);
          }
          if (_flatten != null) {
            _elvis_1 = _flatten;
          } else {
            List<ErrorType> _emptyList_1 = CollectionLiterals.<ErrorType>emptyList();
            _elvis_1 = _emptyList_1;
          }
          final Iterable<ErrorType> types = _elvis_1;
          _xblockexpression = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(subcomponents, types));
        }
        _switchResult = _xblockexpression;
      }
    }
    return _switchResult;
  }

  public SimpleScope scope_ErrorModelLibrary(final EObject context, final EReference reference) {
    return this.scopeWithoutEMV2Prefix(context, reference);
  }

  public SimpleScope scope_TypeMappingSet(final EObject context, final EReference reference) {
    return this.scopeWithoutEMV2Prefix(context, reference);
  }

  public SimpleScope scope_ErrorModelSubclause_useBehavior(final EObject context, final EReference reference) {
    return this.scopeWithoutEMV2Prefix(context, reference);
  }

  public SimpleScope scope_TypeTransformationSet(final EObject context, final EReference reference) {
    return this.scopeWithoutEMV2Prefix(context, reference);
  }

  /**
   * This is a very complicated scoping rule. First of all, EMV2PathElement can be chained (e.g. "name1.name2.name3")
   * and the contents of the scope are different for the first element than for subsequent elements. More importantly,
   * the contents of the scope depend on which grammar rules were used to create the EMV2PathElement. In other words,
   * the scope for an EMV2PathElement in the condition of an ErrorDetection is different from the scope for an
   * EMV2PathElement in the "applies to" of an EMV2PropertyAssociation in an ErrorBehaviorStateMachine. To better
   * understand this scoping rule, please use Graphviz on the following diagram:
   * 
   * 	digraph EMV2PathElement {
   * 		ErrorModelLibrary [fontcolor=blue, fontsize=20]
   * 		ErrorModelSubclause [fontcolor=blue, fontsize=20]
   * 		EMV2PathElementOrKind [fontcolor=red, fontsize=20]
   * 		EMV2PathElement [fontcolor=red, fontsize=20]
   * 		EMV2ErrorPropagationPath [fontcolor=red, fontsize=20]
   * 		BasicEMV2Path -> EMV2PathElementOrKind
   * 		EMV2Path -> EMV2PathElementOrKind
   * 		EMV2PathElementOrKind -> EMV2PathElement
   * 		EMV2PathElement -> EMV2PathElement
   * 		EMV2ErrorPropagationPath -> EMV2ErrorPropagationPath
   * 		QualifiedErrorEventOrPropagation -> EMV2ErrorPropagationPath
   * 		QualifiedErrorPropagation -> EMV2ErrorPropagationPath
   * 		BasicEMV2PropertyAssociation -> BasicEMV2Path
   * 		EMV2PropertyAssociation -> EMV2Path
   * 		ErrorModelSubclause -> EMV2PropertyAssociation
   * 		ErrorBehaviorStateMachine -> BasicEMV2PropertyAssociation
   * 		ErrorModelLibrary -> BasicEMV2PropertyAssociation
   * 		ErrorModelLibrary -> ErrorBehaviorStateMachine
   * 		ConditionElement -> QualifiedErrorEventOrPropagation
   * 		AllExpression -> ConditionElement
   * 		ConditionTerm -> ConditionElement
   * 		OrlessExpression -> ConditionElement
   * 		ConditionTerm -> AllExpression
   * 		ConditionTerm -> OrlessExpression
   * 		AndExpression -> ConditionTerm
   * 		ConditionExpression -> AndExpression
   * 		ConditionTerm -> ConditionExpression
   * 		ErrorBehaviorTransition -> ConditionExpression
   * 		ErrorDetection -> ConditionExpression
   * 		OrmoreExpression -> ConditionExpression
   * 		OutgoingPropagationCondition -> ConditionExpression
   * 		ErrorBehaviorStateMachine -> ErrorBehaviorTransition
   * 		ErrorModelSubclause -> ErrorBehaviorTransition
   * 		ErrorModelSubclause -> ErrorDetection
   * 		ConditionTerm -> OrmoreExpression
   * 		ErrorModelSubclause -> OutgoingPropagationCondition
   * 		SConditionElement -> QualifiedErrorPropagation
   * 		SAllExpression -> SConditionElement
   * 		SConditionTerm -> SConditionElement
   * 		SOrlessExpression -> SConditionElement
   * 		SOrmoreExpression -> SConditionElement
   * 		SConditionTerm -> SAllExpression
   * 		SConditionTerm -> SOrlessExpression
   * 		SConditionTerm -> SOrmoreExpression
   * 		SAndExpression -> SConditionTerm
   * 		SConditionExpression -> SAndExpression
   * 		CompositeState -> SConditionExpression
   * 		SConditionTerm -> SConditionExpression
   * 		ErrorModelSubclause -> CompositeState
   * 	}
   * 
   * EMV2PathElement objects are created in the grammar rules EMV2PathElementOrKind, EMV2PathElement, and
   * EMV2ErrorPropagationPath. The graph shows all of the possible ways to get to one of these grammar rules from
   * the rules ErrorModelLibrary and ErrorModelSubclause. Throughout this method, there are comments which state which
   * grammar path in the graph is being tested for.
   * 
   * Scope elements for grammar path: ErrorModelLibrary -> ErrorBehaviorStateMachine -> ErrorBehaviorTransition ->
   * 			ConditionExpression -> ... -> QualifiedErrorEventOrPropagation -> EMV2ErrorPropagationPath
   * 		ErrorBehaviorEvent
   * 
   * Scope elements for grammar path: ErrorModelSubclause -> ErrorBehaviorTransition -> ConditionExpression -> ... ->
   * 			QualifiedErrorEventOrPropagation -> EMV2ErrorPropagationPath
   * 		ErrorBehaviorEvent |
   * 		(Subcomponent '.')* (FeatureGroup '.')* ErrorPropagation
   * 
   * Scope elements for grammar path: ErrorModelSubclause -> OutgoingPropagationCondition -> ConditionExpression ->
   * 			... -> QualifiedErrorEventOrPropagation -> EMV2ErrorPropagationPath
   * 		ErrorBehaviorEvent |
   * 		(Subcomponent '.')* (FeatureGroup '.')* ErrorPropagation
   * 
   * Scope elements for grammar path: ErrorModelSubclause -> ErrorDetection -> ConditionExpression -> ... ->
   * 			QualifiedErrorEventOrPropagation -> EMV2ErrorPropagationPath
   * 		ErrorBehaviorEvent |
   * 		(Subcomponent '.')* (FeatureGroup '.')* ErrorPropagation
   * 
   * Scope elements for grammar path: ErrorModelSubclause -> CompositeState -> SConditionExpression -> ... ->
   * 			QualifiedErrorPropagation -> EMV2ErrorPropagationPath
   * 		(FeatureGroup '.')* ErrorPropagation
   * 
   * Scope elements for grammar path: ErrorModelLibrary -> BasicEMV2PropertyAssociation -> BasicEMV2Path ->
   * 			EMV2PathElementOrKind
   * 		ErrorTypes
   * 
   * Scope elements for grammar path: ErrorModelLibrary -> ErrorBehaviorStateMachine ->
   * 			BasicEMV2PropartyAssociation -> BasicEMV2Path -> EMV2PathElementOrKind
   * 		ErrorBehaviorEvent |
   * 		ErrorBehaviorState |
   * 		ErrorBehaviorTransition
   * 
   * Scope elements for grammar path: ErrorModelSubclause -> EMV2PropertyAssociation -> EMV2Path ->
   * 			EMV2PathElementOrKind
   * 		(FeatureGroup '.')* ErrorPropagation ('.' ErrorType)? |
   * 		ErrorBehaviorEvent ('.' ErrorType)? |
   * 		ErrorBehaviorTransition |
   * 		OutgoingPropagationConditoin |
   * 		ErrorDetection |
   * 		CompositeState |
   * 		ConnectionErrorSource ('.' ErrorType)? |
   * 		PropagationPath |
   * 		ErrorSource ('.' ErrorType)? |
   * 		ErrorSink ('.' ErrorType)? |
   * 		ErrorPath |
   * 		ErrorBehaviorState ('.' ErrorType)?
   */
  public IScope scope_EMV2PathElement_namedElement(final EMV2PathElement context, final EReference reference) {
    IScope _switchResult = null;
    EObject _eContainer = context.eContainer();
    final EObject parent = _eContainer;
    boolean _matched = false;
    if (parent instanceof QualifiedErrorEventOrPropagation) {
      _matched=true;
      SimpleScope _xblockexpression = null;
      {
        final ConditionExpression topConditionExpression = IterableExtensions.<ConditionExpression>last(Iterables.<ConditionExpression>filter(ErrorModelScopeProvider.getAllContainers(parent), ConditionExpression.class));
        SimpleScope _switchResult_1 = null;
        EObject _eContainer_1 = topConditionExpression.eContainer();
        final EObject parentOfCondition = _eContainer_1;
        boolean _matched_1 = false;
        if (parentOfCondition instanceof ErrorBehaviorTransition) {
          _matched_1=true;
          SimpleScope _switchResult_2 = null;
          EObject _eContainer_2 = ((ErrorBehaviorTransition)parentOfCondition).eContainer();
          final EObject parentOfTransition = _eContainer_2;
          boolean _matched_2 = false;
          if (parentOfTransition instanceof ErrorBehaviorStateMachine) {
            _matched_2=true;
            _switchResult_2 = PropertiesScopeProvider.scopeFor(((ErrorBehaviorStateMachine)parentOfTransition).getEvents());
          }
          if (!_matched_2) {
            if (parentOfTransition instanceof ErrorModelSubclause) {
              _matched_2=true;
              SimpleScope _xblockexpression_1 = null;
              {
                final Function1<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>> _function = (ErrorModelSubclause it) -> {
                  EList<ErrorBehaviorEvent> _events = it.getEvents();
                  List<ErrorBehaviorEvent> _elvis = null;
                  ErrorBehaviorStateMachine _useBehavior = it.getUseBehavior();
                  EList<ErrorBehaviorEvent> _events_1 = null;
                  if (_useBehavior!=null) {
                    _events_1=_useBehavior.getEvents();
                  }
                  if (_events_1 != null) {
                    _elvis = _events_1;
                  } else {
                    List<ErrorBehaviorEvent> _emptyList = CollectionLiterals.<ErrorBehaviorEvent>emptyList();
                    _elvis = _emptyList;
                  }
                  return Iterables.<ErrorBehaviorEvent>concat(_events, _elvis);
                };
                final Iterable<ErrorBehaviorEvent> events = Iterables.<ErrorBehaviorEvent>concat(ListExtensions.<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfTransition)), _function));
                final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(EcoreUtil2.<Classifier>getContainerOfType(parentOfTransition, Classifier.class).getAllFeatures(), FeatureGroup.class);
                List<Subcomponent> _elvis = null;
                ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parentOfTransition, 
                  ComponentImplementation.class);
                EList<Subcomponent> _allSubcomponents = null;
                if (_containerOfType!=null) {
                  _allSubcomponents=_containerOfType.getAllSubcomponents();
                }
                if (_allSubcomponents != null) {
                  _elvis = _allSubcomponents;
                } else {
                  List<Subcomponent> _emptyList = CollectionLiterals.<Subcomponent>emptyList();
                  _elvis = _emptyList;
                }
                final List<Subcomponent> subcomponents = _elvis;
                final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                  return it.getPropagations();
                };
                final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                  return Boolean.valueOf((((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && 
                    (it.getFeatureorPPRef().getFeatureorPP().getName() != null)));
                };
                final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfTransition)), _function_1)), _function_2);
                final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                  return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
                };
                Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
                final SimpleScope propagationsScope = new SimpleScope(_map, true);
                Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(events, featureGroups);
                _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(_plus, subcomponents), propagationsScope);
              }
              _switchResult_2 = _xblockexpression_1;
            }
          }
          _switchResult_1 = _switchResult_2;
        }
        if (!_matched_1) {
          if (parentOfCondition instanceof OutgoingPropagationCondition) {
            _matched_1=true;
            SimpleScope _xblockexpression_1 = null;
            {
              final Function1<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>> _function = (ErrorModelSubclause it) -> {
                EList<ErrorBehaviorEvent> _events = it.getEvents();
                List<ErrorBehaviorEvent> _elvis = null;
                ErrorBehaviorStateMachine _useBehavior = it.getUseBehavior();
                EList<ErrorBehaviorEvent> _events_1 = null;
                if (_useBehavior!=null) {
                  _events_1=_useBehavior.getEvents();
                }
                if (_events_1 != null) {
                  _elvis = _events_1;
                } else {
                  List<ErrorBehaviorEvent> _emptyList = CollectionLiterals.<ErrorBehaviorEvent>emptyList();
                  _elvis = _emptyList;
                }
                return Iterables.<ErrorBehaviorEvent>concat(_events, _elvis);
              };
              final Iterable<ErrorBehaviorEvent> events = Iterables.<ErrorBehaviorEvent>concat(ListExtensions.<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfCondition)), _function));
              final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(EcoreUtil2.<Classifier>getContainerOfType(parentOfCondition, Classifier.class).getAllFeatures(), 
                FeatureGroup.class);
              List<Subcomponent> _elvis = null;
              ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parentOfCondition, 
                ComponentImplementation.class);
              EList<Subcomponent> _allSubcomponents = null;
              if (_containerOfType!=null) {
                _allSubcomponents=_containerOfType.getAllSubcomponents();
              }
              if (_allSubcomponents != null) {
                _elvis = _allSubcomponents;
              } else {
                List<Subcomponent> _emptyList = CollectionLiterals.<Subcomponent>emptyList();
                _elvis = _emptyList;
              }
              final List<Subcomponent> subcomponents = _elvis;
              final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                return it.getPropagations();
              };
              final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                return Boolean.valueOf((((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && 
                  (it.getFeatureorPPRef().getFeatureorPP().getName() != null)));
              };
              final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfCondition)), _function_1)), _function_2);
              final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
              };
              Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
              final SimpleScope propagationsScope = new SimpleScope(_map, true);
              Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(events, featureGroups);
              _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(_plus, subcomponents), propagationsScope);
            }
            _switchResult_1 = _xblockexpression_1;
          }
        }
        if (!_matched_1) {
          if (parentOfCondition instanceof ErrorDetection) {
            _matched_1=true;
            SimpleScope _xblockexpression_1 = null;
            {
              final Function1<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>> _function = (ErrorModelSubclause it) -> {
                EList<ErrorBehaviorEvent> _events = it.getEvents();
                List<ErrorBehaviorEvent> _elvis = null;
                ErrorBehaviorStateMachine _useBehavior = it.getUseBehavior();
                EList<ErrorBehaviorEvent> _events_1 = null;
                if (_useBehavior!=null) {
                  _events_1=_useBehavior.getEvents();
                }
                if (_events_1 != null) {
                  _elvis = _events_1;
                } else {
                  List<ErrorBehaviorEvent> _emptyList = CollectionLiterals.<ErrorBehaviorEvent>emptyList();
                  _elvis = _emptyList;
                }
                return Iterables.<ErrorBehaviorEvent>concat(_events, _elvis);
              };
              final Iterable<ErrorBehaviorEvent> events = Iterables.<ErrorBehaviorEvent>concat(ListExtensions.<ErrorModelSubclause, Iterable<ErrorBehaviorEvent>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfCondition)), _function));
              final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(EcoreUtil2.<Classifier>getContainerOfType(parentOfCondition, Classifier.class).getAllFeatures(), 
                FeatureGroup.class);
              List<Subcomponent> _elvis = null;
              ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parentOfCondition, 
                ComponentImplementation.class);
              EList<Subcomponent> _allSubcomponents = null;
              if (_containerOfType!=null) {
                _allSubcomponents=_containerOfType.getAllSubcomponents();
              }
              if (_allSubcomponents != null) {
                _elvis = _allSubcomponents;
              } else {
                List<Subcomponent> _emptyList = CollectionLiterals.<Subcomponent>emptyList();
                _elvis = _emptyList;
              }
              final List<Subcomponent> subcomponents = _elvis;
              final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                return it.getPropagations();
              };
              final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                return Boolean.valueOf((((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && 
                  (it.getFeatureorPPRef().getFeatureorPP().getName() != null)));
              };
              final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfCondition)), _function_1)), _function_2);
              final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
              };
              Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
              final SimpleScope propagationsScope = new SimpleScope(_map, true);
              Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(events, featureGroups);
              _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(_plus, subcomponents), propagationsScope);
            }
            _switchResult_1 = _xblockexpression_1;
          }
        }
        _xblockexpression = _switchResult_1;
      }
      _switchResult = _xblockexpression;
    }
    if (!_matched) {
      if (parent instanceof QualifiedErrorPropagation) {
        _matched=true;
        SimpleScope _xblockexpression = null;
        {
          final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(EcoreUtil2.<Classifier>getContainerOfType(parent, Classifier.class).getAllFeatures(), FeatureGroup.class);
          final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function = (ErrorModelSubclause it) -> {
            return it.getPropagations();
          };
          final Function1<ErrorPropagation, Boolean> _function_1 = (ErrorPropagation it) -> {
            return Boolean.valueOf((((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && (it.getFeatureorPPRef().getFeatureorPP().getName() != null)));
          };
          final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parent)), _function)), _function_1);
          final Function1<ErrorPropagation, IEObjectDescription> _function_2 = (ErrorPropagation it) -> {
            return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
          };
          Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_2);
          final SimpleScope propagationsScope = new SimpleScope(_map, true);
          _xblockexpression = PropertiesScopeProvider.scopeFor(featureGroups, propagationsScope);
        }
        _switchResult = _xblockexpression;
      }
    }
    if (!_matched) {
      if (parent instanceof EMV2Path) {
        _matched=true;
        IScope _xblockexpression = null;
        {
          final EObject parentOfAssociation = ((EMV2Path)parent).eContainer().eContainer();
          IScope _switchResult_1 = null;
          boolean _matched_1 = false;
          if (parentOfAssociation instanceof ErrorModelLibrary) {
            _matched_1=true;
            Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(((ErrorModelLibrary)parentOfAssociation));
            Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(((ErrorModelLibrary)parentOfAssociation));
            _switchResult_1 = PropertiesScopeProvider.scopeFor(Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets));
          }
          if (!_matched_1) {
            if (parentOfAssociation instanceof ErrorBehaviorStateMachine) {
              _matched_1=true;
              EList<ErrorBehaviorEvent> _events = ((ErrorBehaviorStateMachine)parentOfAssociation).getEvents();
              EList<ErrorBehaviorState> _states = ((ErrorBehaviorStateMachine)parentOfAssociation).getStates();
              Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(_events, _states);
              EList<ErrorBehaviorTransition> _transitions = ((ErrorBehaviorStateMachine)parentOfAssociation).getTransitions();
              _switchResult_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(_plus, _transitions));
            }
          }
          if (!_matched_1) {
            if (parentOfAssociation instanceof ErrorModelSubclause) {
              ContainmentPathElement _containmentPath = ((EMV2Path)parent).getContainmentPath();
              boolean _tripleEquals = (_containmentPath == null);
              if (_tripleEquals) {
                _matched_1=true;
                SimpleScope _xblockexpression_1 = null;
                {
                  final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(EcoreUtil2.<Classifier>getContainerOfType(parentOfAssociation, Classifier.class).getAllFeatures(), 
                    FeatureGroup.class);
                  final Function1<ErrorModelSubclause, Iterable<NamedElement>> _function = (ErrorModelSubclause it) -> {
                    Iterable<NamedElement> _xblockexpression_2 = null;
                    {
                      Iterable<NamedElement> _xifexpression = null;
                      ErrorBehaviorStateMachine _useBehavior = it.getUseBehavior();
                      boolean _tripleNotEquals = (_useBehavior != null);
                      if (_tripleNotEquals) {
                        EList<ErrorBehaviorEvent> _events = it.getUseBehavior().getEvents();
                        EList<ErrorBehaviorState> _states = it.getUseBehavior().getStates();
                        Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(_events, _states);
                        EList<ErrorBehaviorTransition> _transitions = it.getUseBehavior().getTransitions();
                        _xifexpression = Iterables.<NamedElement>concat(_plus, _transitions);
                      } else {
                        _xifexpression = CollectionLiterals.<NamedElement>emptyList();
                      }
                      final Iterable<NamedElement> behaviorElements = _xifexpression;
                      EList<ErrorFlow> _flows = it.getFlows();
                      EList<ErrorBehaviorEvent> _events_1 = it.getEvents();
                      Iterable<NamedElement> _plus_1 = Iterables.<NamedElement>concat(_flows, _events_1);
                      EList<ErrorBehaviorTransition> _transitions_1 = it.getTransitions();
                      Iterable<NamedElement> _plus_2 = Iterables.<NamedElement>concat(_plus_1, _transitions_1);
                      EList<OutgoingPropagationCondition> _outgoingPropagationConditions = it.getOutgoingPropagationConditions();
                      Iterable<NamedElement> _plus_3 = Iterables.<NamedElement>concat(_plus_2, _outgoingPropagationConditions);
                      EList<ErrorDetection> _errorDetections = it.getErrorDetections();
                      Iterable<NamedElement> _plus_4 = Iterables.<NamedElement>concat(_plus_3, _errorDetections);
                      EList<CompositeState> _states_1 = it.getStates();
                      Iterable<NamedElement> _plus_5 = Iterables.<NamedElement>concat(_plus_4, _states_1);
                      EList<ErrorSource> _connectionErrorSources = it.getConnectionErrorSources();
                      Iterable<NamedElement> _plus_6 = Iterables.<NamedElement>concat(_plus_5, _connectionErrorSources);
                      EList<PropagationPath> _paths = it.getPaths();
                      final Iterable<NamedElement> localElements = Iterables.<NamedElement>concat(_plus_6, _paths);
                      _xblockexpression_2 = Iterables.<NamedElement>concat(behaviorElements, localElements);
                    }
                    return _xblockexpression_2;
                  };
                  final Iterable<NamedElement> subclauseElements = Iterables.<NamedElement>concat(ListExtensions.<ErrorModelSubclause, Iterable<NamedElement>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfAssociation)), _function));
                  final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                    return it.getPropagations();
                  };
                  final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                    boolean _and = false;
                    if (!(((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && 
                      (it.getFeatureorPPRef().getFeatureorPP().getName() != null))) {
                      _and = false;
                    } else {
                      boolean _xblockexpression_2 = false;
                      {
                        final Feature f = EMV2Util.getFeature(it);
                        boolean _xifexpression = false;
                        if ((f instanceof FeatureGroup)) {
                          _xifexpression = ((((FeatureGroup)f).getAllFeatureGroupType() == null) || ((FeatureGroup)f).getAllFeatureGroupType().getAllFeatures().isEmpty());
                        } else {
                          _xifexpression = true;
                        }
                        _xblockexpression_2 = _xifexpression;
                      }
                      _and = _xblockexpression_2;
                    }
                    return Boolean.valueOf(_and);
                  };
                  final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parentOfAssociation)), _function_1)), _function_2);
                  final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                    return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
                  };
                  final Iterable<IEObjectDescription> propagationsDescriptions = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
                  SimpleScope _scopeFor = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(featureGroups, subclauseElements));
                  _xblockexpression_1 = new SimpleScope(_scopeFor, propagationsDescriptions, true);
                }
                _switchResult_1 = _xblockexpression_1;
              }
            }
          }
          if (!_matched_1) {
            if (parentOfAssociation instanceof ErrorModelSubclause) {
              _matched_1=true;
              IScope _xblockexpression_1 = null;
              {
                ContainmentPathElement lastContainmentPath = ((EMV2Path)parent).getContainmentPath();
                while ((lastContainmentPath.getPath() != null)) {
                  lastContainmentPath = lastContainmentPath.getPath();
                }
                final NamedElement lastSubcomponent = lastContainmentPath.getNamedElement();
                IScope _xifexpression = null;
                if ((lastSubcomponent instanceof Subcomponent)) {
                  IScope _xblockexpression_2 = null;
                  {
                    final ComponentClassifier classifier = ((Subcomponent)lastSubcomponent).getAllClassifier();
                    IScope _xifexpression_1 = null;
                    if ((classifier != null)) {
                      SimpleScope _xblockexpression_3 = null;
                      {
                        final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(classifier.getAllFeatures(), FeatureGroup.class);
                        final Function1<ErrorModelSubclause, Iterable<NamedElement>> _function = (ErrorModelSubclause it) -> {
                          Iterable<NamedElement> _xblockexpression_4 = null;
                          {
                            Iterable<NamedElement> _xifexpression_2 = null;
                            ErrorBehaviorStateMachine _useBehavior = it.getUseBehavior();
                            boolean _tripleNotEquals = (_useBehavior != null);
                            if (_tripleNotEquals) {
                              EList<ErrorBehaviorEvent> _events = it.getUseBehavior().getEvents();
                              EList<ErrorBehaviorState> _states = it.getUseBehavior().getStates();
                              Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(_events, _states);
                              EList<ErrorBehaviorTransition> _transitions = it.getUseBehavior().getTransitions();
                              _xifexpression_2 = Iterables.<NamedElement>concat(_plus, _transitions);
                            } else {
                              _xifexpression_2 = CollectionLiterals.<NamedElement>emptyList();
                            }
                            final Iterable<NamedElement> behaviorElements = _xifexpression_2;
                            EList<ErrorFlow> _flows = it.getFlows();
                            EList<ErrorBehaviorEvent> _events_1 = it.getEvents();
                            Iterable<NamedElement> _plus_1 = Iterables.<NamedElement>concat(_flows, _events_1);
                            EList<ErrorBehaviorTransition> _transitions_1 = it.getTransitions();
                            Iterable<NamedElement> _plus_2 = Iterables.<NamedElement>concat(_plus_1, _transitions_1);
                            EList<OutgoingPropagationCondition> _outgoingPropagationConditions = it.getOutgoingPropagationConditions();
                            Iterable<NamedElement> _plus_3 = Iterables.<NamedElement>concat(_plus_2, _outgoingPropagationConditions);
                            EList<ErrorDetection> _errorDetections = it.getErrorDetections();
                            Iterable<NamedElement> _plus_4 = Iterables.<NamedElement>concat(_plus_3, _errorDetections);
                            EList<CompositeState> _states_1 = it.getStates();
                            Iterable<NamedElement> _plus_5 = Iterables.<NamedElement>concat(_plus_4, _states_1);
                            EList<ErrorSource> _connectionErrorSources = it.getConnectionErrorSources();
                            Iterable<NamedElement> _plus_6 = Iterables.<NamedElement>concat(_plus_5, _connectionErrorSources);
                            EList<PropagationPath> _paths = it.getPaths();
                            final Iterable<NamedElement> localElements = Iterables.<NamedElement>concat(_plus_6, _paths);
                            _xblockexpression_4 = Iterables.<NamedElement>concat(behaviorElements, localElements);
                          }
                          return _xblockexpression_4;
                        };
                        final Iterable<NamedElement> subclauseElements = Iterables.<NamedElement>concat(ListExtensions.<ErrorModelSubclause, Iterable<NamedElement>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(classifier), _function));
                        final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                          return it.getPropagations();
                        };
                        final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                          boolean _and = false;
                          if (!(((it.getFeatureorPPRef() != null) && (it.getFeatureorPPRef().getNext() == null)) && 
                            (it.getFeatureorPPRef().getFeatureorPP().getName() != null))) {
                            _and = false;
                          } else {
                            boolean _xblockexpression_4 = false;
                            {
                              final Feature f = EMV2Util.getFeature(it);
                              boolean _xifexpression_2 = false;
                              if ((f instanceof FeatureGroup)) {
                                _xifexpression_2 = ((((FeatureGroup)f).getAllFeatureGroupType() == null) || 
                                  ((FeatureGroup)f).getAllFeatureGroupType().getAllFeatures().isEmpty());
                              } else {
                                _xifexpression_2 = true;
                              }
                              _xblockexpression_4 = _xifexpression_2;
                            }
                            _and = _xblockexpression_4;
                          }
                          return Boolean.valueOf(_and);
                        };
                        final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(classifier), _function_1)), _function_2);
                        final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                          return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
                        };
                        final Iterable<IEObjectDescription> propagationsDescriptions = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
                        SimpleScope _scopeFor = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(featureGroups, subclauseElements));
                        _xblockexpression_3 = new SimpleScope(_scopeFor, propagationsDescriptions, 
                          true);
                      }
                      _xifexpression_1 = _xblockexpression_3;
                    } else {
                      _xifexpression_1 = IScope.NULLSCOPE;
                    }
                    _xblockexpression_2 = _xifexpression_1;
                  }
                  _xifexpression = _xblockexpression_2;
                } else {
                  _xifexpression = IScope.NULLSCOPE;
                }
                _xblockexpression_1 = _xifexpression;
              }
              _switchResult_1 = _xblockexpression_1;
            }
          }
          _xblockexpression = _switchResult_1;
        }
        _switchResult = _xblockexpression;
      }
    }
    if (!_matched) {
      if (parent instanceof EMV2PathElement) {
        boolean _eIsProxy = ((EMV2PathElement)parent).getNamedElement().eIsProxy();
        boolean _not = (!_eIsProxy);
        if (_not) {
          _matched=true;
          IScope _switchResult_1 = null;
          NamedElement _namedElement = ((EMV2PathElement)parent).getNamedElement();
          final NamedElement previous = _namedElement;
          boolean _matched_1 = false;
          if (previous instanceof ErrorSource) {
            _matched_1=true;
          }
          if (!_matched_1) {
            if (previous instanceof ErrorSink) {
              _matched_1=true;
            }
          }
          if (!_matched_1) {
            if (previous instanceof ErrorBehaviorState) {
              _matched_1=true;
            }
          }
          if (!_matched_1) {
            if (previous instanceof ErrorEvent) {
              if (((((EMV2PathElement)parent).eContainer() instanceof EMV2Path) && 
                (((EMV2PathElement)parent).eContainer().eContainer().eContainer() instanceof ErrorModelSubclause))) {
                _matched_1=true;
              }
            }
          }
          if (!_matched_1) {
            if (previous instanceof ErrorPropagation) {
              if (((EcoreUtil2.<EMV2Path>getContainerOfType(parent, EMV2Path.class) != null) && 
                (EcoreUtil2.<ErrorModelSubclause>getContainerOfType(parent, ErrorModelSubclause.class) != null))) {
                _matched_1=true;
              }
            }
          }
          if (_matched_1) {
            final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
              return ErrorModelUtil.getAllErrorTypes(it);
            };
            _switchResult_1 = this.scopeForErrorTypes(context, EMV2Util.getUseTypes(previous), Optional.<ErrorModelLibrary>empty(), _function);
          }
          if (!_matched_1) {
            if (previous instanceof Subcomponent) {
              _matched_1=true;
              IScope _xblockexpression = null;
              {
                final ComponentClassifier classifier = ((Subcomponent)previous).getAllClassifier();
                IScope _xifexpression = null;
                if ((classifier != null)) {
                  SimpleScope _xblockexpression_1 = null;
                  {
                    List<Subcomponent> _xifexpression_1 = null;
                    if ((classifier instanceof ComponentImplementation)) {
                      _xifexpression_1 = ((ComponentImplementation)classifier).getAllSubcomponents();
                    } else {
                      _xifexpression_1 = CollectionLiterals.<Subcomponent>emptyList();
                    }
                    final List<Subcomponent> subcomponents = _xifexpression_1;
                    final Iterable<FeatureGroup> featureGroups = Iterables.<FeatureGroup>filter(classifier.getAllFeatures(), FeatureGroup.class);
                    final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_1 = (ErrorModelSubclause it) -> {
                      return it.getPropagations();
                    };
                    final Function1<ErrorPropagation, Boolean> _function_2 = (ErrorPropagation it) -> {
                      return Boolean.valueOf(((((!it.isNot()) && 
                        (it.getFeatureorPPRef() != null)) && 
                        (it.getFeatureorPPRef().getNext() == null)) && 
                        (it.getFeatureorPPRef().getFeatureorPP().getName() != null)));
                    };
                    final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(classifier), _function_1)), _function_2);
                    final Function1<ErrorPropagation, IEObjectDescription> _function_3 = (ErrorPropagation it) -> {
                      return EObjectDescription.create(it.getFeatureorPPRef().getFeatureorPP().getName(), it);
                    };
                    Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_3);
                    final SimpleScope propagationsScope = new SimpleScope(_map, true);
                    _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<Element>concat(subcomponents, featureGroups), propagationsScope);
                  }
                  _xifexpression = _xblockexpression_1;
                } else {
                  _xifexpression = IScope.NULLSCOPE;
                }
                _xblockexpression = _xifexpression;
              }
              _switchResult_1 = _xblockexpression;
            }
          }
          if (!_matched_1) {
            if (previous instanceof FeatureGroup) {
              _matched_1=true;
              SimpleScope _xblockexpression = null;
              {
                Iterable<FeatureGroup> _elvis = null;
                FeatureGroupType _allFeatureGroupType = ((FeatureGroup)previous).getAllFeatureGroupType();
                EList<Feature> _allFeatures = null;
                if (_allFeatureGroupType!=null) {
                  _allFeatures=_allFeatureGroupType.getAllFeatures();
                }
                Iterable<FeatureGroup> _filter = null;
                if (_allFeatures!=null) {
                  _filter=Iterables.<FeatureGroup>filter(_allFeatures, FeatureGroup.class);
                }
                if (_filter != null) {
                  _elvis = _filter;
                } else {
                  List<FeatureGroup> _emptyList = CollectionLiterals.<FeatureGroup>emptyList();
                  _elvis = _emptyList;
                }
                final Iterable<FeatureGroup> featureGroups = _elvis;
                final ArrayList<FeatureGroup> previousFeatureGroups = CollectionLiterals.<FeatureGroup>newArrayList(((FeatureGroup)previous));
                EObject currentPathElement = ((EMV2PathElement)parent).eContainer();
                while (((currentPathElement instanceof EMV2PathElement) && 
                  (((EMV2PathElement) currentPathElement).getNamedElement() instanceof FeatureGroup))) {
                  {
                    NamedElement _namedElement_1 = ((EMV2PathElement) currentPathElement).getNamedElement();
                    previousFeatureGroups.add(0, 
                      ((FeatureGroup) _namedElement_1));
                    currentPathElement = currentPathElement.eContainer();
                  }
                }
                final Function1<FeatureGroup, String> _function_1 = (FeatureGroup it) -> {
                  return it.getName();
                };
                String _join = IterableExtensions.join(ListExtensions.<FeatureGroup, String>map(previousFeatureGroups, _function_1), ".");
                final String previousPath = (_join + ".");
                final boolean lookForSubcomponentInEMV2PathElement = (((EcoreUtil2.<ErrorBehaviorTransition>getContainerOfType(currentPathElement, 
                  ErrorBehaviorTransition.class) != null) || 
                  (EcoreUtil2.<OutgoingPropagationCondition>getContainerOfType(currentPathElement, OutgoingPropagationCondition.class) != null)) || 
                  (EcoreUtil2.<ErrorDetection>getContainerOfType(currentPathElement, ErrorDetection.class) != null));
                Subcomponent _xifexpression = null;
                if (lookForSubcomponentInEMV2PathElement) {
                  Subcomponent _xifexpression_1 = null;
                  if ((currentPathElement instanceof EMV2PathElement)) {
                    NamedElement _namedElement_1 = ((EMV2PathElement)currentPathElement).getNamedElement();
                    _xifexpression_1 = ((Subcomponent) _namedElement_1);
                  }
                  _xifexpression = _xifexpression_1;
                } else {
                  Subcomponent _xblockexpression_1 = null;
                  {
                    final EMV2Path emv2Path = EcoreUtil2.<EMV2Path>getContainerOfType(currentPathElement, EMV2Path.class);
                    Subcomponent _xifexpression_2 = null;
                    ContainmentPathElement _containmentPath = null;
                    if (emv2Path!=null) {
                      _containmentPath=emv2Path.getContainmentPath();
                    }
                    boolean _tripleNotEquals = (_containmentPath != null);
                    if (_tripleNotEquals) {
                      Subcomponent _xblockexpression_2 = null;
                      {
                        ContainmentPathElement lastContainmentPath = emv2Path.getContainmentPath();
                        while ((lastContainmentPath.getPath() != null)) {
                          lastContainmentPath = lastContainmentPath.getPath();
                        }
                        Subcomponent _xifexpression_3 = null;
                        NamedElement _namedElement_2 = lastContainmentPath.getNamedElement();
                        if ((_namedElement_2 instanceof Subcomponent)) {
                          NamedElement _namedElement_3 = lastContainmentPath.getNamedElement();
                          _xifexpression_3 = ((Subcomponent) _namedElement_3);
                        }
                        _xblockexpression_2 = _xifexpression_3;
                      }
                      _xifexpression_2 = _xblockexpression_2;
                    }
                    _xblockexpression_1 = _xifexpression_2;
                  }
                  _xifexpression = _xblockexpression_1;
                }
                final Subcomponent previousSubcomponent = _xifexpression;
                Iterable<ErrorPropagation> _xifexpression_2 = null;
                if ((previousSubcomponent == null)) {
                  final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_2 = (ErrorModelSubclause it) -> {
                    return it.getPropagations();
                  };
                  _xifexpression_2 = Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(((Element)parent)), _function_2));
                } else {
                  Iterable<ErrorPropagation> _elvis_1 = null;
                  ComponentClassifier _allClassifier = previousSubcomponent.getAllClassifier();
                  EList<ErrorModelSubclause> _allContainingClassifierEMV2Subclauses = null;
                  if (_allClassifier!=null) {
                    _allContainingClassifierEMV2Subclauses=EMV2Util.getAllContainingClassifierEMV2Subclauses(_allClassifier);
                  }
                  List<EList<ErrorPropagation>> _map = null;
                  if (_allContainingClassifierEMV2Subclauses!=null) {
                    final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function_3 = (ErrorModelSubclause it) -> {
                      return it.getPropagations();
                    };
                    _map=ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(_allContainingClassifierEMV2Subclauses, _function_3);
                  }
                  Iterable<ErrorPropagation> _flatten = null;
                  if (_map!=null) {
                    _flatten=Iterables.<ErrorPropagation>concat(_map);
                  }
                  if (_flatten != null) {
                    _elvis_1 = _flatten;
                  } else {
                    List<ErrorPropagation> _emptyList_1 = CollectionLiterals.<ErrorPropagation>emptyList();
                    _elvis_1 = _emptyList_1;
                  }
                  _xifexpression_2 = _elvis_1;
                }
                final Iterable<ErrorPropagation> propagations = _xifexpression_2;
                final Function1<ErrorPropagation, Boolean> _function_4 = (ErrorPropagation it) -> {
                  boolean _xblockexpression_2 = false;
                  {
                    final String name = EMV2Util.getPropagationName(it);
                    boolean _xifexpression_3 = false;
                    if (((name != null) && name.startsWith(previousPath))) {
                      boolean _xblockexpression_3 = false;
                      {
                        final String remainingName = name.substring(previousPath.length());
                        boolean _and = false;
                        if (!((!remainingName.isEmpty()) && (!remainingName.contains(".")))) {
                          _and = false;
                        } else {
                          boolean _xblockexpression_4 = false;
                          {
                            final Feature f = EMV2Util.getFeature(it);
                            boolean _xifexpression_4 = false;
                            if ((f instanceof FeatureGroup)) {
                              _xifexpression_4 = ((((FeatureGroup)f).getAllFeatureGroupType() == null) || ((FeatureGroup)f).getAllFeatureGroupType().getAllFeatures().isEmpty());
                            } else {
                              _xifexpression_4 = true;
                            }
                            _xblockexpression_4 = _xifexpression_4;
                          }
                          _and = _xblockexpression_4;
                        }
                        _xblockexpression_3 = _and;
                      }
                      _xifexpression_3 = _xblockexpression_3;
                    } else {
                      _xifexpression_3 = false;
                    }
                    _xblockexpression_2 = _xifexpression_3;
                  }
                  return Boolean.valueOf(_xblockexpression_2);
                };
                final Iterable<ErrorPropagation> filteredPropagations = IterableExtensions.<ErrorPropagation>filter(propagations, _function_4);
                final Function1<ErrorPropagation, IEObjectDescription> _function_5 = (ErrorPropagation it) -> {
                  return EObjectDescription.create(IterableExtensions.<String>last(((Iterable<String>)Conversions.doWrapArray(EMV2Util.getPropagationName(it).split("\\.")))), it);
                };
                final Iterable<IEObjectDescription> propagationsDescriptions = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(filteredPropagations, _function_5);
                SimpleScope _scopeFor = PropertiesScopeProvider.scopeFor(featureGroups);
                _xblockexpression = new SimpleScope(_scopeFor, propagationsDescriptions, true);
              }
              _switchResult_1 = _xblockexpression;
            }
          }
          _switchResult = _switchResult_1;
        }
      }
    }
    if (!_matched) {
      _switchResult = IScope.NULLSCOPE;
    }
    return _switchResult;
  }

  private static ArrayList<EObject> getAllContainers(final EObject object) {
    ArrayList<EObject> _xblockexpression = null;
    {
      final ArrayList<EObject> containers = CollectionLiterals.<EObject>newArrayList();
      for (EObject current = object.eContainer(); (current != null); current = current.eContainer()) {
        containers.add(current);
      }
      _xblockexpression = containers;
    }
    return _xblockexpression;
  }

  public SimpleScope scope_EMV2PathElement_errorType(final EMV2PathElement context, final EReference reference) {
    SimpleScope _xblockexpression = null;
    {
      final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function = (ErrorModelSubclause it) -> {
        return it.getPropagations();
      };
      final Iterable<ErrorPropagation> propagations = Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(context), _function));
      final Function1<ErrorPropagation, Boolean> _function_1 = (ErrorPropagation it) -> {
        String _kind = it.getKind();
        String _emv2PropagationKind = context.getEmv2PropagationKind();
        return Boolean.valueOf(Objects.equal(_kind, _emv2PropagationKind));
      };
      final Iterable<ErrorPropagation> filteredPropagations = IterableExtensions.<ErrorPropagation>filter(propagations, _function_1);
      final Function1<ErrorPropagation, EList<TypeToken>> _function_2 = (ErrorPropagation it) -> {
        return it.getTypeSet().getTypeTokens();
      };
      final Iterable<TypeToken> typeTokens = Iterables.<TypeToken>concat(IterableExtensions.<ErrorPropagation, EList<TypeToken>>map(filteredPropagations, _function_2));
      final Function1<TypeToken, Boolean> _function_3 = (TypeToken it) -> {
        int _size = it.getType().size();
        return Boolean.valueOf((_size == 1));
      };
      final Function1<TypeToken, ErrorTypes> _function_4 = (TypeToken it) -> {
        return IterableExtensions.<ErrorTypes>head(it.getType());
      };
      _xblockexpression = PropertiesScopeProvider.scopeFor(Iterables.<ErrorType>filter(IterableExtensions.<TypeToken, ErrorTypes>map(IterableExtensions.<TypeToken>filter(typeTokens, _function_3), _function_4), ErrorType.class));
    }
    return _xblockexpression;
  }

  public SimpleScope scope_ErrorType(final ErrorModelLibrary context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      return ErrorModelUtil.getAllErrorTypes(it);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>of(context), _function);
  }

  public SimpleScope scope_TypeSet_aliasedType(final ErrorModelLibrary context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      return ErrorModelUtil.getAllTypesets(it);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>of(context), _function);
  }

  public SimpleScope scope_TypeToken_type(final ErrorModelLibrary context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(it);
      Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(it);
      return Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>of(context), _function);
  }

  public SimpleScope scope_TypeToken_type(final ErrorBehaviorStateMachine context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(it);
      Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(it);
      return Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>empty(), _function);
  }

  public SimpleScope scope_TypeToken_type(final TypeMappingSet context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(it);
      Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(it);
      return Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>empty(), _function);
  }

  public SimpleScope scope_TypeToken_type(final TypeTransformationSet context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(it);
      Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(it);
      return Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets);
    };
    return this.scopeForErrorTypes(context, context.getUseTypes(), Optional.<ErrorModelLibrary>empty(), _function);
  }

  public SimpleScope scope_TypeToken_type(final ErrorModelSubclause context, final EReference reference) {
    final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
      Iterable<ErrorType> _allErrorTypes = ErrorModelUtil.getAllErrorTypes(it);
      Iterable<TypeSet> _allTypesets = ErrorModelUtil.getAllTypesets(it);
      return Iterables.<ErrorTypes>concat(_allErrorTypes, _allTypesets);
    };
    return this.scopeForErrorTypes(context, EMV2Util.getUseTypes(context), Optional.<ErrorModelLibrary>empty(), _function);
  }

  public IScope scope_FeatureorPPReference_featureorPP(final FeatureorPPReference context, final EReference reference) {
    IScope _switchResult = null;
    EObject _eContainer = context.eContainer();
    final EObject parent = _eContainer;
    boolean _matched = false;
    if (parent instanceof ErrorPropagation) {
      _matched=true;
      SimpleScope _xblockexpression = null;
      {
        final Classifier classifier = EcoreUtil2.<Classifier>getContainerOfType(parent, Classifier.class);
        EList<Feature> _allFeatures = classifier.getAllFeatures();
        Collection<PropagationPoint> _allPropagationPoints = EMV2Util.getAllPropagationPoints(classifier);
        Iterable<NamedElement> _plus = Iterables.<NamedElement>concat(_allFeatures, _allPropagationPoints);
        List<? extends NamedElement> _xifexpression = null;
        if ((classifier instanceof ComponentImplementation)) {
          _xifexpression = ((ComponentImplementation)classifier).getAllInternalFeatures();
        } else {
          _xifexpression = CollectionLiterals.<NamedElement>emptyList();
        }
        _xblockexpression = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(_plus, _xifexpression));
      }
      _switchResult = _xblockexpression;
    }
    if (!_matched) {
      if (parent instanceof FeatureorPPReference) {
        _matched=true;
        IScope _switchResult_1 = null;
        NamedElement _featureorPP = ((FeatureorPPReference)parent).getFeatureorPP();
        final NamedElement previous = _featureorPP;
        boolean _matched_1 = false;
        if (previous instanceof FeatureGroup) {
          _matched_1=true;
          _switchResult_1 = PropertiesScopeProvider.scopeFor(((FeatureGroup)previous).getFeatureGroupType().getAllFeatures());
        }
        if (!_matched_1) {
          _switchResult_1 = IScope.NULLSCOPE;
        }
        _switchResult = _switchResult_1;
      }
    }
    return _switchResult;
  }

  public SimpleScope scope_ErrorSource_sourceModelElement(final ErrorSource context, final EReference reference) {
    SimpleScope _xblockexpression = null;
    {
      EObject _eContainer = context.eContainer();
      final ErrorModelSubclause subc = ((ErrorModelSubclause) _eContainer);
      SimpleScope _xifexpression = null;
      boolean _contains = subc.getConnectionErrorSources().contains(context);
      if (_contains) {
        _xifexpression = PropertiesScopeProvider.scopeFor(subc.getContainingComponentImpl().getAllConnections());
      } else {
        _xifexpression = ErrorModelScopeProvider.scopeForErrorPropagation(subc.getContainingClassifier(), DirectionType.OUT);
      }
      _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
  }

  public SimpleScope scope_ErrorSource_failureModeReference(final ErrorModelSubclause context, final EReference reference) {
    SimpleScope _xblockexpression = null;
    {
      final Function1<ErrorModelLibrary, Iterable<TypeSet>> _function = (ErrorModelLibrary it) -> {
        return ErrorModelUtil.getAllTypesets(it);
      };
      final Iterable<TypeSet> typesets = Iterables.<TypeSet>concat(ListExtensions.<ErrorModelLibrary, Iterable<TypeSet>>map(context.getUseTypes(), _function));
      List<ErrorBehaviorState> _elvis = null;
      EList<ErrorBehaviorState> _states = context.getUseBehavior().getStates();
      if (_states != null) {
        _elvis = _states;
      } else {
        List<ErrorBehaviorState> _emptyList = CollectionLiterals.<ErrorBehaviorState>emptyList();
        _elvis = _emptyList;
      }
      final List<ErrorBehaviorState> behaviorStates = _elvis;
      _xblockexpression = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(typesets, behaviorStates));
    }
    return _xblockexpression;
  }

  public SimpleScope scope_ErrorSink_incoming(final Classifier context, final EReference reference) {
    return ErrorModelScopeProvider.scopeForErrorPropagation(context, DirectionType.IN);
  }

  public SimpleScope scope_ErrorPath_incoming(final Classifier context, final EReference reference) {
    return ErrorModelScopeProvider.scopeForErrorPropagation(context, DirectionType.IN);
  }

  public SimpleScope scope_ErrorPath_outgoing(final Classifier context, final EReference reference) {
    return ErrorModelScopeProvider.scopeForErrorPropagation(context, DirectionType.OUT);
  }

  public IScope scope_QualifiedPropagationPoint_propagationPoint(final QualifiedPropagationPoint context, final EReference reference) {
    IScope _xifexpression = null;
    EObject _eContainer = context.eContainer();
    if ((_eContainer instanceof QualifiedPropagationPoint)) {
      IScope _xblockexpression = null;
      {
        EObject _eContainer_1 = context.eContainer();
        final ComponentClassifier lastSubcomponentClassifier = ((QualifiedPropagationPoint) _eContainer_1).getSubcomponent().getSubcomponent().getAllClassifier();
        IScope _xifexpression_1 = null;
        if ((lastSubcomponentClassifier != null)) {
          SimpleScope _xblockexpression_1 = null;
          {
            final EList<ErrorModelSubclause> allSubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(lastSubcomponentClassifier);
            final Function1<ErrorModelSubclause, EList<PropagationPoint>> _function = (ErrorModelSubclause it) -> {
              return it.getPoints();
            };
            final Iterable<PropagationPoint> points = Iterables.<PropagationPoint>concat(ListExtensions.<ErrorModelSubclause, EList<PropagationPoint>>map(allSubclauses, _function));
            final EList<Feature> features = lastSubcomponentClassifier.getAllFeatures();
            _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(points, features));
          }
          _xifexpression_1 = _xblockexpression_1;
        } else {
          _xifexpression_1 = IScope.NULLSCOPE;
        }
        _xblockexpression = _xifexpression_1;
      }
      _xifexpression = _xblockexpression;
    } else {
      SimpleScope _xblockexpression_1 = null;
      {
        final EList<ErrorModelSubclause> allSubclauses = EMV2Util.getAllContainingClassifierEMV2Subclauses(context);
        final Function1<ErrorModelSubclause, EList<PropagationPoint>> _function = (ErrorModelSubclause it) -> {
          return it.getPoints();
        };
        final Iterable<PropagationPoint> points = Iterables.<PropagationPoint>concat(ListExtensions.<ErrorModelSubclause, EList<PropagationPoint>>map(allSubclauses, _function));
        final EList<Feature> features = context.getContainingClassifier().getAllFeatures();
        _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(points, features));
      }
      _xifexpression = _xblockexpression_1;
    }
    return _xifexpression;
  }

  public SimpleScope scope_RepairEvent_eventInitiator(final Classifier context, final EReference reference) {
    final Function1<NamedElement, Boolean> _function = (NamedElement it) -> {
      return Boolean.valueOf((!(it instanceof DefaultAnnexSubclause)));
    };
    return PropertiesScopeProvider.scopeFor(PropertiesScopeProvider.<NamedElement>filterRefined(IterableExtensions.<NamedElement>filter(PropertiesScopeProvider.allMembers(context), _function)));
  }

  public IScope scope_RepairEvent_eventInitiator(final ErrorBehaviorStateMachine context, final EReference reference) {
    return IScope.NULLSCOPE;
  }

  public SimpleScope scope_RecoverEvent_eventInitiator(final Classifier context, final EReference reference) {
    final Function1<NamedElement, Boolean> _function = (NamedElement it) -> {
      return Boolean.valueOf((!(it instanceof DefaultAnnexSubclause)));
    };
    return PropertiesScopeProvider.scopeFor(PropertiesScopeProvider.<NamedElement>filterRefined(IterableExtensions.<NamedElement>filter(PropertiesScopeProvider.allMembers(context), _function)));
  }

  public IScope scope_RecoverEvent_eventInitiator(final ErrorBehaviorStateMachine context, final EReference reference) {
    return IScope.NULLSCOPE;
  }

  public SimpleScope scope_ErrorBehaviorState(final ErrorBehaviorStateMachine context, final EReference reference) {
    return PropertiesScopeProvider.scopeFor(context.getStates());
  }

  public IScope scope_ErrorBehaviorState(final Classifier context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      final Function1<ErrorModelSubclause, ErrorBehaviorStateMachine> _function = (ErrorModelSubclause it) -> {
        return it.getUseBehavior();
      };
      final ErrorBehaviorStateMachine stateMachine = IterableExtensions.<ErrorBehaviorStateMachine>head(IterableExtensions.<ErrorBehaviorStateMachine>filterNull(ListExtensions.<ErrorModelSubclause, ErrorBehaviorStateMachine>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(context), _function)));
      IScope _elvis = null;
      EList<ErrorBehaviorState> _states = null;
      if (stateMachine!=null) {
        _states=stateMachine.getStates();
      }
      SimpleScope _scopeFor = null;
      if (_states!=null) {
        _scopeFor=PropertiesScopeProvider.scopeFor(_states);
      }
      if (_scopeFor != null) {
        _elvis = _scopeFor;
      } else {
        _elvis = IScope.NULLSCOPE;
      }
      _xblockexpression = _elvis;
    }
    return _xblockexpression;
  }

  public SimpleScope scope_OutgoingPropagationCondition_outgoing(final Classifier context, final EReference reference) {
    return ErrorModelScopeProvider.scopeForErrorPropagation(context, DirectionType.OUT);
  }

  /**
   * @since 3.0
   */
  public IScope scope_ReportingPortReference_element(final ReportingPortReference context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      final ReportingPortReference previous = context.getPrevious();
      IScope _xifexpression = null;
      if ((previous == null)) {
        SimpleScope _xblockexpression_1 = null;
        {
          final EList<Feature> features = EcoreUtil2.<Classifier>getContainerOfType(context, Classifier.class).getAllFeatures();
          Collection<InternalFeature> _switchResult = null;
          Classifier _containerOfType = EcoreUtil2.<Classifier>getContainerOfType(context, Classifier.class);
          final Classifier classifier = _containerOfType;
          boolean _matched = false;
          if (classifier instanceof ComponentImplementation) {
            _matched=true;
            _switchResult = ((ComponentImplementation)classifier).getAllInternalFeatures();
          }
          if (!_matched) {
            _switchResult = CollectionLiterals.<InternalFeature>emptySet();
          }
          final Collection<InternalFeature> internalFeatures = _switchResult;
          _xblockexpression_1 = PropertiesScopeProvider.scopeFor(Iterables.<NamedElement>concat(features, internalFeatures));
        }
        _xifexpression = _xblockexpression_1;
      } else {
        IScope _xblockexpression_2 = null;
        {
          final NamedElement previousElement = previous.getElement();
          IScope _xifexpression_1 = null;
          if ((previousElement instanceof FeatureGroup)) {
            IScope _elvis = null;
            FeatureGroupType _allFeatureGroupType = ((FeatureGroup)previousElement).getAllFeatureGroupType();
            EList<Feature> _allFeatures = null;
            if (_allFeatureGroupType!=null) {
              _allFeatures=_allFeatureGroupType.getAllFeatures();
            }
            SimpleScope _scopeFor = null;
            if (_allFeatures!=null) {
              _scopeFor=PropertiesScopeProvider.scopeFor(_allFeatures);
            }
            if (_scopeFor != null) {
              _elvis = _scopeFor;
            } else {
              _elvis = IScope.NULLSCOPE;
            }
            _xifexpression_1 = _elvis;
          } else {
            _xifexpression_1 = IScope.NULLSCOPE;
          }
          _xblockexpression_2 = _xifexpression_1;
        }
        _xifexpression = _xblockexpression_2;
      }
      _xblockexpression = _xifexpression;
    }
    return _xblockexpression;
  }

  public SimpleScope scope_ErrorStateToModeMapping_mappedModes(final ComponentClassifier context, final EReference reference) {
    return PropertiesScopeProvider.scopeFor(context.getAllModes());
  }

  public IScope scope_QualifiedErrorBehaviorState_state(final QualifiedErrorBehaviorState context, final EReference reference) {
    IScope _xblockexpression = null;
    {
      final ComponentClassifier subcomponentClassifier = context.getSubcomponent().getSubcomponent().getAllClassifier();
      EList<ErrorModelSubclause> _allContainingClassifierEMV2Subclauses = null;
      if (subcomponentClassifier!=null) {
        _allContainingClassifierEMV2Subclauses=EMV2Util.getAllContainingClassifierEMV2Subclauses(subcomponentClassifier);
      }
      List<ErrorBehaviorStateMachine> _map = null;
      if (_allContainingClassifierEMV2Subclauses!=null) {
        final Function1<ErrorModelSubclause, ErrorBehaviorStateMachine> _function = (ErrorModelSubclause it) -> {
          return it.getUseBehavior();
        };
        _map=ListExtensions.<ErrorModelSubclause, ErrorBehaviorStateMachine>map(_allContainingClassifierEMV2Subclauses, _function);
      }
      Iterable<ErrorBehaviorStateMachine> _filterNull = null;
      if (_map!=null) {
        _filterNull=IterableExtensions.<ErrorBehaviorStateMachine>filterNull(_map);
      }
      ErrorBehaviorStateMachine _head = null;
      if (_filterNull!=null) {
        _head=IterableExtensions.<ErrorBehaviorStateMachine>head(_filterNull);
      }
      final ErrorBehaviorStateMachine stateMachine = _head;
      IScope _elvis = null;
      EList<ErrorBehaviorState> _states = null;
      if (stateMachine!=null) {
        _states=stateMachine.getStates();
      }
      SimpleScope _scopeFor = null;
      if (_states!=null) {
        _scopeFor=PropertiesScopeProvider.scopeFor(_states);
      }
      if (_scopeFor != null) {
        _elvis = _scopeFor;
      } else {
        _elvis = IScope.NULLSCOPE;
      }
      _xblockexpression = _elvis;
    }
    return _xblockexpression;
  }

  public IScope scope_SubcomponentElement_subcomponent(final QualifiedErrorBehaviorState context, final EReference reference) {
    IScope _switchResult = null;
    EObject _eContainer = context.eContainer();
    final EObject parent = _eContainer;
    boolean _matched = false;
    if (parent instanceof QualifiedErrorBehaviorState) {
      _matched=true;
      IScope _switchResult_1 = null;
      ComponentClassifier _allClassifier = ((QualifiedErrorBehaviorState)parent).getSubcomponent().getSubcomponent().getAllClassifier();
      final ComponentClassifier subcomponentClassifier = _allClassifier;
      boolean _matched_1 = false;
      if (subcomponentClassifier instanceof ComponentImplementation) {
        _matched_1=true;
        _switchResult_1 = PropertiesScopeProvider.scopeFor(((ComponentImplementation)subcomponentClassifier).getAllSubcomponents());
      }
      if (!_matched_1) {
        _switchResult_1 = IScope.NULLSCOPE;
      }
      _switchResult = _switchResult_1;
    }
    if (!_matched) {
      IScope _elvis = null;
      ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parent, ComponentImplementation.class);
      EList<Subcomponent> _allSubcomponents = null;
      if (_containerOfType!=null) {
        _allSubcomponents=_containerOfType.getAllSubcomponents();
      }
      SimpleScope _scopeFor = null;
      if (_allSubcomponents!=null) {
        _scopeFor=PropertiesScopeProvider.scopeFor(_allSubcomponents);
      }
      if (_scopeFor != null) {
        _elvis = _scopeFor;
      } else {
        _elvis = IScope.NULLSCOPE;
      }
      _switchResult = _elvis;
    }
    return _switchResult;
  }

  public IScope scope_SubcomponentElement_subcomponent(final QualifiedPropagationPoint context, final EReference reference) {
    IScope _switchResult = null;
    EObject _eContainer = context.eContainer();
    final EObject parent = _eContainer;
    boolean _matched = false;
    if (parent instanceof QualifiedPropagationPoint) {
      _matched=true;
      IScope _switchResult_1 = null;
      ComponentClassifier _allClassifier = ((QualifiedPropagationPoint)parent).getSubcomponent().getSubcomponent().getAllClassifier();
      final ComponentClassifier subcomponentClassifier = _allClassifier;
      boolean _matched_1 = false;
      if (subcomponentClassifier instanceof ComponentImplementation) {
        _matched_1=true;
        _switchResult_1 = PropertiesScopeProvider.scopeFor(((ComponentImplementation)subcomponentClassifier).getAllSubcomponents());
      }
      if (!_matched_1) {
        _switchResult_1 = IScope.NULLSCOPE;
      }
      _switchResult = _switchResult_1;
    }
    if (!_matched) {
      IScope _elvis = null;
      ComponentImplementation _containerOfType = EcoreUtil2.<ComponentImplementation>getContainerOfType(parent, ComponentImplementation.class);
      EList<Subcomponent> _allSubcomponents = null;
      if (_containerOfType!=null) {
        _allSubcomponents=_containerOfType.getAllSubcomponents();
      }
      SimpleScope _scopeFor = null;
      if (_allSubcomponents!=null) {
        _scopeFor=PropertiesScopeProvider.scopeFor(_allSubcomponents);
      }
      if (_scopeFor != null) {
        _elvis = _scopeFor;
      } else {
        _elvis = IScope.NULLSCOPE;
      }
      _switchResult = _elvis;
    }
    return _switchResult;
  }

  private SimpleScope scopeWithoutEMV2Prefix(final EObject context, final EReference reference) {
    final Function1<IEObjectDescription, IEObjectDescription> _function = (IEObjectDescription it) -> {
      IEObjectDescription _xblockexpression = null;
      {
        final String nameAsString = it.getName().toString("::");
        IEObjectDescription _xifexpression = null;
        boolean _startsWith = nameAsString.startsWith(ErrorModelCrossReferenceSerializer.PREFIX);
        if (_startsWith) {
          IEObjectDescription _xblockexpression_1 = null;
          {
            final String strippedName = nameAsString.substring(ErrorModelCrossReferenceSerializer.PREFIX.length());
            _xblockexpression_1 = EObjectDescription.create(this.qualifiedNameConverter.toQualifiedName(strippedName), it.getEObjectOrProxy());
          }
          _xifexpression = _xblockexpression_1;
        } else {
          _xifexpression = it;
        }
        _xblockexpression = _xifexpression;
      }
      return _xblockexpression;
    };
    Iterable<IEObjectDescription> _map = IterableExtensions.<IEObjectDescription, IEObjectDescription>map(this.delegateGetScope(context, reference).getAllElements(), _function);
    return new SimpleScope(_map, true);
  }

  private SimpleScope scopeForErrorTypes(final EObject context, final Iterable<ErrorModelLibrary> useTypes, final Optional<ErrorModelLibrary> parentLibrary, final Function1<? super ErrorModelLibrary, ? extends Iterable<? extends ErrorTypes>> elementGetter) {
    SimpleScope _xblockexpression = null;
    {
      final Function1<ErrorModelLibrary, Iterable<? extends ErrorTypes>> _function = (ErrorModelLibrary it) -> {
        return elementGetter.apply(it);
      };
      final Iterable<ErrorTypes> fromUseTypes = Iterables.<ErrorTypes>concat(IterableExtensions.<ErrorModelLibrary, Iterable<? extends ErrorTypes>>map(useTypes, _function));
      final Function<ErrorModelLibrary, Set<? extends ErrorTypes>> _function_1 = (ErrorModelLibrary it) -> {
        return IterableExtensions.toSet(elementGetter.apply(it));
      };
      final Optional<Set<? extends ErrorTypes>> contextErrorTypes = parentLibrary.<Set<? extends ErrorTypes>>map(_function_1);
      Set<? extends ErrorTypes> _orElse = contextErrorTypes.orElse(CollectionLiterals.<ErrorTypes>emptySet());
      final Set<ErrorTypes> allErrorTypes = IterableExtensions.<ErrorTypes>toSet(Iterables.<ErrorTypes>concat(fromUseTypes, _orElse));
      final Function1<ErrorTypes, String> _function_2 = (ErrorTypes it) -> {
        return it.getName().toLowerCase();
      };
      final Map<String, List<ErrorTypes>> groupedTypes = IterableExtensions.<String, ErrorTypes>groupBy(allErrorTypes, _function_2);
      final Predicate<List<ErrorTypes>> _function_3 = (List<ErrorTypes> it) -> {
        int _size = it.size();
        return (_size == 1);
      };
      final Function1<List<List<ErrorTypes>>, Iterable<ErrorTypes>> _function_4 = (List<List<ErrorTypes>> it) -> {
        return Iterables.<ErrorTypes>concat(it);
      };
      final Map<Boolean, Iterable<ErrorTypes>> partitionResult = MapExtensions.<Boolean, List<List<ErrorTypes>>, Iterable<ErrorTypes>>mapValues(groupedTypes.values().stream().collect(
        Collectors.<List<ErrorTypes>>partitioningBy(_function_3)), _function_4);
      final Function1<ErrorTypes, IEObjectDescription> _function_5 = (ErrorTypes it) -> {
        return EObjectDescription.create(QualifiedName.create(it.getName()), it);
      };
      final Iterable<IEObjectDescription> noConflictsDescriptions = IterableExtensions.<ErrorTypes, IEObjectDescription>map(partitionResult.get(Boolean.valueOf(true)), _function_5);
      final Function1<ErrorTypes, Boolean> _function_6 = (ErrorTypes it) -> {
        return Boolean.valueOf((contextErrorTypes.isPresent() && contextErrorTypes.get().contains(it)));
      };
      final Function1<ErrorTypes, IEObjectDescription> _function_7 = (ErrorTypes it) -> {
        return EObjectDescription.create(QualifiedName.create(it.getName()), it);
      };
      final Iterable<IEObjectDescription> conflictsDescriptions = IterableExtensions.<ErrorTypes, IEObjectDescription>map(IterableExtensions.<ErrorTypes>filter(partitionResult.get(Boolean.valueOf(false)), _function_6), _function_7);
      final IScope librariesScope = this.scope_ErrorModelLibrary(context, 
        ErrorModelPackage.Literals.ERROR_MODEL_LIBRARY__USE_TYPES);
      final Function1<IEObjectDescription, ErrorModelLibrary> _function_8 = (IEObjectDescription it) -> {
        EObject _resolve = EcoreUtil.resolve(it.getEObjectOrProxy(), context);
        return ((ErrorModelLibrary) _resolve);
      };
      final Iterable<ErrorModelLibrary> allLibraries = IterableExtensions.<IEObjectDescription, ErrorModelLibrary>map(librariesScope.getAllElements(), _function_8);
      final Function1<ErrorModelLibrary, Iterable<IEObjectDescription>> _function_9 = (ErrorModelLibrary library) -> {
        Iterable<IEObjectDescription> _xblockexpression_1 = null;
        {
          final Iterable<? extends ErrorTypes> x = elementGetter.apply(library);
          final Function1<ErrorTypes, IEObjectDescription> _function_10 = (ErrorTypes errorTypes) -> {
            return EObjectDescription.create(QualifiedName.create(EMV2Util.getLibraryName(library), errorTypes.getName()), errorTypes);
          };
          _xblockexpression_1 = IterableExtensions.map(x, _function_10);
        }
        return _xblockexpression_1;
      };
      final Iterable<IEObjectDescription> qualifiedDescriptions = Iterables.<IEObjectDescription>concat(IterableExtensions.<ErrorModelLibrary, Iterable<IEObjectDescription>>map(allLibraries, _function_9));
      Iterable<IEObjectDescription> _plus = Iterables.<IEObjectDescription>concat(noConflictsDescriptions, conflictsDescriptions);
      Iterable<IEObjectDescription> _plus_1 = Iterables.<IEObjectDescription>concat(_plus, qualifiedDescriptions);
      _xblockexpression = new SimpleScope(_plus_1, true);
    }
    return _xblockexpression;
  }

  public static Iterable<IEObjectDescription> eDescriptionsForErrorPropagation(final Classifier context, final DirectionType requiredDirection) {
    Iterable<IEObjectDescription> _xblockexpression = null;
    {
      final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function = (ErrorModelSubclause it) -> {
        return it.getPropagations();
      };
      final Function1<ErrorPropagation, Boolean> _function_1 = (ErrorPropagation it) -> {
        return Boolean.valueOf(((!it.isNot()) && Objects.equal(it.getDirection(), requiredDirection)));
      };
      final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(context), _function)), _function_1);
      final Function1<ErrorPropagation, IEObjectDescription> _function_2 = (ErrorPropagation it) -> {
        return EObjectDescription.create(EMV2Util.getPropagationName(it), it);
      };
      _xblockexpression = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_2);
    }
    return _xblockexpression;
  }

  public static SimpleScope scopeForErrorPropagation(final Classifier context, final DirectionType requiredDirection) {
    SimpleScope _xblockexpression = null;
    {
      final Function1<ErrorModelSubclause, EList<ErrorPropagation>> _function = (ErrorModelSubclause it) -> {
        return it.getPropagations();
      };
      final Function1<ErrorPropagation, Boolean> _function_1 = (ErrorPropagation it) -> {
        return Boolean.valueOf(((!it.isNot()) && Objects.equal(it.getDirection(), requiredDirection)));
      };
      final Iterable<ErrorPropagation> propagations = IterableExtensions.<ErrorPropagation>filter(Iterables.<ErrorPropagation>concat(ListExtensions.<ErrorModelSubclause, EList<ErrorPropagation>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(context), _function)), _function_1);
      final Function1<ErrorPropagation, IEObjectDescription> _function_2 = (ErrorPropagation it) -> {
        return EObjectDescription.create(EMV2Util.getPropagationName(it), it);
      };
      Iterable<IEObjectDescription> _map = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(propagations, _function_2);
      _xblockexpression = new SimpleScope(_map, true);
    }
    return _xblockexpression;
  }

  public static Iterable<IEObjectDescription> getEventandIncomingPropagationDescriptions(final Classifier classifier) {
    Iterable<IEObjectDescription> _xblockexpression = null;
    {
      EList<ErrorModelSubclause> _allContainingClassifierEMV2Subclauses = null;
      if (classifier!=null) {
        _allContainingClassifierEMV2Subclauses=EMV2Util.getAllContainingClassifierEMV2Subclauses(classifier);
      }
      List<ErrorBehaviorStateMachine> _map = null;
      if (_allContainingClassifierEMV2Subclauses!=null) {
        final Function1<ErrorModelSubclause, ErrorBehaviorStateMachine> _function = (ErrorModelSubclause it) -> {
          return it.getUseBehavior();
        };
        _map=ListExtensions.<ErrorModelSubclause, ErrorBehaviorStateMachine>map(_allContainingClassifierEMV2Subclauses, _function);
      }
      Iterable<ErrorBehaviorStateMachine> _filterNull = null;
      if (_map!=null) {
        _filterNull=IterableExtensions.<ErrorBehaviorStateMachine>filterNull(_map);
      }
      ErrorBehaviorStateMachine _head = null;
      if (_filterNull!=null) {
        _head=IterableExtensions.<ErrorBehaviorStateMachine>head(_filterNull);
      }
      final ErrorBehaviorStateMachine stateMachine = _head;
      EList<ErrorBehaviorEvent> _events = null;
      if (stateMachine!=null) {
        _events=stateMachine.getEvents();
      }
      final EList<ErrorBehaviorEvent> ebsmevents = _events;
      List<IEObjectDescription> _elvis = null;
      List<IEObjectDescription> _map_1 = null;
      if (ebsmevents!=null) {
        final Function1<ErrorBehaviorEvent, IEObjectDescription> _function_1 = (ErrorBehaviorEvent it) -> {
          return EObjectDescription.create(QualifiedName.create(it.getName()), it);
        };
        _map_1=ListExtensions.<ErrorBehaviorEvent, IEObjectDescription>map(ebsmevents, _function_1);
      }
      if (_map_1 != null) {
        _elvis = _map_1;
      } else {
        List<IEObjectDescription> _emptyList = CollectionLiterals.<IEObjectDescription>emptyList();
        _elvis = _emptyList;
      }
      final List<IEObjectDescription> ebsmeventDescriptions = _elvis;
      final Function1<ErrorModelSubclause, Iterable<IEObjectDescription>> _function_2 = (ErrorModelSubclause it) -> {
        Iterable<IEObjectDescription> _xblockexpression_1 = null;
        {
          final Function1<ErrorBehaviorEvent, IEObjectDescription> _function_3 = (ErrorBehaviorEvent it_1) -> {
            return EObjectDescription.create(QualifiedName.create(it_1.getName()), it_1);
          };
          final List<IEObjectDescription> eventsDescriptions = ListExtensions.<ErrorBehaviorEvent, IEObjectDescription>map(it.getEvents(), _function_3);
          final Function1<ErrorFlow, IEObjectDescription> _function_4 = (ErrorFlow it_1) -> {
            return EObjectDescription.create(QualifiedName.create(it_1.getName()), it_1);
          };
          final List<IEObjectDescription> flowDescriptions = ListExtensions.<ErrorFlow, IEObjectDescription>map(it.getFlows(), _function_4);
          final Function1<ErrorPropagation, Boolean> _function_5 = (ErrorPropagation it_1) -> {
            return Boolean.valueOf(((!it_1.isNot()) && Objects.equal(it_1.getDirection(), DirectionType.IN)));
          };
          final Iterable<ErrorPropagation> inPropagations = IterableExtensions.<ErrorPropagation>filter(it.getPropagations(), _function_5);
          final Function1<ErrorPropagation, IEObjectDescription> _function_6 = (ErrorPropagation it_1) -> {
            return EObjectDescription.create(QualifiedName.create(EMV2Util.getPropagationName(it_1)), it_1);
          };
          final Iterable<IEObjectDescription> propagationsDescriptions = IterableExtensions.<ErrorPropagation, IEObjectDescription>map(inPropagations, _function_6);
          Iterable<IEObjectDescription> _plus = Iterables.<IEObjectDescription>concat(eventsDescriptions, flowDescriptions);
          _xblockexpression_1 = Iterables.<IEObjectDescription>concat(_plus, propagationsDescriptions);
        }
        return _xblockexpression_1;
      };
      Iterable<IEObjectDescription> _flatten = Iterables.<IEObjectDescription>concat(ListExtensions.<ErrorModelSubclause, Iterable<IEObjectDescription>>map(EMV2Util.getAllContainingClassifierEMV2Subclauses(classifier), _function_2));
      _xblockexpression = Iterables.<IEObjectDescription>concat(_flatten, ebsmeventDescriptions);
    }
    return _xblockexpression;
  }
}