use of org.eclipse.xtend.core.xtend.XtendMember in project xtext-xtend by eclipse.
the class XtendHoverSignatureProviderTest method testSignatureForXtendField.
@Test
public void testSignatureForXtendField() {
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("@Inject");
_builder.newLine();
_builder.append("\t");
_builder.append("Collections collections");
_builder.newLine();
_builder.append("\t");
_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 XtendField xtendField = ((XtendField) _get);
final String signature = this.signatureProvider.getSignature(xtendField);
Assert.assertEquals("Collections collections", 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 testSignatureForXtendConstructor.
@Test
public void testSignatureForXtendConstructor() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("new(String a, int b){}");
_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 xtendConstructor = clazz.getMembers().get(0);
final String signature = this.signatureProvider.getSignature(xtendConstructor);
Assert.assertEquals("Foo(String a, int b)", 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_03.
@Test
public void testSignatureForAnonymousClassLocalVarTypeTest_03() {
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 = newArrayList(new Runnable { override run() {} })");
_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("ArrayList<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 testAutcastExpressions_2.
@Test
public void testAutcastExpressions_2() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package testPackage");
_builder.newLine();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("CharSequence c = \"\"");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() {");
_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());
Assert.assertEquals("CharSequence c", this.signatureProvider.getSignature(IterableExtensions.<XtendMember>head(((XtendClass) _head).getMembers())));
XtendTypeDeclaration _head_1 = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes());
XtendMember _get = ((XtendClass) _head_1).getMembers().get(1);
final XtendFunction func = ((XtendFunction) _get);
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 Foo.c", this.signatureProvider.getSignature(target));
XExpression _get_1 = block.getExpressions().get(1);
final XSwitchExpression switchExpr = ((XSwitchExpression) _get_1);
XExpression _then = IterableExtensions.<XCasePart>head(switchExpr.getCases()).getThen();
final XExpression expr = ((XMemberFeatureCall) _then).getMemberCallTarget();
Assert.assertEquals("String Foo.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 testSignatureForAnonymousClassLocalVarTypeTest.
@Test
public void testSignatureForAnonymousClassLocalVarTypeTest() {
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() {} }");
_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);
}
}
Aggregations