use of org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl 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);
}
use of org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl in project xtext-xtend by eclipse.
the class AbstractReusableActiveAnnotationTests method testDeterministicExecutionOrder_02.
@Test
public void testDeterministicExecutionOrder_02() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import myannotation.*");
_builder.newLine();
_builder.append("class MyClass {");
_builder.newLine();
_builder.append("\t");
_builder.append("@_A @_B @_C String field1");
_builder.newLine();
_builder.append("\t");
_builder.append("@_C @_B @_A String field2");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("MyClass.xtend", _builder.toString());
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
final MutableClassDeclaration myClass = it.getTypeLookup().findClass("MyClass");
Assert.assertEquals("field1_A_B_C", IterableExtensions.head(myClass.getDeclaredFields()).getSimpleName());
Assert.assertEquals("field2_A_B_C", ((MutableFieldDeclaration[]) Conversions.unwrapArray(myClass.getDeclaredFields(), MutableFieldDeclaration.class))[1].getSimpleName());
};
this.assertProcessing(this.THREE_ANNOTATIONS, _mappedTo, _function);
}
use of org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl in project xtext-xtend by eclipse.
the class AbstractReusableActiveAnnotationTests method testAccessAndModifyEnumerationValueDeclaration.
@Test
public void testAccessAndModifyEnumerationValueDeclaration() {
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.CodeGenerationContext");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.CodeGenerationParticipant");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.RegisterGlobalsContext");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.RegisterGlobalsParticipant");
_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.EnumerationTypeDeclaration");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.MutableEnumerationTypeDeclaration");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.TypeDeclaration");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.Visibility");
_builder.newLine();
_builder.newLine();
_builder.append("import static com.google.common.base.Preconditions.*");
_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 RegisterGlobalsParticipant<EnumerationTypeDeclaration>, TransformationParticipant<MutableEnumerationTypeDeclaration>, CodeGenerationParticipant<EnumerationTypeDeclaration> {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override doGenerateCode(List<? extends EnumerationTypeDeclaration> annotatedSourceElements,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("extension CodeGenerationContext context) {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override doRegisterGlobals(List<? extends EnumerationTypeDeclaration> annotatedSourceElements,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("RegisterGlobalsContext context) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for (enumeration : annotatedSourceElements) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("enumeration.checkState");
_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 checkState(EnumerationTypeDeclaration enumeration) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("val values = enumeration.declaredValues");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(values.size == 3, \"enumeration.declaredValues.size != 3\")");
_builder.newLine();
_builder.append("\t\t");
_builder.append("enumeration.findDeclaredValue(values.get(0).simpleName).checkState(\"A\", enumeration)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("enumeration.findDeclaredValue(values.get(1).simpleName).checkState(\"B\", enumeration)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("enumeration.findDeclaredValue(values.get(2).simpleName).checkState(\"C\", enumeration)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("def checkState(EnumerationValueDeclaration value, String expectedSimpleName, TypeDeclaration expectedType) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(value.simpleName == expectedSimpleName, \"value.simpleName != expectedSimpleName\")");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(value.declaringType == expectedType, \"value.declaringType != expectedType\")");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(value.visibility == Visibility.PUBLIC, \"value.visibility != Visibility.PUBLIC\")");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(value.annotations.size == 0, \"value.annotations.size != 0\")");
_builder.newLine();
_builder.append("\t\t");
_builder.append("checkState(value.findAnnotation(null) == null, \"value.findAnnotation(null) != null\")");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override doTransform(List<? extends MutableEnumerationTypeDeclaration> annotatedTargetElements,");
_builder.newLine();
_builder.append("\t\t");
_builder.append("extension TransformationContext context) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for (enumeration : annotatedTargetElements) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("enumeration.checkState");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("for (value : enumeration.declaredValues) {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("checkState(value.annotations.size == 0, value.annotations.size != 0)");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("value.addAnnotation(Deprecated.newAnnotationReference)");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("checkState(value.annotations.size == 1, value.annotations.size != 1)");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("enumeration.addValue(\"D\") [");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("addAnnotation(Deprecated.newAnnotationReference)");
_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.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("enum UserCode {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("A, ");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("B,");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("C");
_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 MutableEnumerationTypeDeclaration enumerationType = it.getTypeLookup().findEnumerationType("myusercode.UserCode");
Assert.assertEquals(4, IterableExtensions.size(enumerationType.getDeclaredValues()));
final Type deprecatedAnnotationType = it.getTypeReferenceProvider().newTypeReference(Deprecated.class).getType();
Iterable<? extends MutableEnumerationValueDeclaration> _declaredValues = enumerationType.getDeclaredValues();
for (final MutableEnumerationValueDeclaration value : _declaredValues) {
{
Assert.assertEquals(1, IterableExtensions.size(value.getAnnotations()));
Assert.assertNotNull(value.findAnnotation(deprecatedAnnotationType));
}
}
Assert.assertEquals("D", IterableExtensions.last(enumerationType.getDeclaredValues()).getSimpleName());
Assert.assertNotNull(enumerationType.findDeclaredValue("D"));
};
this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
use of org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl in project xtext-xtend by eclipse.
the class AbstractReusableActiveAnnotationTests method testAnnotationArrayValueGetting_01.
@Test
public void testAnnotationArrayValueGetting_01() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package myannotation");
_builder.newLine();
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.AbstractClassProcessor");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.Active");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.RegisterGlobalsContext");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.TransformationContext");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.ClassDeclaration");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration");
_builder.newLine();
_builder.newLine();
_builder.append("@Active(MyAnnotationProcessor)");
_builder.newLine();
_builder.append("annotation MyAnnotation {");
_builder.newLine();
_builder.append("\t");
_builder.append("boolean[] value");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class MyAnnotationProcessor extends AbstractClassProcessor {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override doRegisterGlobals(ClassDeclaration it, extension RegisterGlobalsContext context) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("check");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override doTransform(MutableClassDeclaration it, extension TransformationContext context) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("check");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("def check(ClassDeclaration it) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("switch qualifiedName {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("case \'myusercode.UserCode\',");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("case \'myusercode.UserCode2\',");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("case \'myusercode.UserCode4\': {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("val value = annotations.head.getBooleanArrayValue(\"value\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if (value.size != 1) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\"value.size != 1\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if (!value.head) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\"!value.head\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("try {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("annotations.head.getBooleanValue(\"value\")");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\'annotations.head.getBooleanValue(\"value\")\')");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("} catch (Exception e) {");
_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\t");
_builder.append("case \'myusercode.UserCode3\',");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("case \'myusercode.UserCode5\': {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("val value = annotations.head.getBooleanArrayValue(\"value\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if (value.size != 2) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\"value.size != 2\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if (!value.head) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\"!value.head\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if (value.last) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\"value.last\")");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("try {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("annotations.head.getBooleanValue(\"value\")");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("throw new AssertionError(\'annotations.head.getBooleanValue(\"value\")\')");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("} catch (Exception e) {");
_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\t");
_builder.append("default:");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("throw new AssertionError(\'Unexpected type: \' + qualifiedName)");
_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(true)");
_builder_1.newLine();
_builder_1.append("class UserCode {}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("@MyAnnotation(#[true])");
_builder_1.newLine();
_builder_1.append("class UserCode2 {}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("@MyAnnotation(true, false)");
_builder_1.newLine();
_builder_1.append("class UserCode3 {}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("@MyAnnotation(value=true)");
_builder_1.newLine();
_builder_1.append("class UserCode4 {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("@MyAnnotation(value=#[true, false])");
_builder_1.newLine();
_builder_1.append("class UserCode5 {");
_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) -> {
};
this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
use of org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl 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);
}
Aggregations