Search in sources :

Example 26 with ElementRule

use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.

the class EditorRules method ignoreSelectedRules.

public void ignoreSelectedRules(boolean flag) {
    for (ElementRule r : getSelectedRules()) {
        r.ignored = flag;
    }
    rulesTree.repaint();
    window.rulesDidChange();
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 27 with ElementRule

use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.

the class EditorRules method selectNextRule.

public void selectNextRule() {
    ElementRule rule = getEnclosingRuleAtPosition(window.getCaretPosition());
    int index = getGrammarEngine().getRules().indexOf(rule) + 1;
    rule = getGrammarEngine().getRuleAtIndex(index);
    if (rule != null) {
        window.setCaretPosition(rule.getStartIndex());
        window.rulesCaretPositionDidChange();
    }
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 28 with ElementRule

use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.

the class EditorRules method getSortedRules.

public List<ElementRule> getSortedRules(List<ElementRule> rules) {
    if (rules == null)
        return null;
    List<ElementRule> sortedRules = new ArrayList<ElementRule>(rules);
    Collections.sort(sortedRules);
    if (!sortedRules.isEmpty()) {
        ElementRule firstRule = sortedRules.get(0);
        if (firstRule.lexer) {
            for (int index = 0; index < sortedRules.size(); index++) {
                ElementRule rule = sortedRules.get(0);
                if (!rule.lexer)
                    break;
                sortedRules.add(rule);
                sortedRules.remove(0);
            }
        }
    }
    return sortedRules;
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 29 with ElementRule

use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.

the class EditorRules method xjTreeDrop.

public boolean xjTreeDrop(XJTree tree, Object sourceObject, Object targetObject, int dropLocation) {
    StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_DROP_RULE);
    ElementRule sourceRule = ((EditorRules.RuleTreeUserObject) sourceObject).rule;
    ElementRule targetRule = ((EditorRules.RuleTreeUserObject) targetObject).rule;
    return moveRule(sourceRule, targetRule, dropLocation == XJTree.DROP_ABOVE);
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 30 with ElementRule

use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.

the class EditorRules method buildTree.

protected void buildTree(DefaultMutableTreeNode parentNode, List<ElementRule> rules, int from, int to) {
    // Sort the list of subrules
    List<ElementRule> subrules = rules.subList(from, to + 1);
    if (sort && !subrules.isEmpty()) {
        subrules = getSortedRules(subrules);
        Collections.sort(subrules);
        ElementRule firstRule = subrules.get(0);
        if (firstRule.lexer) {
            for (int index = 0; index < subrules.size(); index++) {
                ElementRule rule = subrules.get(0);
                if (!rule.lexer)
                    break;
                subrules.add(rule);
                subrules.remove(0);
            }
        }
    }
    for (ElementRule rule : subrules) {
        parentNode.add(new DefaultMutableTreeNode(new RuleTreeUserObject(rule)));
    }
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Aggregations

ElementRule (org.antlr.works.grammar.element.ElementRule)30 ElementReference (org.antlr.works.grammar.element.ElementReference)3 ATEToken (org.antlr.works.ate.syntax.misc.ATEToken)2 IOException (java.io.IOException)1 Set (java.util.Set)1 ATEGutterItem (org.antlr.works.ate.gutter.ATEGutterItem)1 Usages (org.antlr.works.find.Usages)1 ElementAction (org.antlr.works.grammar.element.ElementAction)1 ElementGroup (org.antlr.works.grammar.element.ElementGroup)1 SDGenerator (org.antlr.works.visualization.SDGenerator)1