Search in sources :

Example 46 with XtendInterface

use of org.eclipse.xtend.core.xtend.XtendInterface in project xtext-xtend by eclipse.

the class OverrideValidationTest method testOverrideGenericInterfaceMethod_8.

@Test
public void testOverrideGenericInterfaceMethod_8() throws Exception {
    XtendInterface xtendInterface = interfaze(" import java.util.List interface Foo<T> extends test.GenericSuperTypeInterface<T> {  " + "override <T1, T2 extends T1> getValue8(List<T1> t, List<T2> t2) " + "}");
    helper.assertNoErrors(xtendInterface);
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) Test(org.junit.Test)

Example 47 with XtendInterface

use of org.eclipse.xtend.core.xtend.XtendInterface in project xtext-xtend by eclipse.

the class OverrideValidationTest method testInterfaceOverrideReturnType.

@Test
public void testInterfaceOverrideReturnType() throws Exception {
    XtendInterface xtendInterface = interfaze("interface Foo<T> extends test.GenericSuperTypeInterface<T> {  " + "override <T> T getSomething(T t) " + "}");
    helper.assertNoErrors(xtendInterface);
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) Test(org.junit.Test)

Example 48 with XtendInterface

use of org.eclipse.xtend.core.xtend.XtendInterface in project xtext-xtend by eclipse.

the class XtendJvmModelInferrer method doInferTypeSceleton.

protected JvmDeclaredType doInferTypeSceleton(final XtendTypeDeclaration declaration, final IJvmDeclaredTypeAcceptor acceptor, boolean preIndexingPhase, XtendFile xtendFile, List<Runnable> doLater) {
    if (Strings.isEmpty(declaration.getName()))
        return null;
    if (declaration instanceof XtendAnnotationType) {
        final JvmAnnotationType annotation = typesFactory.createJvmAnnotationType();
        if (!preIndexingPhase) {
            doLater.add(new Runnable() {

                @Override
                public void run() {
                    initialize((XtendAnnotationType) declaration, annotation);
                }
            });
        }
        return annotation;
    } else if (declaration instanceof XtendClass) {
        XtendClass xtendClass = (XtendClass) declaration;
        final JvmGenericType javaType = typesFactory.createJvmGenericType();
        copyTypeParameters(xtendClass.getTypeParameters(), javaType);
        if (!preIndexingPhase) {
            doLater.add(new Runnable() {

                @Override
                public void run() {
                    initialize((XtendClass) declaration, javaType);
                }
            });
        }
        return javaType;
    } else if (declaration instanceof XtendInterface) {
        XtendInterface xtendInterface = (XtendInterface) declaration;
        final JvmGenericType javaType = typesFactory.createJvmGenericType();
        javaType.setInterface(true);
        copyTypeParameters(xtendInterface.getTypeParameters(), javaType);
        if (!preIndexingPhase) {
            doLater.add(new Runnable() {

                @Override
                public void run() {
                    initialize((XtendInterface) declaration, javaType);
                }
            });
        }
        return javaType;
    } else if (declaration instanceof XtendEnum) {
        final JvmEnumerationType javaType = typesFactory.createJvmEnumerationType();
        if (!preIndexingPhase) {
            doLater.add(new Runnable() {

                @Override
                public void run() {
                    initialize((XtendEnum) declaration, javaType);
                }
            });
        }
        return javaType;
    } else {
        return null;
    }
}
Also used : JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) JvmEnumerationType(org.eclipse.xtext.common.types.JvmEnumerationType)

Example 49 with XtendInterface

use of org.eclipse.xtend.core.xtend.XtendInterface in project xtext-xtend by eclipse.

the class JavaConverterTest method testInnerIntefaceCase.

@Test
public void testInnerIntefaceCase() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public class Clazz {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("interface Inner {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("void test();");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("interface Test{}");
    XtendClass type = this.toValidXtendClass(_builder);
    final XtendMember inner = type.getMembers().get(0);
    Assert.assertTrue((inner instanceof XtendInterface));
    final XtendInterface xtendInterfaze = ((XtendInterface) inner);
    Assert.assertEquals(JvmVisibility.PUBLIC, xtendInterfaze.getVisibility());
    Assert.assertEquals(JvmVisibility.PUBLIC, this.method(xtendInterfaze, 0).getVisibility());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 50 with XtendInterface

use of org.eclipse.xtend.core.xtend.XtendInterface in project xtext-xtend by eclipse.

the class JavaConverterTest method testFieldVisibility1.

@Test
public void testFieldVisibility1() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("public interface JavaToConvert {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static String pub;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("final String fin;");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static String def;");
    _builder.newLine();
    _builder.append("}");
    final XtendInterface interfaze = this.toValidXtendInterface(_builder.toString());
    Assert.assertEquals(JvmVisibility.PUBLIC, this.field(interfaze, 0).getVisibility());
    Assert.assertEquals(JvmVisibility.PUBLIC, this.field(interfaze, 1).getVisibility());
    Assert.assertEquals(JvmVisibility.PUBLIC, this.field(interfaze, 2).getVisibility());
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

XtendInterface (org.eclipse.xtend.core.xtend.XtendInterface)82 Test (org.junit.Test)78 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)5 XtendAnnotationType (org.eclipse.xtend.core.xtend.XtendAnnotationType)4 XtendEnum (org.eclipse.xtend.core.xtend.XtendEnum)4 RichString (org.eclipse.xtend.core.xtend.RichString)3 XtendField (org.eclipse.xtend.core.xtend.XtendField)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)2 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 EObject (org.eclipse.emf.ecore.EObject)1 EPackage (org.eclipse.emf.ecore.EPackage)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 XtendAnnotationTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl)1 XtendClassDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendClassDeclarationImpl)1 XtendEnumerationDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendEnumerationDeclarationImpl)1 XtendInterfaceDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendInterfaceDeclarationImpl)1 XtendTypeDeclarationImpl (org.eclipse.xtend.core.macro.declaration.XtendTypeDeclarationImpl)1 JavaConverterTest (org.eclipse.xtend.core.tests.javaconverter.JavaConverterTest)1 RichStringLiteral (org.eclipse.xtend.core.xtend.RichStringLiteral)1