Search in sources :

Example 1 with EParameter

use of org.eclipse.emf.ecore.EParameter in project xtext-xtend by eclipse.

the class EmfModelsTest method check.

public void check(final EClass eClassifier) {
    boolean _isAbstract = eClassifier.isAbstract();
    boolean _not = (!_isAbstract);
    if (_not) {
        final EObject obj = eClassifier.getEPackage().getEFactoryInstance().create(eClassifier);
        EList<EOperation> _eAllOperations = eClassifier.getEAllOperations();
        for (final EOperation eOperation : _eAllOperations) {
            {
                final List<Class<?>> paramTypes = CollectionLiterals.<Class<?>>newArrayList();
                final List<Object> parameters = CollectionLiterals.<Object>newArrayList();
                EList<EParameter> _eParameters = eOperation.getEParameters();
                for (final EParameter parameter : _eParameters) {
                    {
                        final Class<?> javaClass = this.toJavaClass(parameter.getEType());
                        paramTypes.add(javaClass);
                        parameters.add(this.getDefaultValue(javaClass));
                    }
                }
                try {
                    final Method method = obj.getClass().getMethod(eOperation.getName(), ((Class<?>[]) Conversions.unwrapArray(paramTypes, Class.class)));
                    try {
                        String _name = method.getDeclaringClass().getName();
                        String _plus = ("Invoking: " + _name);
                        String _plus_1 = (_plus + ".");
                        String _name_1 = method.getName();
                        String _plus_2 = (_plus_1 + _name_1);
                        EmfModelsTest.LOGGER.info(_plus_2);
                        method.invoke(obj, parameters.toArray());
                    } catch (final Throwable _t) {
                        if (_t instanceof InvocationTargetException) {
                            final InvocationTargetException exc1 = (InvocationTargetException) _t;
                            Throwable _cause = exc1.getCause();
                            if ((_cause instanceof UnsupportedOperationException)) {
                                String _name_2 = eClassifier.getName();
                                String _plus_3 = (_name_2 + ": EOperation ");
                                String _name_3 = eOperation.getEContainingClass().getName();
                                String _plus_4 = (_plus_3 + _name_3);
                                String _plus_5 = (_plus_4 + "#");
                                String _name_4 = eOperation.getName();
                                String _plus_6 = (_plus_5 + _name_4);
                                String _plus_7 = (_plus_6 + " not implemented in ");
                                String _name_5 = obj.getClass().getName();
                                final String errorMessage = (_plus_7 + _name_5);
                                EmfModelsTest.LOGGER.error(errorMessage);
                                Assert.fail(errorMessage);
                            }
                        } else {
                            throw Exceptions.sneakyThrow(_t);
                        }
                    }
                } catch (final Throwable _t_1) {
                    if (_t_1 instanceof Exception) {
                        final Exception e = (Exception) _t_1;
                        e.printStackTrace();
                        Assert.fail(e.getMessage());
                    } else {
                        throw Exceptions.sneakyThrow(_t_1);
                    }
                }
            }
        }
        boolean _isDebugEnabled = EmfModelsTest.LOGGER.isDebugEnabled();
        if (_isDebugEnabled) {
            this.dumpFeatures(eClassifier, obj);
        }
    }
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) EParameter(org.eclipse.emf.ecore.EParameter) EOperation(org.eclipse.emf.ecore.EOperation) EList(org.eclipse.emf.common.util.EList) List(java.util.List) EClass(org.eclipse.emf.ecore.EClass)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 EClass (org.eclipse.emf.ecore.EClass)1 EObject (org.eclipse.emf.ecore.EObject)1 EOperation (org.eclipse.emf.ecore.EOperation)1 EParameter (org.eclipse.emf.ecore.EParameter)1