Search in sources :

Example 81 with JvmTypeReference

use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.

the class ValidationBug433213Test method test_03.

@Test
public void test_03() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("new Object {");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("def m2() {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("new Object {");
        _builder.newLine();
        _builder.append("\t\t\t\t\t");
        _builder.append("def <T> T m3() {}");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
        XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
        final XtendFunction m = ((XtendFunction) _head);
        XExpression _expression = m.getExpression();
        final XBlockExpression body = ((XBlockExpression) _expression);
        XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
        final AnonymousClass anon = ((AnonymousClass) _head_1);
        XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
        final XtendFunction m2 = ((XtendFunction) _head_2);
        XExpression _expression_1 = m2.getExpression();
        final XBlockExpression body2 = ((XBlockExpression) _expression_1);
        XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
        final AnonymousClass anon2 = ((AnonymousClass) _head_3);
        XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
        final XtendFunction m3 = ((XtendFunction) _head_4);
        final JvmTypeReference returnType = m3.getReturnType();
        final JvmType t = returnType.getType();
        Assert.assertNotNull("notNull", t);
        Assert.assertFalse("t.eIsProxy", t.eIsProxy());
        this.helper.assertNoErrors(file);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) AnonymousClass(org.eclipse.xtend.core.xtend.AnonymousClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 82 with JvmTypeReference

use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.

the class ValidationBug433213Test method test_06.

@Test
public void test_06() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class C {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def <K> m() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("new Object {");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("def <V> m2() {");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("new java.util.AbstractMap<K, V> {");
        _builder.newLine();
        _builder.append("\t\t\t\t\t");
        _builder.append("def Entry<K, V> m() {}");
        _builder.newLine();
        _builder.append("\t\t\t\t\t");
        _builder.append("override entrySet() {}");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile file = this.parser.parse(_builder);
        final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
        XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
        final XtendFunction m = ((XtendFunction) _head);
        XExpression _expression = m.getExpression();
        final XBlockExpression body = ((XBlockExpression) _expression);
        XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
        final AnonymousClass anon = ((AnonymousClass) _head_1);
        XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
        final XtendFunction m2 = ((XtendFunction) _head_2);
        XExpression _expression_1 = m2.getExpression();
        final XBlockExpression body2 = ((XBlockExpression) _expression_1);
        XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
        final AnonymousClass anon2 = ((AnonymousClass) _head_3);
        XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
        final XtendFunction m3 = ((XtendFunction) _head_4);
        final JvmTypeReference returnType = m3.getReturnType();
        final JvmType t = returnType.getType();
        Assert.assertNotNull("notNull", t);
        Assert.assertFalse("t.eIsProxy", t.eIsProxy());
        this.helper.assertNoErrors(file);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) AnonymousClass(org.eclipse.xtend.core.xtend.AnonymousClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 83 with JvmTypeReference

use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.

the class XtendFunctionImpl method basicSetReturnType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetReturnType(JvmTypeReference newReturnType, NotificationChain msgs) {
    JvmTypeReference oldReturnType = returnType;
    returnType = newReturnType;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_FUNCTION__RETURN_TYPE, oldReturnType, newReturnType);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 84 with JvmTypeReference

use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.

the class XtendParameterImpl method basicSetParameterType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetParameterType(JvmTypeReference newParameterType, NotificationChain msgs) {
    JvmTypeReference oldParameterType = parameterType;
    parameterType = newParameterType;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_PARAMETER__PARAMETER_TYPE, oldParameterType, newParameterType);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 85 with JvmTypeReference

use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.

the class MemberFromSuperImplementor method getImplementedInterface.

private Procedure1<? super ISourceAppender> getImplementedInterface(final JvmDeclaredType subType, final JvmDeclaredType superInterface) {
    if (((superInterface instanceof JvmGenericType) && ((JvmGenericType) superInterface).isInterface())) {
        final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> {
            JvmType _type = it.getType();
            return Boolean.valueOf(Objects.equal(_type, superInterface));
        };
        boolean _exists = IterableExtensions.<JvmTypeReference>exists(subType.getSuperTypes(), _function);
        if (_exists) {
            final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it) -> {
                it.append(superInterface).append(".");
            };
            return _function_1;
        }
        final Function1<JvmTypeReference, Boolean> _function_2 = (JvmTypeReference it) -> {
            return Boolean.valueOf(this.isInterface(it.getType()));
        };
        final Function1<JvmTypeReference, JvmDeclaredType> _function_3 = (JvmTypeReference it) -> {
            JvmType _type = it.getType();
            return ((JvmDeclaredType) _type);
        };
        final Function1<JvmDeclaredType, Boolean> _function_4 = (JvmDeclaredType it) -> {
            Procedure1<? super ISourceAppender> _implementedInterface = this.getImplementedInterface(it, superInterface);
            return Boolean.valueOf((_implementedInterface != null));
        };
        final JvmDeclaredType interfaze = IterableExtensions.<JvmDeclaredType>findFirst(IterableExtensions.<JvmTypeReference, JvmDeclaredType>map(IterableExtensions.<JvmTypeReference>filter(subType.getSuperTypes(), _function_2), _function_3), _function_4);
        if ((interfaze != null)) {
            final Procedure1<ISourceAppender> _function_5 = (ISourceAppender it) -> {
                it.append(interfaze).append(".");
            };
            return _function_5;
        }
    }
    return null;
}
Also used : JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmType(org.eclipse.xtext.common.types.JvmType) ISourceAppender(org.eclipse.xtext.xbase.compiler.ISourceAppender)

Aggregations

JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)130 Test (org.junit.Test)58 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)46 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)38 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)36 JvmType (org.eclipse.xtext.common.types.JvmType)28 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)23 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)18 XExpression (org.eclipse.xtext.xbase.XExpression)18 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)17 EObject (org.eclipse.emf.ecore.EObject)15 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)12 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)12 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)12 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)12 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)8 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)8 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)8 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)8 JvmParameterizedTypeReference (org.eclipse.xtext.common.types.JvmParameterizedTypeReference)8