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;
}
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;
}
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));
}
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);
}
}
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);
}
}
Aggregations