Package com.aptana.shared_core.string

Examples of com.aptana.shared_core.string.FastStringBuffer


                        ModulesKey modName = (ModulesKey) tuple.o1;
                        List<IInfo> l = (List<IInfo>) tuple.o2;
                        String infoToString = InfoStrFactory.infoToString(l);
                        String fileStr = modName.file.toString();

                        FastStringBuffer buf = new FastStringBuffer("TUP", modName.name.length() + fileStr.length()
                                + infoToString.length() + 3);
                        buf.append(modName.name);
                        buf.append('\n');
                        buf.append(fileStr);
                        buf.append('\n');
                        buf.append(infoToString);
                        return buf.toString();
                    }
                }
                throw new AssertionError("Expecting Tuple<String, List<IInfo>> or String. Found: " + arg);
            }
        });
View Full Code Here


        //TODO: Check if keeping a zip file open makes things faster...
        //Timer timer = new Timer();
        ModulesKey[] allModules = m.getOnlyDirectModules();
        int i = 0;

        FastStringBuffer msgBuffer = new FastStringBuffer();

        for (ModulesKey key : allModules) {
            if (monitor.isCanceled()) {
                return null;
            }
            i++;

            if (PythonPathHelper.canAddAstInfoFor(key)) { //otherwise it should be treated as a compiled module (no ast generation)

                if (i % 17 == 0) {
                    msgBuffer.clear();
                    msgBuffer.append("Creating ");
                    msgBuffer.append(additionalFeedback);
                    msgBuffer.append(" additional info (");
                    msgBuffer.append(i);
                    msgBuffer.append(" of ");
                    msgBuffer.append(allModules.length);
                    msgBuffer.append(") for ");
                    msgBuffer.append(key.file.getName());
                    monitor.setTaskName(msgBuffer.toString());
                    monitor.worked(1);
                }

                try {
                    if (info.addAstInfo(key, false) == null) {
View Full Code Here

    public void testForwardCurrentStatement() throws Exception {
        reader = new PythonCodeReader();
        doc = new Document("a = 10\n" +
                "def m1(self): pass");
        reader.configureForwardReader(doc, 0, doc.getLength(), true, true, true);
        FastStringBuffer buf = new FastStringBuffer();
        int c;
        while ((c = reader.read()) != PythonCodeReader.EOF) {
            buf.append((char) c);
        }
        assertEquals("a = 10\n", buf.toString());
    }
View Full Code Here

        reader = new PythonCodeReader();
        doc = new Document("a = 10\n" +
                "def m1(self):\n" +
                "   a = 10");
        reader.configureBackwardReader(doc, doc.getLength(), true, true, true);
        FastStringBuffer buf = new FastStringBuffer();
        int c;
        while ((c = reader.read()) != PythonCodeReader.EOF) {
            buf.append((char) c);
        }
        buf.reverse();
        assertEquals(" m1(self):\n   a = 10", buf.toString());
    }
View Full Code Here

        doc = new Document("" +
                "titleEnd = ('''\n" +
                "            [#''')" + //should wrap to the start
                "");
        reader.configureBackwardReader(doc, doc.getLength(), true, true, true);
        FastStringBuffer buf = new FastStringBuffer();
        int c;
        while ((c = reader.read()) != PythonCodeReader.EOF) {
            buf.append((char) c);
        }
        buf.reverse();
        assertEquals("titleEnd = ()", buf.toString());
    }
View Full Code Here

                "titleEnd = ('''\n" +
                "# inside string" +
                "            [#''') #actual" + //should wrap to the start
                "");
        reader.configureBackwardReader(doc, doc.getLength(), true, true, true);
        FastStringBuffer buf = new FastStringBuffer();
        int c;
        while ((c = reader.read()) != PythonCodeReader.EOF) {
            buf.append((char) c);
        }
        buf.reverse();
        assertEquals("titleEnd = () #", buf.toString());
    }
