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();
}
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();
}
}
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;
}
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);
}
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)));
}
}
Aggregations