Package com.aptana.shared_core.string

Examples of com.aptana.shared_core.string.FastStringBuffer


            commandLine = newCommandLine;
        }

        if (commandLine.length < 1)
            return ""; //$NON-NLS-1$
        FastStringBuffer buf = new FastStringBuffer();
        FastStringBuffer command = new FastStringBuffer();
        for (int i = 0; i < commandLine.length; i++) {
            if (commandLine[i] == null) {
                continue; //ignore nulls (changed from original code)
            }

            buf.append(' ');
            char[] characters = commandLine[i].toCharArray();
            command.clear();
            boolean containsSpace = false;
            for (int j = 0; j < characters.length; j++) {
                char character = characters[j];
                if (character == '\"') {
                    command.append('\\');
                } else if (character == ' ') {
                    containsSpace = true;
                }
                command.append(character);
            }
            if (containsSpace) {
                buf.append('\"');
                buf.append(command.toString());
                buf.append('\"');
            } else {
                buf.append(command.toString());
            }
        }
        return buf.toString();
    }
View Full Code Here


     */
    public boolean showTemplates = true;

    @Override
    public String toString() {
        FastStringBuffer buffer = new FastStringBuffer();
        buffer.append("CompletionRequest[");
        buffer.append(" editorFile:");
        buffer.appendObject(editorFile);
        buffer.append(" activationToken:");
        buffer.append(activationToken);
        buffer.append(" qualifier:");
        buffer.append(qualifier);
        buffer.append(" isInCalltip:");
        buffer.append(isInCalltip);
        buffer.append(" alreadyHasParams:");
        buffer.append(alreadyHasParams);
        buffer.append("]");
        return buffer.toString();
    }
View Full Code Here

            workspaceMetadataFile.mkdirs();
        }

        File modulesKeysFile = new File(workspaceMetadataFile, "modulesKeys");
        File pythonpatHelperFile = new File(workspaceMetadataFile, "pythonpath");
        FastStringBuffer buf;
        HashMap<String, Integer> commonTokens = new HashMap<String, Integer>();

        synchronized (modulesKeysLock) {
            buf = new FastStringBuffer(this.modulesKeys.size() * 50);
            buf.append(MODULES_MANAGER_V2);

            for (Iterator<ModulesKey> iter = this.modulesKeys.keySet().iterator(); iter.hasNext();) {
                ModulesKey next = iter.next();
                buf.append(next.name);
                if (next.file != null) {
                    buf.append("|");
                    if (next instanceof ModulesKeyForZip) {
                        ModulesKeyForZip modulesKeyForZip = (ModulesKeyForZip) next;
                        if (modulesKeyForZip.zipModulePath != null) {
                            String fileStr = next.file.toString();
                            Integer t = commonTokens.get(fileStr);
                            if (t == null) {
                                t = commonTokens.size();
                                commonTokens.put(fileStr, t);
                            }
                            buf.append(t);
                            buf.append("|");

                            buf.append(modulesKeyForZip.zipModulePath);
                            buf.append("|");
                            buf.append(modulesKeyForZip.isFile ? '1' : '0');
                        }
                    } else {
                        buf.append(next.file.toString());
                    }
                }
                buf.append('\n');
            }
        }
        if (commonTokens.size() > 0) {
            FastStringBuffer header = new FastStringBuffer(buf.length() + (commonTokens.size() * 50));
            header.append(MODULES_MANAGER_V2);
            header.append("--COMMON--\n");
            for (Map.Entry<String, Integer> entries : commonTokens.entrySet()) {
                header.append(entries.getValue());
                header.append('=');
                header.append(entries.getKey());
                header.append('\n');
            }
            header.append("--END-COMMON--\n");
            header.append(buf);
            buf = header;
        }
        FileUtils.writeStrToFile(buf.toString(), modulesKeysFile);

        this.pythonPathHelper.saveToFile(pythonpatHelperFile);
