Search in sources :

Example 46 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class JvmModelTests method testJvmTypeParameter_01.

@Test
public void testJvmTypeParameter_01() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo< {");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
        final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
        EList<JvmTypeParameter> _typeParameters = clazz.getTypeParameters();
        String _plus = ("" + _typeParameters);
        Assert.assertTrue(_plus, clazz.getTypeParameters().isEmpty());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 47 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class JvmModelTests method testJvmTypeParameter_03.

@Test
public void testJvmTypeParameter_03() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("new <() {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
        final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
        final JvmConstructor member = IterableExtensions.<JvmConstructor>head(Iterables.<JvmConstructor>filter(clazz.getMembers(), JvmConstructor.class));
        EList<JvmTypeParameter> _typeParameters = member.getTypeParameters();
        String _plus = ("" + _typeParameters);
        Assert.assertTrue(_plus, member.getTypeParameters().isEmpty());
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) Test(org.junit.Test)

Example 48 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toXtendTypeParameterDeclaration.

public XtendTypeParameterDeclarationImpl toXtendTypeParameterDeclaration(final JvmTypeParameter delegate) {
    final Function1<JvmTypeParameter, XtendTypeParameterDeclarationImpl> _function = (JvmTypeParameter it) -> {
        XtendTypeParameterDeclarationImpl _xtendTypeParameterDeclarationImpl = new XtendTypeParameterDeclarationImpl();
        final Procedure1<XtendTypeParameterDeclarationImpl> _function_1 = (XtendTypeParameterDeclarationImpl it_1) -> {
            it_1.setDelegate(delegate);
            it_1.setCompilationUnit(this);
        };
        return ObjectExtensions.<XtendTypeParameterDeclarationImpl>operator_doubleArrow(_xtendTypeParameterDeclarationImpl, _function_1);
    };
    return this.<JvmTypeParameter, XtendTypeParameterDeclarationImpl>getOrCreate(delegate, _function);
}
Also used : JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) XtendTypeParameterDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendTypeParameterDeclarationImpl) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)

Example 49 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toTypeParameterDeclaration.

public TypeParameterDeclaration toTypeParameterDeclaration(final JvmTypeParameter delegate) {
    final Function1<JvmTypeParameter, JvmTypeParameterDeclarationImpl> _function = (JvmTypeParameter it) -> {
        JvmTypeParameterDeclarationImpl _xifexpression = null;
        boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
        if (_isBelongedToCompilationUnit) {
            MutableJvmTypeParameterDeclarationImpl _mutableJvmTypeParameterDeclarationImpl = new MutableJvmTypeParameterDeclarationImpl();
            final Procedure1<MutableJvmTypeParameterDeclarationImpl> _function_1 = (MutableJvmTypeParameterDeclarationImpl it_1) -> {
                it_1.setDelegate(delegate);
                it_1.setCompilationUnit(this);
            };
            _xifexpression = ObjectExtensions.<MutableJvmTypeParameterDeclarationImpl>operator_doubleArrow(_mutableJvmTypeParameterDeclarationImpl, _function_1);
        } else {
            JvmTypeParameterDeclarationImpl _jvmTypeParameterDeclarationImpl = new JvmTypeParameterDeclarationImpl();
            final Procedure1<JvmTypeParameterDeclarationImpl> _function_2 = (JvmTypeParameterDeclarationImpl it_1) -> {
                it_1.setDelegate(delegate);
                it_1.setCompilationUnit(this);
            };
            _xifexpression = ObjectExtensions.<JvmTypeParameterDeclarationImpl>operator_doubleArrow(_jvmTypeParameterDeclarationImpl, _function_2);
        }
        return _xifexpression;
    };
    return this.<JvmTypeParameter, JvmTypeParameterDeclarationImpl>getOrCreate(delegate, _function);
}
Also used : MutableJvmTypeParameterDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmTypeParameterDeclarationImpl) JvmTypeParameterDeclarationImpl(org.eclipse.xtend.core.macro.declaration.JvmTypeParameterDeclarationImpl) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) MutableJvmTypeParameterDeclarationImpl(org.eclipse.xtend.core.macro.declaration.MutableJvmTypeParameterDeclarationImpl)

Example 50 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toType.

public Type toType(final JvmType delegate) {
    final Function1<JvmType, Type> _function = (JvmType it) -> {
        Type _switchResult = null;
        boolean _matched = false;
        if (delegate instanceof JvmDeclaredType) {
            _matched = true;
            _switchResult = this.toTypeDeclaration(((JvmDeclaredType) delegate));
        }
        if (!_matched) {
            if (delegate instanceof JvmTypeParameter) {
                _matched = true;
                _switchResult = this.toTypeParameterDeclaration(((JvmTypeParameter) delegate));
            }
        }
        if (!_matched) {
            if (delegate instanceof JvmVoid) {
                _matched = true;
                VoidTypeImpl _voidTypeImpl = new VoidTypeImpl();
                final Procedure1<VoidTypeImpl> _function_1 = (VoidTypeImpl it_1) -> {
                    it_1.setDelegate(((JvmVoid) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<VoidTypeImpl>operator_doubleArrow(_voidTypeImpl, _function_1);
            }
        }
        if (!_matched) {
            if (delegate instanceof JvmPrimitiveType) {
                _matched = true;
                PrimitiveTypeImpl _primitiveTypeImpl = new PrimitiveTypeImpl();
                final Procedure1<PrimitiveTypeImpl> _function_1 = (PrimitiveTypeImpl it_1) -> {
                    it_1.setDelegate(((JvmPrimitiveType) delegate));
                    it_1.setCompilationUnit(this);
                };
                _switchResult = ObjectExtensions.<PrimitiveTypeImpl>operator_doubleArrow(_primitiveTypeImpl, _function_1);
            }
        }
        return _switchResult;
    };
    return this.<JvmType, Type>getOrCreate(delegate, _function);
}
Also used : PrimitiveTypeImpl(org.eclipse.xtend.core.macro.declaration.PrimitiveTypeImpl) JvmArrayType(org.eclipse.xtext.common.types.JvmArrayType) JvmEnumerationType(org.eclipse.xtext.common.types.JvmEnumerationType) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) XtendAnnotationType(org.eclipse.xtend.core.xtend.XtendAnnotationType) JvmType(org.eclipse.xtext.common.types.JvmType) JvmComponentType(org.eclipse.xtext.common.types.JvmComponentType) JvmPrimitiveType(org.eclipse.xtext.common.types.JvmPrimitiveType) AccessorType(org.eclipse.xtend.lib.annotations.AccessorType) Type(org.eclipse.xtend.lib.macro.declaration.Type) JvmAnnotationType(org.eclipse.xtext.common.types.JvmAnnotationType) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) JvmVoid(org.eclipse.xtext.common.types.JvmVoid) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) JvmPrimitiveType(org.eclipse.xtext.common.types.JvmPrimitiveType) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) VoidTypeImpl(org.eclipse.xtend.core.macro.declaration.VoidTypeImpl) JvmType(org.eclipse.xtext.common.types.JvmType)

Aggregations

JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)57 Test (org.junit.Test)20 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)16 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)14 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)13 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)12 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)12 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)10 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)8 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)7 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)7 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)6 List (java.util.List)5 EList (org.eclipse.emf.common.util.EList)5 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)5 EObject (org.eclipse.emf.ecore.EObject)4 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4 ArrayList (java.util.ArrayList)3 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)3 AbstractMethodBuilder (org.eclipse.xtend.ide.codebuilder.AbstractMethodBuilder)3