Package com.aptana.shared_core.string

Examples of com.aptana.shared_core.string.FastStringBuffer


    public static Map<Integer, String> loadDictFrom(FastBufferedReader reader, FastStringBuffer buf,
            ObjectsPoolMap objectsPoolMap) throws IOException {
        int size = com.aptana.shared_core.string.StringUtils.parsePositiveInt(reader.readLine());
        HashMap<Integer, String> map = new HashMap<Integer, String>(size + 5);

        FastStringBuffer line;
        int val = 0;
        while (true) {
            line = reader.readLine();
            if (line == null) {
                return map;

            } else if (line.startsWith("-- ")) {
                if (line.startsWith("-- END DICTIONARY")) {
                    return map;
                }
                throw new RuntimeException("Unexpected line: " + line);

            } else {
                int length = line.length();
                //line is str=int
                for (int i = 0; i < length; i++) {
                    char c = line.charAt(i);
                    if (c == '=') {
                        val = com.aptana.shared_core.string.StringUtils.parsePositiveInt(buf);
                        buf.clear();
                    } else {
                        buf.appendResizeOnExc(c);
View Full Code Here


        }
        return new Tuple<Boolean, String>(isActuallyUndefined, rep);
    }

    public void onArgumentsMismatch(IToken token, Call callNode) {
        FastStringBuffer buf = new FastStringBuffer(128);
        buf.append(token.getRepresentation());
        buf.append(": arguments don't match");
        List<IMessage> msgs = getMsgsList(token);

        //Code that'll gather the position of the start/end parenthesis and will create a message at that location
        //(otherwise, it'd create the message at the name location, which may be a bit confusing).
        ParsingUtils parsingUtils = ParsingUtils.create(document);
        try {
            int offset = PySelection.getAbsoluteCursorOffset(document, callNode.func.beginLine - 1,
                    callNode.func.beginColumn - 1); //-1: from ast to document coords
            int openParensPos = parsingUtils.findNextChar(offset, '(');
            if (openParensPos != -1) {
                int closeParensPos = parsingUtils.eatPar(openParensPos, null);
                if (closeParensPos != -1) {
                    int startLine = PySelection.getLineOfOffset(document, openParensPos) + 1; //+1: from document to ast
                    int endLine = PySelection.getLineOfOffset(document, closeParensPos) + 1;
                    int startCol = openParensPos - document.getLineInformationOfOffset(openParensPos).getOffset() + 1;

                    //+1 doc to ast +1 because we also want to get the closing ')' char.
                    int endCol = closeParensPos - document.getLineInformationOfOffset(closeParensPos).getOffset() + 1
                            + 1;
                    Message messageToAdd = new Message(IAnalysisPreferences.TYPE_ARGUMENTS_MISATCH, buf.toString(),
                            startLine, endLine, startCol, endCol, prefs);
                    doAddMessage(msgs, messageToAdd);
                    return;
                }
            }
        } catch (BadLocationException e) {
            Log.log(e);
        } catch (SyntaxErrorException e) {
            //Just ignore
        }

        //If some error happened getting the parens position, just add it to the name.
        doAddMessage(msgs, IAnalysisPreferences.TYPE_ARGUMENTS_MISATCH, buf.toString(), token);
    }
View Full Code Here

        List<StyleRange> ranges = new ArrayList<StyleRange>();
        if (baseLocation == null) {
            baseLocation = "";
        }

        FastStringBuffer buffer = new FastStringBuffer();

        try {
            List<ICoverageNode> list = getFiles(node); //array of FileNode

            //40 chars for name.
            int nameNumberOfColumns = PyCoveragePreferences.getNameNumberOfColumns();
            buffer.append("Name").appendN(' ', nameNumberOfColumns - 4)
                    .append("  Stmts     Miss      Cover  Missing\n");
            buffer.appendN('-', nameNumberOfColumns);
            buffer.append("-------------------------------------\n");

            int totalMiss = 0;
            int totalStmts = 0;

            for (ICoverageNode element : list) {
                if (element instanceof FileNode) { //it may have been an error node...
                    FileNode fileNode = (FileNode) element;
                    int start = buffer.length();
                    fileNode.appendToBuffer(buffer, baseLocation, nameNumberOfColumns).append("\n");
                    int len = buffer.indexOf(' ', start) - start;
                    StyleRangeWithCustomData styleRange = new StyleRangeWithCustomData(start, len, null, null);
                    styleRange.underline = true;
                    try {
                        styleRange.underlineStyle = SWT.UNDERLINE_LINK;
                    } catch (Throwable e) {
                        //Ignore (not available on earlier versions of eclipse)
                    }
                    onStyleCreated.call(styleRange);
                    ranges.add(styleRange);
                    styleRange.customData = element;

                    totalMiss += fileNode.miss;
                    totalStmts += fileNode.stmts;
                } else {
                    buffer.append(element.toString()).append("\n");
                }
            }

            buffer.appendN('-', nameNumberOfColumns);
            buffer.append("-------------------------------------\n");
            FileNode.appendToBuffer(buffer, "TOTAL", totalStmts, totalMiss, "", nameNumberOfColumns).append("\n");

        } catch (NodeNotFoudException e) {
            buffer.append("File has no statistics.");
        }
        return new Tuple<String, List<StyleRange>>(buffer.toString(), ranges);
    }
View Full Code Here

    public void write(String o) {
        buf.peek().append(o);
    }

    public void erase(String o) {
        FastStringBuffer buffer = buf.peek();
        if (buffer.toString().endsWith(o)) {
            //only delete if it ends with what was passed
            int len = o.length();
            int bufLen = buffer.length();
            buffer.delete(bufLen - len, bufLen);
        }
    }
View Full Code Here

            buffer.delete(bufLen - len, bufLen);
        }
    }

    public boolean endsWithSpace() {
        FastStringBuffer current = buf.peek();
        if (current.length() == 0) {
            return false;
        }
        return current.lastChar() == ' ';
    }
View Full Code Here

    public FastStringBuffer getBuffer() {
        return buf.peek();
    }

    public void pushTempBuffer() {
        buf.push(new FastStringBuffer());
    }
View Full Code Here

    public String getTreeItemsAsStr() {
        if (editingStyle != EDITING_STYLE_ARRAY_OF_STRINGS) {
            throw new AssertionError("Can only call it if we're dealing with array of strings.");
        }
        FastStringBuffer ret = new FastStringBuffer();
        TreeItem[] items = tree.getItems();
        for (int i = 0; i < items.length; i++) {
            String text = items[i].getText();

            if (text != null && text.trim().length() > 0) {
                if (ret.length() > 0) {
                    ret.append("|");
                }
                ret.append(text);
            }
        }
        return ret.toString();
    }
View Full Code Here

        if (!goToLinkedMode) {
            return;
        }
        List<Integer> offsetsAndLens = new ArrayList<Integer>();

        FastStringBuffer buffer = new FastStringBuffer();
        for (int i = 0; i < newStr.length(); i++) {
            char c = newStr.charAt(i);

            if (Character.isJavaIdentifierPart(c)) {
                if (buffer.length() == 0) {
                    offsetsAndLens.add(i);
                    buffer.append(c);
                } else {
                    buffer.append(c);
                }
            } else {
                if (buffer.length() > 0) {
                    offsetsAndLens.add(buffer.length());
                    buffer.clear();
                }
            }
        }
        if (buffer.length() > 0) {
            offsetsAndLens.add(buffer.length());
        }
        buffer = null;

        goToLinkedMode(viewer, offset, doc, exitPos, iPar, offsetsAndLens);
    }
View Full Code Here

     */
    protected void changeItokenToCompletionPropostal(ITextViewer viewer, CompletionRequest request,
            List<ICompletionProposal> convertedProposals, List<Object> iTokenList, boolean importsTip,
            ICompletionState state) {

        FastStringBuffer result = new FastStringBuffer();
        FastStringBuffer temp = new FastStringBuffer();

        int replacementOffset = request.documentOffset - request.qlen;

        int forcedContextInformationOffset = -1;

View Full Code Here

        boolean lookingForInstance = lookingFor == ICompletionState.LOOKING_FOR_INSTANCE_UNDEFINED
                || lookingFor == ICompletionState.LOOKING_FOR_INSTANCED_VARIABLE
                || lookingFor == ICompletionState.LOOKING_FOR_ASSIGN;
        String trimmed = argsReceived.trim();
        if (trimmed.length() > 0) {
            FastStringBuffer buffer = new FastStringBuffer("(", 128);

            char c = trimmed.charAt(0);
            if (c == '(') {
                trimmed = trimmed.substring(1);
            }
            if (trimmed.length() > 0) {
                c = trimmed.charAt(trimmed.length() - 1);
                if (c == ')') {
                    trimmed = trimmed.substring(0, trimmed.length() - 1);
                }
            }
            trimmed = trimmed.trim();

            //Now, if it starts with self or cls, we may have to remove it.
            String temp;
            if (lookingForInstance && trimmed.startsWith("self")) {
                temp = trimmed.substring(4);

            } else if (trimmed.startsWith("cls")) {
                temp = trimmed.substring(3);
            } else {
                temp = trimmed;
            }
            temp = temp.trim();
            if (temp.length() > 0) {
                //but only if it wasn't a self or cls followed by a valid identifier part.
                if (!Character.isJavaIdentifierPart(temp.charAt(0))) {
                    trimmed = temp;
                }
            } else {
                trimmed = temp;
            }

            trimmed = trimmed.trim();
            if (trimmed.startsWith(",")) {
                trimmed = trimmed.substring(1);
            }
            trimmed = trimmed.trim();
            buffer.append(trimmed);

            buffer.append(")");
            args = buffer.toString();
        } else if (type == IToken.TYPE_FUNCTION) {
            args = "()";
        }

        return args;
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.