org.eclipse.xtext.xbase.XPostfixOperation Java Examples

The following examples show how to use org.eclipse.xtext.xbase.XPostfixOperation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeatureLinkHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public XExpression getSyntacticReceiver(XExpression expression) {
	if (expression instanceof XAbstractFeatureCall) {
		if (expression instanceof XFeatureCall) {
			return null;
		}
		if (expression instanceof XMemberFeatureCall) {
			return ((XMemberFeatureCall) expression).getMemberCallTarget();
		}
		if (expression instanceof XAssignment) {
			return ((XAssignment) expression).getAssignable();
		}
		if (expression instanceof XBinaryOperation) {
			return ((XBinaryOperation) expression).getLeftOperand();
		}
		if (expression instanceof XUnaryOperation) {
			return ((XUnaryOperation) expression).getOperand();
		}
		if (expression instanceof XPostfixOperation) {
			return ((XPostfixOperation) expression).getOperand();
		}
	}
	return null;
}
 
Example #2
Source File: FeatureLinkHelper.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public List<XExpression> getSyntacticArguments(XAbstractFeatureCall expression) {
	if (expression instanceof XFeatureCall) {
		return ((XFeatureCall) expression).getFeatureCallArguments();
	}
	if (expression instanceof XMemberFeatureCall) {
		return ((XMemberFeatureCall) expression).getMemberCallArguments();
	}
	if (expression instanceof XAssignment) {
		return Collections.singletonList(((XAssignment) expression).getValue());
	}
	if (expression instanceof XBinaryOperation) {
		return Collections.singletonList(((XBinaryOperation) expression).getRightOperand());
	}
	// explicit condition to make sure we thought about it
	if (expression instanceof XUnaryOperation) {
		return Collections.emptyList();
	}
	if (expression instanceof XPostfixOperation) {
		return Collections.emptyList();
	}
	return Collections.emptyList();
}
 
Example #3
Source File: PyExpressionGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Generate the given object.
 *
 * @param operation the postfix operator.
 * @param it the target for the generated content.
 * @param context the context.
 * @return the operation.
 */
protected XExpression _generate(XPostfixOperation operation, IAppendable it, IExtraLanguageGeneratorContext context) {
	appendReturnIfExpectedReturnedExpression(it, context);
	final String operator = getOperatorSymbol(operation);
	if (operator != null) {
		it.append("("); //$NON-NLS-1$
		switch (operator) {
		case "++": //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			it.append(" += 1"); //$NON-NLS-1$
			break;
		case "--": //$NON-NLS-1$
			generate(operation.getOperand(), it, context);
			it.append(" -= 1"); //$NON-NLS-1$
			break;
		default:
			throw new IllegalArgumentException(MessageFormat.format(Messages.PyExpressionGenerator_0, operator));
		}
		it.append(")"); //$NON-NLS-1$
	}
	return operation;
}
 
Example #4
Source File: XbaseValidator.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Check
public void checkAssignment(XPostfixOperation postfixOperation) {
	if (expressionHelper.isGetAndAssign(postfixOperation)) {
		XExpression firstArgument = postfixOperation.getActualArguments().get(0);
		checkAssignment(firstArgument, false);
	}
}
 
Example #5
Source File: AmbiguousFeatureLinkingCandidate.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String getSyntaxDescriptions() {
	XExpression expression = getExpression();
	if (expression instanceof XBinaryOperation) {
		return "binary operation";
	} else if (expression instanceof XUnaryOperation) {
		return "unary operation";
	} else if (expression instanceof XPostfixOperation) {
		return "postfix operation";
	} else {
		return "feature call";
	}
}
 
Example #6
Source File: XbaseSyntacticSequencer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean startsWithUnaryOperator(EObject obj) {
	if(obj instanceof XUnaryOperation)
		return true;
	if(obj instanceof XBinaryOperation)
		return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand());
	if(obj instanceof XPostfixOperation) {
		return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand());
	}
	return false;
}
 
Example #7
Source File: XbaseFormatter.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void _format(final XPostfixOperation expr, @Extension final IFormattableDocument doc) {
  final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
    it.noSpace();
  };
  doc.prepend(this.textRegionExtensions.regionFor(expr).feature(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE), _function);
  doc.<XExpression>format(expr.getOperand());
}
 
