Package com.aptana.shared_core.string

Examples of com.aptana.shared_core.string.FastStringBuffer


    protected void save(File persistingLocation) {
        try {
            FileOutputStream stream = new FileOutputStream(persistingLocation);
            OutputStreamWriter writer = new OutputStreamWriter(stream);
            try {
                FastStringBuffer tempBuf = new FastStringBuffer();
                tempBuf.append("-- VERSION_");
                tempBuf.append(AbstractAdditionalTokensInfo.version);
                tempBuf.append('\n');
                writer.write(tempBuf.getInternalCharsArray(), 0, tempBuf.length());
                tempBuf.clear();

                saveTo(writer, tempBuf, persistingLocation);
            } finally {
                try {
                    writer.close();
View Full Code Here


    /**
     * @return the message considering all the internal messages available.
     */
    public String getShortMessage() {
        if (shortMessage == null) {
            FastStringBuffer buffer = new FastStringBuffer(msgs.size() * 40);

            List<String> messages = new ArrayList<String>();
            for (Iterator<IMessage> iter = msgs.iterator(); iter.hasNext();) {
                IMessage msg = iter.next();
                messages.add(msg.getShortMessage().toString());
            }

            //sort them accordingly
            Collections.sort(messages);

            for (Iterator<String> iter = messages.iterator(); iter.hasNext();) {
                buffer.append(iter.next());
                if (iter.hasNext()) {
                    buffer.append(", ");
                }
            }

            //let the user know if we suppressed something
            if (addSupressMessage) {
                buffer.append("... others suppressed");
            }
            shortMessage = buffer.toString();
        }
        return shortMessage;
    }
View Full Code Here

            TreeIO.dumpTreeToBuffer(this.topLevelInitialsToInfo, tempBuf, dictionary);

            tempBuf.append("-- START TREE 2\n");
            TreeIO.dumpTreeToBuffer(this.innerInitialsToInfo, tempBuf, dictionary);

            FastStringBuffer buf2 = new FastStringBuffer(50 * (dictionary.size() + 4));
            TreeIO.dumpDictToBuffer(dictionary, buf2);

            //Write the dictionary before the actual trees.
            writer.write(buf2.getInternalCharsArray(), 0, buf2.length());
            buf2 = null;

            //Note: tried LZFFileInputStream from https://github.com/ning/compress
            //and Snappy from https://github.com/dain/snappy checking to see if by writing less we'd
            //get a better time but it got a bit slower (gzip was slowest, then snappy and the faster was LZFFileInputStream)
View Full Code Here

    }

    @Override
    public String toString() {
        synchronized (lock) {
            FastStringBuffer buffer = new FastStringBuffer();
            buffer.append("AdditionalInfo{");

            buffer.append("topLevel=[");
            entrySetToString(buffer, this.topLevelInitialsToInfo.entrySet());
            buffer.append("]\n");
            buffer.append("inner=[");
            entrySetToString(buffer, this.innerInitialsToInfo.entrySet());
            buffer.append("]");

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

            Log.log(e1);
            buf.append("Unable to compute hover. Details: " + e1.getMessage());
            return;
        }

        FastStringBuffer temp = new FastStringBuffer();

        if (tokenAndQual != null && selected.size() > 0) {
            for (IDefinition d : selected) {
                Definition def = (Definition) d;

                SimpleNode astToPrint = null;
                if (def.ast != null) {
                    astToPrint = def.ast;
                    if ((astToPrint instanceof Name || astToPrint instanceof NameTok) && def.scope != null) {
                        //There's no real point in just printing the name, let's see if we're able to actually find
                        //the scope where it's in and print that scope.
                        FastStack<SimpleNode> scopeStack = def.scope.getScopeStack();
                        if (scopeStack != null && scopeStack.size() > 0) {
                            SimpleNode peek = scopeStack.peek();
                            if (peek != null) {
                                stmtType stmt = NodeUtils.findStmtForNode(peek, astToPrint);
                                if (stmt != null) {
                                    astToPrint = stmt;
                                }
                            }
                        }
                    }
                    try {
                        astToPrint = astToPrint.createCopy();
                        MakeAstValidForPrettyPrintingVisitor.makeValid(astToPrint);
                    } catch (Exception e) {
                        Log.log(e);
                    }
                }

                temp = temp.clear();
                if (def.value != null) {
                    if (astToPrint instanceof FunctionDef) {
                        temp.append("def ");

                    } else if (astToPrint instanceof ClassDef) {
                        temp.append("class ");

                    }
                    temp.append("<pydev_hint_bold>");
                    temp.append(def.value);
                    temp.append("</pydev_hint_bold>");
                    temp.append(' ');
                }

                if (def.module != null) {
                    temp.append("Found at: ");
                    temp.append("<pydev_hint_bold>");
                    temp.append(def.module.getName());
                    temp.append("</pydev_hint_bold>");
                    temp.append(PyInformationPresenter.LINE_DELIM);
                }

                if (def.module != null && def.value != null) {
                    ItemPointer pointer = PyRefactoringFindDefinition.createItemPointer(def);
                    String asPortableString = pointer.asPortableString();
                    if (asPortableString != null) {
                        //may happen if file is not in the pythonpath
                        temp.replaceAll(
                                "<pydev_hint_bold>",
                                com.aptana.shared_core.string.StringUtils.format("<pydev_link pointer=\"%s\">",
                                        StringEscapeUtils.escapeXml(asPortableString)));
                        temp.replaceAll("</pydev_hint_bold>", "</pydev_link>");
                    }
                }

                String str = printAst(edit, astToPrint);

                if (str != null && str.trim().length() > 0) {
                    temp.append(PyInformationPresenter.LINE_DELIM);
                    temp.append(str);

                } else {
                    String docstring = d.getDocstring(nature, completionCache);
                   
                    // Jiawei Zhang Add Begin.
                    if (docstring == null && d.getModule().getName().indexOf("PyQt4") == 0) {
                        // Convert the full method name such as: QApplication.aboutQt -> QApplication, about or Phonon.AudioOutput.method -> Phonon.AudioOutput, method
                        int index = def.value.lastIndexOf(".");
                        if (index != -1) {
                            String className = def.value.substring(0, index);
                            String methodName = def.value.substring(index + 1, def.value.length());
                            String[] argsDoc = PythonShell.getQtArgsDoc(className, methodName);
                            docstring = argsDoc[1];
                        }
                    }
                    // Jiawei Zhang Add End.

                    if (docstring != null && docstring.trim().length() > 0) {
                        IIndentPrefs indentPrefs = edit.getIndentPrefs();
                        temp.append(StringUtils.fixWhitespaceColumnsToLeftFromDocstring(docstring,
                                indentPrefs.getIndentationString()));
                    }
                }

                if (temp.length() > 0) {
                    if (buf.length() > 0) {
                        buf.append(PyInformationPresenter.LINE_DELIM);
                    }
                    buf.append(temp);
                }
View Full Code Here

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        FastStringBuffer buf = new FastStringBuffer();
        FileNode.appendToBuffer(buf, node.toString(), stmts, miss, notExecuted,
                PyCoveragePreferences.getNameNumberOfColumns());
        return buf.toString();
    }
View Full Code Here

    }

    public void beforeClassDef(ClassDef node) {
        scope.push(Scope.SCOPE_TYPE_CLASS);

        FastStringBuffer buf = new FastStringBuffer();
        for (exprType base : node.bases) {
            if (buf.length() > 0) {
                buf.append(",");
            }
            String rep = NodeUtils.getRepresentationString(base);
            if (rep != null) {
                buf.append(FullRepIterable.getLastPart(rep));
            }
        }
        classBases.push(buf.toString());
        maybeNoSelfDefinedItems.push(new HashMap<String, Tuple<Expected, FunctionDef>>());
    }
View Full Code Here

                .append(notExecuted);
        return buffer;
    }

    public static String getName(String str, int nameNumberOfColumns) {
        FastStringBuffer buffer = new FastStringBuffer(str, str.length() > nameNumberOfColumns ? 0
                : nameNumberOfColumns - str.length());

        if (buffer.length() > nameNumberOfColumns) {
            buffer = buffer.delete(0, Math.abs((nameNumberOfColumns - 2) - str.length()));
            buffer.insert(0, "..");
        }
        if (buffer.length() < nameNumberOfColumns) {
            buffer.appendN(' ', nameNumberOfColumns - str.length());
        }
        return buffer.toString();
    }
View Full Code Here

        }
        return buffer.toString();
    }

    private static String getStmts(int stmts) {
        FastStringBuffer str = new FastStringBuffer();
        if (stmts == 0) {
            str.append('-');

        } else {
            str.append(stmts);
        }
        while (str.length() < 4) {
            str.insert(0, ' ');
        }
        return str.toString();
    }
View Full Code Here

        this.scopeFound = scopeFound;
    }

    @Override
    public String toString() {
        FastStringBuffer buffer = new FastStringBuffer();
        buffer.append("GenAndTok [ ");

        buffer.append(generator.getRepresentation());
        buffer.append(" - ");
        buffer.append(tok.getRepresentation());

        buffer.append(" (scopeId:");
        buffer.append(scopeId);
        buffer.append(") ");

        if (references.size() > 0) {
            buffer.append(" (references:");
            for (IToken ref : references) {
                buffer.append(ref.getRepresentation());
                buffer.append(",");
            }
            buffer.deleteLast(); //remove the last comma
            buffer.append(") ");
        }

        buffer.append("]");
        return buffer.toString();
    }
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.