Search in sources :

Example 26 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.

the class AbstractReusableActiveAnnotationTests method testSetUpperBoundsForMutableTypeParameterDeclaration.

@Test
public void testSetUpperBoundsForMutableTypeParameterDeclaration() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package myannotation");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.Active");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.TransformationContext");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.TransformationParticipant");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@Active(MyAnnotationProcessor)");
    _builder.newLine();
    _builder.append("annotation MyAnnotation {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class MyAnnotationProcessor implements TransformationParticipant<MutableTypeParameterDeclarator> {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override doTransform(List<? extends MutableTypeParameterDeclarator> annotatedTargetElements,");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("extension TransformationContext context) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("for (annotatedTargetElement : annotatedTargetElements) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("doTransform(annotatedTargetElement, context)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def doTransform(MutableTypeParameterDeclarator it, extension TransformationContext context) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("typeParameters.head.upperBounds = #[String.newTypeReference]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myannotation/MyAnnotation.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package myusercode");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import myannotation.MyAnnotation");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("class MyClass<T extends CharSequence> {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("interface MyInterface<T extends CharSequence> {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("abstract def <T extends CharSequence> void foo();");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("myusercode/UserCode.xtend", _builder_1.toString());
    final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
        final Procedure1<MutableTypeParameterDeclarator> _function_1 = (MutableTypeParameterDeclarator it_1) -> {
            Assert.assertEquals(1, IterableExtensions.size(it_1.getTypeParameters()));
            final MutableTypeParameterDeclaration typeParameter = IterableExtensions.head(it_1.getTypeParameters());
            Assert.assertEquals(1, IterableExtensions.size(typeParameter.getUpperBounds()));
            Assert.assertEquals("java.lang.String", IterableExtensions.head(typeParameter.getUpperBounds()).getName());
        };
        final Procedure1<? super MutableTypeParameterDeclarator> assertMyAnnotationChanges = _function_1;
        assertMyAnnotationChanges.apply(it.getTypeLookup().findClass("myusercode.MyClass"));
        final MutableInterfaceDeclaration myInterface = it.getTypeLookup().findInterface("myusercode.MyInterface");
        assertMyAnnotationChanges.apply(myInterface);
        assertMyAnnotationChanges.apply(IterableExtensions.head(myInterface.getDeclaredMethods()));
    };
    this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
Also used : MutableInterfaceDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration) CompilationUnitImpl(org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl) MutableTypeParameterDeclarator(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) MutableTypeParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration) Test(org.junit.Test)

Example 27 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.

the class AbstractReusableActiveAnnotationTests method testRemoveTypeParameters.

