[Pydev-cvs] org.python.pydev/src/org/python/pydev/builder/pylint PyLintVisitor.java, 1.40, 1.41
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-05-21 01:38:03
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4510/src/org/python/pydev/builder/pylint Modified Files: PyLintVisitor.java Log Message: - No longer using Runtime.exec(String), only Runtime.exec(String[]) - Updating the markers in a better (faster) way Index: PyLintVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint/PyLintVisitor.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** PyLintVisitor.java 5 Feb 2008 01:11:59 -0000 1.40 --- PyLintVisitor.java 21 May 2008 01:38:09 -0000 1.41 *************** *** 24,28 **** import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; --- 24,27 ---- *************** *** 33,36 **** --- 32,36 ---- import org.python.pydev.builder.PyDevBuilderVisitor; import org.python.pydev.builder.PydevMarkerUtils; + import org.python.pydev.builder.PydevMarkerUtils.MarkerInfo; import org.python.pydev.core.REF; import org.python.pydev.core.Tuple; *************** *** 110,118 **** protected IStatus run(IProgressMonitor monitor) { ! try { ! resource.deleteMarkers(PYLINT_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); ! } catch (CoreException e3) { ! PydevPlugin.log(e3); ! } for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { --- 110,115 ---- protected IStatus run(IProgressMonitor monitor) { ! ! ArrayList<MarkerInfo> lst = new ArrayList<PydevMarkerUtils.MarkerInfo>(); for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { *************** *** 120,135 **** String tok = (String) el[0]; ! String type = (String) el[1]; ! int priority = ((Integer)el[2]).intValue(); ! String id = (String) el[3]; ! int line = ((Integer)el[4]).intValue(); ! try { ! PydevMarkerUtils.createMarker(resource, document, "ID:"+id+" "+tok , ! line, 0,line, 0, ! type, priority); ! } catch (BadLocationException e) { ! // ignore (the file may have changed during the time we were analyzing the file) ! } } return PydevPlugin.makeStatus(Status.OK, "", null); --- 117,129 ---- String tok = (String) el[0]; ! int priority = ((Integer)el[1]).intValue(); ! String id = (String) el[2]; ! int line = ((Integer)el[3]).intValue(); ! ! lst.add(new PydevMarkerUtils.MarkerInfo(document, "ID:" + id + " " + tok, ! PYLINT_PROBLEM_MARKER, priority, false, false, line, 0, line, 0, null)); } + + PydevMarkerUtils.replaceMarkers(lst, resource, PYLINT_PROBLEM_MARKER); return PydevPlugin.makeStatus(Status.OK, "", null); *************** *** 174,179 **** * @param line */ ! private void addToMarkers(String tok, String type, int priority, String id, int line) { ! markers.add(new Object[]{tok, type, priority, id, line} ); } --- 168,173 ---- * @param line */ ! private void addToMarkers(String tok, int priority, String id, int line) { ! markers.add(new Object[]{tok, priority, id, line} ); } *************** *** 193,197 **** //user args ! String userArgs = PyLintPrefPage.getPylintArgs().replaceAll("\r","").replaceAll("\n"," "); StringTokenizer tokenizer2 = new StringTokenizer(userArgs); while(tokenizer2.hasMoreTokens()){ --- 187,191 ---- //user args ! String userArgs = PyLintPrefPage.getPylintArgs().replaceAll("\r\n"," ").replaceAll("\r"," ").replaceAll("\n"," "); StringTokenizer tokenizer2 = new StringTokenizer(userArgs); while(tokenizer2.hasMoreTokens()){ *************** *** 205,212 **** String scriptToExe = REF.getFileAbsolutePath(script); String[] paramsToExe = list.toArray(new String[0]); ! String cmdLineToExe = SimplePythonRunner.makeExecutableCommandStr(scriptToExe, paramsToExe); ! write("Pylint: Executing command line:'"+cmdLineToExe+"'", out); ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutput(cmdLineToExe, arg.getParentFile(), project); write("Pylint: The stdout of the command line is: "+outTup.o1, out); write("Pylint: The stderr of the command line is: "+outTup.o2, out); --- 199,205 ---- String scriptToExe = REF.getFileAbsolutePath(script); String[] paramsToExe = list.toArray(new String[0]); ! write("Pylint: Executing command line:'", out, scriptToExe, paramsToExe, "'"); ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputFromPythonScript(scriptToExe, paramsToExe, arg.getParentFile(), project); write("Pylint: The stdout of the command line is: "+outTup.o1, out); write("Pylint: The stderr of the command line is: "+outTup.o2, out); *************** *** 242,246 **** try { ! String type = null; int priority = 0; --- 235,239 ---- try { ! boolean found=false; int priority = 0; *************** *** 252,276 **** if(tok.startsWith("C")&& useC){ ! type = PYLINT_PROBLEM_MARKER; //priority = IMarker.SEVERITY_WARNING; priority = cSeverity; } else if(tok.startsWith("R") && useR ){ ! type = PYLINT_PROBLEM_MARKER; //priority = IMarker.SEVERITY_WARNING; priority = rSeverity; } else if(tok.startsWith("W") && useW ){ ! type = PYLINT_PROBLEM_MARKER; //priority = IMarker.SEVERITY_WARNING; priority = wSeverity; } else if(tok.startsWith("E") && useE ){ ! type = PYLINT_PROBLEM_MARKER; //priority = IMarker.SEVERITY_ERROR; priority = eSeverity; } else if(tok.startsWith("F") && useF ){ ! type = PYLINT_PROBLEM_MARKER; //priority = IMarker.SEVERITY_ERROR; priority = fSeverity; --- 245,269 ---- if(tok.startsWith("C")&& useC){ ! found=true; //priority = IMarker.SEVERITY_WARNING; priority = cSeverity; } else if(tok.startsWith("R") && useR ){ ! found=true; //priority = IMarker.SEVERITY_WARNING; priority = rSeverity; } else if(tok.startsWith("W") && useW ){ ! found=true; //priority = IMarker.SEVERITY_WARNING; priority = wSeverity; } else if(tok.startsWith("E") && useE ){ ! found=true; //priority = IMarker.SEVERITY_ERROR; priority = eSeverity; } else if(tok.startsWith("F") && useF ){ ! found=true; //priority = IMarker.SEVERITY_ERROR; priority = fSeverity; *************** *** 284,288 **** try { ! if(type != null){ String id = tok.substring(0, tok.indexOf(":")).trim(); --- 277,281 ---- try { ! if(found){ String id = tok.substring(0, tok.indexOf(":")).trim(); *************** *** 320,324 **** tok = tok.substring(i+1); ! addToMarkers(tok, type, priority, id, line-1); } } catch (RuntimeException e2) { --- 313,317 ---- tok = tok.substring(i+1); ! addToMarkers(tok, priority, id, line-1); } } catch (RuntimeException e2) { *************** *** 368,375 **** } ! public static void write(String cmdLineToExe, IOConsoleOutputStream out) { try { if(fConsole != null && out != null){ synchronized(fConsole){ out.write(cmdLineToExe); } --- 361,380 ---- } ! public static void write(String cmdLineToExe, IOConsoleOutputStream out, Object ... args) { try { if(fConsole != null && out != null){ synchronized(fConsole){ + if(args != null){ + for (Object arg : args) { + if(arg instanceof String){ + cmdLineToExe += " "+arg; + }else if(arg instanceof String[]){ + String[] strings = (String[]) arg; + for (String string : strings) { + cmdLineToExe += " "+string; + } + } + } + } out.write(cmdLineToExe); } |