Search in sources :

Example 1 with CreateExtensionInfo

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

the class XtendHighlightingCalculator method highlightElement.

protected void highlightElement(XtendFunction function, IHighlightedPositionAcceptor acceptor, CancelIndicator cancelIndicator) {
    highlightFeature(acceptor, function, XtendPackage.Literals.XTEND_FUNCTION__NAME, METHOD);
    XExpression rootExpression = function.getExpression();
    highlightRichStrings(rootExpression, acceptor);
    CreateExtensionInfo createExtensionInfo = function.getCreateExtensionInfo();
    if (createExtensionInfo != null) {
        highlightRichStrings(createExtensionInfo.getCreateExpression(), acceptor);
    }
}
Also used : XExpression(org.eclipse.xtext.xbase.XExpression) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo)

Example 2 with CreateExtensionInfo

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

the class XtendFunctionImpl method basicSetCreateExtensionInfo.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetCreateExtensionInfo(CreateExtensionInfo newCreateExtensionInfo, NotificationChain msgs) {
    CreateExtensionInfo oldCreateExtensionInfo = createExtensionInfo;
    createExtensionInfo = newCreateExtensionInfo;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_FUNCTION__CREATE_EXTENSION_INFO, oldCreateExtensionInfo, newCreateExtensionInfo);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo)

Example 3 with CreateExtensionInfo

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

the class XtendReentrantTypeResolver method computeTypes.

protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, XtendMember member) {
    XExpression expression = null;
    if (member instanceof XtendFunction) {
        XtendFunction function = (XtendFunction) member;
        expression = function.getExpression();
        CreateExtensionInfo createInfo = function.getCreateExtensionInfo();
        if (createInfo != null) {
            computeDanglingExpressionType(resolvedTypes, featureScopeSession, function, createInfo.getCreateExpression());
        }
        for (XtendParameter parameter : function.getParameters()) {
            computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, parameter.getAnnotations());
        }
    } else if (member instanceof XtendConstructor) {
        XtendConstructor constructor = (XtendConstructor) member;
        expression = constructor.getExpression();
        for (XtendParameter parameter : constructor.getParameters()) {
            computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, parameter.getAnnotations());
        }
    } else if (member instanceof XtendField) {
        expression = ((XtendField) member).getInitialValue();
    }
    if (expression != null) {
        computeDanglingExpressionType(resolvedTypes, featureScopeSession, member, expression);
    }
    computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, member.getAnnotations());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) XExpression(org.eclipse.xtext.xbase.XExpression) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo) XtendField(org.eclipse.xtend.core.xtend.XtendField)

Example 4 with CreateExtensionInfo

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

the class XtendJvmModelInferrer method transform.

