Search in sources :

Example 51 with XtendInterface

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

the class JavaConverterTest method testSimpleInterfaceDeclarationCase.

@Test
public void testSimpleInterfaceDeclarationCase() throws Exception {
    String javaCode = "public interface JavaToConvert<T> {}";
    XtendInterface xtendInterface = this.toValidXtendInterface(javaCode);
    Assert.assertFalse("Non Final", xtendInterface.isFinal());
    Assert.assertFalse("Non Static", xtendInterface.isStatic());
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) RichString(org.eclipse.xtend.core.xtend.RichString) Test(org.junit.Test)

Example 52 with XtendInterface

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

the class CompilationUnitImpl method toXtendTypeDeclaration.

public XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> toXtendTypeDeclaration(final XtendTypeDeclaration delegate) {
    final Function1<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>> _function = (XtendTypeDeclaration it) -> {
        XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _switchResult = null;
        boolean _matched = false;
        if (delegate instanceof XtendClass) {
            _matched = true;
            XtendClassDeclarationImpl _xtendClassDeclarationImpl = new XtendClassDeclarationImpl();
            final Procedure1<XtendClassDeclarationImpl> _function_1 = (XtendClassDeclarationImpl it_1) -> {
                it_1.setDelegate(((XtendClass) delegate));
                it_1.setCompilationUnit(this);
            };
            _switchResult = ObjectExtensions.<XtendClassDeclarationImpl>operator_doubleArrow(_xtendClassDeclarationImpl, _function_1);
        }
        if (!_matched) {
            if (delegate instanceof XtendInterface) {
                _matched = true;
                XtendInterfaceDeclarationImpl _xtendInterfaceDeclarationImpl = new XtendInterfaceDeclarationImpl();
                final Procedure1<XtendInterfaceDeclarationImpl> _function_1 = (XtendInterfaceDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendInterface) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendInterfaceDeclarationImpl>operator_doubleArrow(_xtendInterfaceDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendAnnotationType) {
                _matched = true;
                XtendAnnotationTypeDeclarationImpl _xtendAnnotationTypeDeclarationImpl = new XtendAnnotationTypeDeclarationImpl();
                final Procedure1<XtendAnnotationTypeDeclarationImpl> _function_1 = (XtendAnnotationTypeDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendAnnotationType) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendAnnotationTypeDeclarationImpl>operator_doubleArrow(_xtendAnnotationTypeDeclarationImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof XtendEnum) {
                _matched = true;
                XtendEnumerationDeclarationImpl _xtendEnumerationDeclarationImpl = new XtendEnumerationDeclarationImpl();
                final Procedure1<XtendEnumerationDeclarationImpl> _function_1 = (XtendEnumerationDeclarationImpl it_1) -> {
                    it_1.setDelegate(((XtendEnum) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<XtendEnumerationDeclarationImpl>operator_doubleArrow(_xtendEnumerationDeclarationImpl, _function_1);
            }
        }
        return _switchResult;
    };
    return this.<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>>getOrCreate(delegate, _function);
}
Also used : XtendTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendTypeDeclarationImpl) XtendClassDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendClassDeclarationImpl) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) XtendInterfaceDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendInterfaceDeclarationImpl) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XtendEnum(org.eclipse.xtend.core.xtend.XtendEnum) XtendAnnotationTypeDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendAnnotationTypeDeclarationImpl) XtendEnumerationDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendEnumerationDeclarationImpl)

Example 53 with XtendInterface

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

the class OverrideValidationTest method testInterfaceOverrideWithTypeParameter_1.

@Test
public void testInterfaceOverrideWithTypeParameter_1() throws Exception {
    XtendInterface xtendInterface = interfaze("interface Foo extends test.GenericClass<String> { override java.util.List<String> foo() }");
    helper.assertNoError(xtendInterface.getMembers().get(0), INCOMPATIBLE_RETURN_TYPE);
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) Test(org.junit.Test)

Example 54 with XtendInterface

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

the class OverrideValidationTest method testOverrideGenericInterfaceMethod_15.

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

Example 55 with XtendInterface

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

the class OverrideValidationTest method testOverrideGenericInterfaceMethod_11.

@Test
public void testOverrideGenericInterfaceMethod_11() throws Exception {
    XtendInterface xtendInterface = interfaze(" interface Foo<T> extends test.GenericSuperTypeInterface<T> {  " + "override <T extends CharSequence> foo1()" + "}");
    helper.assertNoErrors(xtendInterface);
}
Also used : XtendInterface(org.eclipse.xtend.core.xtend.XtendInterface) 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