Package org.antlr.works.ate.syntax.misc

Examples of org.antlr.works.ate.syntax.misc.ATEToken


    }

    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);
            }
        }
View Full Code Here


        window.beginGroupChange("Ungroup");

        if(closingGroup != null) {
            // End of file is considered as a closing group but no group really exists
            // for that purpose
            ATEToken t = closingGroup.token;
            window.replaceText(t.getStartIndex()-1, t.getEndIndex(), "");
        }

        ATEToken t = openGroup.token;
        window.replaceText(t.getStartIndex()-1, t.getEndIndex(), "");

        window.endGroupChange();
    }
View Full Code Here

        String attr = t.getAttribute();

        boolean renameRefRule = t.type == GrammarSyntaxLexer.TOKEN_REFERENCE || t.type == GrammarSyntaxLexer.TOKEN_DECL;

        for(int index = tokens.size()-1; index>0; index--) {
            ATEToken token = tokens.get(index);
            if(!token.getAttribute().equals(attr)) continue;

            if(token.type == t.type ||
                    renameRefRule && (token.type == GrammarSyntaxLexer.TOKEN_REFERENCE || token.type == GrammarSyntaxLexer.TOKEN_DECL))
            {
                mutator.replace(token.getStartIndex(), token.getEndIndex(), name);
            }
        }
        return true;
    }
View Full Code Here

    public int getDebuggerLocation() {
        return debuggerLocation;
    }

    public int getSelectionLeftIndexOnTokenBoundary() {
        ATEToken t = getTokenAtPosition(getTextPane().getSelectionStart(), true);
        if(t == null)
            return -1;
        else
            return t.getStartIndex();
    }
View Full Code Here

        else
            return t.getStartIndex();
    }

    public int getSelectionRightIndexOnTokenBoundary() {
        ATEToken t = getTokenAtPosition(getTextPane().getSelectionEnd(), false);
        if(t == null)
            return -1;
        else
            return t.getEndIndex();
    }
View Full Code Here

        if(tokens == null)
            return null;

        if(fromRight) {
            for (int i = tokens.size()-1; i >= 0; i--) {
                ATEToken token = tokens.get(i);
                if (token.containsIndex(pos))
                    return token;
            }
        } else {
            for (ATEToken token : tokens) {
                if (token.containsIndex(pos))
                    return token;
            }
        }
        return null;
    }
View Full Code Here

    }

    public void rename() {
        StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_RENAME);

        ATEToken token = window.getCurrentToken();
        if(token == null)
            return;

        String s = (String) JOptionPane.showInputDialog(window.getJavaContainer(), "Rename '"+token.getAttribute()+"' and its usages to:", "Rename",
                JOptionPane.QUESTION_MESSAGE, null, null, token.getAttribute());
        if(s != null && !s.equals(token.getAttribute())) {
            beginRefactor("Rename");
            renameToken(token, s);
            endRefactor();
        }
    }
View Full Code Here

        boolean renameRefRule = t.type == ATEStringTemplateSyntaxLexer.TOKEN_REFERENCE ||
                t.type == ATEStringTemplateSyntaxLexer.TOKEN_DECL;

        if (renameRefRule) {
            for(int index = tokens.size()-1; index>0; index--) {
                ATEToken token = tokens.get(index);
                if(!token.getAttribute().equals(attr)) continue;

                if(token.type == ATEStringTemplateSyntaxLexer.TOKEN_REFERENCE ||
                        token.type == ATEStringTemplateSyntaxLexer.TOKEN_DECL) {
                    mutator.replace(token.getStartIndex(), token.getEndIndex(), name);
                }
            }
        } else if (isArg) {
            ElementTemplateRule rule = getRuleAtPosition(window.getCaretPosition());
            for(int index = tokens.size()-1; index>0; index--) {
                ATEToken token = tokens.get(index);
                if(!token.getAttribute().equals(attr)) continue;

                if (rule.containsIndex(token.start)) {
                    if (token.type == ATEStringTemplateSyntaxLexer.TOKEN_ARG_DECL ||
                            token.type == ATEStringTemplateSyntaxLexer.TOKEN_ARG_REFERENCE) {
                        mutator.replace(token.getStartIndex(), token.getEndIndex(), name);
                    }
                }
            }
        } else {
            mutator.replace(t.getStartIndex(), t.getEndIndex(), name);
View Full Code Here

    }

    public void rename() {
        StatisticsAW.shared().recordEvent(StatisticsAW.EVENT_RENAME);

        ATEToken token = window.getCurrentToken();
        if(token == null)
            return;

        String s = (String) JOptionPane.showInputDialog(window.getJavaContainer(), "Rename '"+token.getAttribute()+"' and its usages to:", "Rename",
                JOptionPane.QUESTION_MESSAGE, null, null, token.getAttribute());
        if(s != null && !s.equals(token.getAttribute())) {
            beginRefactor("Rename");
            engine.renameToken(token, s);
            endRefactor();
        }
    }
View Full Code Here

            endRefactor();
        }
    }

    public boolean canReplaceLiteralWithTokenLabel() {
        ATEToken token = window.getCurrentToken();
        return token != null && (token.type == ATESyntaxLexer.TOKEN_SINGLE_QUOTE_STRING || token.type == ATESyntaxLexer.TOKEN_DOUBLE_QUOTE_STRING);
    }
View Full Code Here

TOP

Related Classes of org.antlr.works.ate.syntax.misc.ATEToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.