Search in sources :

Example 16 with ElementRule

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;
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 17 with ElementRule

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);
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 18 with ElementRule

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);
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule)

Example 19 with ElementRule

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);
        }
    }
}
Also used : ElementRule(org.antlr.works.grammar.element.ElementRule) Usages(org.antlr.works.find.Usages) ATEToken(org.antlr.works.ate.syntax.misc.ATEToken)

Example 20 with ElementRule

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