use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method addDefaultConstructor.
protected void addDefaultConstructor(XtendClass source, JvmGenericType target) {
for (XtendMember member : source.getMembers()) {
if (member instanceof XtendConstructor)
return;
}
JvmConstructor constructor = typesFactory.createJvmConstructor();
target.getMembers().add(constructor);
associator.associate(source, constructor);
constructor.setSimpleName(source.getName());
constructor.setVisibility(JvmVisibility.PUBLIC);
typeExtensions.setSynthetic(constructor, true);
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_016.
@Test
public void testErrorModel_016() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class <T> {");
_builder.newLine();
_builder.append("\t");
_builder.append("val String s");
_builder.newLine();
_builder.append(" ");
_builder.append("new(String ^new) {");
_builder.newLine();
_builder.append(" ");
_builder.append("s = ^new");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration unnamed = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _last = IterableExtensions.<XtendMember>last(unnamed.getMembers());
final XtendConstructor constructor = ((XtendConstructor) _last);
XExpression _expression = constructor.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions());
final XAssignment assignment = ((XAssignment) _head);
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(assignment);
Assert.assertNotNull(resolvedTypes.getActualType(assignment));
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class ParserTest method testConstructor_01.
@Test
public void testConstructor_01() throws Exception {
XtendConstructor constructor = constructor("new() {}");
assertTrue(constructor.getTypeParameters().isEmpty());
assertTrue(constructor.getExceptions().isEmpty());
assertTrue(constructor.getParameters().isEmpty());
assertEquals(JvmVisibility.PUBLIC, constructor.getVisibility());
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class TypeProviderTest method constructor.
protected XtendConstructor constructor(String string, boolean validate) throws Exception {
String clazzString = "class Foo { " + string + "}";
XtendClass clazz = (XtendClass) file(clazzString, validate).getXtendTypes().get(0);
return (XtendConstructor) clazz.getMembers().get(0);
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class TypeProviderTest method testReturnTypeInConstructor_01.
@Test
public void testReturnTypeInConstructor_01() throws Exception {
XtendConstructor constructor = constructor("new() {\n" + " ''.toString\n" + "}\n");
XBlockExpression body = (XBlockExpression) constructor.getExpression();
assertEquals("void", getExpectedType(body).getIdentifier());
assertEquals("void", getExpectedReturnType(body).getIdentifier());
XMemberFeatureCall toString = (XMemberFeatureCall) body.getExpressions().get(0);
assertNull(getExpectedType(toString));
assertNull(getExpectedReturnType(toString));
}
Aggregations