use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureDelegateConstructorCall_02.
@Ignore
@Test
public void testSignatureDelegateConstructorCall_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo<S extends CharSequence> {");
_builder.newLine();
_builder.append("\t");
_builder.append("new(int i) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("this(StringBuilder)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("new<X>(Class<X> c) {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
XtendMember _get = clazz.getMembers().get(0);
final XtendConstructor xtendConstructor = ((XtendConstructor) _get);
XExpression _expression = xtendConstructor.getExpression();
XExpression _get_1 = ((XBlockExpression) _expression).getExpressions().get(0);
final XFeatureCall featureCall = ((XFeatureCall) _get_1);
final String signature = this.signatureProvider.getSignature(featureCall);
Assert.assertEquals("Foo<S>()", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureDelegateConstructorCall_01.
@Ignore
@Test
public void testSignatureDelegateConstructorCall_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo<S extends CharSequence> {");
_builder.newLine();
_builder.append("\t");
_builder.append("new(int i) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("this()");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("new() {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
final XtendClass clazz = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class));
XtendMember _get = clazz.getMembers().get(0);
final XtendConstructor xtendConstructor = ((XtendConstructor) _get);
XExpression _expression = xtendConstructor.getExpression();
XExpression _get_1 = ((XBlockExpression) _expression).getExpressions().get(0);
final XFeatureCall featureCall = ((XFeatureCall) _get_1);
final String signature = this.signatureProvider.getSignature(featureCall);
Assert.assertEquals("Foo<S>()", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class JavaConverterTest method testForceStatementForTargetObject.
@Test
public void testForceStatementForTargetObject() {
Assert.assertFalse("Not a statement before annotation", this.j2x.shouldForceStatementMode(new XAnnotationsFactoryImpl().createXAnnotation()));
final XtendConstructor xc = new XtendFactoryImpl().createXtendConstructor();
Assert.assertFalse("Not a statement before constructor", this.j2x.shouldForceStatementMode(xc));
final XBlockExpression block = new XbaseFactoryImpl().createXBlockExpression();
xc.setExpression(block);
Assert.assertTrue("Force statement when parent is executable", this.j2x.shouldForceStatementMode(block));
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class RenameStrategyTest method testXtendConstructorIgnored.
@Test
public void testXtendConstructorIgnored() throws Exception {
XtendConstructor constructor = (XtendConstructor) ((XtendClass) testHelper.xtendFile("Foo", "class Foo { new() {} }").getXtendTypes().get(0)).getMembers().get(0);
IRenameStrategy renameStrategy = createRenameStrategy(constructor);
assertNull(renameStrategy);
}
use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.
the class LinkingTest method testDeclaredConstructor_01.
@Test
public void testDeclaredConstructor_01() throws Exception {
XtendClass clazz = clazz("class Foo { " + " int i" + " new(int i) { this.i = i }" + "}");
assertEquals(2, clazz.getMembers().size());
XtendConstructor constructor = (XtendConstructor) clazz.getMembers().get(1);
XAssignment assignment = (XAssignment) ((XBlockExpression) constructor.getExpression()).getExpressions().get(0);
JvmField field = (JvmField) assignment.getFeature();
assertEquals("i", field.getSimpleName());
XFeatureCall target = (XFeatureCall) assignment.getAssignable();
JvmDeclaredType identifiableElement = (JvmDeclaredType) target.getFeature();
assertEquals("Foo", identifiableElement.getSimpleName());
XFeatureCall value = (XFeatureCall) assignment.getValue();
JvmFormalParameter parameter = (JvmFormalParameter) value.getFeature();
assertEquals("i", parameter.getSimpleName());
}
Aggregations