Search in sources :

Example 76 with XExpression

use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.

the class RichStringIfImpl method basicSetElse.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetElse(XExpression newElse, NotificationChain msgs) {
    XExpression oldElse = else_;
    else_ = newElse;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.RICH_STRING_IF__ELSE, oldElse, newElse);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) XExpression(org.eclipse.xtext.xbase.XExpression)

Example 77 with XExpression

use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.

the class RichStringIfImpl method basicSetIf.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetIf(XExpression newIf, NotificationChain msgs) {
    XExpression oldIf = if_;
    if_ = newIf;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.RICH_STRING_IF__IF, oldIf, newIf);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) XExpression(org.eclipse.xtext.xbase.XExpression)

Example 78 with XExpression

use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.

the class PrintedExpressionImpl method setExpression.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void setExpression(XExpression newExpression) {
    XExpression oldExpression = expression;
    expression = newExpression;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ProcessedRichStringPackage.PRINTED_EXPRESSION__EXPRESSION, oldExpression, expression));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) XExpression(org.eclipse.xtext.xbase.XExpression)

Example 79 with XExpression

use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.

the class XtendCompiler method _toJavaStatement.

@Override
protected void _toJavaStatement(final XConstructorCall expr, ITreeAppendable b, final boolean isReferenced) {
    for (XExpression arg : expr.getArguments()) {
        prepareExpression(arg, b);
    }
    if (!isReferenced) {
        b.newLine();
        constructorCallToJavaExpression(expr, b);
        if (expr.eContainer() instanceof AnonymousClass) {
            JvmConstructor constructor = expr.getConstructor();
            JvmDeclaredType declaringType = constructor.getDeclaringType();
            compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, b);
        }
        b.append(";");
    } else if (isVariableDeclarationRequired(expr, b, true)) {
        Later later = new Later() {

            @Override
            public void exec(ITreeAppendable appendable) {
                constructorCallToJavaExpression(expr, appendable);
                if (expr.eContainer() instanceof AnonymousClass) {
                    JvmConstructor constructor = expr.getConstructor();
                    JvmDeclaredType declaringType = constructor.getDeclaringType();
                    compileAnonymousClassBody((AnonymousClass) expr.eContainer(), declaringType, appendable);
                }
            }
        };
        declareFreshLocalVariable(expr, b, later);
    }
}
Also used : Later(org.eclipse.xtext.xbase.compiler.Later) AnonymousClass(org.eclipse.xtend.core.xtend.AnonymousClass) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) JvmDeclaredType(org.eclipse.xtext.common.types.JvmDeclaredType) XExpression(org.eclipse.xtext.xbase.XExpression) ITreeAppendable(org.eclipse.xtext.xbase.compiler.output.ITreeAppendable)

Example 80 with XExpression

use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.

the class StaticExtensionMethodImporter method computeChange.

@Override
protected void computeChange(final XMemberFeatureCall call, final DocumentRewriter rewriter) {
    try {
        boolean _isEmpty = call.getMemberCallArguments().isEmpty();
        if (_isEmpty) {
            super.computeChange(call, rewriter);
        } else {
            final XExpression firstArg = IterableExtensions.<XExpression>head(call.getMemberCallArguments());
            final ICompositeNode firstArgNode = NodeModelUtils.findActualNodeFor(firstArg);
            final String firstArgText = rewriter.getDocument().get(firstArgNode.getOffset(), firstArgNode.getLength());
            int _xifexpression = (int) 0;
            int _size = call.getMemberCallArguments().size();
            boolean _greaterThan = (_size > 1);
            if (_greaterThan) {
                int _xblockexpression = (int) 0;
                {
                    final ICompositeNode secondArgNode = NodeModelUtils.findActualNodeFor(call.getMemberCallArguments().get(1));
                    int _offset = secondArgNode.getOffset();
                    int _offset_1 = firstArgNode.getOffset();
                    _xblockexpression = (_offset - _offset_1);
                }
                _xifexpression = _xblockexpression;
            } else {
                _xifexpression = firstArgNode.getLength();
            }
            final int replaceLength = _xifexpression;
            final ICompositeNode memberNode = NodeModelUtils.findActualNodeFor(call.getMemberCallTarget());
            String _xifexpression_1 = null;
            boolean _shouldWrap = this.shouldWrap(firstArg);
            if (_shouldWrap) {
                StringConcatenation _builder = new StringConcatenation();
                _builder.append("(");
                _builder.append(firstArgText);
                _builder.append(")");
                _xifexpression_1 = _builder.toString();
            } else {
                _xifexpression_1 = firstArgText;
            }
            final String replaceText = _xifexpression_1;
            try {
                rewriter.newSection(firstArgNode.getOffset(), replaceLength);
                rewriter.newSection(memberNode.getOffset(), memberNode.getLength()).append(replaceText);
            } catch (final Throwable _t) {
                if (_t instanceof IllegalArgumentException) {
                } else {
                    throw Exceptions.sneakyThrow(_t);
                }
            }
        }
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) XExpression(org.eclipse.xtext.xbase.XExpression)

Aggregations

XExpression (org.eclipse.xtext.xbase.XExpression)266 Test (org.junit.Test)134 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)97 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)86 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)85 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)84 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)83 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)64 EObject (org.eclipse.emf.ecore.EObject)40 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)37 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)29 IFeatureCallArguments (org.eclipse.xtext.xbase.typesystem.arguments.IFeatureCallArguments)28 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)25 XtendField (org.eclipse.xtend.core.xtend.XtendField)24 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)23 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)22 XNumberLiteral (org.eclipse.xtext.xbase.XNumberLiteral)22 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)21 XtextResource (org.eclipse.xtext.resource.XtextResource)18 XClosure (org.eclipse.xtext.xbase.XClosure)18