use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureConstructorCall_01.
@Test
public void testSignatureConstructorCall_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo<S extends CharSequence> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Foo()");
_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 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("Foo<CharSequence>()", 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 testSignatureConstructorCall_03.
@Test
public void testSignatureConstructorCall_03() {
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<String>()");
_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 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("Foo<String>()", 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 testSignatureForXtendParameter.
@Test
public void testSignatureForXtendParameter() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(String a) throws NullPointerException");
_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);
final XtendParameter xtendParameter = xtendFunction.getParameters().get(0);
final String signature = this.signatureProvider.getSignature(xtendParameter);
Assert.assertEquals("String a - bar(String)", 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 testAutcastExpressions_3.
@Test
public void testAutcastExpressions_3() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(CharSequence c) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (c instanceof String) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("c.substring(1, 1)");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("switch(c){");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("String : c.length");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile xtendFile = this.parseHelper.parse(_builder, this.getResourceSet());
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(((XtendClass) _head).getMembers());
final XtendFunction func = ((XtendFunction) _head_1);
Assert.assertEquals("CharSequence c - foo(CharSequence)", this.signatureProvider.getSignature(IterableExtensions.<XtendParameter>head(func.getParameters())));
XExpression _expression = func.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
XExpression _head_2 = IterableExtensions.<XExpression>head(block.getExpressions());
final XIfExpression ifexpr = ((XIfExpression) _head_2);
final XExpression then = ifexpr.getThen();
XExpression _head_3 = IterableExtensions.<XExpression>head(((XBlockExpression) then).getExpressions());
final XExpression target = ((XMemberFeatureCall) _head_3).getMemberCallTarget();
Assert.assertEquals("String c", this.signatureProvider.getSignature(target));
XExpression _get = block.getExpressions().get(1);
final XSwitchExpression switchExpr = ((XSwitchExpression) _get);
XExpression _then = IterableExtensions.<XCasePart>head(switchExpr.getCases()).getThen();
final XExpression expr = ((XMemberFeatureCall) _then).getMemberCallTarget();
Assert.assertEquals("String c", this.signatureProvider.getSignature(expr));
} 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 testSignatureForXtendDefaultConstructor.
@Test
public void testSignatureForXtendDefaultConstructor() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar(){");
_builder.newLine();
_builder.append("\t");
_builder.append("new Foo()");
_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 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.getConstructor());
Assert.assertEquals("Foo()", signature);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations