}
public void removeLeftRecursion() {
StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_REMOVE_LEFT_RECURSION);
ElementRule rule = window.editorRules.getEnclosingRuleAtPosition(window.getCaretPosition());
if(rule == null) {
XJAlert.display(window.getJavaContainer(), "Remove Left Recursion", "There is no rule at cursor position.");
return;
}
if(!rule.hasLeftRecursion()) {
XJAlert.display(window.getJavaContainer(), "Remove Left Recursion", "The rule doesn't have a left recursion.");
return;
}
beginRefactor("Remove Left Recursion");
String ruleText = rule.getTextRuleAfterRemovingLeftRecursion();
mutator.replace(rule.getInternalTokensStartIndex(), rule.getInternalTokensEndIndex(), ruleText);
endRefactor();
}