Search in sources :

Example 46 with JvmAnnotationReference

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

the class XtendJvmModelInferrer method transform.

protected void transform(XtendField source, JvmGenericType container) {
    if ((source.isExtension() && source.getType() != null) || source.getName() != null) {
        JvmField field = typesFactory.createJvmField();
        final String computeFieldName = computeFieldName(source);
        field.setSimpleName(computeFieldName);
        container.getMembers().add(field);
        associator.associatePrimary(source, field);
        field.setVisibility(source.getVisibility());
        field.setStatic(source.isStatic());
        field.setTransient(source.isTransient());
        field.setVolatile(source.isVolatile());
        field.setFinal(source.isFinal());
        if (source.getType() != null) {
            field.setType(jvmTypesBuilder.cloneWithProxies(source.getType()));
        } else if (source.getInitialValue() != null) {
            field.setType(jvmTypesBuilder.inferredType(source.getInitialValue()));
        }
        for (XAnnotation anno : source.getAnnotations()) {
            if (!annotationTranslationFilter.apply(anno))
                continue;
            JvmAnnotationReference annotationReference = jvmTypesBuilder.getJvmAnnotationReference(anno);
            if (annotationReference != null)
                field.getAnnotations().add(annotationReference);
        }
        if (source.isExtension() && typeReferences.findDeclaredType(Extension.class, source) != null) {
            field.getAnnotations().add(_annotationTypesBuilder.annotationRef(Extension.class));
        }
        jvmTypesBuilder.copyDocumentationTo(source, field);
        jvmTypesBuilder.setInitializer(field, source.getInitialValue());
        initializeLocalTypes(field, source.getInitialValue());
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) JvmField(org.eclipse.xtext.common.types.JvmField) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 47 with JvmAnnotationReference

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

the class MemberFromSuperImplementor method initializeExecutableBuilder.

protected void initializeExecutableBuilder(final AbstractExecutableBuilder builder, final JvmDeclaredType overrider, final IResolvedExecutable overridden) {
    final JvmExecutable executable = overridden.getDeclaration();
    builder.setContext(overrider);
    builder.setVisibility(overridden.getDeclaration().getVisibility());
    final Procedure2<LightweightTypeReference, Integer> _function = (LightweightTypeReference it, Integer index) -> {
        final JvmFormalParameter declaredParameter = executable.getParameters().get((index).intValue());
        final AbstractParameterBuilder parameterBuilder = builder.newParameterBuilder();
        parameterBuilder.setName(declaredParameter.getSimpleName());
        parameterBuilder.setType(it);
        JvmAnnotationReference _findAnnotation = this.annotationLookup.findAnnotation(declaredParameter, Extension.class);
        boolean _tripleNotEquals = (_findAnnotation != null);
        parameterBuilder.setExtensionFlag(_tripleNotEquals);
    };
    IterableExtensions.<LightweightTypeReference>forEach(overridden.getResolvedParameterTypes(), _function);
    builder.setVarArgsFlag(executable.isVarArgs());
    builder.setExceptions(overridden.getResolvedExceptions());
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) JvmExecutable(org.eclipse.xtext.common.types.JvmExecutable) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Aggregations

JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)47 Test (org.junit.Test)23 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)15 JvmAnnotationValue (org.eclipse.xtext.common.types.JvmAnnotationValue)11 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)9 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)7 JvmAnnotationAnnotationValue (org.eclipse.xtext.common.types.JvmAnnotationAnnotationValue)6 JvmAnnotationTarget (org.eclipse.xtext.common.types.JvmAnnotationTarget)6 JvmTypeAnnotationValue (org.eclipse.xtext.common.types.JvmTypeAnnotationValue)6 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)6 EObject (org.eclipse.emf.ecore.EObject)5 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 JvmStringAnnotationValue (org.eclipse.xtext.common.types.JvmStringAnnotationValue)5 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)5 TestAnnotation (org.eclipse.xtext.common.types.testSetups.TestAnnotation)4 TestAnnotationWithStringDefault (org.eclipse.xtext.common.types.testSetups.TestAnnotationWithStringDefault)4 Extension (org.eclipse.xtext.xbase.lib.Extension)4 IFile (org.eclipse.core.resources.IFile)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3