Example #8
Source File: XtendSyntacticSequencer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean startsWithUnaryOperator(EObject obj) {
	if(obj instanceof XUnaryOperation)
		return true;
	if(obj instanceof XBinaryOperation)
		return startsWithUnaryOperator(((XBinaryOperation)obj).getLeftOperand());
	if(obj instanceof XPostfixOperation) {
		return startsWithUnaryOperator(((XPostfixOperation)obj).getOperand());
	}
	return false;
}
 
Example #9
Source File: AbstractXbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Deprecated
protected void sequence_XPostfixOperation(EObject context, XPostfixOperation semanticObject) {
	sequence_XPostfixOperation(createContext(context, semanticObject), semanticObject);
}
 
Example #10
Source File: XExpressionHelper.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public boolean isGetAndAssign(XAbstractFeatureCall featureCall) {
	if (!(featureCall instanceof XPostfixOperation)) {
		return false;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, DoubleExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, DoubleExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, FloatExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, FloatExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, LongExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, LongExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, IntegerExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, IntegerExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, ShortExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, ShortExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, CharacterExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, CharacterExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.MINUS_MINUS, ByteExtensions.class)) {
		return true;
	}
	if (isOperatorFromExtension(featureCall, OperatorMapping.PLUS_PLUS, ByteExtensions.class)) {
		return true;
	}
	return false;
}
 
Example #11
Source File: AbstractXbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Contexts:
 *     XExpression returns XPostfixOperation
 *     XAssignment returns XPostfixOperation
 *     XAssignment.XBinaryOperation_1_1_0_0_0 returns XPostfixOperation
 *     XOrExpression returns XPostfixOperation
 *     XOrExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XAndExpression returns XPostfixOperation
 *     XAndExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XEqualityExpression returns XPostfixOperation
 *     XEqualityExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XRelationalExpression returns XPostfixOperation
 *     XRelationalExpression.XInstanceOfExpression_1_0_0_0_0 returns XPostfixOperation
 *     XRelationalExpression.XBinaryOperation_1_1_0_0_0 returns XPostfixOperation
 *     XOtherOperatorExpression returns XPostfixOperation
 *     XOtherOperatorExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XAdditiveExpression returns XPostfixOperation
 *     XAdditiveExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XMultiplicativeExpression returns XPostfixOperation
 *     XMultiplicativeExpression.XBinaryOperation_1_0_0_0 returns XPostfixOperation
 *     XUnaryOperation returns XPostfixOperation
 *     XCastedExpression returns XPostfixOperation
 *     XCastedExpression.XCastedExpression_1_0_0_0 returns XPostfixOperation
 *     XPostfixOperation returns XPostfixOperation
 *     XPostfixOperation.XPostfixOperation_1_0_0 returns XPostfixOperation
 *     XMemberFeatureCall returns XPostfixOperation
 *     XMemberFeatureCall.XAssignment_1_0_0_0_0 returns XPostfixOperation
 *     XMemberFeatureCall.XMemberFeatureCall_1_1_0_0_0 returns XPostfixOperation
 *     XPrimaryExpression returns XPostfixOperation
 *     XParenthesizedExpression returns XPostfixOperation
 *     XExpressionOrVarDeclaration returns XPostfixOperation
 *
 * Constraint:
 *     (operand=XPostfixOperation_XPostfixOperation_1_0_0 feature=[JvmIdentifiableElement|OpPostfix])
 */
protected void sequence_XPostfixOperation(ISerializationContext context, XPostfixOperation semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XPOSTFIX_OPERATION__OPERAND) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XPOSTFIX_OPERATION__OPERAND));
		if (transientValues.isValueTransient(semanticObject, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getXPostfixOperationAccess().getXPostfixOperationOperandAction_1_0_0(), semanticObject.getOperand());
	feeder.accept(grammarAccess.getXPostfixOperationAccess().getFeatureJvmIdentifiableElementOpPostfixParserRuleCall_1_0_1_0_1(), semanticObject.eGet(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, false));
	feeder.finish();
}
 
Example #12
Source File: SARLOperationHelper.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Test if the given expression has side effects.
 *
 * @param expression the expression.
 * @param context the list of context expressions.
 * @return {@code true} if the expression has side effects.
 */
@SuppressWarnings("static-method")
protected Boolean _hasSideEffects(XPostfixOperation expression, ISideEffectContext context) {
	return Boolean.TRUE;
}