Search in sources :

Example 1 with SerializerPDACloneFactory

use of org.eclipse.xtext.serializer.analysis.SerializerPDA.SerializerPDACloneFactory in project xtext-core by eclipse.

the class ContextPDAProvider method filterUnneededUnassignedRuleCalls.

protected Pda<ISerState, RuleCall> filterUnneededUnassignedRuleCalls(Pda<ISerState, RuleCall> pda, Map<ParserRule, Integer> indexedRules) {
    Set<ParserRule> exclude = findRuleCallsToExclude(pda, indexedRules);
    if (exclude.isEmpty())
        return pda;
    SerializerPDA filtered = pdaUtil.filter(pda, new Predicate<ISerState>() {

        @Override
        public boolean apply(ISerState input) {
            SerStateType type = input.getType();
            if (type == SerStateType.PUSH || type == SerStateType.POP) {
                AbstractRule rule = ((RuleCall) input.getGrammarElement()).getRule();
                return !exclude.contains(rule);
            }
            return true;
        }
    }, new SerializerPDACloneFactory());
    return filtered;
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) AbstractRule(org.eclipse.xtext.AbstractRule) SerStateType(org.eclipse.xtext.serializer.analysis.ISerState.SerStateType) SerializerPDACloneFactory(org.eclipse.xtext.serializer.analysis.SerializerPDA.SerializerPDACloneFactory)

Aggregations

AbstractRule (org.eclipse.xtext.AbstractRule)1 ParserRule (org.eclipse.xtext.ParserRule)1 SerStateType (org.eclipse.xtext.serializer.analysis.ISerState.SerStateType)1 SerializerPDACloneFactory (org.eclipse.xtext.serializer.analysis.SerializerPDA.SerializerPDACloneFactory)1