Search in sources :

Example 6 with MutableTypeParameterDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration 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 7 with MutableTypeParameterDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration in project xtext-xtend by eclipse.

the class AbstractReusableActiveAnnotationTests method testModifyTypeParameters.

@Test
public void testModifyTypeParameters() {
    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("if (typeParameters.size != 0) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"Before: typeParameters.size != 0\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("addTypeParameter(\"T\", String.newTypeReference)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (typeParameters.size != 1) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"After: typeParameters.size != 1\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val typeParameter = typeParameters.head");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (!typeParameter.simpleName.equals(\"T\")) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"After: expected type name: \'T\', actual type name: \'\" + typeParameter.simpleName + \"\'\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _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 {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("new() {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("interface MyInterface {");
    _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 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("T", typeParameter.getSimpleName());
            Assert.assertEquals(1, IterableExtensions.size(typeParameter.getUpperBounds()));
            Assert.assertEquals("java.lang.String", IterableExtensions.head(typeParameter.getUpperBounds()).getName());
        };
        final Procedure1<? super MutableTypeParameterDeclarator> assertMyAnnotationChanges = _function_1;
        final MutableClassDeclaration clazz = it.getTypeLookup().findClass("myusercode.MyClass");
        assertMyAnnotationChanges.apply(clazz);
        assertMyAnnotationChanges.apply(IterableExtensions.head(clazz.getDeclaredConstructors()));
        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) MutableClassDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration) Test(org.junit.Test)

Example 8 with MutableTypeParameterDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration in project xtext-xtend by eclipse.

the class AbstractReusableActiveAnnotationTests method testModifyTypeParameters.

@Test
public void testModifyTypeParameters() {
    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("if (typeParameters.size != 0) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"Before: typeParameters.size != 0\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("addTypeParameter(\"T\", String.newTypeReference)");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (typeParameters.size != 1) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"After: typeParameters.size != 1\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val typeParameter = typeParameters.head");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (!typeParameter.simpleName.equals(\"T\")) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"After: expected type name: \'T\', actual type name: \'\" + typeParameter.simpleName + \"\'\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _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 {");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("new() {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("interface MyInterface {");
    _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 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("T", typeParameter.getSimpleName());
            Assert.assertEquals(1, IterableExtensions.size(typeParameter.getUpperBounds()));
            Assert.assertEquals("java.lang.String", IterableExtensions.head(typeParameter.getUpperBounds()).getName());
        };
        final Procedure1<? super MutableTypeParameterDeclarator> assertMyAnnotationChanges = _function_1;
        final MutableClassDeclaration clazz = it.getTypeLookup().findClass("myusercode.MyClass");
        assertMyAnnotationChanges.apply(clazz);
        assertMyAnnotationChanges.apply(IterableExtensions.head(clazz.getDeclaredConstructors()));
        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) MutableClassDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration) Test(org.junit.Test)

Example 9 with MutableTypeParameterDeclaration

use of org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration in project xtext-xtend by eclipse.

the class CheckMutableClassDeclarationProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    final Procedure0 _function = () -> {
        annotatedClass.setImplementedInterfaces(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot be null", _function);
    final Procedure0 _function_1 = () -> {
        annotatedClass.setImplementedInterfaces(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot contain null", _function_1);
    annotatedClass.setImplementedInterfaces(CollectionLiterals.<TypeReference>emptyList());
    final Procedure1<String> _function_2 = (String identifier) -> {
        annotatedClass.addTypeParameter(identifier).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_2);
    final Procedure0 _function_3 = () -> {
        annotatedClass.addTypeParameter("T", ((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_3);
    final Procedure0 _function_4 = () -> {
        annotatedClass.addTypeParameter("T", new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_4);
    final MutableTypeParameterDeclaration typeParameter = annotatedClass.addTypeParameter("T");
    final Procedure1<String> _function_5 = (String identifier) -> {
        typeParameter.setSimpleName(identifier);
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_5);
    final Procedure0 _function_6 = () -> {
        typeParameter.setUpperBounds(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_6);
    final Procedure0 _function_7 = () -> {
        typeParameter.setUpperBounds(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_7);
    typeParameter.setUpperBounds(CollectionLiterals.<TypeReference>emptyList());
    final Procedure0 _function_8 = () -> {
        annotatedClass.setSimpleName(null);
    };
    MutableAssert.<UnsupportedOperationException>assertThrowable(UnsupportedOperationException.class, "The type cannot be renamed.", _function_8);
    final Procedure1<String> _function_9 = (String identifier) -> {
        final Procedure1<MutableFieldDeclaration> _function_10 = (MutableFieldDeclaration it) -> {
            it.setType(context.newTypeReference(String.class));
        };
        annotatedClass.addField(identifier, _function_10).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_9);
    final Procedure0 _function_10 = () -> {
        annotatedClass.addField("foo", null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_10);
    final Procedure1<String> _function_11 = (String identifier) -> {
        final Procedure1<MutableMethodDeclaration> _function_12 = (MutableMethodDeclaration it) -> {
        };
        annotatedClass.addMethod(identifier, _function_12).remove();
    };
    MutableAssert.assertValidJavaIdentifier("name", _function_11);
    final Procedure0 _function_12 = () -> {
        annotatedClass.addMethod("foo", null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_12);
    final Procedure0 _function_13 = () -> {
        annotatedClass.addConstructor(null);
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_13);
    final Procedure1<MutableMethodDeclaration> _function_14 = (MutableMethodDeclaration it) -> {
    };
    final MutableMethodDeclaration method = annotatedClass.addMethod("foo", _function_14);
    annotatedClass.findDeclaredMethod(null);
    annotatedClass.findDeclaredMethod("foo");
    final Procedure0 _function_15 = () -> {
        annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_15);
    final Procedure0 _function_16 = () -> {
        annotatedClass.findDeclaredMethod("foo", new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_16);
    annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
    method.remove();
    final Procedure0 _function_17 = () -> {
        annotatedClass.findDeclaredConstructor(((TypeReference[]) null));
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_17);
    final Procedure0 _function_18 = () -> {
        annotatedClass.findDeclaredConstructor(new TypeReference[] { null });
    };
    MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_18);
    annotatedClass.findDeclaredConstructor(((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
}
Also used : Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) MutableFieldDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) MutableMethodDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) MutableTypeParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration)

Aggregations

MutableTypeParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration)9 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)6 MutableInterfaceDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration)5 TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)5 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)4 MutableTypeParameterDeclarator (org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclarator)4 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)4 Test (org.junit.Test)4 TypeParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.TypeParameterDeclaration)3 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)3 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)3 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)3 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)2 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)2 MutableMethodDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration)2 Procedure0 (org.eclipse.xtext.xbase.lib.Procedures.Procedure0)2