use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.
the class GrammarWindow method goToRule.
public boolean goToRule(String ruleName) {
ElementRule rule = editorRules.selectRuleNameInTree(ruleName);
if (rule != null) {
goToHistoryRememberCurrentPosition();
editorRules.goToRule(rule);
return true;
}
return false;
}
use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.
the class GrammarWindow method setCaretPosition.
private void setCaretPosition(int position, boolean animate) {
ElementRule rule = editorRules.getEnclosingRuleAtPosition(position);
if (rule != null && !rule.isExpanded()) {
foldingManager.toggleFolding(rule);
}
textEditor.setCaretPosition(position, true, animate);
}
use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.
the class GrammarRefactorMenu method inlineRule.
public void inlineRule() {
StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_INLINE_RULE);
ElementRule rule = window.editorRules.getEnclosingRuleAtPosition(window.getCaretPosition());
if (rule == null) {
XJAlert.display(window.getJavaContainer(), "Inline Rule", "There is no rule at cursor position.");
return;
}
inlineRule(rule);
}
use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.
the class FindMenu method findUsage.
public void findUsage() {
StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_FIND_USAGES);
ATEToken token = delegate.getCurrentToken();
if (token == null)
return;
Usages usage = new Usages(delegate, token);
delegate.addUsagesTab(usage);
for (ATEToken ateToken : delegate.getTokens()) {
if (ateToken.getAttribute().equals(token.getAttribute())) {
ElementRule matchedRule = delegate.getEditorRules().getEnclosingRuleAtPosition(ateToken.getStartIndex());
if (matchedRule != null)
usage.addMatch(matchedRule, ateToken);
}
}
}
use of org.antlr.works.grammar.element.ElementRule in project antlrworks by antlr.
the class GenerateMenu method showRuleGeneratedCode.
public void showRuleGeneratedCode() {
StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_SHOW_RULE_GENERATED_CODE);
if (window.getCurrentRule() == null) {
XJAlert.display(window.getJavaContainer(), "Error", "A rule must be selected first.");
} else {
ElementRule r = window.getCurrentRule();
checkAndShowGeneratedCode(r.name, r.lexer ? ElementGrammarName.LEXER : ElementGrammarName.PARSER);
}
}
Aggregations