Search in sources :

Example 31 with TypeReference

use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.

the class CompilationUnitImpl method translate.

protected Object translate(final Object object) {
    if ((object instanceof XAnnotation[])) {
        final AnnotationReference[] result = new AnnotationReference[((Object[]) object).length];
        int _length = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length, true);
        for (final Integer i : _doubleDotLessThan) {
            result[(i).intValue()] = this.translateAnnotation(((XAnnotation[]) object)[(i).intValue()]);
        }
        return result;
    }
    if ((object instanceof XAnnotation)) {
        return this.translateAnnotation(((XAnnotation) object));
    }
    if ((object instanceof JvmTypeReference[])) {
        final TypeReference[] result_1 = new TypeReference[((Object[]) object).length];
        int _length_1 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, _length_1, true);
        for (final Integer i_1 : _doubleDotLessThan_1) {
            Object _translate = this.translate(((Object[]) object)[(i_1).intValue()]);
            result_1[(i_1).intValue()] = ((TypeReference) _translate);
        }
        return result_1;
    }
    if ((object instanceof JvmTypeReference)) {
        return this.toTypeReference(((JvmTypeReference) object));
    }
    if ((object instanceof JvmEnumerationLiteral[])) {
        final EnumerationValueDeclaration[] result_2 = new EnumerationValueDeclaration[((Object[]) object).length];
        int _length_2 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_2 = new ExclusiveRange(0, _length_2, true);
        for (final Integer i_2 : _doubleDotLessThan_2) {
            Object _translate_1 = this.translate(((Object[]) object)[(i_2).intValue()]);
            result_2[(i_2).intValue()] = ((EnumerationValueDeclaration) _translate_1);
        }
        return result_2;
    }
    if ((object instanceof JvmEnumerationLiteral)) {
        return this.toMemberDeclaration(((JvmMember) object));
    }
    return object;
}
Also used : ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) JvmEnumerationLiteral(org.eclipse.xtext.common.types.JvmEnumerationLiteral) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) AnnotationReference(org.eclipse.xtend.lib.macro.declaration.AnnotationReference) EObject(org.eclipse.emf.ecore.EObject) JvmMember(org.eclipse.xtext.common.types.JvmMember) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) EnumerationValueDeclaration(org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration)

Example 32 with TypeReference

use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.

the class JvmExecutableDeclarationImpl method setExceptions.

public void setExceptions(final TypeReference... exceptions) {
    this.checkMutable();
    ConditionUtils.checkIterable(((Iterable<?>) Conversions.doWrapArray(exceptions)), "exceptions");
    ConditionUtils.checkInferredTypeReferences("exception type", exceptions);
    this.getDelegate().getExceptions().clear();
    for (final TypeReference exceptionType : exceptions) {
        if ((exceptionType != null)) {
            this.getDelegate().getExceptions().add(this.getCompilationUnit().toJvmTypeReference(exceptionType));
        }
    }
}
Also used : TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference)

Example 33 with TypeReference

use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.

the class JvmTypeParameterDeclarationImpl method isAssignableFrom.

@Override
public boolean isAssignableFrom(final Type otherType) {
    if ((otherType == null)) {
        return false;
    }
    final TypeReference thisTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(this);
    final TypeReference thatTypeRef = this.getCompilationUnit().getTypeReferenceProvider().newTypeReference(otherType);
    return thisTypeRef.isAssignableFrom(thatTypeRef);
}
Also used : TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference)

Example 34 with TypeReference

use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.

the class MutableJvmTypeParameterDeclarationImpl method setUpperBounds.

@Override
public void setUpperBounds(final Iterable<? extends TypeReference> upperBounds) {
    this.checkMutable();
    ConditionUtils.checkIterable(upperBounds, "upperBounds");
    ConditionUtils.checkInferredTypeReferences("parameter type", ((TypeReference[]) Conversions.unwrapArray(upperBounds, TypeReference.class)));
    this.getDelegate().getConstraints().clear();
    for (final TypeReference upper : upperBounds) {
        {
            final JvmTypeReference typeRef = this.getCompilationUnit().toJvmTypeReference(upper);
            final JvmUpperBound jvmUpperBound = TypesFactory.eINSTANCE.createJvmUpperBound();
            jvmUpperBound.setTypeReference(typeRef);
            this.getDelegate().getConstraints().add(jvmUpperBound);
        }
    }
}
Also used : JvmUpperBound(org.eclipse.xtext.common.types.JvmUpperBound) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference)

Example 35 with TypeReference

use of org.eclipse.xtend.lib.macro.declaration.TypeReference in project xtext-xtend by eclipse.

the class ResolvedExecutableImpl method getResolvedParameters.

@Override
public Iterable<? extends ResolvedParameter> getResolvedParameters() {
    Iterable<? extends ResolvedParameter> _xblockexpression = null;
    {
        if ((this.resolvedParameters == null)) {
            int _size = this.getDelegate().getDeclaration().getParameters().size();
            final Function1<Integer, ResolvedParameterImpl> _function = (Integer i) -> {
                ParameterDeclaration _parameterDeclaration = this.getCompilationUnit().toParameterDeclaration(this.getDelegate().getDeclaration().getParameters().get((i).intValue()));
                TypeReference _typeReference = this.getCompilationUnit().toTypeReference(this.getDelegate().getResolvedParameterTypes().get((i).intValue()));
                return new ResolvedParameterImpl(_parameterDeclaration, _typeReference);
            };
            this.resolvedParameters = IterableExtensions.<Integer, ResolvedParameterImpl>map(new ExclusiveRange(0, _size, true), _function);
        }
        _xblockexpression = this.resolvedParameters;
    }
    return _xblockexpression;
}
Also used : Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ResolvedParameterImpl(org.eclipse.xtend.core.macro.declaration.ResolvedParameterImpl) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) ParameterDeclaration(org.eclipse.xtend.lib.macro.declaration.ParameterDeclaration)

Aggregations

TypeReference (org.eclipse.xtend.lib.macro.declaration.TypeReference)37 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)13 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)10 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)10 MutableMethodDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration)8 Test (org.junit.Test)8 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)7 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)6 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)5 MutableTypeParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableTypeParameterDeclaration)5 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)4 Type (org.eclipse.xtend.lib.macro.declaration.Type)4 TypeParameterDeclaration (org.eclipse.xtend.lib.macro.declaration.TypeParameterDeclaration)4 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)4 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)4 Serializable (java.io.Serializable)3 EObject (org.eclipse.emf.ecore.EObject)3 MutableInterfaceDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableInterfaceDeclaration)3 JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)3 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)3