Search in sources :

Example 26 with XtendConstructor

use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.

the class XtendValidationTest method testVarArgMustBeLast_3.

@Test
public void testVarArgMustBeLast_3() throws Exception {
    XtendConstructor constr = constructor("new(int x, String... myParam) { }");
    helper.assertNoErrors(constr);
}
Also used : XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) Test(org.junit.Test)

Example 27 with XtendConstructor

use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.

the class XtendCopyQualifiedNameServiceTest method testJvmConstructor_4.

@Test
public void testJvmConstructor_4() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new () {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("this(<String>newArrayList)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (java.util.List<?> list) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
        final XtendTypeDeclaration xtendType = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
        XtendMember _head = IterableExtensions.<XtendMember>head(xtendType.getMembers());
        XExpression _expression = ((XtendConstructor) _head).getExpression();
        final XBlockExpression expression = ((XBlockExpression) _expression);
        this.assertCopyQualifiedName(expression.getExpressions().get(0), "Foo(ArrayList<String>)");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 28 with XtendConstructor

use of org.eclipse.xtend.core.xtend.XtendConstructor in project xtext-xtend by eclipse.

the class XtendCopyQualifiedNameServiceTest method testJvmConstructor_3.

@Test
public void testJvmConstructor_3() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo extends Bar {");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (java.util.List<?> list) {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("super(list)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new () {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("super(<String>newArrayList)");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("class Bar {");
        _builder.newLine();
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new (java.util.List<?> list) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
        final XtendTypeDeclaration xtendType = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
        XtendMember _head = IterableExtensions.<XtendMember>head(xtendType.getMembers());
        XExpression _expression = ((XtendConstructor) _head).getExpression();
        final XBlockExpression expression = ((XBlockExpression) _expression);
        this.assertCopyQualifiedName(expression.getExpressions().get(0), "Bar(List<?>)");
        XtendMember _head_1 = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendMember>tail(xtendType.getMembers()));
        XExpression _expression_1 = ((XtendConstructor) _head_1).getExpression();
        final XBlockExpression expression2 = ((XBlockExpression) _expression_1);
        this.assertCopyQualifiedName(expression2.getExpressions().get(0), "Bar(ArrayList<String>)");
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Aggregations

XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)28 Test (org.junit.Test)18 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)9 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)9 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)7 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)7 XExpression (org.eclipse.xtext.xbase.XExpression)7 XtendField (org.eclipse.xtend.core.xtend.XtendField)6 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)6 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)5 XtendEnumLiteral (org.eclipse.xtend.core.xtend.XtendEnumLiteral)3 EObject (org.eclipse.emf.ecore.EObject)2 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)2 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)2 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)2 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)2 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)2