Search in sources :

Example 81 with XtendMember

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);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XConstructorCall(org.eclipse.xtext.xbase.XConstructorCall) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 82 with XtendMember

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);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XVariableDeclaration(org.eclipse.xtext.xbase.XVariableDeclaration) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 83 with XtendMember

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);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 84 with XtendMember

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);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 85 with XtendMember

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);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Aggregations

XtendMember (org.eclipse.xtend.core.xtend.XtendMember)175 Test (org.junit.Test)140 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)131 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)119 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)101 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)91 XExpression (org.eclipse.xtext.xbase.XExpression)84 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)57 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)56 XtendField (org.eclipse.xtend.core.xtend.XtendField)33 EObject (org.eclipse.emf.ecore.EObject)17 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)15 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)14 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)12 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)12 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)10 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)9 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)8 JvmType (org.eclipse.xtext.common.types.JvmType)8