use of org.eclipse.xtend.lib.macro.declaration.TypeParameterDeclaration in project xtext-xtend by eclipse.
the class AbstractReusableActiveAnnotationTests method testBug441081.
@Test
public void testBug441081() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package bug441081");
_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.TransformationContext");
_builder.newLine();
_builder.append("import org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration");
_builder.newLine();
_builder.newLine();
_builder.append("interface GenericInterface {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <T> T m()");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("@Active(Bug441081Processor)");
_builder.newLine();
_builder.append("annotation Bug441081 {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("class Bug441081Processor extends AbstractClassProcessor {");
_builder.newLine();
_builder.append("\t");
_builder.append("override doTransform(MutableClassDeclaration annotatedClass, extension TransformationContext context) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("annotatedClass.implementedInterfaces = annotatedClass.implementedInterfaces + #[findTypeGlobally(GenericInterface).newTypeReference]");
_builder.newLine();
_builder.append("\t\t");
_builder.append("annotatedClass.addMethod(\"m\") [");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("returnType = addTypeParameter(\"T\", object).newTypeReference");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("body = \'");
_builder.append("\'\'return null;\'");
_builder.append("\'\'");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("primarySourceElement = annotatedClass");
_builder.newLine();
_builder.append("\t\t");
_builder.append("]");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
Pair<String, String> _mappedTo = Pair.<String, String>of("bug441081/Bug441081.xtend", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("import bug441081.Bug441081");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("@Bug441081");
_builder_1.newLine();
_builder_1.append("class Bug441081Client {");
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
Pair<String, String> _mappedTo_1 = Pair.<String, String>of("Bug441081Client.xtend", _builder_1.toString());
final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> {
final MutableClassDeclaration c = it.getTypeLookup().findClass("Bug441081Client");
Type _type = c.findDeclaredMethod("m").getReturnType().getType();
final TypeParameterDeclaration typeParam = ((TypeParameterDeclaration) _type);
Assert.assertFalse(IterableExtensions.isEmpty(typeParam.getUpperBounds()));
this.validator.assertNoIssues(it.getXtendFile());
};
this.assertProcessing(_mappedTo, _mappedTo_1, _function);
}
Aggregations