Search in sources :

Example 1 with IFollowElementAcceptor

use of org.eclipse.xtext.ide.editor.contentassist.IFollowElementAcceptor in project n4js by eclipse.

the class PatchedFollowElementComputer method computeFollowElements.

@Override
public void computeFollowElements(Collection<FollowElement> followElements, final IFollowElementAcceptor followElementAcceptor) {
    FollowElementCalculator calculator = feCalculatorProvider.get();
    calculator.setAcceptor(new IFollowElementAcceptor() {

        @Override
        public void accept(AbstractElement element) {
            ParserRule rule = GrammarUtil.containingParserRule(element);
            if (rule == null || !GrammarUtil.isDatatypeRule(rule))
                followElementAcceptor.accept(element);
        }
    });
    for (FollowElement element : followElements) {
        List<Integer> paramStack = element.getParamStack();
        if (!paramStack.isEmpty()) {
            calculator.setParameterConfig(paramStack.get(paramStack.size() - 1));
        } else {
            calculator.setParameterConfig(0);
        }
        computeFollowElements(calculator, element);
    }
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) FollowElementCalculator(org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElementCalculator) AbstractElement(org.eclipse.xtext.AbstractElement) IFollowElementAcceptor(org.eclipse.xtext.ide.editor.contentassist.IFollowElementAcceptor) FollowElement(org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement)

Aggregations

AbstractElement (org.eclipse.xtext.AbstractElement)1 ParserRule (org.eclipse.xtext.ParserRule)1 IFollowElementAcceptor (org.eclipse.xtext.ide.editor.contentassist.IFollowElementAcceptor)1 FollowElement (org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElement)1 FollowElementCalculator (org.eclipse.xtext.ide.editor.contentassist.antlr.FollowElementCalculator)1