org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider Java Examples

The following examples show how to use org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider. 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: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isXShortClosure(List<?> values, EReference reference, INodesForEObjectProvider nodes) {
	if (values.isEmpty() || values.size() > 2 || !(values.get(0) instanceof XClosure))
		return false;
	XClosure closure = (XClosure) values.get(0);
	if (!closure.isExplicitSyntax())
		return false;
	INode node = nodes.getNodeForMultiValue(reference, 0, 0, closure);
	if (node != null) {
		if (node.getGrammarElement() instanceof RuleCall)
			return ((RuleCall) node.getGrammarElement()).getRule() == grammarAccess.getXShortClosureRule();
		if (node.getGrammarElement() instanceof Action)
			return node.getGrammarElement() == grammarAccess.getXShortClosureAccess().getXClosureAction_0_0_0();
		return false;
	}
	return true;
}
 
Example #2
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isBuilderSyntax(List<?> values, EReference reference, INodesForEObjectProvider nodes) {
	if (values.isEmpty())
		return false;
	int lastIndex = values.size() - 1;
	Object lastValue = values.get(lastIndex);
	if (!(lastValue instanceof XClosure))
		return false;
	INode node = nodes.getNodeForMultiValue(reference, lastIndex, lastIndex, values.get(lastIndex));
	if (node != null) {
		if (node.getGrammarElement() instanceof RuleCall)
			return ((RuleCall) node.getGrammarElement()).getRule() == grammarAccess.getXClosureRule();
		if (node.getGrammarElement() instanceof Action) 
			return node.getGrammarElement() == grammarAccess.getXClosureAccess().getXClosureAction_0_0_0();
		return false;
	}
	return true;
}
 
Example #3
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Greater(EObject context, Operation_Greater semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_GreaterAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_GreaterAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #4
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=BOOLEAN
 */
protected void sequence_Expression_Boolean(EObject context, Expression_Boolean semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_BOOLEAN__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_BOOLEAN__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getExpression_BooleanAccess().getValueBOOLEANTerminalRuleCall_1_0(), semanticObject.isValue());
	feeder.finish();
}
 
Example #5
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=DOUBLE
 */
