Search in sources :

Example 1 with CompoundReentrantTypeResolver

use of org.eclipse.xtext.xbase.typesystem.internal.CompoundReentrantTypeResolver in project xtext-xtend by eclipse.

the class Oven method assertExpressionTypeIsResolved.

public void assertExpressionTypeIsResolved(final XExpression expression, final IResolvedTypes types) {
    try {
        final Object internalTypes = this._reflectExtensions.invoke(types, "delegate");
        TypeData _switchResult = null;
        boolean _matched = false;
        if (internalTypes instanceof CompoundReentrantTypeResolver) {
            _matched = true;
            TypeData _xblockexpression = null;
            {
                final Method method = CompoundReentrantTypeResolver.class.getDeclaredMethod("getDelegate", XExpression.class);
                method.setAccessible(true);
                final Object delegate = method.invoke(internalTypes, expression);
                TypeData _xifexpression = null;
                if ((delegate instanceof RootResolvedTypes)) {
                    Object _invoke = this._reflectExtensions.invoke(delegate, "getTypeData", expression, Boolean.FALSE);
                    _xifexpression = ((TypeData) _invoke);
                }
                _xblockexpression = _xifexpression;
            }
            _switchResult = _xblockexpression;
        }
        if (!_matched) {
            Object _invoke = this._reflectExtensions.invoke(internalTypes, "getTypeData", expression, Boolean.FALSE);
            _switchResult = ((TypeData) _invoke);
        }
        final TypeData type = _switchResult;
        String _string = expression.toString();
        String _plus = ("Type is not resolved. Expression: " + _string);
        boolean _xifexpression = false;
        if ((expression instanceof XAbstractFeatureCall)) {
            _xifexpression = (((XAbstractFeatureCall) expression).isPackageFragment() || (type != null));
        } else {
            _xifexpression = (type != null);
        }
        Assert.assertTrue(_plus, _xifexpression);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : RootResolvedTypes(org.eclipse.xtext.xbase.typesystem.internal.RootResolvedTypes) TypeData(org.eclipse.xtext.xbase.typesystem.internal.TypeData) CompoundReentrantTypeResolver(org.eclipse.xtext.xbase.typesystem.internal.CompoundReentrantTypeResolver) EObject(org.eclipse.emf.ecore.EObject) XExpression(org.eclipse.xtext.xbase.XExpression) Method(java.lang.reflect.Method) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall)

Aggregations

Method (java.lang.reflect.Method)1 EObject (org.eclipse.emf.ecore.EObject)1 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)1 XExpression (org.eclipse.xtext.xbase.XExpression)1 CompoundReentrantTypeResolver (org.eclipse.xtext.xbase.typesystem.internal.CompoundReentrantTypeResolver)1 RootResolvedTypes (org.eclipse.xtext.xbase.typesystem.internal.RootResolvedTypes)1 TypeData (org.eclipse.xtext.xbase.typesystem.internal.TypeData)1