@Test
public void testRemoveTypeParameters() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package myannotation");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import java.util.List");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.Active");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.TransformationContext");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.TransformationParticipant");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@Active(MyAnnotationProcessor)");
    _builder.newLine();
    _builder.append("annotation MyAnnotation {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class MyAnnotationProcessor implements TransformationParticipant<MutableTypeParameterDeclarator> {");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override doTransform(List<? extends MutableTypeParameterDeclarator> annotatedTargetElements,");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("extension TransformationContext context) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("for (annotatedTargetElement : annotatedTargetElements) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("doTransform(annotatedTargetElement, context)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def doTransform(MutableTypeParameterDeclarator it, extension TransformationContext context) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("typeParameters.head.remove");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myannotation/MyAnnotation.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package myusercode");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import myannotation.MyAnnotation");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("class MyClass<T extends String> {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("interface MyInterface<T extends String> {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("abstract def <T extends String> void foo();");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("myusercode/UserCode.xtend", _builder_1.toString());
    final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
        final Procedure1<MutableTypeParameterDeclarator> _function_1 = (MutableTypeParameterDeclarator it_1) -> {
            Assert.assertEquals(0, IterableExtensions.size(it_1.getTypeParameters()));
        };
        final Procedure1<? super MutableTypeParameterDeclarator> assertMyAnnotationChanges = _function_1;
        assertMyAnnotationChanges.apply(it.getTypeLookup().findClass("myusercode.MyClass"));
        final MutableInterfaceDeclaration myInterface = it.getTypeLookup().findInterface("myusercode.MyInterface");
        assertMyAnnotationChanges.apply(myInterface);
        assertMyAnnotationChanges.apply(IterableExtensions.head(myInterface.getDeclaredMethods()));
    };
    this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
Also used : MutableInterfaceDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration) CompilationUnitImpl(org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl) MutableTypeParameterDeclarator(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 28 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.

the class CheckMutableEnumerationTypeDeclarationProcessor method doTransform.

@Override
public void doTransform(final List<? extends MutableEnumerationTypeDeclaration> annotatedTargetElements, @Extension final TransformationContext context) {
    for (final MutableEnumerationTypeDeclaration enumeration : annotatedTargetElements) {
        {
            final Procedure1<String> _function = (String identifier) -> {
                final Procedure1<MutableEnumerationValueDeclaration> _function_1 = (MutableEnumerationValueDeclaration it) -> {
                };
                enumeration.addValue(identifier, _function_1).remove();
            };
            MutableAssert.assertValidJavaIdentifier("name", _function);
            final Procedure0 _function_1 = () -> {
                enumeration.addValue("foo", null);
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_1);
            final Procedure0 _function_2 = () -> {
                final Procedure1<MutableEnumerationValueDeclaration> _function_3 = (MutableEnumerationValueDeclaration it) -> {
                };
                enumeration.addValue("A", _function_3).setVisibility(Visibility.PRIVATE);
            };
            MutableAssert.<UnsupportedOperationException>assertThrowable(UnsupportedOperationException.class, "It is not possible to change visibility of enumeration value.", _function_2);
        }
    }
}
Also used : MutableEnumerationTypeDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableEnumerationTypeDeclaration) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) MutableEnumerationValueDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableEnumerationValueDeclaration)

Example 29 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.

the class CheckMutableInterfaceDeclarationProcessor method doTransform.