protected void sequence_Expression_Double(EObject context, Expression_Double semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_DOUBLE__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_DOUBLE__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getExpression_DoubleAccess().getValueDOUBLETerminalRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example #6
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=LONG
 */
protected void sequence_Expression_Integer(EObject context, Expression_Integer semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_INTEGER__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_INTEGER__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getExpression_IntegerAccess().getValueLONGTerminalRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example #7
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=[EObject|ID]
 */
protected void sequence_Expression_ProcessRef(EObject context, Expression_ProcessRef semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_PROCESS_REF__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_PROCESS_REF__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getExpression_ProcessRefAccess().getValueEObjectIDTerminalRuleCall_1_0_1(), semanticObject.getValue());
	feeder.finish();
}
 
Example #8
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=STRING
 */
protected void sequence_Expression_String(EObject context, Expression_String semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.EXPRESSION_STRING__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.EXPRESSION_STRING__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getExpression_StringAccess().getValueSTRINGTerminalRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example #9
Source File: SequenceFeeder.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected SequenceFeeder(Provider provider, ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes,
		ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
	super();
	if (semanticObject == null || nodes == null || sequenceAcceptor == null)
		throw new NullPointerException();
	this.context = context;
	this.provider = provider;
	this.semanticObject = semanticObject;
	this.nodes = nodes;
	this.masterSequencer = masterSequencer;
	this.sequenceAcceptor = sequenceAcceptor;
	this.errorAcceptor = errorAcceptor;
}
 
Example #10
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Equals(EObject context, Operation_Equals semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_EqualsAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_EqualsAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #11
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Greater_Equals(EObject context, Operation_Greater_Equals semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_Greater_EqualsAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_Greater_EqualsAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #12
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Less_Equals(EObject context, Operation_Less_Equals semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_Less_EqualsAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_Less_EqualsAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #13
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Less(EObject context, Operation_Less semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_LessAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_LessAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #14
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=Expression_Terminal
 */
protected void sequence_Operation_NotUnary(EObject context, Operation_NotUnary semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.UNARY_OPERATION__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.UNARY_OPERATION__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_NotUnaryAccess().getValueExpression_TerminalParserRuleCall_2_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example #15
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isBuilderSyntax(EObject expression, EReference reference, boolean explicitOperationCall, INodesForEObjectProvider nodes) {
	List<?> values = (List<?>) expression.eGet(reference);
	if (values.size() < 1)
		return false;
	if (values.size() == 1 && !explicitOperationCall)
		return true;
	return isBuilderSyntax(values, reference, nodes);
}
 
Example #16
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     (left=Expression_Terminal right=Expression_Terminal)
 */
protected void sequence_Operation_Not_Equals(EObject context, Operation_Not_Equals semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__LEFT));
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.OPERATION__RIGHT));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_Not_EqualsAccess().getLeftExpression_TerminalParserRuleCall_1_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getOperation_Not_EqualsAccess().getRightExpression_TerminalParserRuleCall_3_0(), semanticObject.getRight());
	feeder.finish();
}
 
Example #17
Source File: ConditionModelSemanticSequencer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constraint:
 *     value=Expression_Terminal
 */
protected void sequence_Operation_Unary(EObject context, Operation_Unary semanticObject) {
	if(errorAcceptor != null) {
		if(transientValues.isValueTransient(semanticObject, ConditionModelPackage.Literals.UNARY_OPERATION__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ConditionModelPackage.Literals.UNARY_OPERATION__VALUE));
	}
	INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
	SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
	feeder.accept(grammarAccess.getOperation_UnaryAccess().getValueExpression_TerminalParserRuleCall_1_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example #18
Source File: AbstractSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected SequenceFeeder createSequencerFeeder(ISerializationContext context, EObject semanticObject) {
	INodesForEObjectProvider nodeProvider = createNodeProvider(semanticObject);
	return feederProvider.create(context, semanticObject, nodeProvider, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #19
Source File: BacktrackingSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public SerializableObject(ISerializationContext context, EObject eObject,
		INodesForEObjectProvider nodeProvider) {
	super();
	this.eObject = eObject;
	this.context = context;
	this.firstNode = nodeProvider.getFirstSemanticNode();
	EClass clazz = eObject.eClass();
	values = new Object[clazz.getFeatureCount()];
	nodes = new List[clazz.getFeatureCount()];
	optional = new boolean[clazz.getFeatureCount()];
	for (EStructuralFeature feature : eObject.eClass().getEAllStructuralFeatures()) {
		int featureID = eObject.eClass().getFeatureID(feature);
		if (feature.isMany())
			switch (transientValues.isListTransient(eObject, feature)) {
			case NO:
				List<ISemanticNode> nodes1 = Lists.newArrayList();
				List<?> values1;
				if (feature instanceof EReference && ((EReference) feature).isResolveProxies()) {
					values1 = ((InternalEList<?>) eObject.eGet(feature)).basicList();
				} else {
					values1 = (List<?>) eObject.eGet(feature);
				}
				for (int i = 0; i < values1.size(); i++)
					nodes1.add(nodeProvider.getSemanticNodeForMultiValue(feature, i, i, values1.get(i)));
				values[featureID] = values1;
				nodes[featureID] = nodes1;
				break;
			case SOME:
				List<ISemanticNode> nodes2 = Lists.newArrayList();
				List<?> values2;
				if (feature instanceof EReference && ((EReference) feature).isResolveProxies()) {
					values2 = ((InternalEList<?>) eObject.eGet(feature)).basicList();
				} else {
					values2 = (List<?>) eObject.eGet(feature);
				}
				List<Object> values3 = Lists.newArrayList();
				for (int i = 0, j = 0; i < values2.size(); i++)
					if (!transientValues.isValueInListTransient(eObject, i, feature)) {
						Object value = values2.get(i);
						ISemanticNode node = nodeProvider.getSemanticNodeForMultiValue(feature, i, j++, value);
						values3.add(value);
						nodes2.add(node);
					}
				values[featureID] = values3;
				nodes[featureID] = nodes2;
				break;
			case YES:
				values[featureID] = INVALID;
			}
		else
			switch (transientValues.isValueTransient(eObject, feature)) {
			case PREFERABLY:
				optional[featureID] = true;
				Object value1 = eObject.eGet(feature, false);
				values[featureID] = value1;
				nodes[featureID] = Collections
						.singletonList(nodeProvider.getSemanticNodeForSingelValue(feature, value1));
				break;
			case NO:
				Object value2 = eObject.eGet(feature, false);
				values[featureID] = value2;
				nodes[featureID] = Collections
						.singletonList(nodeProvider.getSemanticNodeForSingelValue(feature, value2));
				break;
			case YES:
				values[featureID] = INVALID;
			}
	}
}
 
Example #20
Source File: AbstractSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected SequenceFeeder createSequencerFeeder(ISerializationContext context, EObject semanticObject,
		INodesForEObjectProvider nodeProvider) {
	return feederProvider.create(context, semanticObject, nodeProvider, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #21
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constraint:
 *     (
 *         (leftOperand=XAdditiveExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpAdd] rightOperand=XMultiplicativeExpression) | 
 *         (leftOperand=XMultiplicativeExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpMulti] rightOperand=XUnaryOperation) | 
 *         (leftOperand=XOtherOperatorExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpOther] rightOperand=XAdditiveExpression) | 
 *         (leftOperand=XRelationalExpression_XBinaryOperation_1_1_0_0_0 feature=[JvmIdentifiableElement|OpCompare] rightOperand=XOtherOperatorExpression) | 
 *         (leftOperand=XEqualityExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpEquality] rightOperand=XRelationalExpression) | 
 *         (leftOperand=XAndExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpAnd] rightOperand=XEqualityExpression) | 
 *         (leftOperand=XOrExpression_XBinaryOperation_1_0_0_0 feature=[JvmIdentifiableElement|OpOr] rightOperand=XAndExpression) | 
 *         (leftOperand=XAssignment_XBinaryOperation_1_1_0_0_0 feature=[JvmIdentifiableElement|OpMultiAssign] rightOperand=XAssignment)
 *     )
 */
@Override
protected void sequence_XAdditiveExpression_XAndExpression_XAssignment_XEqualityExpression_XMultiplicativeExpression_XOrExpression_XOtherOperatorExpression_XRelationalExpression(ISerializationContext context, XBinaryOperation operation) {
	INodesForEObjectProvider nodes = createNodeProvider(operation);
	SequenceFeeder acceptor = createSequencerFeeder(context, operation, nodes);
	XAdditiveExpressionElements opAdd = grammarAccess.getXAdditiveExpressionAccess();
	XMultiplicativeExpressionElements opMulti = grammarAccess.getXMultiplicativeExpressionAccess();
	XOtherOperatorExpressionElements opOther = grammarAccess.getXOtherOperatorExpressionAccess();
	XRelationalExpressionElements opCompare = grammarAccess.getXRelationalExpressionAccess();
	XEqualityExpressionElements opEquality = grammarAccess.getXEqualityExpressionAccess();
	XAndExpressionElements opAnd = grammarAccess.getXAndExpressionAccess();
	XOrExpressionElements opOr = grammarAccess.getXOrExpressionAccess();
	XAssignmentElements opMultiAssign = grammarAccess.getXAssignmentAccess();
	
	JvmIdentifiableElement feature = operation.getFeature();
	Set<String> operatorNames = Sets.newHashSet();
	if (feature.eIsProxy()) {
		List<INode> ops = NodeModelUtils.findNodesForFeature(operation, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE);
		for (INode o : ops)
			operatorNames.add(NodeModelUtils.getTokenText(o));
	} else {
		IScope scope = scopeProvider.getScope(operation, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE);
		for (IEObjectDescription desc : scope.getElements(feature))
			operatorNames.add(qualifiedNameConverter.toString(desc.getName()));
	}
	ICompositeNode featureNode = (ICompositeNode) nodes.getNodeForSingelValue(XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, operation.getFeature());
	String featureToken;
	
	if((featureToken = getValidOperator(operation, opAdd.getFeatureJvmIdentifiableElementOpAddParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opAdd.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opAdd.getFeatureJvmIdentifiableElementOpAddParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opAdd.getRightOperandXMultiplicativeExpressionParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opMulti.getFeatureJvmIdentifiableElementOpMultiParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opMulti.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opMulti.getFeatureJvmIdentifiableElementOpMultiParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opMulti.getRightOperandXUnaryOperationParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opOther.getFeatureJvmIdentifiableElementOpOtherParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opOther.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opOther.getFeatureJvmIdentifiableElementOpOtherParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opOther.getRightOperandXAdditiveExpressionParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opCompare.getFeatureJvmIdentifiableElementOpCompareParserRuleCall_1_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opCompare.getXBinaryOperationLeftOperandAction_1_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opCompare.getFeatureJvmIdentifiableElementOpCompareParserRuleCall_1_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opCompare.getRightOperandXOtherOperatorExpressionParserRuleCall_1_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opEquality.getFeatureJvmIdentifiableElementOpEqualityParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opEquality.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opEquality.getFeatureJvmIdentifiableElementOpEqualityParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opEquality.getRightOperandXRelationalExpressionParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opAnd.getFeatureJvmIdentifiableElementOpAndParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opAnd.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opAnd.getFeatureJvmIdentifiableElementOpAndParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opAnd.getRightOperandXEqualityExpressionParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opOr.getFeatureJvmIdentifiableElementOpOrParserRuleCall_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opOr.getXBinaryOperationLeftOperandAction_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opOr.getFeatureJvmIdentifiableElementOpOrParserRuleCall_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opOr.getRightOperandXAndExpressionParserRuleCall_1_1_0(), operation.getRightOperand());
	} else if((featureToken = getValidOperator(operation, opMultiAssign.getFeatureJvmIdentifiableElementOpMultiAssignParserRuleCall_1_1_0_0_1_0_1(), operatorNames, featureNode)) != null) {
		acceptor.accept(opMultiAssign.getXBinaryOperationLeftOperandAction_1_1_0_0_0(), operation.getLeftOperand());
		acceptor.accept(opMultiAssign.getFeatureJvmIdentifiableElementOpMultiAssignParserRuleCall_1_1_0_0_1_0_1(), operation.getFeature(), featureToken, featureNode);
		acceptor.accept(opMultiAssign.getRightOperandXAssignmentParserRuleCall_1_1_1_0(), operation.getRightOperand());
	} else if (errorAcceptor != null) {
		errorAcceptor.accept(new SerializationDiagnostic(OPERATOR_NOT_SUPPORTED, operation, context, grammarAccess.getGrammar(), "Operator "+operatorNames+" is not supported."));
	} 
	acceptor.finish();
}
 
Example #22
Source File: AbstractSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
protected SequenceFeeder createSequencerFeeder(EObject semanticObject, INodesForEObjectProvider nodeProvider) {
	return feederProvider.create(semanticObject, nodeProvider, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #23
Source File: AbstractSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
protected SequenceFeeder createSequencerFeeder(EObject semanticObject) {
	INodesForEObjectProvider nodeProvider = createNodeProvider(semanticObject);
	return feederProvider.create(semanticObject, nodeProvider, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #24
Source File: AbstractSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected INodesForEObjectProvider createNodeProvider(EObject semanticObject) {
	return nodeProvider.getNodesForSemanticObject(semanticObject, null);
}
 
Example #25
Source File: SequenceFeeder.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated {@link #SequenceFeeder(SequenceFeeder.Provider, ISerializationContext, EObject, ISemanticNodeProvider.INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, ISerializationDiagnostic.Acceptor)}
 */
@Deprecated
protected SequenceFeeder(Provider provider, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer,
		ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
	this(provider, null, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #26
Source File: SequenceFeeder.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public SequenceFeeder create(ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes,
		ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
	return new SequenceFeeder(this, context, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #27
Source File: SequenceFeeder.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @deprecated {@link #create(ISerializationContext, EObject, ISemanticNodeProvider.INodesForEObjectProvider, ISemanticSequencer, ISemanticSequenceAcceptor, ISerializationDiagnostic.Acceptor)}
 */
@Deprecated
public SequenceFeeder create(EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer,
		ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
	return new SequenceFeeder(this, semanticObject, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
}
 
Example #28
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constraint:
 *     (
 *         constructor=[JvmConstructor|QualifiedName] 
 *         (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)? 
 *         (arguments+=XShortClosure | (arguments+=XExpression arguments+=XExpression*))? 
 *         arguments+=XClosure?
 *     )
 */
@Override
protected void sequence_XConstructorCall(ISerializationContext context, XConstructorCall constructorCall) {
	INodesForEObjectProvider nodes = createNodeProvider(constructorCall);
	SequenceFeeder acceptor = createSequencerFeeder(context, constructorCall, nodes);
	XConstructorCallElements constructorCallElements = grammarAccess.getXConstructorCallAccess();

	// constructor=[types::JvmConstructor|QualifiedName]
	acceptor.accept(constructorCallElements.getConstructorJvmConstructorQualifiedNameParserRuleCall_2_0_1(), constructorCall.getConstructor());

	// '<' typeArguments+=JvmArgumentTypeReference (',' typeArguments+=JvmArgumentTypeReference)* '>'
	List<JvmTypeReference> typeArguments = constructorCall.getTypeArguments();
	if (!typeArguments.isEmpty()) {
		acceptor.accept(constructorCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_3_1_0(), typeArguments.get(0), 0);
		for (int i = 1; i < typeArguments.size(); i++)
			acceptor.accept(constructorCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_3_2_1_0(), typeArguments.get(i), i);
	}
	

	/*
	 * Constraint:
	 *      
	 *     (explicitConstructorCall?='(' (arguments+=XShortClosure | (arguments+=XExpression arguments+=XExpression*))?)? 
	 *     arguments+=XClosure?
	 *     
	 */
	if (constructorCall.isExplicitConstructorCall()) {
		acceptor.accept(constructorCallElements.getExplicitConstructorCallLeftParenthesisKeyword_4_0_0());
	}
	List<XExpression> arguments = constructorCall.getArguments();
	if (!arguments.isEmpty()) {
		if (constructorCall.isExplicitConstructorCall() && isXShortClosureAndBuilderSyntax(arguments, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) {
			acceptor.accept(constructorCallElements.getArgumentsXShortClosureParserRuleCall_4_1_0_0(), arguments.get(0), 0);
			acceptor.accept(constructorCallElements.getArgumentsXClosureParserRuleCall_5_0(), arguments.get(1), 1);
		} else if (constructorCall.isExplicitConstructorCall() && isXShortClosure(constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) {
			acceptor.accept(constructorCallElements.getArgumentsXShortClosureParserRuleCall_4_1_0_0(), arguments.get(0), 0);
		} else {
			int diff = 0;
			if (isBuilderSyntax(arguments, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) {
				diff = 1;
			}
			if (constructorCall.isExplicitConstructorCall()) {
				if (arguments.size() - diff > 0)
					acceptor.accept(constructorCallElements.getArgumentsXExpressionParserRuleCall_4_1_1_0_0(), arguments.get(0), 0);
				for (int i = 1; i < arguments.size() - diff; i++)
					acceptor.accept(constructorCallElements.getArgumentsXExpressionParserRuleCall_4_1_1_1_1_0(), arguments.get(i), i);
			}
			if (diff != 0) {
				int lastIdx = arguments.size() - 1;
				acceptor.accept(constructorCallElements.getArgumentsXClosureParserRuleCall_5_0(), arguments.get(lastIdx), lastIdx);
			}
		}
	}
	acceptor.finish();
}
 
Example #29
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constraint:
 *     (
 *         memberCallTarget=XMemberFeatureCall_XMemberFeatureCall_1_1_0_0_0
 *         (nullSafe?='?.' | spreading?='*.')?
 *         (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)?
 *         feature=[JvmIdentifiableElement|ID]
 *         (explicitOperationCall?='(' (memberCallArguments+=XShortClosure | (memberCallArguments+=XExpression memberCallArguments+=XExpression*))?)?
 *     )
 *     
 *
 * Features:
 *    feature[1, 1]
 *    typeArguments[0, *]
 *    memberCallTarget[1, 1]
 *    memberCallArguments[1, *]
 *         EXCLUDE_IF_UNSET explicitOperationCall
 *    explicitOperationCall[0, 1]
 *         MANDATORY_IF_SET memberCallArguments
 *         EXCLUDE_IF_UNSET memberCallArguments
 *         MANDATORY_IF_SET memberCallArguments
 *         MANDATORY_IF_SET memberCallArguments
 *    spreading[0, 1]
 *         EXCLUDE_IF_SET nullSafe
 *    nullSafe[0, 1]
 *         EXCLUDE_IF_SET spreading
 */
@Override
protected void sequence_XMemberFeatureCall(ISerializationContext context, XMemberFeatureCall featureCall) {
	INodesForEObjectProvider nodes = createNodeProvider(featureCall);
	SequenceFeeder acceptor = createSequencerFeeder(context, featureCall, nodes);
	XMemberFeatureCallElements memberFeatureCallElements= grammarAccess.getXMemberFeatureCallAccess();

	// memberCallTarget=XMemberFeatureCall_XMemberFeatureCall_1_1_0_0_0
	acceptor.accept(memberFeatureCallElements.getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0(), featureCall.getMemberCallTarget());

	// (nullSafe?='?.' | explicitStatic?='::')?
	if (featureCall.isNullSafe())
		acceptor.accept(memberFeatureCallElements.getNullSafeQuestionMarkFullStopKeyword_1_1_0_0_1_1_0());
	else if (featureCall.isExplicitStatic())
		acceptor.accept(memberFeatureCallElements.getExplicitStaticColonColonKeyword_1_1_0_0_1_2_0());

	// (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)?
	List<JvmTypeReference> typeArguments = featureCall.getTypeArguments();
	if (!typeArguments.isEmpty()) {
		acceptor.accept(memberFeatureCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_1_1_1_1_0(), typeArguments.get(0), 0);
		for (int i = 1; i < typeArguments.size(); i++)
			acceptor.accept(memberFeatureCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_1_1_1_2_1_0(), typeArguments.get(i), i);
	}

	// feature=[JvmIdentifiableElement|ID]
	acceptor.accept(memberFeatureCallElements.getFeatureJvmIdentifiableElementIdOrSuperParserRuleCall_1_1_2_0_1(), featureCall.getFeature());

	// (explicitOperationCall?='(' (memberCallArguments+=XShortClosure | (memberCallArguments+=XExpression memberCallArguments+=XExpression*))?)? memberCallArguments+=XClosure? 
	if (featureCall.isExplicitOperationCallOrBuilderSyntax()) {
		if (featureCall.isExplicitOperationCall())
			acceptor.accept(memberFeatureCallElements.getExplicitOperationCallLeftParenthesisKeyword_1_1_3_0_0());
		List<XExpression> arguments = featureCall.getMemberCallArguments();
		if (!arguments.isEmpty()) {
			if (featureCall.isExplicitOperationCall() && isXShortClosureAndBuilderSyntax(arguments, XbasePackage.Literals.XFEATURE_CALL__FEATURE_CALL_ARGUMENTS, nodes)) {
				acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXShortClosureParserRuleCall_1_1_3_1_0_0(), arguments.get(0), 0);
				acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0(), arguments.get(1), 1);
			} else if (featureCall.isExplicitOperationCall() && isXShortClosure(featureCall, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_ARGUMENTS, nodes)) {
				acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXShortClosureParserRuleCall_1_1_3_1_0_0(), arguments.get(0), 0);
			} else {
				int diff = 0;
				if (isBuilderSyntax(featureCall, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_ARGUMENTS, featureCall.isExplicitOperationCall(), nodes)) {
					diff = 1;
				}
				if (featureCall.isExplicitOperationCall()) {
					if (arguments.size() - diff > 0)
						acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXExpressionParserRuleCall_1_1_3_1_1_0_0(), arguments.get(0), 0);
					for (int i = 1; i < arguments.size() - diff; i++)
						acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXExpressionParserRuleCall_1_1_3_1_1_1_1_0(), arguments.get(i), i);
				}
				if (diff != 0) {
					int lastIdx = arguments.size() - 1;
					acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0(), arguments.get(lastIdx), lastIdx);
				}
			}
		}
	}
	acceptor.finish();
}
 
Example #30
Source File: XbaseSemanticSequencer.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isXShortClosureAndBuilderSyntax(List<?> values, EReference reference, INodesForEObjectProvider nodes) {
	if (values.size() != 2)
		return false;
	return isXShortClosure(values, reference, nodes) && isBuilderSyntax(values, reference, nodes);
}