use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureConstructorCall_02.
@Test
public void testSignatureConstructorCall_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo<S> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Foo(StringBuilder, StringBuffer)");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("new <X>(Class<X> c, Class<S> c2) {}");
_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 XtendFunction xtendFunction = ((XtendFunction) _get);
XExpression _expression = xtendFunction.getExpression();
XExpression _get_1 = ((XBlockExpression) _expression).getExpressions().get(0);
final XConstructorCall constructorCall = ((XConstructorCall) _get_1);
final String signature = this.signatureProvider.getSignature(constructorCall);
Assert.assertEquals("<StringBuilder> Foo<StringBuffer>(Class<StringBuilder> c, Class<StringBuffer> c2)", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForAnonymousClassLocalVarTypeTest_02.
@Test
public void testSignatureForAnonymousClassLocalVarTypeTest_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.newLine();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("val r = new Runnable { override run() {} def void m() {} }");
_builder.newLine();
_builder.append("\t\t");
_builder.append("r");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_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 XtendFunction function = ((XtendFunction) _get);
XExpression _expression = function.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions());
final XVariableDeclaration variable = ((XVariableDeclaration) _head);
final String signature = this.signatureProvider.getSignature(variable);
Assert.assertEquals("new Runnable(){} r", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testBug378082.
@Test
public void testBug378082() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("@Data");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("int id");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch void a(int i){}");
_builder.newLine();
_builder.append("\t");
_builder.append("def dispatch void a(int i){}");
_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));
final XtendMember field = IterableExtensions.<XtendMember>head(clazz.getMembers());
final XtendMember function = clazz.getMembers().get(1);
final String fieldSignature = this.signatureProvider.getSignature(field);
Assert.assertEquals("int id", fieldSignature);
final String functionSignature = this.signatureProvider.getSignature(function);
Assert.assertEquals("void a(int i)", functionSignature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testEnumReference.
@Test
public void testEnumReference() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("def baz(Foo f){}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("enum Foo { BAR, BAZ }");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendMember _head = IterableExtensions.<XtendMember>head(IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers());
final JvmType en = IterableExtensions.<XtendParameter>head(((XtendFunction) _head).getParameters()).getParameterType().getType();
Assert.assertEquals("Foo", this.signatureProvider.getSignature(en));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForExtensionFieldWithoutName.
@Test
public void testSignatureForExtensionFieldWithoutName() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("import java.util.Collections");
_builder.newLine();
_builder.append("import com.google.inject.Inject");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("extension String");
_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 XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("String", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations