Package org.eclipse.php.internal.core.util.text

Examples of org.eclipse.php.internal.core.util.text.TextSequence


            try {

                if (getPartitionType() == TwigPartitionTypes.TWIG_QUOTED_STRING)
                    return false;

                TextSequence sequence = getStatementText();

                if (TwigTextSequenceUtilities.isInField(sequence)) {
                    return false;
                }
View Full Code Here


     * @return <code>true</code> if there are whitespace characters before the
     *         cursor
     */
    public boolean hasWhitespaceBeforeCursor()
    {
        TextSequence statementText = getStatementText();

        assert statementText != null;

        // determine whether there are whitespaces before the cursor
        int statementLength = statementText.length();
        int statementEnd = PHPTextSequenceUtilities.readBackwardSpaces(
                statementText, statementLength);
        return statementLength != statementEnd;
    }
View Full Code Here

     *
     * @throws BadLocationException
     */
    public String getPreviousWord() throws BadLocationException
    {
        TextSequence statementText = getStatementText();


        int statementLength = statementText.length();
        int wordEnd = PHPTextSequenceUtilities.readBackwardSpaces(
                statementText, statementLength); // read whitespace
        int wordStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
                phpVersion, statementText, wordEnd, true);
        if (wordStart < 0 || wordEnd < 0 || wordStart > wordEnd) {
            return "";
        }
        String previousWord = statementText.subSequence(wordStart, wordEnd)
                .toString();

        if (hasWhitespaceBeforeCursor()) {
            return previousWord;
        }

        wordEnd = PHPTextSequenceUtilities.readBackwardSpaces(statementText,
                wordStart - 1); // read whitespace
        wordStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
                phpVersion, statementText, wordEnd, true);
        if (wordStart < 0 || wordEnd < 0 || wordStart > wordEnd) {
            return "";
        }
        previousWord = statementText.subSequence(wordStart, wordEnd).toString();

        return previousWord;
    }
View Full Code Here

     *
     * @throws BadLocationException
     */
    public String getPreviousWord(int times) throws BadLocationException
    {
        TextSequence statementText = getStatementText();

        int statementLength = statementText.length();
        int wordEnd = PHPTextSequenceUtilities.readBackwardSpaces(
                statementText, statementLength); // read whitespace
        int wordStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
                phpVersion, statementText, wordEnd, true);

        for (int i = 0; i < times - 1; i++) {
            statementLength = wordStart;
            wordEnd = PHPTextSequenceUtilities.readBackwardSpaces(
                    statementText, statementLength); // read whitespace
            wordStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
                    phpVersion, statementText, wordEnd, true);

        }
        if (wordStart < 0 || wordEnd < 0 || wordStart > wordEnd) {
            return "";
        }
        String previousWord = statementText.subSequence(wordStart, wordEnd)
                .toString();

        if (hasWhitespaceBeforeCursor()) {
            return previousWord;
        }

        wordEnd = PHPTextSequenceUtilities.readBackwardSpaces(statementText,
                wordStart - 1); // read whitespace
        wordStart = PHPTextSequenceUtilities.readIdentifierStartIndex(
                phpVersion, statementText, wordEnd, true);
        if (wordStart < 0 || wordEnd < 0 || wordStart > wordEnd) {
            return "";
        }
        previousWord = statementText.subSequence(wordStart, wordEnd).toString();

        return previousWord;
    }
View Full Code Here

    {

        if (hasWhitespaceBeforeCursor()) {
            return ""; //$NON-NLS-1$
        }
        TextSequence statementText = getStatementText();
        int statementLength = statementText.length();
        int prefixEnd = PHPTextSequenceUtilities.readBackwardSpaces(
                statementText, statementLength); // read whitespace

        int prefixStart = TwigTextSequenceUtilities.readIdentifierStartIndex(
                statementText, prefixEnd);

        return statementText.subSequence(prefixStart, prefixEnd).toString();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.core.util.text.TextSequence

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.