View Full Code Here

            ModulesFoundStructure modulesFound) {
        //now, on to actually filling the module keys
        PyPublicTreeMap<ModulesKey, ModulesKey> keys = new PyPublicTreeMap<ModulesKey, ModulesKey>();
        int j = 0;

        FastStringBuffer buffer = new FastStringBuffer();
        //now, create in memory modules for all the loaded files (empty modules).
        for (Iterator<Map.Entry<File, String>> iterator = modulesFound.regularModules.entrySet().iterator(); iterator
                .hasNext() && monitor.isCanceled() == false; j++) {
            Map.Entry<File, String> entry = iterator.next();
            File f = entry.getKey();
            String m = entry.getValue();

            if (j % 20 == 0) {
                //no need to report all the time (that's pretty fast now)
                buffer.clear();
                monitor.setTaskName(buffer.append("Module resolved: ").append(m).toString());
                monitor.worked(1);
            }

            if (m != null) {
                //we don't load them at this time.
View Full Code Here

        InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(jythonJar,
                new NullProgressMonitor());

        //pythonpath is: base path + libs path.
        String libs = SimpleRunner.makePythonPathEnvFromPaths(info.libs);
        FastStringBuffer jythonPath = new FastStringBuffer(basePythonPath, 128);
        String pathSeparator = SimpleRunner.getPythonPathSeparator();
        if (jythonPath.length() != 0) {
            jythonPath.append(pathSeparator);
        }
        jythonPath.append(libs);

        //may have the dir or be null
        String cacheDir = null;
        try {
            cacheDir = PydevPrefs.getChainedPrefStore().getString(IInterpreterManager.JYTHON_CACHE_DIR);
        } catch (NullPointerException e) {
            //this may happen while running the tests... it should be ok.
            cacheDir = null;
        }
        if (cacheDir != null && cacheDir.trim().length() == 0) {
            cacheDir = null;
        }
        if (cacheDir != null) {
            cacheDir = "-Dpython.cachedir=" + cacheDir.trim();
        }

        String[] s;
        if (cacheDir != null) {
            s = new String[] { javaLoc, cacheDir, "-Dpython.path=" + jythonPath.toString(), "-classpath",
                    jythonJar + pathSeparator + jythonPath, vmArgs, "org.python.util.jython", script };
        } else {
            s = new String[] { javaLoc,
                    //cacheDir, no cache dir if it's not available
                    "-Dpython.path=" + jythonPath.toString(), "-classpath", jythonJar + pathSeparator + jythonPath,
                    vmArgs, "org.python.util.jython", script };

        }

        List<String> asList = new ArrayList<String>(Arrays.asList(s));
View Full Code Here

                template = createNewTemplate(template, StringUtils.replaceAll(pattern, "\t", spacesIndentString));
                changed = true;
            }
        } else {
            if (pattern.indexOf(spacesIndentString) != -1) {
                FastStringBuffer newPattern = new FastStringBuffer();
                FastStringBuffer newTabsIndent = new FastStringBuffer();

                for (int i = 0; i < splitted.size(); i++) {
                    String string = splitted.get(i);

                    int spacesFound = 0;
                    while (string.length() > 0 && string.charAt(0) == ' ') {
                        string = string.substring(1);
                        spacesFound += 1;
                    }

                    int tabsToAdd = 0;
                    if (spacesFound > 0) {
                        tabsToAdd = spacesFound / spacesIndentString.length();
                        if (spacesFound % spacesIndentString.length() != 0) {
                            tabsToAdd += 1;
                        }
                        newTabsIndent.clear();
                        for (int j = 0; j < tabsToAdd; j++) {
                            newTabsIndent.append("\t");
                        }
                        newPattern.append(newTabsIndent);
                    }
                    newPattern.append(string);
                }
                template = createNewTemplate(template, newPattern.toString());
                changed = true;
            }
        }

        //recreate it (if needed).
        if (changed) {
            pattern = template.getPattern();
            splitted = StringUtils.splitInLines(pattern);
        }

        String indentToStr = indentTo != null ? indentTo : "";
        String endLineDelim = PySelection.getDelimiter(this.getDocument());

        int size = splitted.size();
        if (size > 0) {

            FastStringBuffer buffer = new FastStringBuffer("", (pattern.length() + (size * 2))
                    + ((size + 1) * indentToStr.length()));
            for (int i = 0; i < size; i++) { //we don't want to get the first line

                if (i != 0) {
                    //the 1st line is not indented (that's where the user requested the completion -- others should be indented to it)
                    buffer.append(indentToStr);
                }

                String str = splitted.get(i);

                //we have to make the new line delimiter correct:
                //https://sourceforge.net/tracker/index.php?func=detail&aid=2019419&group_id=85796&atid=577329
                boolean hasNewLine = false;
                if (str.endsWith("\r") || str.endsWith("\n")) {
                    hasNewLine = true;
                    if (str.endsWith("\r\n")) {
                        str = str.substring(0, str.length() - 2);
                    } else {
                        str = str.substring(0, str.length() - 1);
                    }
                }
                buffer.append(str);
                if (hasNewLine) {
                    buffer.append(endLineDelim);
                }
            }
            //just to change the pattern...
            template = createNewTemplate(template, buffer.toString());
        }

        try {
            TemplateTranslator translator = new TemplateTranslator();
            TemplateBuffer templateBuffer = translator.translate(template);
View Full Code Here

        SimpleNode jjtn000 = builder.openNode(JJTDOTTED_NAME);
        boolean jjtc000 = true;
        jjtree.openNodeScope(jjtn000);
        jjtreeOpenNodeScope(jjtn000);
        Token t;
        FastStringBuffer sb = dottedNameStringBuffer.clear();
        try {
            t = Name();
            sb.append(t.image);
            label_12: while (true) {
                switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                    case DOT:
                        ;
                        break;
                    default:
                        jj_la1[34] = jj_gen;
                        break label_12;
                }
                jj_consume_token(DOT);
                t = Name2();
                sb.append(".").append(t.image);
            }
            jjtree.closeNodeScope(jjtn000, true);
            jjtc000 = false;
            jjtreeCloseNodeScope(jjtn000);
            {
                if (true)
                    return sb.toString();
            }
        } catch (Throwable jjte000) {
            if (jjtc000) {
                jjtree.clearNodeScope(jjtn000);
                jjtc000 = false;
View Full Code Here

        SimpleNode jjtn000 = builder.openNode(JJTDOTTED_NAME);
        boolean jjtc000 = true;
        jjtree.openNodeScope(jjtn000);
        jjtreeOpenNodeScope(jjtn000);
        Token t;
        FastStringBuffer sb = dottedNameStringBuffer.clear();
        try {
            t = Name();
            sb.append(t.image);
            label_13: while (true) {
                switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
                    case DOT:
                        ;
                        break;
                    default:
                        jj_la1[51] = jj_gen;
                        break label_13;
                }
                jj_consume_token(DOT);
                t = Name();
                sb.append(".").append(t.image);
            }
            jjtree.closeNodeScope(jjtn000, true);
            jjtc000 = false;
            jjtreeCloseNodeScope(jjtn000);
            {
                if (true)
                    return sb.toString();
            }
        } catch (Throwable jjte000) {
            if (jjtc000) {
                jjtree.clearNodeScope(jjtn000);
                jjtc000 = false;
View Full Code Here

        final String loc = resource.getLocation().toOSString();
        if (loc != null && (loc.endsWith(".pyc") || loc.endsWith("$py.class"))) {
            String dotPyLoc = null;

            final FastStringBuffer buf = new FastStringBuffer(StringUtils.stripExtension(loc), 8);
            for (String ext : FileTypesPreferencesPage.getDottedValidSourceFiles()) {
                buf.append(ext);
                final String bufStr = buf.toString();
                File file = new File(bufStr);
                if (dotPyLoc == null) {
                    dotPyLoc = bufStr;
                }
                if (file.exists()) {
                    markAsDerived(resource);
                    return;
                }
                buf.deleteLastChars(ext.length());
            }

            //this is needed because this method might be called alone (not in the grouper that checks
            //if it is in the pythonpath before)
            //
View Full Code Here

                    isAddOrChange = chooseVisit(delta, resource, isAddOrChange);

                    if (isAddOrChange) {
                        //communicate the progress
                        currentResourcesVisited++;
                        FastStringBuffer bufferToCreateString = new FastStringBuffer();
                        PyDevBuilder.communicateProgress(monitor, totalResources, currentResourcesVisited, resource,
                                this, bufferToCreateString);
                    }
                } else if (ext.equals("pyc")) {
                    if (delta.getKind() == IResourceDelta.ADDED) {
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.