Package org.jitterbit.ui.text.partition.TextPartitioner

Examples of org.jitterbit.ui.text.partition.TextPartitioner.Partition


    private final class PrintTokensAction extends AbstractAction {

        @Override
        public void actionPerformed(ActionEvent e) {
            Partition p = partitioner.getFirst();
            while (p != null) {
                System.out.println(p.token.getClass().getSimpleName() + ": " + DocumentUtils.getText(getDocument(), p));
                p = p.getNext();
            }
        }
View Full Code Here


            }
            return null;
        }

        private boolean isFirstArgumentOfFunction(Document doc, int offset) {
            Partition p = findFunction(offset - 1);
            if (p != null) {
                String name = DocumentUtils.getText(doc, p);
                function = FunctionRegistry.getRegistry().getFunctionByName(name);
                return function != null;
            }
View Full Code Here

            }
            return false;
        }

        private Partition findFunction(int pos) {
            Partition p = consumeCommentsAndWhitespace(partitioner.getPartitionAt(pos));
            if (p != null && p.token == Tokens.GROUPING) {
                p = p.getPrevious();
                if (p != null && p.token == Tokens.FUNCTION) {
                    return p;
                }
            }
            return null;
View Full Code Here

     *
     * @param pos
     *            the position in the text (0-based)
     */
    public boolean isAutoCompletionAvailable(int pos) {
        Partition p = getPartitionAt(pos);
        if (p == null) {
            return true;
        }
        Token t = p.token;
        return t != BEGIN_TRANS && t != END_TRANS && t != STRING && t != SINGLE_LINE_COMMENT && t != BLOCK_COMMENT;
View Full Code Here

     *
     * @param pos
     *            the position in the text (0-based)
     */
    public boolean isContextHelpAvailable(int pos) {
        Partition p = getPartitionAt(pos);
        return isFunction(p);
    }
View Full Code Here

     *
     * @param pos
     *            the position in the text (0-based)
     */
    public boolean isGlobalDataElement(int pos) {
        Partition p = getPartitionAt(pos);
        return isToken(p, GLOBAL_DATA_ELEMENT);
    }
View Full Code Here

     *
     * @param pos
     *            the position in the text (0-based)
     */
    public boolean isWhitespaceDecoratingRegion(int pos) {
        Partition p = getPartitionAt(pos);
        if (p != null && p.token.isWhitespace()) {
            Partition prev = p.getPrevious();
            while (prev != null) {
                if (prev.token == END_TRANS) {
                    return true;
                } else if (prev.token == BEGIN_TRANS) {
                    return false;
                }
                prev = prev.getPrevious();
            }
            return true;
        }
        return false;
    }
View Full Code Here

     * @return the name of the function if the partition at the given position represents a
     *         function; <code>null</code> if the partition is not a function
     */
    public String getFunctionNameAt(int pos) {
        if (document != null) {
            Partition p = getPartitionAt(pos);
            if (isFunction(p)) {
                return DocumentUtils.getText(document, p);
            }
        }
        return null;
View Full Code Here

    public Partition getFirst() {
        return worker.getFirst();
    }

    private boolean isActivePosition(int pos) {
        Partition p = getPartitionAt(pos);
        if (p == null) {
            return true;
        }
        Token t = p.token;
        if (t == NO_CODE || t == BEGIN_TRANS) {
View Full Code Here

            super(scanner);
        }

        @Override
        protected Partition calculateStartOfDamagedRegion(int pos) {
            Partition p = getPartitionAt(pos);
            if (p != null) {
                /*
                 * This is needed to cover cases like the following:
                 * The user is about to comment out the Length() call in the script. After the first
                 * "/" character is typed we have:
                 *
                 * <trans>
                 *  /Length($x)
                 * </trans>
                 *
                 * When the second "/" is typed p will represent the Length token. The logic below
                 * will then break immediately, and we will end up with two /-operator tokens rather
                 * than with a start-comment token.
                 */
                p = p.getPrevious();
            }
            while (p != null) {
                Token t = p.token;
                /*
                 * This is needed to cover cases like the following:
                 *
                 *   <trans>"abc"</trans
                 *
                 * At this point he currect partitioning will end with
                 *
                 *   OPERATOR("<") OPERATOR("/") SOURCE_PATH("trans")
                 *
                 * When the final ">" is typed, we need to go back all the way to the string literal
                 * "abc" in order to correctly detect the new END_TRANS token.
                 *
                 * Another example:
                 *
                 *     <trans>"abc"</tra ns>  [note the space in the closing trans]
                 *
                 * At this point the current partitioning will end with
                 *
                 *   OPERATOR("<") OPERATOR("/") SOURCE_PATH("tra") WHITESPACE(" ") SOURCE_PATH("ns") OPERATOR(">")
                 *
                 * When the erroneous space is deleted we must again walk back to the string literal "abc"
                 * as a starting point.
                 */
                if (!t.isWhitespace() && t != SOURCE_PATH && t != OPERATOR && t != WORD_TOKEN) {
                    break;
                }
                p = p.getPrevious();
            }
            return p;
        }
View Full Code Here

TOP

Related Classes of org.jitterbit.ui.text.partition.TextPartitioner.Partition

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.