Search in sources :

Example 1 with AllRulesCache

use of org.eclipse.xtext.service.AllRulesCache in project xtext-core by eclipse.

the class AbstractInternalAntlrParser method createAllRules.

/**
 * @since 2.11
 */
protected Map<String, AbstractRule> createAllRules(Grammar grammar) {
    AllRulesCache cache = AllRulesCache.findInEmfObject(grammar);
    if (cache != null) {
        return cache.getAllRules();
    }
    Map<String, AbstractRule> allRules = Maps.newHashMap();
    for (AbstractRule rule : GrammarUtil.allRules(grammar)) {
        if (rule instanceof TerminalRule)
            allRules.put(rule.getName().toUpperCase(), rule);
        else
            allRules.put(rule.getName(), rule);
    }
    return allRules;
}
Also used : AllRulesCache(org.eclipse.xtext.service.AllRulesCache) TerminalRule(org.eclipse.xtext.TerminalRule) AbstractRule(org.eclipse.xtext.AbstractRule)

Aggregations

AbstractRule (org.eclipse.xtext.AbstractRule)1 TerminalRule (org.eclipse.xtext.TerminalRule)1 AllRulesCache (org.eclipse.xtext.service.AllRulesCache)1