protected void transform(XtendFunction source, JvmGenericType container, boolean allowDispatch) {
    JvmOperation operation = typesFactory.createJvmOperation();
    operation.setAbstract(source.isAbstract());
    operation.setNative(source.isNative());
    operation.setSynchronized(source.isSynchonized());
    operation.setStrictFloatingPoint(source.isStrictFloatingPoint());
    if (!source.isAbstract())
        operation.setFinal(source.isFinal());
    container.getMembers().add(operation);
    associator.associatePrimary(source, operation);
    String sourceName = source.getName();
    JvmVisibility visibility = source.getVisibility();
    if (allowDispatch && source.isDispatch()) {
        if (source.getDeclaredVisibility() == null)
            visibility = JvmVisibility.PROTECTED;
        sourceName = "_" + sourceName;
    }
    operation.setSimpleName(sourceName);
    operation.setVisibility(visibility);
    operation.setStatic(source.isStatic());
    if (!operation.isAbstract() && !operation.isStatic() && container.isInterface())
        operation.setDefault(true);
    for (XtendParameter parameter : source.getParameters()) {
        translateParameter(operation, parameter);
    }
    XExpression expression = source.getExpression();
    CreateExtensionInfo createExtensionInfo = source.getCreateExtensionInfo();
    JvmTypeReference returnType = null;
    if (source.getReturnType() != null) {
        returnType = jvmTypesBuilder.cloneWithProxies(source.getReturnType());
    } else if (createExtensionInfo != null) {
        returnType = jvmTypesBuilder.inferredType(createExtensionInfo.getCreateExpression());
    } else if (expression != null) {
        returnType = jvmTypesBuilder.inferredType(expression);
    } else {
        returnType = jvmTypesBuilder.inferredType();
    }
    operation.setReturnType(returnType);
    copyAndFixTypeParameters(source.getTypeParameters(), operation);
    for (JvmTypeReference exception : source.getExceptions()) {
        operation.getExceptions().add(jvmTypesBuilder.cloneWithProxies(exception));
    }
    translateAnnotationsTo(source.getAnnotations(), operation);
    if (source.isOverride() && generatorConfig.getJavaSourceVersion().isAtLeast(JAVA6) && !containsAnnotation(operation, Override.class) && typeReferences.findDeclaredType(Override.class, source) != null) {
        operation.getAnnotations().add(_annotationTypesBuilder.annotationRef(Override.class));
    }
    if (createExtensionInfo != null) {
        transformCreateExtension(source, createExtensionInfo, container, operation, returnType);
    } else {
        setBody(operation, expression);
    }
    jvmTypesBuilder.copyDocumentationTo(source, operation);
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmVisibility(org.eclipse.xtext.common.types.JvmVisibility) XExpression(org.eclipse.xtext.xbase.XExpression) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo)

Example 5 with CreateExtensionInfo

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

the class EclipseXtendOutlineSourceContext method markCreateExtensionJvmFeaturesAsProcessed.

protected void markCreateExtensionJvmFeaturesAsProcessed(final JvmMember member) {
    final EObject function = this._iXtendJvmAssociations.getPrimarySourceElement(member);
    if ((function instanceof XtendFunction)) {
        CreateExtensionInfo _createExtensionInfo = ((XtendFunction) function).getCreateExtensionInfo();
        boolean _tripleNotEquals = (_createExtensionInfo != null);
        if (_tripleNotEquals) {
            final Function1<JvmFeature, Boolean> _function = (JvmFeature it) -> {
                return Boolean.valueOf((!Objects.equal(it, member)));
            };
            final Function1<JvmFeature, Boolean> _function_1 = (JvmFeature it) -> {
                return Boolean.valueOf((it.getSimpleName().startsWith(XtendJvmModelInferrer.CREATE_CHACHE_VARIABLE_PREFIX) || it.getSimpleName().startsWith(XtendJvmModelInferrer.CREATE_INITIALIZER_PREFIX)));
            };
            Iterable<JvmFeature> _filter = IterableExtensions.<JvmFeature>filter(IterableExtensions.<JvmFeature>filter(Iterables.<JvmFeature>filter(this._iXtendJvmAssociations.getJvmElements(function), JvmFeature.class), _function), _function_1);
            for (final JvmFeature jvmFeature : _filter) {
                super.markAsProcessed(jvmFeature);
            }
        }
    }
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmFeature(org.eclipse.xtext.common.types.JvmFeature) EObject(org.eclipse.emf.ecore.EObject) CreateExtensionInfo(org.eclipse.xtend.core.xtend.CreateExtensionInfo)

Aggregations

CreateExtensionInfo (org.eclipse.xtend.core.xtend.CreateExtensionInfo)5 XExpression (org.eclipse.xtext.xbase.XExpression)3 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)2 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 EObject (org.eclipse.emf.ecore.EObject)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 XtendConstructor (org.eclipse.xtend.core.xtend.XtendConstructor)1 XtendField (org.eclipse.xtend.core.xtend.XtendField)1 JvmFeature (org.eclipse.xtext.common.types.JvmFeature)1 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)1 JvmVisibility (org.eclipse.xtext.common.types.JvmVisibility)1