@Override
public void doTransform(final List<? extends MutableInterfaceDeclaration> annotatedTargetElements, @Extension final TransformationContext context) {
    for (final MutableInterfaceDeclaration annotatedTargetElement : annotatedTargetElements) {
        {
            final Procedure1<String> _function = (String identifier) -> {
                annotatedTargetElement.addTypeParameter(identifier).remove();
            };
            MutableAssert.assertValidJavaIdentifier("name", _function);
            final Procedure0 _function_1 = () -> {
                annotatedTargetElement.addTypeParameter("T", ((TypeReference[]) null));
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_1);
            final Procedure0 _function_2 = () -> {
                annotatedTargetElement.addTypeParameter("T", new TypeReference[] { null });
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_2);
            annotatedTargetElement.addTypeParameter("T", ((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class))).remove();
            final Procedure0 _function_3 = () -> {
                annotatedTargetElement.setExtendedInterfaces(null);
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superinterfaces cannot be null", _function_3);
            final Procedure0 _function_4 = () -> {
                annotatedTargetElement.setExtendedInterfaces(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superinterfaces cannot contain null", _function_4);
            annotatedTargetElement.setExtendedInterfaces(CollectionLiterals.<TypeReference>emptyList());
            final Procedure1<AnnotationReferenceBuildContext> _function_5 = (AnnotationReferenceBuildContext it) -> {
                final Procedure0 _function_6 = () -> {
                    it.set(null, null);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_6);
                final Procedure0 _function_7 = () -> {
                    it.set(null, "foo");
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_7);
                final Procedure0 _function_8 = () -> {
                    String[] _xblockexpression = null;
                    {
                        final String[] array = { "foo" };
                        _xblockexpression = array;
                    }
                    it.set(null, _xblockexpression);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_8);
                final Procedure0 _function_9 = () -> {
                    it.set(null, Boolean.valueOf(true));
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_9);
                final Procedure0 _function_10 = () -> {
                    it.set(null, ((boolean[]) ((boolean[]) Conversions.unwrapArray(Collections.<Boolean>unmodifiableList(CollectionLiterals.<Boolean>newArrayList(Boolean.valueOf(true))), boolean.class))));
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_10);
                final Procedure0 _function_11 = () -> {
                    it.set(null, Integer.valueOf(0));
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_11);
                final Procedure0 _function_12 = () -> {
                    it.set(null, ((int[]) ((int[]) Conversions.unwrapArray(Collections.<Integer>unmodifiableList(CollectionLiterals.<Integer>newArrayList(Integer.valueOf(0))), int.class))));
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "name has to be a valid java identifier", _function_12);
                final Procedure0 _function_13 = () -> {
                    String[] _xblockexpression = null;
                    {
                        final String[] array = { "foo" };
                        _xblockexpression = array;
                    }
                    it.set("doesNotExist", _xblockexpression);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "The annotation property \'doesNotExist\' is not declared on the annotation type \'java.lang.Deprecated\'.", _function_13);
            };
            final AnnotationReference annotationReference = annotatedTargetElement.addAnnotation(context.newAnnotationReference(Deprecated.class, _function_5));
            annotatedTargetElement.removeAnnotation(annotationReference);
            final Procedure1<AnnotationReferenceBuildContext> _function_6 = (AnnotationReferenceBuildContext it) -> {
                String[] _xblockexpression = null;
                {
                    final String[] array = { "foo" };
                    _xblockexpression = array;
                }
                it.set("value", _xblockexpression);
                final Procedure0 _function_7 = () -> {
                    int[] _xblockexpression_1 = null;
                    {
                        final int[] array = { 1 };
                        _xblockexpression_1 = array;
                    }
                    it.set("value", _xblockexpression_1);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "int[] is not applicable at this location. Expected java.lang.String[]", _function_7);
            };
            final AnnotationReference otherAnnotationReference = annotatedTargetElement.addAnnotation(context.newAnnotationReference(SuppressWarnings.class, _function_6));
            annotatedTargetElement.removeAnnotation(otherAnnotationReference);
            final Procedure1<AnnotationReferenceBuildContext> _function_7 = (AnnotationReferenceBuildContext it) -> {
                it.set("validators", new TypeReference[0]);
                it.set("validators", context.newTypeReference(String.class));
                final Procedure0 _function_8 = () -> {
                    it.set("validators", new String[0]);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "java.lang.String[] is not applicable at this location. Expected org.eclipse.xtend.lib.macro.declaration.TypeReference[]", _function_8);
                final Procedure0 _function_9 = () -> {
                    it.set("validators", new Object[0]);
                };
                MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot set annotation values of type java.lang.Object[]", _function_9);
            };
            final AnnotationReference composedChecksReference = annotatedTargetElement.addAnnotation(context.newAnnotationReference(ComposedChecks.class, _function_7));
            annotatedTargetElement.removeAnnotation(composedChecksReference);
        }
    }
}
Also used : MutableInterfaceDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) AnnotationReferenceBuildContext(org.eclipse.xtend.lib.macro.services.AnnotationReferenceBuildContext) AnnotationReference(org.eclipse.xtend.lib.macro.declaration.AnnotationReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference)

Example 30 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.

the class InferredTypeReferencesCheckProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration it, @Extension final TransformationContext context) {
    final TypeReference type = it.findDeclaredField("foo").getType();
    Assert.assertTrue(type.isInferred());
    final Procedure0 _function = () -> {
        it.setExtendedClass(type);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as extended class.", _function);
    final Procedure0 _function_1 = () -> {
        Iterable<? extends TypeReference> _implementedInterfaces = it.getImplementedInterfaces();
        Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_implementedInterfaces, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(type)));
        it.setImplementedInterfaces(_plus);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as implemented interface.", _function_1);
    final Procedure1<MutableMethodDeclaration> _function_2 = (MutableMethodDeclaration it_1) -> {
        it_1.setReturnType(type);
        final Procedure0 _function_3 = () -> {
            it_1.addParameter("bar", type);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_3);
        final Procedure0 _function_4 = () -> {
            it_1.setExceptions(type);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as exception type.", _function_4);
        final Procedure0 _function_5 = () -> {
            it_1.addTypeParameter("T", type);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_5);
        MutableTypeParameterDeclaration _addTypeParameter = it_1.addTypeParameter("T");
        final Procedure1<MutableTypeParameterDeclaration> _function_6 = (MutableTypeParameterDeclaration it_2) -> {
            final Procedure0 _function_7 = () -> {
                Iterable<? extends TypeReference> _upperBounds = it_2.getUpperBounds();
                Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_upperBounds, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(type)));
                it_2.setUpperBounds(_plus);
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_7);
        };
        ObjectExtensions.<MutableTypeParameterDeclaration>operator_doubleArrow(_addTypeParameter, _function_6);
    };
    it.addMethod("bar", _function_2);
    final Procedure1<MutableFieldDeclaration> _function_3 = (MutableFieldDeclaration field) -> {
        field.setType(type);
    };
    it.addField("bar2", _function_3);
    MutableInterfaceDeclaration _findInterface = context.findInterface("Bar");
    final Procedure1<MutableInterfaceDeclaration> _function_4 = (MutableInterfaceDeclaration it_1) -> {
        final Procedure0 _function_5 = () -> {
            Iterable<? extends TypeReference> _extendedInterfaces = it_1.getExtendedInterfaces();
            Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_extendedInterfaces, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(type)));
            it_1.setExtendedInterfaces(_plus);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as extended interface.", _function_5);
        final Procedure0 _function_6 = () -> {
            it_1.addTypeParameter("T", type);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_6);
        MutableTypeParameterDeclaration _addTypeParameter = it_1.addTypeParameter("T");
        final Procedure1<MutableTypeParameterDeclaration> _function_7 = (MutableTypeParameterDeclaration it_2) -> {
            final Procedure0 _function_8 = () -> {
                Iterable<? extends TypeReference> _upperBounds = it_2.getUpperBounds();
                Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_upperBounds, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(type)));
                it_2.setUpperBounds(_plus);
            };
            MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_8);
        };
        ObjectExtensions.<MutableTypeParameterDeclaration>operator_doubleArrow(_addTypeParameter, _function_7);
    };
    ObjectExtensions.<MutableInterfaceDeclaration>operator_doubleArrow(_findInterface, _function_4);
    final Procedure0 _function_5 = () -> {
        it.addTypeParameter("T", type);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_5);
    MutableTypeParameterDeclaration _addTypeParameter = it.addTypeParameter("T");
    final Procedure1<MutableTypeParameterDeclaration> _function_6 = (MutableTypeParameterDeclaration it_1) -> {
        final Procedure0 _function_7 = () -> {
            Iterable<? extends TypeReference> _upperBounds = it_1.getUpperBounds();
            Iterable<TypeReference> _plus = Iterables.<TypeReference>concat(_upperBounds, Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList(type)));
            it_1.setUpperBounds(_plus);
        };
        MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "Cannot use inferred type as parameter type.", _function_7);
    };
    ObjectExtensions.<MutableTypeParameterDeclaration>operator_doubleArrow(_addTypeParameter, _function_6);
}
Also used : MutableFieldDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration) MutableMethodDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration) MutableTypeParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration) MutableInterfaceDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference)

Aggregations

Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)188 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)101 Test (org.junit.Test)100 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)32 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)20 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)20 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)20 EList (org.eclipse.emf.common.util.EList)18 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)18 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)16 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)16 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)15 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)14 EObject (org.eclipse.emf.ecore.EObject)13 IDList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.IDList)13 ISemanticRegion (org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion)11 Method (java.lang.reflect.Method)10 Resource (org.eclipse.emf.ecore.resource.Resource)10 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)10 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)10