View Full Code Here

            }
            messageToIgnore = prefs.getRequiredMessageToIgnore(IAnalysisPreferences.TYPE_PEP8);

            String[] pep8CommandLine = AnalysisPreferencesPage.getPep8CommandLine();

            FastStringBuffer args = new FastStringBuffer(pep8CommandLine.length * 20);
            for (String string : pep8CommandLine) {
                args.append(',').append("r'").append(string).append('\'');
            }

            String pep8Location = AnalysisPreferencesPage.getPep8Location();

            File pep8Loc = new File(pep8Location);

            if (!pep8Loc.exists()) {
                Log.log("Specified location for pep8.py does not exist (" + pep8Location + ").");
                return messages;
            }

            this.prefs = prefs;
            this.document = document;

            //It's important that the interpreter is created in the Thread and not outside the thread (otherwise
            //it may be that the output ends up being shared, which is not what we want.)
            boolean useConsole = AnalysisPreferencesPage.useConsole();
            IPythonInterpreter interpreter = JythonPlugin.newPythonInterpreter(useConsole, false);
            if (!useConsole) {
                interpreter.setErr(NullOutputStream.singleton);
                interpreter.setOut(NullOutputStream.singleton);
            }
            String file = StringUtils.replaceAllSlashes(module.getFile().getAbsolutePath());
            interpreter.set("visitor", this);

            List<String> splitInLines = StringUtils.splitInLines(document.get());
            interpreter.set("lines", splitInLines);
            PyObject tempPep8 = pep8;
            if (tempPep8 != null) {
                interpreter.set("pep8", tempPep8);
            } else {
                interpreter.set("pep8", Py.None);
            }

            String formatted = com.aptana.shared_core.string.StringUtils.format(EXECUTE_PEP8, file, args.toString(),
                    StringUtils.replaceAllSlashes(pep8Loc.getParentFile().getAbsolutePath()), //put the parent dir of pep8.py in the pythonpath.
                    file);
            interpreter.exec(formatted);
            if (pep8 == null) {
                synchronized (lock) {
View Full Code Here

        int tabWidth = indentPrefs.getTabWidth();
        //if we're analyzing the spaces, let's mark invalid indents (tabs are not searched for those because
        //a tab always marks a full indent).

        FastStringBuffer buffer = new FastStringBuffer();
        for (Tuple3<String, Integer, Boolean> indentation : validsAre) {
            if (monitor.isCanceled()) {
                return;
            }

            if (!indentation.o3) { //if it does not have more contents (its only whitespaces), let's keep on going!
                continue;
            }
            String indentStr = indentation.o1;
            if (indentStr.indexOf("\t") != -1) {
                continue; //the ones that appear in tabs and spaces should not be analyzed here (they'll have their own error messages).
            }

            int lenFound = indentStr.length();
            int extraChars = lenFound % tabWidth;
            if (extraChars != 0) {

                Integer offset = indentation.o2;
                int startLine = PySelection.getLineOfOffset(doc, offset) + 1;
                int startCol = 1;
                int endCol = startCol + lenFound;

                buffer.clear();
                ret.add(new Message(IAnalysisPreferences.TYPE_INDENTATION_PROBLEM, buffer.append("Bad Indentation (")
                        .append(lenFound).append(" spaces)").toString(), startLine, startLine, startCol, endCol,
                        analysisPrefs));

            }
View Full Code Here

     * @return
     */
    public static String infoToString(List<IInfo> iInfo) {
        HashMap<String, Integer> map = new HashMap<String, Integer>();

        FastStringBuffer infos = new FastStringBuffer();

        int next = 0;
        map.put(null, next);
        next++;

        for (Iterator<IInfo> it = iInfo.iterator(); it.hasNext();) {
            IInfo info = it.next();
            infos.append("&&");
            infos.append(info.getType());
            String name = info.getName();
            String declaringModuleName = info.getDeclaringModuleName();
            String path = info.getPath();

            next = add(map, infos, next, name);
            next = add(map, infos, next, declaringModuleName);
            next = add(map, infos, next, path);
        }

        FastStringBuffer header = new FastStringBuffer("INFOS:", map.size() * 30);
        Set<Entry<String, Integer>> entrySet = map.entrySet();

        //null is always 0 (not written to header)
        header.append(infos);
        header.append('\n');
        map.remove(null);
        for (Entry<String, Integer> entry : entrySet) {
            header.append(entry.getKey());
            header.append("=");
            header.append(entry.getValue());
            header.append("\n");
        }

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

            final Entry[] entries = new Entry[size];
            //each line is something as: cub|CubeColourDialog!13&999@CUBIC!263@cube!202&999@
            //note: the path (2nd int in record) is optional
            for (int iEntry = 0; iEntry < size; iEntry++) {
                buf.clear();
                FastStringBuffer line = reader.readLine();
                if (line == null || line.startsWith("-- ")) {
                    throw new RuntimeException("Unexpected line: " + line);
                }
                char[] internalCharsArray = line.getInternalCharsArray();
                int length = line.length();
                String key = null;
                String infoName = null;
                String path = null;

                int i = 0;
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.