Java Code Examples for org.eclipse.xtext.serializer.ISerializationContext

The following examples show how to use org.eclipse.xtext.serializer.ISerializationContext. These examples are extracted from open source projects. 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
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == RefactoringTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case RefactoringTestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case RefactoringTestLanguagePackage.REFERENCE_HOLDER:
			sequence_ReferenceHolder(context, (ReferenceHolder) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example 2
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == FoldingPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case FoldingPackage.ELEMENT:
			sequence_Element(context, (Element) semanticObject); 
			return; 
		case FoldingPackage.FOLDING_MODEL:
			sequence_FoldingModel(context, (FoldingModel) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example 3
/**
 * Contexts:
 *     WhereEntry returns VariableWhereEntry
 *     WhereEntry.OrWhereEntry_1_0 returns VariableWhereEntry
 *     AndWhereEntry returns VariableWhereEntry
 *     AndWhereEntry.AndWhereEntry_1_0 returns VariableWhereEntry
 *     ConcreteWhereEntry returns VariableWhereEntry
 *     ParWhereEntry returns VariableWhereEntry
 *     AttributeWhereEntry returns VariableWhereEntry
 *     VariableWhereEntry returns VariableWhereEntry
 *
 * Constraint:
 *     (alias=[FromEntry|ID] attribute=[EAttribute|ID] operator=NumericOperator rightAlias=[FromEntry|ID] rightAttribute=[EAttribute|ID])
 */
protected void sequence_VariableWhereEntry(ISerializationContext context, VariableWhereEntry semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ALIAS) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ALIAS));
		if (transientValues.isValueTransient(semanticObject, Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ATTRIBUTE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ATTRIBUTE));
		if (transientValues.isValueTransient(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__OPERATOR) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__OPERATOR));
		if (transientValues.isValueTransient(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ALIAS) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ALIAS));
		if (transientValues.isValueTransient(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ATTRIBUTE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ATTRIBUTE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getVariableWhereEntryAccess().getAliasFromEntryIDTerminalRuleCall_0_0_1(), semanticObject.eGet(Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ALIAS, false));
	feeder.accept(grammarAccess.getVariableWhereEntryAccess().getAttributeEAttributeIDTerminalRuleCall_2_0_1(), semanticObject.eGet(Bug287941TestLanguagePackage.Literals.ATTRIBUTE_WHERE_ENTRY__ATTRIBUTE, false));
	feeder.accept(grammarAccess.getVariableWhereEntryAccess().getOperatorNumericOperatorEnumRuleCall_3_0(), semanticObject.getOperator());
	feeder.accept(grammarAccess.getVariableWhereEntryAccess().getRightAliasFromEntryIDTerminalRuleCall_4_0_1(), semanticObject.eGet(Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ALIAS, false));
	feeder.accept(grammarAccess.getVariableWhereEntryAccess().getRightAttributeEAttributeIDTerminalRuleCall_6_0_1(), semanticObject.eGet(Bug287941TestLanguagePackage.Literals.VARIABLE_WHERE_ENTRY__RIGHT_ATTRIBUTE, false));
	feeder.finish();
}
 
Example 4
/**
 * Contexts:
 *     Root returns TestOffset
 *     TestOffset returns TestOffset
 *
 * Constraint:
 *     (value=ID first=ID second=ID)
 */
protected void sequence_TestOffset(ISerializationContext context, TestOffset semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__VALUE));
		if (transientValues.isValueTransient(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__FIRST) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__FIRST));
		if (transientValues.isValueTransient(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__SECOND) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, FormatterTestLanguagePackage.Literals.TEST_OFFSET__SECOND));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getTestOffsetAccess().getValueIDTerminalRuleCall_3_0(), semanticObject.getValue());
	feeder.accept(grammarAccess.getTestOffsetAccess().getFirstIDTerminalRuleCall_5_0(), semanticObject.getFirst());
	feeder.accept(grammarAccess.getTestOffsetAccess().getSecondIDTerminalRuleCall_6_0(), semanticObject.getSecond());
	feeder.finish();
}
 
Example 5
/**
 * Contexts:
 *     Rule8 returns Rule8
 *
 * Constraint:
 *     (left=INT right?='#1' unit='s')
 */
protected void sequence_Rule8(ISerializationContext context, Rule8 semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, Gh1462TestPackage.Literals.RULE8__LEFT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Gh1462TestPackage.Literals.RULE8__LEFT));
		if (transientValues.isValueTransient(semanticObject, Gh1462TestPackage.Literals.RULE8__RIGHT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Gh1462TestPackage.Literals.RULE8__RIGHT));
		if (transientValues.isValueTransient(semanticObject, Gh1462TestPackage.Literals.RULE8__UNIT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Gh1462TestPackage.Literals.RULE8__UNIT));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getRule8Access().getLeftINTTerminalRuleCall_0_0(), semanticObject.getLeft());
	feeder.accept(grammarAccess.getRule8Access().getRight1Keyword_1_0(), semanticObject.isRight());
	feeder.accept(grammarAccess.getRule8Access().getUnitSKeyword_2_0(), semanticObject.getUnit());
	feeder.finish();
}
 
Example 6
@Override
public ISerializationDiagnostic createInvalidContextOrTypeDiagnostic(EObject sem, ISerializationContext context) {
	Set<ISerializationContext> contexts = Sets.newHashSet(contextFinder.findByContentsAndContainer(sem, null));
	Set<EClass> validTypes = getValidTypes(context);
	List<ISerializationContext> recommendedCtxs = Lists.newArrayList();
	List<ISerializationContext> otherValidCtxs = Lists.newArrayList();
	for (ISerializationContext ctx : getValidContexts(sem.eClass())) {
		if (contexts.contains(ctx))
			recommendedCtxs.add(ctx);
		else
			otherValidCtxs.add(ctx);
	}
	String semanticType = sem.eClass().getName();
	String validTypeNames = Joiner.on(", ").join(Iterables.transform(validTypes, new NamedElement2Name()));
	StringBuilder msg = new StringBuilder();
	msg.append("The context '" + context + "' is not valid for type '" + semanticType + "'\n");
	msg.append("Recommended contexts for type '" + semanticType + "': " + recommendedCtxs + "\n");
	if (!otherValidCtxs.isEmpty())
		msg.append("Other valid contexts for type '" + semanticType + "': " + otherValidCtxs);
	msg.append("The context '" + context + "' is valid for types: " + validTypeNames + "\n");
	return new SerializationDiagnostic(INVALID_CONTEXT_OR_TYPE, sem, grammarAccess.getGrammar(), msg.toString());
}
 
Example 7
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == TestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case TestLanguagePackage.GREETING:
			sequence_Greeting(context, (Greeting) semanticObject); 
			return; 
		case TestLanguagePackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example 8
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == IgnoreCaseLinkingTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case IgnoreCaseLinkingTestPackage.ELEMENT:
			sequence_Element(context, (Element) semanticObject); 
			return; 
		}
	else if (epackage == IgnoreCaseNamespacesTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case IgnoreCaseNamespacesTestPackage.IMPORT:
			sequence_Import(context, (Import) semanticObject); 
			return; 
		case IgnoreCaseNamespacesTestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example 9
/**
 * Contexts:
 *     SingleContainmentReferenceChild1 returns SingleContainmentReferenceChild1
 *
 * Constraint:
 *     val='kw1'
 */
protected void sequence_SingleContainmentReferenceChild1(ISerializationContext context, SingleContainmentReferenceChild1 semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, SequencertestPackage.Literals.SINGLE_CONTAINMENT_REFERENCE_CHILD1__VAL) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, SequencertestPackage.Literals.SINGLE_CONTAINMENT_REFERENCE_CHILD1__VAL));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSingleContainmentReferenceChild1Access().getValKw1Keyword_0(), semanticObject.getVal());
	feeder.finish();
}
 
Example 10
/**
 * Contexts:
 *     Person returns Kind
 *     Kind returns Kind
 *
 * Constraint:
 *     (name=ID age=INT)
 */
protected void sequence_Kind(ISerializationContext context, Kind semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, ReferenceGrammarPackage.Literals.PERSON__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ReferenceGrammarPackage.Literals.PERSON__NAME));
		if (transientValues.isValueTransient(semanticObject, ReferenceGrammarPackage.Literals.PERSON__AGE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ReferenceGrammarPackage.Literals.PERSON__AGE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getKindAccess().getNameIDTerminalRuleCall_2_0(), semanticObject.getName());
	feeder.accept(grammarAccess.getKindAccess().getAgeINTTerminalRuleCall_3_0(), semanticObject.getAge());
	feeder.finish();
}
 
Example 11
/**
 * Contexts:
 *     SimpleGroup returns SimpleGroup
 *
 * Constraint:
 *     (val1=ID val2=ID)
 */
protected void sequence_SimpleGroup(ISerializationContext context, SimpleGroup semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, CsvalidationtestPackage.Literals.SIMPLE_GROUP__VAL1) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, CsvalidationtestPackage.Literals.SIMPLE_GROUP__VAL1));
		if (transientValues.isValueTransient(semanticObject, CsvalidationtestPackage.Literals.SIMPLE_GROUP__VAL2) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, CsvalidationtestPackage.Literals.SIMPLE_GROUP__VAL2));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSimpleGroupAccess().getVal1IDTerminalRuleCall_1_0(), semanticObject.getVal1());
	feeder.accept(grammarAccess.getSimpleGroupAccess().getVal2IDTerminalRuleCall_2_0(), semanticObject.getVal2());
	feeder.finish();
}
 
Example 12
/**
 * Contexts:
 *     Wrapper returns Wrapper
 *
 * Constraint:
 *     value=INT
 */
protected void sequence_Wrapper(ISerializationContext context, Wrapper semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, Gh1462TestPackage.Literals.WRAPPER__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Gh1462TestPackage.Literals.WRAPPER__VALUE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getWrapperAccess().getValueINTTerminalRuleCall_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example 13
/**
 * Contexts:
 *     ParameterObject returns MyInt
 *     MyInt returns MyInt
 *
 * Constraint:
 *     int=INT
 */
protected void sequence_MyInt(ISerializationContext context, MyInt semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, Bug288432TestPackage.Literals.MY_INT__INT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug288432TestPackage.Literals.MY_INT__INT));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getMyIntAccess().getIntINTTerminalRuleCall_0(), semanticObject.getInt());
	feeder.finish();
}
 
Example 14
/**
 * Contexts:
 *     Contained returns Contained
 *
 * Constraint:
 *     name=ID
 */
protected void sequence_Contained(ISerializationContext context, Contained semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, Bug289524ExTestPackage.Literals.CONTAINED__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, Bug289524ExTestPackage.Literals.CONTAINED__NAME));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getContainedAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
	feeder.finish();
}
 
Example 15
/**
 * Contexts:
 *     OverridableParserRule2 returns AType
 *
 * Constraint:
 *     name=STRING
 */
protected void sequence_OverridableParserRule2(ISerializationContext context, AType semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, AmetamodelPackage.Literals.ATYPE__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, AmetamodelPackage.Literals.ATYPE__NAME));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getOverridableParserRule2Access().getNameSTRINGTerminalRuleCall_1_0(), semanticObject.getName());
	feeder.finish();
}
 
Example 16
/**
 * Contexts:
 *     AbstractRule returns SecondAbstractRuleChild
 *     SecondAbstractRuleChild returns SecondAbstractRuleChild
 *
 * Constraint:
 *     (name=ID rule=AbstractRuleCall)
 */
protected void sequence_SecondAbstractRuleChild(ISerializationContext context, SecondAbstractRuleChild semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, ContentAssistTestLanguagePackage.Literals.ABSTRACT_RULE__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ContentAssistTestLanguagePackage.Literals.ABSTRACT_RULE__NAME));
		if (transientValues.isValueTransient(semanticObject, ContentAssistTestLanguagePackage.Literals.SECOND_ABSTRACT_RULE_CHILD__RULE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ContentAssistTestLanguagePackage.Literals.SECOND_ABSTRACT_RULE_CHILD__RULE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSecondAbstractRuleChildAccess().getNameIDTerminalRuleCall_0_0(), semanticObject.getName());
	feeder.accept(grammarAccess.getSecondAbstractRuleChildAccess().getRuleAbstractRuleCallParserRuleCall_3_0(), semanticObject.getRule());
	feeder.finish();
}
 
Example 17
@Override
public boolean enterAssignedParserRuleCall(RuleCall rc, EObject semanticChild, ICompositeNode node) {
	navigateToAbsorber(rc, node);
	boolean shouldEnter = delegate.enterAssignedParserRuleCall(rc, semanticChild, node);
	if (shouldEnter) {
		ISerializationContext child = SerializationContext.forChild(contexts.peek().context, rc, semanticChild);
		ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
		if (pda == null)
			throw new IllegalStateException();
		SyntacticalContext j = new SyntacticalContext(child, semanticChild, pda, node);
		contexts.push(j);
	}
	return shouldEnter;
}
 
Example 18
/**
 * Contexts:
 *     Model returns Model
 *
 * Constraint:
 *     value='CaSe'
 */
protected void sequence_Model(ISerializationContext context, Model semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, IgnoreCaseTestLanguagePackage.Literals.MODEL__VALUE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, IgnoreCaseTestLanguagePackage.Literals.MODEL__VALUE));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getModelAccess().getValueCaSeKeyword_2_0(), semanticObject.getValue());
	feeder.finish();
}
 
Example 19
Source Project: xtext-core   Source File: SerializerFragment2.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private StringConcatenationClient genCondition(final List<ISerializationContext> contexts, final IGrammarConstraintProvider.IConstraint constraint, final Multimap<EObject, IGrammarConstraintProvider.IConstraint> ctx2ctr) {
  StringConcatenationClient _xblockexpression = null;
  {
    final List<ISerializationContext> sorted = IterableExtensions.<ISerializationContext>sort(contexts);
    final LinkedHashMultimap<EObject, ISerializationContext> index = LinkedHashMultimap.<EObject, ISerializationContext>create();
    final Consumer<ISerializationContext> _function = (ISerializationContext it) -> {
      index.put(this.getContextObject(it), it);
    };
    sorted.forEach(_function);
    StringConcatenationClient _client = new StringConcatenationClient() {
      @Override
      protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
        {
          Set<EObject> _keySet = index.keySet();
          boolean _hasElements = false;
          for(final EObject obj : _keySet) {
            if (!_hasElements) {
              _hasElements = true;
            } else {
              _builder.appendImmediate("\n\t\t|| ", "");
            }
            StringConcatenationClient _genObjectSelector = SerializerFragment2.this.genObjectSelector(obj);
            _builder.append(_genObjectSelector);
            {
              int _size = ctx2ctr.get(obj).size();
              boolean _greaterThan = (_size > 1);
              if (_greaterThan) {
                StringConcatenationClient _genParameterSelector = SerializerFragment2.this.genParameterSelector(obj, index.get(obj), constraint);
                _builder.append(_genParameterSelector);
              }
            }
          }
        }
      }
    };
    _xblockexpression = _client;
  }
  return _xblockexpression;
}
 
Example 20
Source Project: xtext-core   Source File: ContextFinder.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Set<ISerializationContext> findByContents(EObject semanticObject, Iterable<ISerializationContext> contextCandidates) {
	if (semanticObject == null)
		throw new NullPointerException();

	initConstraints();

	Multimap<IConstraint, ISerializationContext> constraints;
	if (contextCandidates != null)
		constraints = getConstraints(semanticObject, contextCandidates);
	else
		constraints = getConstraints(semanticObject);

	if (constraints.size() < 2)
		return Sets.newLinkedHashSet(constraints.values());

	for (IConstraint cand : Lists.newArrayList(constraints.keySet()))
		if (!isValidValueQuantity(cand, semanticObject))
			constraints.removeAll(cand);

	if (constraints.size() < 2)
		return Sets.newLinkedHashSet(constraints.values());

	LinkedHashSet<ISerializationContext> result = Sets.newLinkedHashSet(constraints.values());
	for (EStructuralFeature feat : semanticObject.eClass().getEAllStructuralFeatures()) {
		if (transientValueUtil.isTransient(semanticObject, feat) != ValueTransient.NO)
			continue;
		if (feat.isMany() && ((List<?>) semanticObject.eGet(feat)).isEmpty())
			continue;
		Multimap<AbstractElement, ISerializationContext> assignments = collectAssignments(constraints, feat);
		Set<AbstractElement> assignedElements = findAssignedElements(semanticObject, feat, assignments);
		Set<ISerializationContext> keep = Sets.newHashSet();
		for (AbstractElement ele : assignedElements)
			keep.addAll(assignments.get(ele));
		result.retainAll(keep);
	}
	return result;
}
 
Example 21
/**
 * Contexts:
 *     Type returns DataType
 *     DataType returns DataType
 *
 * Constraint:
 *     name=ID
 */
protected void sequence_DataType(ISerializationContext context, DataType semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, DomainModelTestPackage.Literals.TYPE__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, DomainModelTestPackage.Literals.TYPE__NAME));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getDataTypeAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
	feeder.finish();
}
 
Example 22
/**
 * Contexts:
 *     ClassifierRef returns SimpleClassifierRef
 *     SimpleClassifierRef returns SimpleClassifierRef
 *
 * Constraint:
 *     classifier=Identifier
 */
protected void sequence_SimpleClassifierRef(ISerializationContext context, SimpleClassifierRef semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, BacktrackingContentAssistTestPackage.Literals.SIMPLE_CLASSIFIER_REF__CLASSIFIER) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, BacktrackingContentAssistTestPackage.Literals.SIMPLE_CLASSIFIER_REF__CLASSIFIER));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSimpleClassifierRefAccess().getClassifierIdentifierParserRuleCall_0(), semanticObject.getClassifier());
	feeder.finish();
}
 
Example 23
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == SecondPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case SecondPackage.SECOND:
			sequence_Second(context, (Second) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example 24
/**
 * Contexts:
 *     Signal returns OutputSignal
 *
 * Constraint:
 *     name=ID
 */
protected void sequence_OutputSignal_Signal(ISerializationContext context, OutputSignal semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, StatemachinePackage.Literals.SIGNAL__NAME) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, StatemachinePackage.Literals.SIGNAL__NAME));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSignalAccess().getNameIDTerminalRuleCall_2_0(), semanticObject.getName());
	feeder.finish();
}
 
Example 25
/**
 * Contexts:
 *     ClassifierRef returns QualifiedClassifierRef
 *     QualifiedClassifierRef returns QualifiedClassifierRef
 *
 * Constraint:
 *     (namespace=Identifier element=ClassifierRef)
 */
protected void sequence_QualifiedClassifierRef(ISerializationContext context, QualifiedClassifierRef semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, BacktrackingContentAssistTestPackage.Literals.QUALIFIED_CLASSIFIER_REF__NAMESPACE) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, BacktrackingContentAssistTestPackage.Literals.QUALIFIED_CLASSIFIER_REF__NAMESPACE));
		if (transientValues.isValueTransient(semanticObject, BacktrackingContentAssistTestPackage.Literals.QUALIFIED_CLASSIFIER_REF__ELEMENT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, BacktrackingContentAssistTestPackage.Literals.QUALIFIED_CLASSIFIER_REF__ELEMENT));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getQualifiedClassifierRefAccess().getNamespaceIdentifierParserRuleCall_0_0(), semanticObject.getNamespace());
	feeder.accept(grammarAccess.getQualifiedClassifierRefAccess().getElementClassifierRefParserRuleCall_2_0(), semanticObject.getElement());
	feeder.finish();
}
 
Example 26
Source Project: xtext-core   Source File: ISyntacticSequencer.java    License: Eclipse Public License 2.0 4 votes vote down vote up
void init(ISerializationContext context, EObject semanticObject, ISyntacticSequenceAcceptor sequenceAcceptor,
ISerializationDiagnostic.Acceptor errorAcceptor);
 
