use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration 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.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendCopyQualifiedNameServiceTest method testXtendConstructor_2.
@Test
public void testXtendConstructor_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo<T> {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("new (java.util.List<T> 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());
this.assertCopyQualifiedName(IterableExtensions.<XtendMember>head(xtendType.getMembers()), "Foo(List<T>)");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendCopyQualifiedNameServiceTest method testXtendConstructor_3.
@Test
public void testXtendConstructor_3() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo<X, Y> {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("new (X x, Y y) {");
_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(X, Y)");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration 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.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class JdtFindReferencesTest method testClassJavaElements.
@Test
public void testClassJavaElements() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Xtend {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendTypeDeclaration clazz = IterableExtensions.<XtendTypeDeclaration>head(this._workbenchTestHelper.xtendFile("Xtend.xtend", _builder.toString()).getXtendTypes());
IResourcesSetupUtil.waitForBuild();
Iterable<IJavaElement> _javaElements = this._jvmModelFindReferenceHandler.getJavaElements(clazz);
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 IType) && Objects.equal(((IType) it_1).getElementName(), "Xtend")));
};
Assert.assertTrue(IterableExtensions.<IJavaElement>exists(it, _function_1));
};
ObjectExtensions.<Iterable<IJavaElement>>operator_doubleArrow(_javaElements, _function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations