use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendCopyQualifiedNameServiceTest method testJvmOperation_2.
@Test
public void testJvmOperation_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(java.util.Map<? extends String, ? extends String> map) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("map.get(null)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("map.put(null, null)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("bar(map)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("def <K, V> void bar(java.util.Map<K, V> map) {");
_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 = ((XtendFunction) _head).getExpression();
final XBlockExpression expression = ((XBlockExpression) _expression);
this.assertCopyQualifiedName(expression.getExpressions().get(0), "java.util.Map.get(Object)");
this.assertCopyQualifiedName(expression.getExpressions().get(1), "java.util.Map.put(? extends String, ? extends String)");
this.assertCopyQualifiedName(expression.getExpressions().get(2), "Foo.bar(Map<? extends String, ? extends String>)");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendCopyQualifiedNameServiceTest method testXtendFunction_3.
@Test
public void testXtendFunction_3() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo extends java.util.ArrayList<String> {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override clear () {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super.clear");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("override add(String value) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("super.add(value)");
_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());
this.assertCopyQualifiedName(IterableExtensions.<XtendMember>head(xtendType.getMembers()), "Foo.clear()");
this.assertCopyQualifiedName(IterableExtensions.<XtendMember>head(IterableExtensions.<XtendMember>tail(xtendType.getMembers())), "Foo.add(String)");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JdtFindReferencesTest method testFieldJavaElements.
@Test
public void testFieldJavaElements() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Xtend {");
_builder.newLine();
_builder.append("\t");
_builder.append("int foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendMember field = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes(), XtendClass.class)).getMembers());
IResourcesSetupUtil.waitForBuild();
Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(field);
final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
Assert.assertEquals(1, IterableExtensions.size(it));
final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
return Boolean.valueOf(((it_1 instanceof IField) && Objects.equal(((IField) it_1).getElementName(), "foo")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
};
ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JdtFindReferencesTest method testPropertyJavaElements.
@Test
public void testPropertyJavaElements() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Xtend {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Property int foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendMember field = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes(), XtendClass.class)).getMembers());
IResourcesSetupUtil.waitForBuild();
Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(field);
final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
Assert.assertEquals(3, IterableExtensions.size(it));
final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
return Boolean.valueOf(((it_1 instanceof IMethod) && Objects.equal(((IMethod) it_1).getElementName(), "getFoo")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
final Function1<IJavaElement, Boolean> _function_2 = (IJavaElement it_1) -> {
return Boolean.valueOf(((it_1 instanceof IMethod) && Objects.equal(((IMethod) it_1).getElementName(), "setFoo")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_2));
final Function1<IJavaElement, Boolean> _function_3 = (IJavaElement it_1) -> {
return Boolean.valueOf(((it_1 instanceof IField) && Objects.equal(((IField) it_1).getElementName(), "_foo")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_3));
};
ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class JdtFindReferencesTest method testMethodJavaElements.
@Test
public void testMethodJavaElements() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Xtend {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendMember method = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes(), XtendClass.class)).getMembers());
IResourcesSetupUtil.waitForBuild();
Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(method);
final Procedure1<Iterable<IJavaElement>> _function = (Iterable<IJavaElement> it) -> {
Assert.assertEquals(1, IterableExtensions.size(it));
final Function1<IJavaElement, Boolean> _function_1 = (IJavaElement it_1) -> {
return Boolean.valueOf(((it_1 instanceof IMethod) && Objects.equal(((IMethod) it_1).getElementName(), "foo")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
};
ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations