Package com.aptana.shared_core.string

Examples of com.aptana.shared_core.string.FastStringBuffer


        final boolean shouldAddCommentSign = PyToggleComment.allLinesStartWithCommentSign(ps) == false;
        String endLineDelim = ps.getEndLineDelim();
        int endLineIndex = ps.getEndLineIndex();
        int startLineIndex = ps.getStartLineIndex();

        final FastStringBuffer sb = new FastStringBuffer(ps.getSelLength() + (endLineIndex - startLineIndex) + 10);

        for (int i = startLineIndex, n = endLineIndex; i <= n; i++) {
            final String line = ps.getLine(i);
            if (shouldAddCommentSign) {
                sb.append("#");
                sb.append(line);
            } else { // remove comment sign
                sb.append(line.replaceFirst("#", ""));
            }
            //add a new line if we're not in the last line.
            sb.append((i < endLineIndex ? endLineDelim : ""));
        }

        final int start = ps.getStartLine().getOffset();
        final String replacement = sb.toString();

        ps.getDoc().replace(start, ps.getSelLength(), replacement);
        return new Tuple<Integer, Integer>(start, replacement.length());
    }
View Full Code Here


        ps.selectCompleteLine();

        String selectedText = ps.getSelectedText();
        List<String> ret = StringUtils.splitInLines(selectedText);

        FastStringBuffer strbuf = new FastStringBuffer(selectedText.length() + ret.size() + 2);
        for (String line : ret) {
            strbuf.append('#').append(line);
        }

        ITextSelection txtSel = ps.getTextSelection();
        int start = txtSel.getOffset();
        int len = txtSel.getLength();

        String replacement = strbuf.toString();
        // Replace the text with the modified information
        ps.getDoc().replace(start, len, replacement);
        return new Tuple<Integer, Integer>(start, replacement.length());
    }
View Full Code Here

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        FastStringBuffer buffer = new FastStringBuffer();
        buffer.append("<xml>\n");
        if (this.name != null) {
            buffer.append("<name>");
            buffer.append(this.name);
            buffer.append("</name>\n");
        }
        buffer.append("<version>");
        buffer.append(version);
        buffer.append("</version>\n");

        buffer.append("<executable>");
        buffer.append(executableOrJar);
        buffer.append("</executable>\n");

        for (Iterator<String> iter = libs.iterator(); iter.hasNext();) {
            buffer.append("<lib>");
            buffer.append(iter.next().toString());
            buffer.append("</lib>\n");
        }

        if (forcedLibs.size() > 0) {
            for (Iterator<String> iter = forcedLibs.iterator(); iter.hasNext();) {
                buffer.append("<forced_lib>");
                buffer.append(iter.next().toString());
                buffer.append("</forced_lib>\n");
            }
        }

        if (this.envVariables != null) {
            for (String s : envVariables) {
                buffer.append("<env_var>");
                buffer.append(s);
                buffer.append("</env_var>\n");
            }
        }

        if (this.stringSubstitutionVariables != null && this.stringSubstitutionVariables.size() > 0) {
            Set<Entry<Object, Object>> entrySet = this.stringSubstitutionVariables.entrySet();
            for (Entry<Object, Object> entry : entrySet) {
                buffer.append("<string_substitution_var>");
                buffer.append("<key>");
                buffer.appendObject(entry.getKey());
                buffer.append("</key>");
                buffer.append("<value>");
                buffer.appendObject(entry.getValue());
                buffer.append("</value>");
                buffer.append("</string_substitution_var>\n");
            }
        }

        if (this.predefinedCompletionsPath.size() > 0) {
            for (String s : this.predefinedCompletionsPath) {
                buffer.append("<predefined_completion_path>");
                buffer.append(s);
                buffer.append("</predefined_completion_path>");
            }
        }
        buffer.append("</xml>");

        return buffer.toString();
    }
View Full Code Here

        double total = 0;
        int totalResources = resourcesToParse.size();
        int i = 0;

        FastStringBuffer bufferToCreateString = new FastStringBuffer();

        boolean loggedMisconfiguration = false;
        for (Iterator<IFile> iter = resourcesToParse.iterator(); iter.hasNext() && monitor.isCanceled() == false;) {
            i += 1;
            total += inc;
View Full Code Here

        /**
         * Given the temporary info found, goes on to fill the actual found modules.
         */
        public void consolidatePythonpathInfo(IProgressMonitor monitor) {
            int i = 0;
            FastStringBuffer buffer = new FastStringBuffer();
            for (Map.Entry<String, String> entry : pyFilesLowerToRegular.entrySet()) {
                if (i % 15 == 0) {

                    if (monitor.isCanceled()) {
                        break;
                    }
                    monitor.setTaskName("Updating zips info...");
                    monitor.worked(1);

                }
                String key = entry.getKey();
                int index = StringUtils.rFind(key, '/');
                boolean add = true;
                if (index != -1) {
                    //If it's in the root, we don't need to check for __init__
                    buffer.clear();
                    buffer.append(key.substring(0, index));
                    if (zipContentsType == ZIP_CONTENTS_TYPE_PY_ZIP) {
                        //we don't need to check for __init__ if we have a jar
                        if (buffer.length() > 0) {
                            buffer.append("/");
                            buffer.append("__init__");
                            add = pyInitFilesLowerWithoutExtension.contains(buffer.toString());
                        }
                    }
                }

                if (add) {
View Full Code Here

    /**
     * Old implementation. Kept only for testing backward compatibility!
     */
    public String toStringOld() {
        FastStringBuffer buffer = new FastStringBuffer();
        if (this.name != null) {
            buffer.append("Name:");
            buffer.append(this.name);
            buffer.append(":EndName:");
        }
        buffer.append("Version");
        buffer.append(version);
        buffer.append("Executable:");
        buffer.append(executableOrJar);
        for (Iterator<String> iter = libs.iterator(); iter.hasNext();) {
            buffer.append("|");
            buffer.append(iter.next().toString());
        }
        buffer.append("@");

        buffer.append("$");
        if (forcedLibs.size() > 0) {
            for (Iterator<String> iter = forcedLibs.iterator(); iter.hasNext();) {
                buffer.append("|");
                buffer.append(iter.next().toString());
            }
        }

        if (this.envVariables != null) {
            buffer.append("^");
            for (String s : envVariables) {
                buffer.append(s);
                buffer.append("|");
            }
        }

        if (this.stringSubstitutionVariables != null && this.stringSubstitutionVariables.size() > 0) {
            buffer.append("@PYDEV_STRING_SUBST_VARS@");
            buffer.append(PropertiesHelper.createStringFromProperties(this.stringSubstitutionVariables));
        }

        if (this.predefinedCompletionsPath.size() > 0) {
            buffer.append("@PYDEV_PREDEF_COMPS_PATHS@");
            for (String s : this.predefinedCompletionsPath) {
                buffer.append("|");
                buffer.append(s);
            }
        }

        return buffer.toString();
    }
View Full Code Here

        if (command.length > 0) {
            String selectedText = ps.getSelectedText();
            if (selectedText.indexOf('\r') != -1 || selectedText.indexOf('\n') != -1) {
                //we have a new line
                FastStringBuffer buf = new FastStringBuffer(selectedText.length() + 10);
                buf.appendN(command.text, 3);
                buf.append(selectedText);
                buf.appendN(command.text, 3);
                document.replace(offset, ps.getSelLength(), buf.toString());
                linkOffset = offset + 3;
                linkLen = selectedText.length();
                linkExitPos = linkOffset + linkLen + 3;
            } else {
                document.replace(offset, ps.getSelLength(), command.text + selectedText + command.text);
View Full Code Here

    /**
     * Gets the reader content as a String
     */
    private static String getString(Reader reader) {
        FastStringBuffer buf = new FastStringBuffer();
        char[] buffer = new char[1024];
        int count;
        try {
            while ((count = reader.read(buffer)) != -1)
                buf.append(buffer, 0, count);
        } catch (IOException e) {
            return null;
        }
        return buf.toString();
    }
View Full Code Here

    /**
     * Restores the path with the discovered libs
     * @param path
     */
    public void restorePythonpath(IProgressMonitor monitor) {
        FastStringBuffer buffer = new FastStringBuffer();
        for (Iterator<String> iter = libs.iterator(); iter.hasNext();) {
            String folder = (String) iter.next();
            buffer.append(folder);
            buffer.append("|");
        }
        restorePythonpath(buffer.toString(), monitor);
    }
View Full Code Here

     * @param ps Given PySelection
     * @return boolean The success or failure of the action
     */
    public int perform(PySelection ps) {
        // What we'll be replacing the selected text with
        FastStringBuffer strbuf = new FastStringBuffer();

        // If they selected a partial line, count it as a full one
        ps.selectCompleteLine();

        int i;
        try {
            // For each line, comment them out
            for (i = ps.getStartLineIndex(); i <= ps.getEndLineIndex(); i++) {
                String line = StringUtils.rightTrim(ps.getLine(i));
                if (getAlignRight()) {
                    strbuf.append(getRightAlignedFullCommentLine(line));
                    strbuf.append(line.trim());
                    if (i != ps.getEndLineIndex()) {
                        strbuf.append(ps.getEndLineDelim());
                    }
                } else {
                    Tuple<Integer, Character> colsAndChar = getColsAndChar();
                    int cols = colsAndChar.o1;
                    char c = colsAndChar.o2;

                    FastStringBuffer buffer = makeBufferToIndent(line, cols);
                    int lenOfStrWithTabsAsSpaces = getLenOfStrConsideringTabEditorLen(buffer.toString());
                    int diff = lenOfStrWithTabsAsSpaces - buffer.length();

                    buffer.append("# ");
                    buffer.append(line.trim());
                    buffer.append(' ');
                    while (buffer.length() + diff < cols) {
                        buffer.append(c);
                    }
                    strbuf.append(buffer);
                    if (i != ps.getEndLineIndex()) {
                        strbuf.append(ps.getEndLineDelim());
                    }
View Full Code Here

TOP

Related Classes of com.aptana.shared_core.string.FastStringBuffer

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.