Esempio n. 1
0
 protected IScope createLocalVarScopeForSwitchExpression(
     XSwitchExpression context, IScope parentScope) {
   if (context.getLocalVarName() != null) {
     return new JvmFeatureScope(
         parentScope,
         "XSwitchExpression",
         new LocalVarDescription(QualifiedName.create(context.getLocalVarName()), context));
   }
   return parentScope;
 }
 private int getInsertOffset(XSwitchExpression switchExpression) {
   EList<XCasePart> cases = switchExpression.getCases();
   if (cases.isEmpty()) {
     return insertionOffsets.inEmpty(switchExpression);
   }
   XCasePart casePart = IterableExtensions.last(cases);
   return insertionOffsets.after(casePart);
 }
 public LightweightTypeReference resolvesTo(final String expression, final String type) {
   try {
     final XExpression xExpression = this.expression(expression, false);
     Resource _eResource = xExpression.eResource();
     EList<Diagnostic> _errors = _eResource.getErrors();
     String _string = _errors.toString();
     Resource _eResource_1 = xExpression.eResource();
     EList<Diagnostic> _errors_1 = _eResource_1.getErrors();
     boolean _isEmpty = _errors_1.isEmpty();
     Assert.assertTrue(_string, _isEmpty);
     Resource _eResource_2 = xExpression.eResource();
     EList<Diagnostic> _warnings = _eResource_2.getWarnings();
     String _string_1 = _warnings.toString();
     Resource _eResource_3 = xExpression.eResource();
     EList<Diagnostic> _warnings_1 = _eResource_3.getWarnings();
     boolean _isEmpty_1 = _warnings_1.isEmpty();
     Assert.assertTrue(_string_1, _isEmpty_1);
     IBatchTypeResolver _typeResolver = this.getTypeResolver();
     final IResolvedTypes resolvedTypes = _typeResolver.resolveTypes(xExpression);
     final LightweightTypeReference resolvedType = resolvedTypes.getActualType(xExpression);
     String _simpleName = resolvedType.getSimpleName();
     Assert.assertEquals(type, _simpleName);
     TreeIterator<EObject> _eAllContents = xExpression.eAllContents();
     Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_eAllContents);
     for (final EObject content : _iterable) {
       boolean _matched = false;
       if (!_matched) {
         if (content instanceof XSwitchExpression) {
           final XSwitchExpression _xSwitchExpression = (XSwitchExpression) content;
           _matched = true;
           this.assertExpressionTypeIsResolved(_xSwitchExpression, resolvedTypes);
           String _localVarName = _xSwitchExpression.getLocalVarName();
           boolean _notEquals = (!Objects.equal(_localVarName, null));
           if (_notEquals) {
             this.assertIdentifiableTypeIsResolved(_xSwitchExpression, resolvedTypes);
           }
         }
       }
       if (!_matched) {
         if (content instanceof XAbstractFeatureCall) {
           final XAbstractFeatureCall _xAbstractFeatureCall = (XAbstractFeatureCall) content;
           _matched = true;
           this.assertExpressionTypeIsResolved(_xAbstractFeatureCall, resolvedTypes);
           XExpression _implicitReceiver = _xAbstractFeatureCall.getImplicitReceiver();
           boolean _notEquals = (!Objects.equal(_implicitReceiver, null));
           if (_notEquals) {
             XExpression _implicitReceiver_1 = _xAbstractFeatureCall.getImplicitReceiver();
             this.assertExpressionTypeIsResolved(_implicitReceiver_1, resolvedTypes);
           }
         }
       }
       if (!_matched) {
         if (content instanceof XExpression) {
           final XExpression _xExpression = (XExpression) content;
           _matched = true;
           this.assertExpressionTypeIsResolved(_xExpression, resolvedTypes);
         }
       }
       if (!_matched) {
         if (content instanceof JvmIdentifiableElement) {
           final JvmIdentifiableElement _jvmIdentifiableElement = (JvmIdentifiableElement) content;
           _matched = true;
           this.assertIdentifiableTypeIsResolved(_jvmIdentifiableElement, resolvedTypes);
         }
       }
     }
     TreeIterator<EObject> _eAllContents_1 = xExpression.eAllContents();
     Iterable<EObject> _iterable_1 = IteratorExtensions.<EObject>toIterable(_eAllContents_1);
     for (final EObject content_1 : _iterable_1) {
       boolean _matched_1 = false;
       if (!_matched_1) {
         if (content_1 instanceof XConstructorCall) {
           final XConstructorCall _xConstructorCall = (XConstructorCall) content_1;
           _matched_1 = true;
           Object _eGet = _xConstructorCall.eGet(Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, false);
           final InternalEObject constructor = ((InternalEObject) _eGet);
           String _string_2 = _xConstructorCall.toString();
           Assert.assertNotNull(_string_2, constructor);
           String _string_3 = _xConstructorCall.toString();
           boolean _eIsProxy = constructor.eIsProxy();
           Assert.assertFalse(_string_3, _eIsProxy);
         }
       }
       if (!_matched_1) {
         if (content_1 instanceof XAbstractFeatureCall) {
           final XAbstractFeatureCall _xAbstractFeatureCall = (XAbstractFeatureCall) content_1;
           _matched_1 = true;
           Object _eGet =
               _xAbstractFeatureCall.eGet(Literals.XABSTRACT_FEATURE_CALL__FEATURE, false);
           final InternalEObject feature = ((InternalEObject) _eGet);
           String _string_2 = _xAbstractFeatureCall.toString();
           Assert.assertNotNull(_string_2, feature);
           String _string_3 = _xAbstractFeatureCall.toString();
           boolean _eIsProxy = feature.eIsProxy();
           Assert.assertFalse(_string_3, _eIsProxy);
           XExpression _implicitReceiver = _xAbstractFeatureCall.getImplicitReceiver();
           boolean _notEquals = (!Objects.equal(_implicitReceiver, null));
           if (_notEquals) {
             XExpression _implicitReceiver_1 = _xAbstractFeatureCall.getImplicitReceiver();
             Object _eGet_1 =
                 _implicitReceiver_1.eGet(Literals.XABSTRACT_FEATURE_CALL__FEATURE, false);
             final InternalEObject implicitFeature = ((InternalEObject) _eGet_1);
             String _string_4 = implicitFeature.toString();
             Assert.assertNotNull(_string_4, feature);
             String _string_5 = implicitFeature.toString();
             boolean _eIsProxy_1 = feature.eIsProxy();
             Assert.assertFalse(_string_5, _eIsProxy_1);
           }
         }
       }
     }
     Resource _eResource_4 = xExpression.eResource();
     Iterable<Diagnostic> _linkingAndSyntaxErrors = this.getLinkingAndSyntaxErrors(_eResource_4);
     String _string_2 = _linkingAndSyntaxErrors.toString();
     Resource _eResource_5 = xExpression.eResource();
     Iterable<Diagnostic> _linkingAndSyntaxErrors_1 = this.getLinkingAndSyntaxErrors(_eResource_5);
     boolean _isEmpty_2 = IterableExtensions.isEmpty(_linkingAndSyntaxErrors_1);
     Assert.assertTrue(_string_2, _isEmpty_2);
     Resource _eResource_6 = xExpression.eResource();
     EList<Diagnostic> _warnings_2 = _eResource_6.getWarnings();
     String _string_3 = _warnings_2.toString();
     Resource _eResource_7 = xExpression.eResource();
     EList<Diagnostic> _warnings_3 = _eResource_7.getWarnings();
     boolean _isEmpty_3 = _warnings_3.isEmpty();
     Assert.assertTrue(_string_3, _isEmpty_3);
     return resolvedType;
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }