Search in sources :

Example 1 with PluralRule

use of org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.PluralRule in project xtext-core by eclipse.

the class AbstractUnassignedTextTestLanguageSemanticSequencer method sequence.

@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 == UnassignedtextPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case UnassignedtextPackage.CASE_INSENSITIVE_KEYWORD_RULE:
                sequence_CaseInsensitiveKeywordRule(context, (CaseInsensitiveKeywordRule) semanticObject);
                return;
            case UnassignedtextPackage.COMMON_TERMINALS_RULE:
                sequence_CommonTerminalsRule(context, (CommonTerminalsRule) semanticObject);
                return;
            case UnassignedtextPackage.DATATYPE_RULE:
                sequence_DatatypeRule(context, (DatatypeRule) semanticObject);
                return;
            case UnassignedtextPackage.MULTI_RULE:
                sequence_MultiRule(context, (MultiRule) semanticObject);
                return;
            case UnassignedtextPackage.PLURAL_RULE:
                sequence_PluralRule(context, (PluralRule) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) PluralRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.PluralRule) Action(org.eclipse.xtext.Action) MultiRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.MultiRule) CommonTerminalsRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.CommonTerminalsRule) Parameter(org.eclipse.xtext.Parameter) CaseInsensitiveKeywordRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.CaseInsensitiveKeywordRule) DatatypeRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.DatatypeRule) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with PluralRule

use of org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.PluralRule in project xtext-core by eclipse.

the class UnassignedTextTestSerializer method serializeUnassignedValueByRuleCall.

@Override
protected String serializeUnassignedValueByRuleCall(RuleCall ruleCall, EObject current, INode node) {
    UnassignedTextTestLanguageGrammarAccess g = (UnassignedTextTestLanguageGrammarAccess) grammar;
    if (ruleCall == g.getCaseInsensitiveKeywordRuleAccess().getCaseInsensitiveKeywordTerminalRuleCall_0())
        return "KeyWord";
    if (ruleCall == g.getPluralRuleAccess().getPluralTerminalRuleCall_2()) {
        PluralRule pr = (PluralRule) current;
        return pr.getCount() == 1 ? "item" : "items";
    }
    MultiRuleElements e = g.getMultiRuleAccess();
    if (ruleCall == e.getMultiTerminalRuleCall_2())
        return "accegj01";
    if (ruleCall == e.getMultiTerminalRuleCall_3())
        return "accegj02";
    if (ruleCall == e.getMultiTerminalRuleCall_4())
        return "accegj03";
    if (ruleCall == g.getDatatypeRuleAccess().getDatatypeParserRuleCall_2())
        return "str";
    CommonTerminalsRuleElements c = g.getCommonTerminalsRuleAccess();
    if (ruleCall == c.getIDTerminalRuleCall_1())
        return "abc";
    if (ruleCall == c.getINTTerminalRuleCall_2())
        return "123";
    if (ruleCall == c.getSTRINGTerminalRuleCall_3())
        return "'abc'";
    return null;
}
Also used : PluralRule(org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.PluralRule) CommonTerminalsRuleElements(org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess.CommonTerminalsRuleElements) UnassignedTextTestLanguageGrammarAccess(org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess) MultiRuleElements(org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess.MultiRuleElements)

Aggregations

PluralRule (org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.PluralRule)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 UnassignedTextTestLanguageGrammarAccess (org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess)1 CommonTerminalsRuleElements (org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess.CommonTerminalsRuleElements)1 MultiRuleElements (org.eclipse.xtext.parsetree.unassignedtext.services.UnassignedTextTestLanguageGrammarAccess.MultiRuleElements)1 CaseInsensitiveKeywordRule (org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.CaseInsensitiveKeywordRule)1 CommonTerminalsRule (org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.CommonTerminalsRule)1 DatatypeRule (org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.DatatypeRule)1 MultiRule (org.eclipse.xtext.parsetree.unassignedtext.unassignedtext.MultiRule)1