Example 27
@Override
public List<ISerializationContext> getContexts() {
	return contexts;
}
 
Example 28
Source Project: xtext-core   Source File: InsertionPointFinder.java    License: Eclipse Public License 2.0 4 votes vote down vote up
protected ISerState findState(ISerializationContext ctx, AbstractElement ele) {
	Pda<ISerState, RuleCall> pda = pdas.get(ctx);
	return new NfaUtil().find(pda, s -> s.getGrammarElement() == ele);
}
 
Example 29
Source Project: dsl-devkit   Source File: IndentingSerializer.java    License: Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Serialize the given object into tokenStream using save options.
 * The initial indentation is passed on to the formatter.
 * This implementation is based on {@link Serializer#serialize(EObject, ITokenStream, SaveOptions)}.
 *
 * @param obj
 *          the obj
 * @param tokenStream
 *          the token stream
 * @param options
 *          the options
 * @param initialIndentation
 *          the initial indentation
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
protected void serialize(final EObject obj, final ITokenStream tokenStream, final SaveOptions options, final String initialIndentation) throws IOException {
  ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR;
  ITokenStream formatterTokenStream;
  if (formatter instanceof IFormatterExtension) {
    formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, initialIndentation, tokenStream, !options.isFormatting());
  } else {
    formatterTokenStream = formatter.createFormatterStream(initialIndentation, tokenStream, !options.isFormatting());
  }
  ISerializationContext context = getIContext(obj);
  ISequenceAcceptor acceptor = new TokenStreamSequenceAdapter(formatterTokenStream, grammar.getGrammar(), errors);
  serialize(context, obj, acceptor, errors);
  formatterTokenStream.flush();
}
 
Example 30
/**
 * Contexts:
 *     NavigationExp returns SimpleNameExp
 *     NavigationExp.InfixExp_1_0_0 returns SimpleNameExp
 *     NavigationExp.OclMessage_1_1_0 returns SimpleNameExp
 *     NavigatingExp returns SimpleNameExp
 *     NavigatingExp.InfixExp_1_0_0 returns SimpleNameExp
 *     NavigatingExp.OclMessage_1_1_0 returns SimpleNameExp
 *     OclMessageArg returns SimpleNameExp
 *     TypeExp returns SimpleNameExp
 *     Expression returns SimpleNameExp
 *     implies returns SimpleNameExp
 *     implies.InfixExp_1_0 returns SimpleNameExp
 *     xor returns SimpleNameExp
 *     xor.InfixExp_1_0 returns SimpleNameExp
 *     or returns SimpleNameExp
 *     or.InfixExp_1_0 returns SimpleNameExp
 *     and returns SimpleNameExp
 *     and.InfixExp_1_0 returns SimpleNameExp
 *     equality returns SimpleNameExp
 *     equality.InfixExp_1_0 returns SimpleNameExp
 *     relational returns SimpleNameExp
 *     relational.InfixExp_1_0 returns SimpleNameExp
 *     additive returns SimpleNameExp
 *     additive.InfixExp_1_0 returns SimpleNameExp
 *     multiplicative returns SimpleNameExp
 *     multiplicative.InfixExp_1_0 returns SimpleNameExp
 *     unary returns SimpleNameExp
 *     SubNavigationExp returns SimpleNameExp
 *     SubNavigatingExp returns SimpleNameExp
 *     NameExp returns SimpleNameExp
 *     SimpleNameExp returns SimpleNameExp
 *
 * Constraint:
 *     element=Identifier
 */
protected void sequence_SimpleNameExp(ISerializationContext context, SimpleNameExp semanticObject) {
	if (errorAcceptor != null) {
		if (transientValues.isValueTransient(semanticObject, BacktrackingContentAssistTestPackage.Literals.SIMPLE_NAME_EXP__ELEMENT) == ValueTransient.YES)
			errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, BacktrackingContentAssistTestPackage.Literals.SIMPLE_NAME_EXP__ELEMENT));
	}
	SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
	feeder.accept(grammarAccess.getSimpleNameExpAccess().getElementIdentifierParserRuleCall_0(), semanticObject.getElement());
	feeder.finish();
}