Search in sources :

Example 96 with XtendMember

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

the class XtendUnsugaredHoverTest method testBug414204_1.

@Test
public void testBug414204_1() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package testpackage");
    _builder.newLine();
    _builder.append("import static testpackage.Bar.*");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def stuff(){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("doStaticStuff()");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("class Bar {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def static void doStaticStuff(){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(0);
    final XtendFunction function = ((XtendFunction) _get);
    XExpression _expression = function.getExpression();
    final XBlockExpression block = ((XBlockExpression) _expression);
    final XExpression call = block.getExpressions().get(0);
    Assert.assertEquals("", this.serializer.computeUnsugaredExpression(call));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 97 with XtendMember

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

the class XtendUnsugaredHoverTest method testUnsuagaredVersionForXtendFunction_9.

@Test
public void testUnsuagaredVersionForXtendFunction_9() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package testpackage");
    _builder.newLine();
    _builder.append("import java.util.ArrayList");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Extension");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def baz(String it){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("substring(0)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
    final XtendFunction function = ((XtendFunction) _get);
    XExpression _expression = function.getExpression();
    final XBlockExpression block = ((XBlockExpression) _expression);
    final XExpression call = block.getExpressions().get(0);
    Assert.assertEquals("it.substring(0)", this.serializer.computeUnsugaredExpression(call));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 98 with XtendMember

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

the class XtendUnsugaredHoverTest method testBug373054.

@Test
public void testBug373054() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package testpackage");
    _builder.newLine();
    _builder.append("import static extension testpackage.Extension.*");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def bar(){}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def baz(String it, String s){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("zonk = s + s + s");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
    final XtendFunction function = ((XtendFunction) _get);
    XExpression _expression = function.getExpression();
    final XBlockExpression block = ((XBlockExpression) _expression);
    final XExpression call = block.getExpressions().get(0);
    Assert.assertEquals("Extension.setZonk(it, s + s + s)", this.serializer.computeUnsugaredExpression(call));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 99 with XtendMember

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

the class XtendUnsugaredHoverTest method testUnsuagaredVersionForXtendFunction_5.

@Test
public void testUnsuagaredVersionForXtendFunction_5() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package testpackage");
    _builder.newLine();
    _builder.append("import java.util.ArrayList");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension Extension");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def baz(Integer it){");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("new ArrayList<String>().bar(42)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
    final XtendFunction function = ((XtendFunction) _get);
    XExpression _expression = function.getExpression();
    final XBlockExpression block = ((XBlockExpression) _expression);
    final XExpression call = block.getExpressions().get(0);
    Assert.assertEquals("this._extension.bar(new ArrayList<String>(), 42)", this.serializer.computeUnsugaredExpression(call));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 100 with XtendMember

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

the class XtendUnsugaredHoverTest method testBug380361_1.

@Test
public void testBug380361_1() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package testpackage");
    _builder.newLine();
    _builder.append("import static java.lang.Integer.*");
    _builder.newLine();
    _builder.append("import static extension java.lang.String.*");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void foo(String it) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("valueOf()");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("valueOf(it)");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(0);
    final XtendFunction function = ((XtendFunction) _get);
    XExpression _expression = function.getExpression();
    final XBlockExpression block = ((XBlockExpression) _expression);
    final XExpression call = block.getExpressions().get(0);
    final XExpression call2 = block.getExpressions().get(1);
    Assert.assertEquals("String.valueOf(it)", this.serializer.computeUnsugaredExpression(call));
    Assert.assertEquals("", this.serializer.computeUnsugaredExpression(call2));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Aggregations

XtendMember (org.eclipse.xtend.core.xtend.XtendMember)175 Test (org.junit.Test)140 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)131 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)119 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)101 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)91 XExpression (org.eclipse.xtext.xbase.XExpression)84 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)57 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)56 XtendField (org.eclipse.xtend.core.xtend.XtendField)33 EObject (org.eclipse.emf.ecore.EObject)17 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)15 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)14 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)12 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)12 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)10 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)9 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)8 JvmType (org.eclipse.xtext.common.types.JvmType)8