pydev-cvs Mailing List for PyDev for Eclipse (Page 17)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
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); } |
From: Fabio Z. <fa...@us...> - 2008-05-21 01:38:03
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/pythontests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4510/tests/org/python/pydev/pythontests Modified Files: PythonTest.java Log Message: - No longer using Runtime.exec(String), only Runtime.exec(String[]) - Updating the markers in a better (faster) way Index: PythonTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/pythontests/PythonTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonTest.java 27 May 2007 13:27:03 -0000 1.1 --- PythonTest.java 21 May 2008 01:38:09 -0000 1.2 *************** *** 56,61 **** private static Throwable exec(File f) { ! String cmdLine = SimplePythonRunner.getCommandLineAsString(new String[]{TestDependent.PYTHON_EXE, "-u", REF.getFileAbsolutePath(f)}); ! Tuple<String, String> output = new SimplePythonRunner().runAndGetOutput(cmdLine, f.getParentFile()); if(output.o2.indexOf("FAILED") != -1){ throw new AssertionError(output.toString()); --- 56,61 ---- private static Throwable exec(File f) { ! Tuple<String, String> output = new SimplePythonRunner().runAndGetOutput(new String[] { ! TestDependent.PYTHON_EXE, "-u", REF.getFileAbsolutePath(f) }, f.getParentFile(), null, null); if(output.o2.indexOf("FAILED") != -1){ throw new AssertionError(output.toString()); |
From: Fabio Z. <fa...@us...> - 2008-05-21 01:38:03
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/runners In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4510/tests/org/python/pydev/runners Modified Files: SimplePythonRunnerTest.java SimpleExeRunnerTest.java Log Message: - No longer using Runtime.exec(String), only Runtime.exec(String[]) - Updating the markers in a better (faster) way Index: SimpleExeRunnerTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/runners/SimpleExeRunnerTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleExeRunnerTest.java 5 Feb 2008 13:07:14 -0000 1.3 --- SimpleExeRunnerTest.java 21 May 2008 01:38:08 -0000 1.4 *************** *** 21,25 **** if(TestDependent.HAS_CYGWIN){ SimpleExeRunner runner = new SimpleExeRunner(); ! Tuple<String, String> tup = runner.runAndGetOutput(TestDependent.CYGWIN_CYGPATH_LOCATION, new String[]{TestDependent.CYGWIN_CYGPATH_LOCATION}, null); assertEquals(TestDependent.CYGWIN_UNIX_CYGPATH_LOCATION, tup.o1.trim()); assertEquals("", tup.o2); --- 21,26 ---- if(TestDependent.HAS_CYGWIN){ SimpleExeRunner runner = new SimpleExeRunner(); ! Tuple<String, String> tup = runner.runAndGetOutput(new String[] { TestDependent.CYGWIN_CYGPATH_LOCATION, ! TestDependent.CYGWIN_CYGPATH_LOCATION }, null, null, null); assertEquals(TestDependent.CYGWIN_UNIX_CYGPATH_LOCATION, tup.o1.trim()); assertEquals("", tup.o2); *************** *** 30,34 **** if(TestDependent.HAS_CYGWIN){ SimpleExeRunner runner = new SimpleExeRunner(); ! List<String> ret = runner.convertToCygwinPath(TestDependent.CYGWIN_CYGPATH_LOCATION, TestDependent.CYGWIN_CYGPATH_LOCATION, "c:\\foo"); assertEquals(2, ret.size()); ArrayList<String> expected = new ArrayList<String>(); --- 31,36 ---- if(TestDependent.HAS_CYGWIN){ SimpleExeRunner runner = new SimpleExeRunner(); ! List<String> ret = runner.convertToCygwinPath(TestDependent.CYGWIN_CYGPATH_LOCATION, ! TestDependent.CYGWIN_CYGPATH_LOCATION, "c:\\foo"); assertEquals(2, ret.size()); ArrayList<String> expected = new ArrayList<String>(); Index: SimplePythonRunnerTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/runners/SimplePythonRunnerTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SimplePythonRunnerTest.java 15 Mar 2006 00:18:35 -0000 1.4 --- SimplePythonRunnerTest.java 21 May 2008 01:38:08 -0000 1.5 *************** *** 50,54 **** File relativePath = PydevPlugin.getBundleInfo().getRelativePath(new Path("PySrc/interpreterInfo.py")); ! String string = new SimplePythonRunner().runAndGetOutput(TestDependent.PYTHON_EXE+" "+relativePath.getCanonicalPath(), null).o1; assertNotNull(string); //System.out.println(string); --- 50,55 ---- File relativePath = PydevPlugin.getBundleInfo().getRelativePath(new Path("PySrc/interpreterInfo.py")); ! String string = new SimplePythonRunner().runAndGetOutput(new String[] { TestDependent.PYTHON_EXE, ! relativePath.getCanonicalPath() }, null, null, null).o1; assertNotNull(string); //System.out.println(string); |
From: Fabio Z. <fa...@us...> - 2008-05-20 02:20:26
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10748/src/org/python/pydev/core/docutils Modified Files: ImportHandle.java Log Message: Simplified regular expression to match imports. Index: ImportHandle.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ImportHandle.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ImportHandle.java 19 May 2008 00:58:28 -0000 1.3 --- ImportHandle.java 20 May 2008 02:20:23 -0000 1.4 *************** *** 24,29 **** //spaces* 'from' space+ module space+ import (mod as y) ! private static final Pattern FromImportPattern = Pattern.compile("(from\\s+)(\\.*\\w+)+(\\s+import\\s+)(\\w+|\\s|,|#|\\(|\\)|\\\\)*"); ! private static final Pattern ImportPattern = Pattern.compile("(import\\s+)(\\w+|\\s|,|#|\\(|\\)|\\\\)*"); /** --- 24,29 ---- //spaces* 'from' space+ module space+ import (mod as y) ! private static final Pattern FromImportPattern = Pattern.compile("(from\\s+)(\\.*\\w+)+(\\s+import\\s+)"); ! private static final Pattern ImportPattern = Pattern.compile("(import\\s+)"); /** *************** *** 87,91 **** //from import Matcher matcher = FromImportPattern.matcher(importFound); ! if(matcher.matches()){ this.fromStr = importFound.substring(matcher.end(1), matcher.end(2)).trim(); --- 87,91 ---- //from import Matcher matcher = FromImportPattern.matcher(importFound); ! if(matcher.find()){ this.fromStr = importFound.substring(matcher.end(1), matcher.end(2)).trim(); *************** *** 93,97 **** //we have to do that because the last group will only have the last match in the string String importedStr = importFound.substring(matcher.end(3), ! matcher.end(4)).trim(); buildImportedList(importedStr); --- 93,97 ---- //we have to do that because the last group will only have the last match in the string String importedStr = importFound.substring(matcher.end(3), ! importFound.length()).trim(); buildImportedList(importedStr); *************** *** 105,112 **** //regular import Matcher matcher = ImportPattern.matcher(importFound); ! if(matcher.matches()){ //we have to do that because the last group will only have the last match in the string String importedStr = importFound.substring(matcher.end(1), ! matcher.end(2)).trim(); buildImportedList(importedStr); --- 105,112 ---- //regular import Matcher matcher = ImportPattern.matcher(importFound); ! if(matcher.find()){ //we have to do that because the last group will only have the last match in the string String importedStr = importFound.substring(matcher.end(1), ! importFound.length()).trim(); buildImportedList(importedStr); |
From: Fabio Z. <fa...@us...> - 2008-05-19 00:58:21
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10132/src/org/python/pydev/core/docutils Modified Files: PySelection.java ImportsSelection.java ImportHandle.java Log Message: Auto-import grouping imports when possible Index: PySelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PySelection.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** PySelection.java 1 May 2008 14:25:53 -0000 1.61 --- PySelection.java 19 May 2008 00:58:28 -0000 1.62 *************** *** 1056,1059 **** --- 1056,1062 ---- + /** + * @return the number of line breaks in the passed string. + */ public static int countLineBreaks(String replacementString) { int lineBreaks = 0; Index: ImportHandle.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ImportHandle.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ImportHandle.java 18 May 2008 20:02:26 -0000 1.2 --- ImportHandle.java 19 May 2008 00:58:28 -0000 1.3 *************** *** 24,29 **** //spaces* 'from' space+ module space+ import (mod as y) ! private static final Pattern FromImportPattern = Pattern.compile("(from\\s+)(\\.*\\w+)(\\s+import\\s+)(\\w+|\\s|,|#|\\(|\\))*(\\z)"); ! private static final Pattern ImportPattern = Pattern.compile("(import\\s+)(\\w+|\\s|,|#|\\(|\\))*(\\z)"); /** --- 24,29 ---- //spaces* 'from' space+ module space+ import (mod as y) ! private static final Pattern FromImportPattern = Pattern.compile("(from\\s+)(\\.*\\w+)+(\\s+import\\s+)(\\w+|\\s|,|#|\\(|\\)|\\\\)*"); ! private static final Pattern ImportPattern = Pattern.compile("(import\\s+)(\\w+|\\s|,|#|\\(|\\)|\\\\)*"); /** *************** *** 44,49 **** --- 44,71 ---- */ private List<String> importedStrComments; + + /** + * Starting line for this import. + */ + private int startLine; + + /** + * Ending line for this import. + */ + private int endLine; + + /** + * Holds whether the import started in the middle of the line (after a ';') + */ + private boolean startedInMiddleOfLine; /** + * Constructor that does not set the line for the import. + */ + public ImportHandleInfo(String importFound) throws ImportNotRecognizedException { + this(importFound, -1, -1, false); + } + + /** * Constructor. * *************** *** 53,57 **** * @throws ImportNotRecognizedException */ ! public ImportHandleInfo(String importFound) throws ImportNotRecognizedException { importFound=importFound.trim(); char firstChar = importFound.charAt(0); --- 75,83 ---- * @throws ImportNotRecognizedException */ ! public ImportHandleInfo(String importFound, int lineStart, int lineEnd, boolean startedInMiddleOfLine) throws ImportNotRecognizedException { ! this.startLine = lineStart; ! this.endLine = lineEnd; ! this.startedInMiddleOfLine = startedInMiddleOfLine; ! importFound=importFound.trim(); char firstChar = importFound.charAt(0); *************** *** 62,66 **** Matcher matcher = FromImportPattern.matcher(importFound); if(matcher.matches()){ ! this.fromStr = matcher.group(2); //we have to do that because the last group will only have the last match in the string --- 88,93 ---- Matcher matcher = FromImportPattern.matcher(importFound); if(matcher.matches()){ ! this.fromStr = importFound.substring(matcher.end(1), ! matcher.end(2)).trim(); //we have to do that because the last group will only have the last match in the string *************** *** 116,120 **** alias = new StringBuffer(); ! }else if(c == '(' || c == ')'){ //do nothing --- 143,147 ---- alias = new StringBuffer(); ! }else if(c == '(' || c == ')' || c == '\\'){ //do nothing *************** *** 184,187 **** --- 211,235 ---- return this.importedStrComments; } + + /** + * @return the start line for this import (0-based) + */ + public int getStartLine() { + return this.startLine; + } + + /** + * @return the end line for this import (0-based) + */ + public int getEndLine() { + return this.endLine; + } + + /** + * @return true if this import was started in the middle of the line. I.e.: after a ';' + */ + public boolean getStartedInMiddleOfLine() { + return this.startedInMiddleOfLine; + } } *************** *** 209,213 **** /** ! * Import informatiot for the import found and handled in this class (only created on request) */ private List<ImportHandleInfo> importInfo; --- 257,261 ---- /** ! * Import information for the import found and handled in this class (only created on request) */ private List<ImportHandleInfo> importInfo; *************** *** 226,230 **** /** ! * @param realImportRep the import to match. Note that only a single import statement may be passed as a parameter. * * @return true if the passed import matches the import in this handle (note: as this class can actually wrap more --- 274,278 ---- /** ! * @param realImportHandleInfo the import to match. Note that only a single import statement may be passed as a parameter. * * @return true if the passed import matches the import in this handle (note: as this class can actually wrap more *************** *** 232,237 **** * @throws ImportNotRecognizedException if the passed import could not be recognized */ ! public boolean contains(String realImportRep) throws ImportNotRecognizedException { ! ImportHandleInfo otherImportInfo = new ImportHandleInfo(realImportRep); List<ImportHandleInfo> importHandleInfo = this.getImportInfo(); --- 280,284 ---- * @throws ImportNotRecognizedException if the passed import could not be recognized */ ! public boolean contains(ImportHandleInfo otherImportInfo) throws ImportNotRecognizedException { List<ImportHandleInfo> importHandleInfo = this.getImportInfo(); *************** *** 268,271 **** --- 315,321 ---- this.importInfo = new ArrayList<ImportHandleInfo>(); + int line = startFoundLine; + boolean startedInMiddle = false; + StringBuffer imp = new StringBuffer(); for(int i=0;i<importFound.length();i++){ *************** *** 277,287 **** }else if(c == ';'){ try { ! this.importInfo.add(new ImportHandleInfo(imp.toString())); } catch (ImportNotRecognizedException e) { //that's ok, not a valid import (at least, we couldn't parse it) } imp = new StringBuffer(); ! }else{ imp.append(c); } --- 327,343 ---- }else if(c == ';'){ try { ! String impStr = imp.toString(); ! int endLine = line+PySelection.countLineBreaks(impStr); ! this.importInfo.add(new ImportHandleInfo(impStr, line, endLine, startedInMiddle)); ! line = endLine; } catch (ImportNotRecognizedException e) { //that's ok, not a valid import (at least, we couldn't parse it) } imp = new StringBuffer(); ! startedInMiddle = true; }else{ + if(c == '\r' || c == '\n'){ + startedInMiddle = false; + } imp.append(c); } *************** *** 289,293 **** } try { ! this.importInfo.add(new ImportHandleInfo(imp.toString())); } catch (ImportNotRecognizedException e) { //that's ok, not a valid import (at least, we couldn't parse it) --- 345,350 ---- } try { ! String impStr = imp.toString(); ! this.importInfo.add(new ImportHandleInfo(impStr, line, line+PySelection.countLineBreaks(impStr), startedInMiddle)); } catch (ImportNotRecognizedException e) { //that's ok, not a valid import (at least, we couldn't parse it) Index: ImportsSelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ImportsSelection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ImportsSelection.java 18 May 2008 20:02:26 -0000 1.2 --- ImportsSelection.java 19 May 2008 00:58:28 -0000 1.3 *************** *** 170,173 **** --- 170,176 ---- allEndingWithSlash = false; } + }else if(trimmedLine.length() == 0){ + //if some empty line was found, stop the analysis. + break; } } |
From: Fabio Z. <fa...@us...> - 2008-05-19 00:58:21
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10132/tests/org/python/pydev/core/docutils Modified Files: ImportHandleTest.java Log Message: Auto-import grouping imports when possible Index: ImportHandleTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils/ImportHandleTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportHandleTest.java 18 May 2008 20:02:26 -0000 1.1 --- ImportHandleTest.java 19 May 2008 00:58:28 -0000 1.2 *************** *** 10,13 **** --- 10,25 ---- public class ImportHandleTest extends TestCase { + public static void main(String[] args) { + try { + ImportHandleTest test = new ImportHandleTest(); + test.setUp(); + test.testImportHandleInfo3(); + test.tearDown(); + junit.textui.TestRunner.run(ImportHandleTest.class); + } catch (Throwable e) { + e.printStackTrace(); + } + } + protected void setUp() throws Exception { super.setUp(); *************** *** 51,54 **** --- 63,98 ---- } + public void testImportHandleInfoLines() throws Exception { + ImportHandle importHandle = new ImportHandle(null, "from AAA import (BBB, \nCCC);from XXX import YYY", 0, 1); + List<ImportHandleInfo> importInfo = importHandle.getImportInfo(); + assertEquals(2, importInfo.size()); + assertEquals("AAA", importInfo.get(0).getFromImportStr()); + assertEquals("XXX", importInfo.get(1).getFromImportStr()); + assertEquals(0, importInfo.get(0).getStartLine()); + assertEquals(1, importInfo.get(0).getEndLine()); + assertEquals(1, importInfo.get(1).getStartLine()); + assertEquals(1, importInfo.get(1).getEndLine()); + assertTrue(importInfo.get(1).getStartedInMiddleOfLine()); + + } + + public void testImportHandleInfo3() throws Exception { + ImportHandle importHandle = new ImportHandle(null, "from wx.xrc import XML_ATTRIBUTE_NODE, XML_CDATA_SECTION_NODE,\\\n"+ + "XML_DOCUMENT_FRAG_NODE, XML_DOCUMENT_TYPE_NODE, XML_ELEMENT_NODE,\\\n"+ + "XML_COMMENT_NODE", 0, 0); + + List<ImportHandleInfo> importInfo = importHandle.getImportInfo(); + assertEquals(1, importInfo.size()); + assertEquals("wx.xrc", importInfo.get(0).getFromImportStr()); + ArrayList<String> lst = new ArrayList<String>(); + lst.add("XML_ATTRIBUTE_NODE"); + lst.add("XML_CDATA_SECTION_NODE"); + lst.add("XML_DOCUMENT_FRAG_NODE"); + lst.add("XML_DOCUMENT_TYPE_NODE"); + lst.add("XML_ELEMENT_NODE"); + lst.add("XML_COMMENT_NODE"); + assertEquals(lst, importInfo.get(0).getImportedStr()); + } + public void testImportHandleInfo() throws Exception { ImportHandle importHandle = new ImportHandle(null, "from AAA import BBB", 0, 0); *************** *** 89,92 **** --- 133,146 ---- assertEquals(comments, importInfo.get(0).getCommentsForImports()); + + importHandle = new ImportHandle(null, "from AAA.bbb.ccc import BBB", 0, 0); + importInfo = importHandle.getImportInfo(); + assertEquals(1, importInfo.size()); + assertEquals("AAA.bbb.ccc", importInfo.get(0).getFromImportStr()); + lst = new ArrayList<String>(); + lst.add("BBB"); + assertEquals(lst, importInfo.get(0).getImportedStr()); + + importHandle = new ImportHandle(null, "from AAA import (BBB, #, DDD as CCC\nKKK)", 0, 0); importInfo = importHandle.getImportInfo(); *************** *** 102,106 **** assertEquals(comments, importInfo.get(0).getCommentsForImports()); ! importHandle = new ImportHandle(null, "from .AAA import (BBB, #, DDD as CCC\nKKK)", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); --- 156,160 ---- assertEquals(comments, importInfo.get(0).getCommentsForImports()); ! importHandle = new ImportHandle(null, "from .AAA import (BBB, #, DDD as CCC\nKKK)", 0, 1); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); *************** *** 114,128 **** assertEquals(lst, importInfo.get(0).getImportedStr()); assertEquals(comments, importInfo.get(0).getCommentsForImports()); } public void testImportMatches() throws Exception { ImportHandle importHandle = new ImportHandle(null, "from AAA import BBB", 0, 0); ! assertFalse(importHandle.contains("from X import BBB")); ! assertFalse(importHandle.contains("from XXX import BBB")); ! assertFalse(importHandle.contains("from AAA import CCC")); ! assertTrue(importHandle.contains("from AAA import BBB")); importHandle = new ImportHandle(null, "from AAA import BBB;from XXX import YYY", 0, 0); ! assertTrue(importHandle.contains("from XXX import YYY")); } --- 168,184 ---- assertEquals(lst, importInfo.get(0).getImportedStr()); assertEquals(comments, importInfo.get(0).getCommentsForImports()); + assertEquals(0, importInfo.get(0).getStartLine()); + assertEquals(1, importInfo.get(0).getEndLine()); } public void testImportMatches() throws Exception { ImportHandle importHandle = new ImportHandle(null, "from AAA import BBB", 0, 0); ! assertFalse(importHandle.contains(new ImportHandle.ImportHandleInfo("from X import BBB"))); ! assertFalse(importHandle.contains(new ImportHandle.ImportHandleInfo("from XXX import BBB"))); ! assertFalse(importHandle.contains(new ImportHandle.ImportHandleInfo("from AAA import CCC"))); ! assertTrue(importHandle.contains(new ImportHandle.ImportHandleInfo("from AAA import BBB"))); importHandle = new ImportHandle(null, "from AAA import BBB;from XXX import YYY", 0, 0); ! assertTrue(importHandle.contains(new ImportHandle.ImportHandleInfo("from XXX import YYY"))); } |
From: Fabio Z. <fa...@us...> - 2008-05-19 00:58:15
|
Update of /cvsroot/pydev/org.python.pydev/META-INF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10109/META-INF Modified Files: MANIFEST.MF Log Message: Auto-import grouping imports when possible Index: MANIFEST.MF =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/META-INF/MANIFEST.MF,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** MANIFEST.MF 7 Apr 2008 19:54:57 -0000 1.47 --- MANIFEST.MF 19 May 2008 00:58:20 -0000 1.48 *************** *** 97,100 **** --- 97,101 ---- org.python.pydev.ui.editors, org.python.pydev.ui.filetypes, + org.python.pydev.ui.importsconf, org.python.pydev.ui.interpreters, org.python.pydev.ui.perspective, |
From: Fabio Z. <fa...@us...> - 2008-05-19 00:58:15
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/importsconf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10109/src/org/python/pydev/ui/importsconf Modified Files: ImportsPreferencesPage.java Log Message: Auto-import grouping imports when possible Index: ImportsPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/importsconf/ImportsPreferencesPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportsPreferencesPage.java 18 May 2008 20:02:16 -0000 1.1 --- ImportsPreferencesPage.java 19 May 2008 00:58:20 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- import org.python.pydev.core.docutils.WordUtils; import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.plugin.PydevPrefs; import org.python.pydev.utils.LabelFieldEditor; *************** *** 65,68 **** --- 66,81 ---- // pass } + + + /** + * @return true if imports should be grouped when possible. E.g.: If from aaa import b and from aaa import c + * exist, they should be grouped as from aaa import b, c + */ + public static boolean getGroupImports() { + if(PydevPlugin.getDefault() == null){ + return true; + } + return PydevPrefs.getPreferences().getBoolean(GROUP_IMPORTS); + } |
From: Fabio Z. <fa...@us...> - 2008-05-19 00:58:15
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10109/tests_completions/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletionTest.java Log Message: Auto-import grouping imports when possible Index: PyCodeCompletionTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCompletionTest.java 25 Mar 2007 18:36:07 -0000 1.2 --- PyCodeCompletionTest.java 19 May 2008 00:58:20 -0000 1.3 *************** *** 76,79 **** --- 76,83 ---- doTest("from this space", ""); doTest("from ", " "); + + doTest("nothere", ""); + doTest("from i import y\n\na=10", ""); + doTest("from i import (y)\n\na=10", ""); } |
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28562/src/org/python/pydev/core/docutils Modified Files: ParsingUtils.java ImportsSelection.java StringUtils.java ImportHandle.java Added Files: ImportNotRecognizedException.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils --- NEW FILE: ImportNotRecognizedException.java --- package org.python.pydev.core.docutils; public class ImportNotRecognizedException extends Exception { public ImportNotRecognizedException(String msg) { super(msg); } } Index: ImportHandle.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ImportHandle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportHandle.java 17 May 2008 14:26:57 -0000 1.1 --- ImportHandle.java 18 May 2008 20:02:26 -0000 1.2 *************** *** 1,4 **** --- 1,9 ---- package org.python.pydev.core.docutils; + import java.util.ArrayList; + import java.util.List; + import java.util.regex.Matcher; + import java.util.regex.Pattern; + import org.eclipse.jface.text.IDocument; *************** *** 9,14 **** --- 14,192 ---- */ public class ImportHandle { + /** + * Class representing some import information + * + * @author Fabio + */ + public static class ImportHandleInfo{ + + //spaces* 'from' space+ module space+ import (mod as y) + private static final Pattern FromImportPattern = Pattern.compile("(from\\s+)(\\.*\\w+)(\\s+import\\s+)(\\w+|\\s|,|#|\\(|\\))*(\\z)"); + private static final Pattern ImportPattern = Pattern.compile("(import\\s+)(\\w+|\\s|,|#|\\(|\\))*(\\z)"); + + /** + * Holds the 'KKK' if the import is from KKK import YYY + * If it's not a From Import, it should be null. + */ + private String fromStr; + + /** + * This is the alias that's been imported. E.g.: in from KKK import YYY, ZZZ, this is a list + * with YYY and ZZZ + */ + private List<String> importedStr; + + /** + * Comments (one for each imported string) E.g.: in from KKK import (YYY, #comment\n ZZZ), this is a list + * with #comment and an empty string. + */ + private List<String> importedStrComments; + + /** + * Constructor. + * + * Creates the information to be returned later + * + * @param importFound + * @throws ImportNotRecognizedException + */ + public ImportHandleInfo(String importFound) throws ImportNotRecognizedException { + importFound=importFound.trim(); + char firstChar = importFound.charAt(0); + + + if (firstChar == 'f') { + //from import + Matcher matcher = FromImportPattern.matcher(importFound); + if(matcher.matches()){ + this.fromStr = matcher.group(2); + + //we have to do that because the last group will only have the last match in the string + String importedStr = importFound.substring(matcher.end(3), + matcher.end(4)).trim(); + + buildImportedList(importedStr); + + }else{ + throw new ImportNotRecognizedException("Could not recognize import: "+importFound); + } + + + }else if(firstChar == 'i'){ + //regular import + Matcher matcher = ImportPattern.matcher(importFound); + if(matcher.matches()){ + //we have to do that because the last group will only have the last match in the string + String importedStr = importFound.substring(matcher.end(1), + matcher.end(2)).trim(); + + buildImportedList(importedStr); + + }else{ + throw new ImportNotRecognizedException("Could not recognize import: "+importFound); + } + + }else{ + throw new ImportNotRecognizedException("Could not recognize import: "+importFound); + } + } + + /** + * Fills the importedStrComments and importedStr given the importedStr passed + * + * @param importedStr string with the tokens imported in an import + */ + private void buildImportedList(String importedStr) { + ArrayList<String> lst = new ArrayList<String>(); + ArrayList<String> importComments = new ArrayList<String>(); + + StringBuffer alias = new StringBuffer(); + for(int i=0;i<importedStr.length();i++){ + char c = importedStr.charAt(i); + if(c == '#'){ + StringBuffer comments = new StringBuffer(); + i = ParsingUtils.eatComments(importedStr, comments, i); + addImportAlias(lst, importComments, alias, comments.toString()); + alias = new StringBuffer(); + + }else if(c == ',' || c == '\r' || c == '\n'){ + addImportAlias(lst, importComments, alias, ""); + alias = new StringBuffer(); + + }else if(c == '(' || c == ')'){ + //do nothing + + + }else if(c == ' ' || c == '\t'){ + String curr = alias.toString(); + if(curr.endsWith(" as") | curr.endsWith("\tas")){ + alias = new StringBuffer(); + } + alias.append(c); + + }else{ + alias.append(c); + } + } + + if(alias.length() > 0){ + addImportAlias(lst, importComments, alias, ""); + + } + + this.importedStrComments = importComments; + this.importedStr = lst; + } + + /** + * Adds an import and its related comment to the given lists (if there's actually something available to be + * added) + * + * @param lst list where the alias will be added + * @param importComments list where the comment will be added + * @param alias the name of the import to be added + * @param importComment the comment related to the import + */ + private void addImportAlias(ArrayList<String> lst, ArrayList<String> importComments, StringBuffer alias, + String importComment) { + + String aliasStr = alias.toString().trim(); + importComment = importComment.trim(); + + if(aliasStr.length() > 0){ + lst.add(aliasStr); + importComments.add(importComment); + }else if(importComment.length() > 0 && importComments.size() > 0){ + importComments.set(importComments.size()-1, importComment); + } + } + + /** + * @return the from module in the import + */ + public String getFromImportStr() { + return this.fromStr; + } + + /** + * @return the tokens imported from the module (or the alias if it's specified) + */ + public List<String> getImportedStr() { + return this.importedStr; + } + + /** + * @return a list with a string for each imported token correspondent to a comment related to that import. + */ + public List<String> getCommentsForImports() { + return this.importedStrComments; + } + + } + + + /** * Document where the import was found */ *************** *** 29,32 **** --- 207,215 ---- */ public int endFoundLine; + + /** + * Import informatiot for the import found and handled in this class (only created on request) + */ + private List<ImportHandleInfo> importInfo; /** *************** *** 42,44 **** --- 225,299 ---- } + /** + * @param realImportRep the import to match. Note that only a single import statement may be passed as a parameter. + * + * @return true if the passed import matches the import in this handle (note: as this class can actually wrap more + * than 1 import, it'll return true if any of the internal imports match the passed import) + * @throws ImportNotRecognizedException if the passed import could not be recognized + */ + public boolean contains(String realImportRep) throws ImportNotRecognizedException { + ImportHandleInfo otherImportInfo = new ImportHandleInfo(realImportRep); + List<ImportHandleInfo> importHandleInfo = this.getImportInfo(); + + for(ImportHandleInfo info : importHandleInfo) { + if(info.fromStr != otherImportInfo.fromStr){ + if(otherImportInfo.fromStr == null || info.fromStr == null){ + continue; //keep on to the next possible match + } + if(!otherImportInfo.fromStr.equals(info.fromStr)){ + continue; //keep on to the next possible match + } + } + + if(otherImportInfo.importedStr.size() != 1){ + continue; + } + + if(info.importedStr.contains(otherImportInfo.importedStr.get(0))){ + return true; + } + + } + + + return false; + } + + + /** + * @return a list with the import information generated from the import this handle is wrapping. + */ + public List<ImportHandleInfo> getImportInfo() { + if(this.importInfo == null){ + this.importInfo = new ArrayList<ImportHandleInfo>(); + + StringBuffer imp = new StringBuffer(); + for(int i=0;i<importFound.length();i++){ + char c = importFound.charAt(i); + + if(c == '#'){ + i = ParsingUtils.eatComments(importFound, imp, i); + + }else if(c == ';'){ + try { + this.importInfo.add(new ImportHandleInfo(imp.toString())); + } catch (ImportNotRecognizedException e) { + //that's ok, not a valid import (at least, we couldn't parse it) + } + imp = new StringBuffer(); + + }else{ + imp.append(c); + } + + } + try { + this.importInfo.add(new ImportHandleInfo(imp.toString())); + } catch (ImportNotRecognizedException e) { + //that's ok, not a valid import (at least, we couldn't parse it) + } + } + return this.importInfo; + } + } Index: ParsingUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ParsingUtils.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ParsingUtils.java 5 Mar 2008 12:44:45 -0000 1.18 --- ParsingUtils.java 18 May 2008 20:02:26 -0000 1.19 *************** *** 10,14 **** import org.eclipse.jface.text.IDocumentExtension3; import org.eclipse.jface.text.IDocumentPartitionerExtension2; - import org.python.pydev.core.FullRepIterable; import org.python.pydev.core.IPythonPartitions; --- 10,13 ---- *************** *** 534,538 **** } ! String[] strings = FullRepIterable.split(code, toSplit); return strings[strings.length-1]; } --- 533,537 ---- } ! String[] strings = StringUtils.split(code, toSplit); return strings[strings.length-1]; } Index: StringUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/StringUtils.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** StringUtils.java 6 Jan 2008 13:32:16 -0000 1.13 --- StringUtils.java 18 May 2008 20:02:26 -0000 1.14 *************** *** 15,18 **** --- 15,25 ---- public class StringUtils { + /** + * Formats a string, replacing %s with the arguments passed. + * + * @param str string to be formatted + * @param args arguments passed + * @return a string with the %s replaced by the arguments passed + */ public static String format(String str, Object... args) { StringBuffer buffer = new StringBuffer(); *************** *** 39,42 **** --- 46,55 ---- } + /** + * Counts the number of %s in the string + * + * @param str the string to be analyzide + * @return the number of %s in the string + */ public static int countPercS(String str) { int j = 0; *************** *** 55,58 **** --- 68,74 ---- } + /** + * Removes whitespaces at the beggining of the string. + */ public static String rightTrim(String input) { int len = input.length(); *************** *** 67,70 **** --- 83,89 ---- } + /** + * Removes whitespaces at the end of the string. + */ public static String leftTrim(String input) { int len = input.length(); *************** *** 109,112 **** --- 128,134 ---- } + /** + * Removes the occurrences of the passed char in the beggining of the string. + */ public static String rightTrim(String input, char charToTrim) { int len = input.length(); *************** *** 121,124 **** --- 143,149 ---- } + /** + * Removes the occurrences of the passed char in the end of the string. + */ public static String leftTrim(String input, char charToTrim) { int len = input.length(); *************** *** 160,163 **** --- 185,194 ---- } + /** + * Splits the given string in a list where each element is a line. + * + * @param string string to be splitted. + * @return list of strings where each string is a line. + */ public static List<String> splitInLines(String string) { ArrayList<String> ret = new ArrayList<String>(); *************** *** 273,275 **** --- 304,349 ---- } + /** + * Splits some string given some char + */ + public static String[] split(String string, char toSplit) { + ArrayList<String> ret = new ArrayList<String>(); + int len = string.length(); + + int last = 0; + + char c = 0; + + for (int i = 0; i < len; i++) { + c = string.charAt(i); + if(c == toSplit){ + if(last != i){ + ret.add(string.substring(last, i)); + } + while(c == toSplit && i < len-1){ + i++; + c = string.charAt(i); + } + last = i; + } + } + if(c != toSplit){ + if(last == 0 && len > 0){ + ret.add(string); //it is equal to the original (no dots) + + }else if(last < len){ + ret.add(string.substring(last, len)); + + } + } + return ret.toArray(new String[ret.size()]); + } + + /** + * Splits the string as would string.split("\\."), but without yielding empty strings + */ + public static String[] dotSplit(String string) { + return split(string, '.'); + } + } Index: ImportsSelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ImportsSelection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportsSelection.java 25 Mar 2007 18:36:15 -0000 1.1 --- ImportsSelection.java 18 May 2008 20:02:26 -0000 1.2 *************** *** 25,30 **** // check if we have a from or an import. if (fromIndex != -1 || importIndex != -1) { ! trimmedLine = trimmedLine.replaceAll("#.*", ""); // remove ! // comments String[] strings = trimmedLine.split(" "); --- 25,29 ---- // check if we have a from or an import. if (fromIndex != -1 || importIndex != -1) { ! trimmedLine = trimmedLine.replaceAll("#.*", ""); // remove comments String[] strings = trimmedLine.split(" "); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:27
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28562/src/org/python/pydev/core Modified Files: ModulesKey.java ICodeCompletionASTManager.java FullRepIterable.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: FullRepIterable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/FullRepIterable.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** FullRepIterable.java 24 Feb 2007 12:39:51 -0000 1.19 --- FullRepIterable.java 18 May 2008 20:02:26 -0000 1.20 *************** *** 4,10 **** package org.python.pydev.core; - import java.util.ArrayList; import java.util.Iterator; /** * iterates through a string so that parts of it are gotten each time in a progressive way based on dots --- 4,11 ---- package org.python.pydev.core; import java.util.Iterator; + import org.python.pydev.core.docutils.StringUtils; + /** * iterates through a string so that parts of it are gotten each time in a progressive way based on dots *************** *** 231,235 **** */ public static boolean containsPart(String foundRep, String nameToFind) { ! String[] strings = dotSplit(foundRep); for (String string : strings) { if(string.equals(nameToFind)){ --- 232,236 ---- */ public static boolean containsPart(String foundRep, String nameToFind) { ! String[] strings = StringUtils.dotSplit(foundRep); for (String string : strings) { if(string.equals(nameToFind)){ *************** *** 239,285 **** return false; } - - /** - * Splits some string given some char - */ - public static String[] split(String string, char toSplit) { - ArrayList<String> ret = new ArrayList<String>(); - int len = string.length(); - - int last = 0; - - char c = 0; - - for (int i = 0; i < len; i++) { - c = string.charAt(i); - if(c == toSplit){ - if(last != i){ - ret.add(string.substring(last, i)); - } - while(c == toSplit && i < len-1){ - i++; - c = string.charAt(i); - } - last = i; - } - } - if(c != toSplit){ - if(last == 0 && len > 0){ - ret.add(string); //it is equal to the original (no dots) - - }else if(last < len){ - ret.add(string.substring(last, len)); - - } - } - return ret.toArray(new String[ret.size()]); - } - - /** - * Splits the string as would string.split("\\."), but without yielding empty strings - */ - public static String[] dotSplit(String string) { - return split(string, '.'); - } --- 240,243 ---- Index: ModulesKey.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ModulesKey.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModulesKey.java 5 Nov 2007 00:28:56 -0000 1.5 --- ModulesKey.java 18 May 2008 20:02:26 -0000 1.6 *************** *** 9,12 **** --- 9,14 ---- import java.io.Serializable; + import org.python.pydev.core.docutils.StringUtils; + /** * This class defines the key to use for some module. All its operations are based on its name. *************** *** 91,95 **** */ public boolean hasPartStartingWith(String startingWithLowerCase) { ! for (String mod : FullRepIterable.dotSplit(this.name.toLowerCase())) { if(mod.startsWith(startingWithLowerCase)){ return true; --- 93,97 ---- */ public boolean hasPartStartingWith(String startingWithLowerCase) { ! for (String mod : StringUtils.dotSplit(this.name.toLowerCase())) { if(mod.startsWith(startingWithLowerCase)){ return true; Index: ICodeCompletionASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/ICodeCompletionASTManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ICodeCompletionASTManager.java 20 Oct 2007 19:31:39 -0000 1.16 --- ICodeCompletionASTManager.java 18 May 2008 20:02:26 -0000 1.17 *************** *** 81,85 **** /** ! * Returns the imports that start with a given string. The comparisson is not case dependent. Passes all the modules in the cache. * * @param initial: this is the initial module (e.g.: foo.bar) or an empty string. --- 81,85 ---- /** ! * Returns the imports that start with a given string. The comparison is not case dependent. Passes all the modules in the cache. * * @param initial: this is the initial module (e.g.: foo.bar) or an empty string. |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:27
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28562/tests/org/python/pydev/core Modified Files: FullRepIterableTest.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: FullRepIterableTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/FullRepIterableTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FullRepIterableTest.java 7 Jun 2006 16:55:16 -0000 1.5 --- FullRepIterableTest.java 18 May 2008 20:02:26 -0000 1.6 *************** *** 6,9 **** --- 6,11 ---- import java.util.Iterator; + import org.python.pydev.core.docutils.StringUtils; + import junit.framework.TestCase; *************** *** 107,111 **** public void testDotSplit() throws Exception { ! String[] strings = FullRepIterable.dotSplit("foo.bar.f"); assertEquals(3, strings.length); assertEquals("foo", strings[0]); --- 109,113 ---- public void testDotSplit() throws Exception { ! String[] strings = StringUtils.dotSplit("foo.bar.f"); assertEquals(3, strings.length); assertEquals("foo", strings[0]); *************** *** 113,117 **** assertEquals("f", strings[2]); ! strings = FullRepIterable.dotSplit("foo.bar."); assertEquals(2, strings.length); assertEquals("foo", strings[0]); --- 115,119 ---- assertEquals("f", strings[2]); ! strings = StringUtils.dotSplit("foo.bar."); assertEquals(2, strings.length); assertEquals("foo", strings[0]); *************** *** 119,138 **** assertEquals(0, "...".split("\\.").length); ! strings = FullRepIterable.dotSplit("..."); assertEquals(0, strings.length); ! strings = FullRepIterable.dotSplit(""); assertEquals(0, strings.length); ! strings = FullRepIterable.dotSplit("foo"); assertEquals(1, strings.length); assertEquals("foo", strings[0]); ! strings = FullRepIterable.dotSplit("f.bu"); assertEquals(2, strings.length); assertEquals("f", strings[0]); assertEquals("bu", strings[1]); ! strings = FullRepIterable.dotSplit("..f.b...u.."); assertEquals(3, strings.length); assertEquals("f", strings[0]); --- 121,140 ---- assertEquals(0, "...".split("\\.").length); ! strings = StringUtils.dotSplit("..."); assertEquals(0, strings.length); ! strings = StringUtils.dotSplit(""); assertEquals(0, strings.length); ! strings = StringUtils.dotSplit("foo"); assertEquals(1, strings.length); assertEquals("foo", strings[0]); ! strings = StringUtils.dotSplit("f.bu"); assertEquals(2, strings.length); assertEquals("f", strings[0]); assertEquals("bu", strings[1]); ! strings = StringUtils.dotSplit("..f.b...u.."); assertEquals(3, strings.length); assertEquals("f", strings[0]); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:27
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28562/tests/org/python/pydev/core/docutils Added Files: ImportHandleTest.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils --- NEW FILE: ImportHandleTest.java --- package org.python.pydev.core.docutils; import java.util.ArrayList; import java.util.List; import org.python.pydev.core.docutils.ImportHandle.ImportHandleInfo; import junit.framework.TestCase; public class ImportHandleTest extends TestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void testImportHandleInfo2() throws Exception { ImportHandle importHandle = new ImportHandle(null, "import BBB", 0, 0); List<ImportHandleInfo> importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals(null, importInfo.get(0).getFromImportStr()); ArrayList<String> lst = new ArrayList<String>(); lst.add("BBB"); assertEquals(lst, importInfo.get(0).getImportedStr()); importHandle = new ImportHandle(null, "import BBB, CCC", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals(null, importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("CCC"); assertEquals(lst, importInfo.get(0).getImportedStr()); importHandle = new ImportHandle(null, "import BBB, CCC #Comment", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals(null, importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("CCC"); assertEquals(lst, importInfo.get(0).getImportedStr()); ArrayList<String> comments = new ArrayList<String>(); comments.add(""); comments.add("#Comment"); assertEquals(comments, importInfo.get(0).getCommentsForImports()); } public void testImportHandleInfo() throws Exception { ImportHandle importHandle = new ImportHandle(null, "from AAA import BBB", 0, 0); List<ImportHandleInfo> importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals("AAA", importInfo.get(0).getFromImportStr()); ArrayList<String> lst = new ArrayList<String>(); lst.add("BBB"); assertEquals(lst, importInfo.get(0).getImportedStr()); importHandle = new ImportHandle(null, "from AAA import BBB, CCC", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals("AAA", importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("CCC"); assertEquals(lst, importInfo.get(0).getImportedStr()); importHandle = new ImportHandle(null, "from AAA import BBB, DDD as CCC", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals("AAA", importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("CCC"); assertEquals(lst, importInfo.get(0).getImportedStr()); importHandle = new ImportHandle(null, "from AAA import BBB #, DDD as CCC", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals("AAA", importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); assertEquals(lst, importInfo.get(0).getImportedStr()); ArrayList<String> comments = new ArrayList<String>(); comments.add("#, DDD as CCC"); assertEquals(comments, importInfo.get(0).getCommentsForImports()); importHandle = new ImportHandle(null, "from AAA import (BBB, #, DDD as CCC\nKKK)", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals("AAA", importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("KKK"); comments = new ArrayList<String>(); comments.add("#, DDD as CCC"); comments.add(""); assertEquals(lst, importInfo.get(0).getImportedStr()); assertEquals(comments, importInfo.get(0).getCommentsForImports()); importHandle = new ImportHandle(null, "from .AAA import (BBB, #, DDD as CCC\nKKK)", 0, 0); importInfo = importHandle.getImportInfo(); assertEquals(1, importInfo.size()); assertEquals(".AAA", importInfo.get(0).getFromImportStr()); lst = new ArrayList<String>(); lst.add("BBB"); lst.add("KKK"); comments = new ArrayList<String>(); comments.add("#, DDD as CCC"); comments.add(""); assertEquals(lst, importInfo.get(0).getImportedStr()); assertEquals(comments, importInfo.get(0).getCommentsForImports()); } public void testImportMatches() throws Exception { ImportHandle importHandle = new ImportHandle(null, "from AAA import BBB", 0, 0); assertFalse(importHandle.contains("from X import BBB")); assertFalse(importHandle.contains("from XXX import BBB")); assertFalse(importHandle.contains("from AAA import CCC")); assertTrue(importHandle.contains("from AAA import BBB")); importHandle = new ImportHandle(null, "from AAA import BBB;from XXX import YYY", 0, 0); assertTrue(importHandle.contains("from XXX import YYY")); } } |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:24
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src/org/python/pydev/plugin Modified Files: PydevPrefsInitializer.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: PydevPrefsInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPrefsInitializer.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PydevPrefsInitializer.java 31 Oct 2007 00:54:45 -0000 1.19 --- PydevPrefsInitializer.java 18 May 2008 20:02:17 -0000 1.20 *************** *** 10,13 **** --- 10,14 ---- import org.python.pydev.parser.PyParserManager; import org.python.pydev.ui.filetypes.FileTypesPreferencesPage; + import org.python.pydev.ui.importsconf.ImportsPreferencesPage; import org.eclipse.core.runtime.preferences.DefaultScope; import org.eclipse.jface.resource.StringConverter; *************** *** 125,128 **** --- 126,134 ---- node.put(FileTypesPreferencesPage.FIRST_CHOICE_PYTHON_SOURCE_FILE, FileTypesPreferencesPage.DEFAULT_FIRST_CHOICE_PYTHON_SOURCE_FILE); + //imports + node.putBoolean(ImportsPreferencesPage.GROUP_IMPORTS, ImportsPreferencesPage.DEFAULT_GROUP_IMPORTS); + node.putBoolean(ImportsPreferencesPage.MULTILINE_IMPORTS, ImportsPreferencesPage.DEFAULT_MULTILINE_IMPORTS); + node.put(ImportsPreferencesPage.BREAK_IMPORTS_MODE, ImportsPreferencesPage.DEFAULT_BREAK_IMPORTS_MODE); + } |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src/org/python/pydev/outline Modified Files: ParsedItem.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: ParsedItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/ParsedItem.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ParsedItem.java 4 Feb 2008 23:39:05 -0000 1.22 --- ParsedItem.java 18 May 2008 20:02:17 -0000 1.23 *************** *** 10,14 **** import org.eclipse.swt.graphics.Image; - import org.python.pydev.core.FullRepIterable; import org.python.pydev.core.bundle.ImageCache; import org.python.pydev.core.docutils.StringUtils; --- 10,13 ---- *************** *** 331,336 **** commentType type = (commentType) astThis.node; String rep = type.id.trim(); ! rep = FullRepIterable.split(rep, '\n')[0]; ! rep = FullRepIterable.split(rep, '\r')[0]; rep = rep.substring(1); rep = StringUtils.rightTrim(rep, '-'); --- 330,335 ---- commentType type = (commentType) astThis.node; String rep = type.id.trim(); ! rep = StringUtils.split(rep, '\n')[0]; ! rep = StringUtils.split(rep, '\r')[0]; rep = rep.substring(1); rep = StringUtils.rightTrim(rep, '-'); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_completions/org/python/pydev/editor/codecompletion/revisited/modules Modified Files: SourceModule.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: SourceModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules/SourceModule.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SourceModule.java 5 May 2008 01:31:22 -0000 1.18 --- SourceModule.java 18 May 2008 20:02:16 -0000 1.19 *************** *** 31,34 **** --- 31,35 ---- import org.python.pydev.core.cache.Cache; import org.python.pydev.core.cache.LRUCache; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.structure.CompletionRecursionException; import org.python.pydev.core.structure.FastStack; *************** *** 346,350 **** String activationToken = initialState.getActivationToken(); int activationTokenLen = activationToken.length(); ! String[] actToks = FullRepIterable.dotSplit(activationToken); String goFor = null; --- 347,351 ---- String activationToken = initialState.getActivationToken(); int activationTokenLen = activationToken.length(); ! String[] actToks = StringUtils.dotSplit(activationToken); String goFor = null; |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475 Modified Files: plugin.xml Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.204 retrieving revision 1.205 diff -C2 -d -r1.204 -r1.205 *** plugin.xml 4 Feb 2008 02:01:35 -0000 1.204 --- plugin.xml 18 May 2008 20:02:16 -0000 1.205 *************** *** 229,232 **** --- 229,238 ---- <page + name="Imports" + category="org.python.pydev.plugin.pyCodeStylePreferencesPage" + class="org.python.pydev.ui.importsconf.ImportsPreferencesPage" + id="org.python.pydev.ui.importsconf.ImportsPreferencesPage"/> + + <page name="Code Completion" class="org.python.pydev.editor.codecompletion.PyCodeCompletionPreferencesPage" |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/filetypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src/org/python/pydev/ui/filetypes Modified Files: FileTypesPreferencesPage.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: FileTypesPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/filetypes/FileTypesPreferencesPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FileTypesPreferencesPage.java 5 May 2008 01:31:22 -0000 1.2 --- FileTypesPreferencesPage.java 18 May 2008 20:02:17 -0000 1.3 *************** *** 8,12 **** import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; ! import org.python.pydev.core.FullRepIterable; import org.python.pydev.core.docutils.WordUtils; import org.python.pydev.plugin.PydevPlugin; --- 8,12 ---- import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; ! import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.docutils.WordUtils; import org.python.pydev.plugin.PydevPlugin; *************** *** 138,142 **** if(ret == null){ String validStr = PydevPrefs.getPreferences().getString(FileTypesPreferencesPage.VALID_SOURCE_FILES); ! String[] s = FullRepIterable.split(validStr, ','); for(int i=0;i<s.length;i++){ s[i] = s[i].trim(); --- 138,142 ---- if(ret == null){ String validStr = PydevPrefs.getPreferences().getString(FileTypesPreferencesPage.VALID_SOURCE_FILES); ! String[] s = StringUtils.split(validStr, ','); for(int i=0;i<s.length;i++){ s[i] = s[i].trim(); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/tests_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration Modified Files: AbstractJavaIntegrationTestWorkbench.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: AbstractJavaIntegrationTestWorkbench.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration/AbstractJavaIntegrationTestWorkbench.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractJavaIntegrationTestWorkbench.java 11 Jan 2008 01:01:18 -0000 1.2 --- AbstractJavaIntegrationTestWorkbench.java 18 May 2008 20:02:16 -0000 1.3 *************** *** 31,35 **** import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; - import org.python.pydev.core.FullRepIterable; import org.python.pydev.core.ICallback; import org.python.pydev.core.IInterpreterManager; --- 31,34 ---- *************** *** 37,40 **** --- 36,40 ---- import org.python.pydev.core.TestDependent; import org.python.pydev.core.Tuple; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codecompletion.revisited.ProjectModulesManager; *************** *** 164,168 **** } IContainer parent = sourceFolder; ! String[] packageParts = FullRepIterable.dotSplit(packageName); for (String packagePart : packageParts) { IFolder folder = parent.getFolder(new Path(packagePart)); --- 164,168 ---- } IContainer parent = sourceFolder; ! String[] packageParts = StringUtils.dotSplit(packageName); for (String packagePart : packageParts) { IFolder folder = parent.getFolder(new Path(packagePart)); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/filters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_navigator/org/python/pydev/navigator/filters Modified Files: CustomFilters.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: CustomFilters.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/filters/CustomFilters.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CustomFilters.java 7 Dec 2007 00:49:20 -0000 1.1 --- CustomFilters.java 18 May 2008 20:02:17 -0000 1.2 *************** *** 10,14 **** import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; ! import org.python.pydev.core.FullRepIterable; import org.python.pydev.navigator.actions.PySetupCustomFilters; import org.python.pydev.navigator.properties.StringMatcherSimple; --- 10,14 ---- import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter; ! import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.navigator.actions.PySetupCustomFilters; import org.python.pydev.navigator.properties.StringMatcherSimple; *************** *** 94,98 **** public void update(String customFilters) { ! String[] splittedCustomFilters = FullRepIterable.split(customFilters, ','); StringMatcherSimple[] temp = new StringMatcherSimple[splittedCustomFilters.length]; for (int i = 0; i < temp.length; i++) { --- 94,98 ---- public void update(String customFilters) { ! String[] splittedCustomFilters = StringUtils.split(customFilters, ','); StringMatcherSimple[] temp = new StringMatcherSimple[splittedCustomFilters.length]; for (int i = 0; i < temp.length; i++) { |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/importsconf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src/org/python/pydev/ui/importsconf Added Files: ImportsPreferencesPage.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils --- NEW FILE: ImportsPreferencesPage.java --- package org.python.pydev.ui.importsconf; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.core.docutils.WordUtils; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.utils.LabelFieldEditor; /** * Preferences regarding the way that imports should be managed: * * - Grouped when possible? * - Can use multilines? * - Multilines with escape char or with '(' * * @author Fabio */ public class ImportsPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public ImportsPreferencesPage() { super(FLAT); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); setDescription("Imports Preferences"); } public static final String GROUP_IMPORTS = "GROUP_IMPORTS"; public final static boolean DEFAULT_GROUP_IMPORTS = true; public static final String MULTILINE_IMPORTS = "MULTILINE_IMPORTS"; public final static boolean DEFAULT_MULTILINE_IMPORTS = true; public static final String BREAK_IMPORTS_MODE = "BREAK_IMPORTS_MODE"; public static final String BREAK_IMPORTS_MODE_ESCAPE = "ESCAPE"; public static final String BREAK_IMPORTS_MODE_PARENTHESIS = "PARENTHESIS"; public final static String DEFAULT_BREAK_IMPORTS_MODE = BREAK_IMPORTS_MODE_ESCAPE; @Override protected void createFieldEditors() { final Composite p = getFieldEditorParent(); addField(new LabelFieldEditor("Label_Info_File_Preferences1", WordUtils.wrap( "These setting are used whenever imports are managed in the application\n\n", 80), p)); addField(new BooleanFieldEditor(GROUP_IMPORTS, "Group 'from' imports when possible?", p)); addField(new BooleanFieldEditor(MULTILINE_IMPORTS, WordUtils.wrap( "Allow multiline imports when the import size would exceed the print margin?", 80), p)); addField(new RadioGroupFieldEditor(BREAK_IMPORTS_MODE, "How to break imports in multiline?", 1, new String[][] { { "Use escape char", BREAK_IMPORTS_MODE_ESCAPE }, { "Use parenthesis", BREAK_IMPORTS_MODE_PARENTHESIS } }, p)); } public void init(IWorkbench workbench) { // pass } } |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration Modified Files: JavaProjectModulesManager.java AbstractJavaClassModule.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: AbstractJavaClassModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration/AbstractJavaClassModule.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractJavaClassModule.java 14 Mar 2008 00:59:04 -0000 1.5 --- AbstractJavaClassModule.java 18 May 2008 20:02:16 -0000 1.6 *************** *** 23,26 **** --- 23,27 ---- import org.python.pydev.core.IToken; import org.python.pydev.core.Tuple; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.editor.actions.PyAction; import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; *************** *** 262,266 **** //to check if we're able to find modules with that name. If a module with that name is found, that means that //we actually have a java class. ! String[] splitted = FullRepIterable.dotSplit(state.getActivationToken()); StringBuffer modNameBuf = new StringBuffer(this.getName()); IModule validModule = null; --- 263,267 ---- //to check if we're able to find modules with that name. If a module with that name is found, that means that //we actually have a java class. ! String[] splitted = StringUtils.dotSplit(state.getActivationToken()); StringBuffer modNameBuf = new StringBuffer(this.getName()); IModule validModule = null; Index: JavaProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/javaintegration/JavaProjectModulesManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** JavaProjectModulesManager.java 5 May 2008 01:31:22 -0000 1.10 --- JavaProjectModulesManager.java 18 May 2008 20:02:16 -0000 1.11 *************** *** 30,33 **** --- 30,34 ---- import org.python.pydev.core.ModulesKey; import org.python.pydev.core.Tuple; + import org.python.pydev.core.docutils.StringUtils; /** *************** *** 124,128 **** public boolean accept(String elementName, IPackageFragmentRoot packageRoot, IJavaElement javaElement) { ! for (String mod : FullRepIterable.dotSplit(elementName)) { if(mod.toLowerCase().startsWith(partStartingWithLowerCase)){ ret.add(elementName); --- 125,129 ---- public boolean accept(String elementName, IPackageFragmentRoot packageRoot, IJavaElement javaElement) { ! for (String mod : StringUtils.dotSplit(elementName)) { if(mod.toLowerCase().startsWith(partStartingWithLowerCase)){ ret.add(elementName); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: AbstractASTManager.java PythonPathHelper.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: AbstractASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/AbstractASTManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractASTManager.java 5 May 2008 01:31:21 -0000 1.15 --- AbstractASTManager.java 18 May 2008 20:02:16 -0000 1.16 *************** *** 30,33 **** --- 30,34 ---- import org.python.pydev.core.Tuple3; import org.python.pydev.core.TupleN; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.log.Log; import org.python.pydev.core.structure.CompletionRecursionException; *************** *** 131,135 **** if(level > 0){ //ok, it is the import added on python 2.5 (from .. import xxx) ! String[] moduleParts = FullRepIterable.dotSplit(moduleName); if(moduleParts.length > level){ relative = FullRepIterable.joinParts(moduleParts, moduleParts.length-level); --- 132,136 ---- if(level > 0){ //ok, it is the import added on python 2.5 (from .. import xxx) ! String[] moduleParts = StringUtils.dotSplit(moduleName); if(moduleParts.length > level){ relative = FullRepIterable.joinParts(moduleParts, moduleParts.length-level); *************** *** 235,239 **** if (element.length() > 0 && goForIt) { ! String[] splitted = FullRepIterable.dotSplit(element); if (splitted.length > 0) { //this is the completion --- 236,240 ---- if (element.length() > 0 && goForIt) { ! String[] splitted = StringUtils.dotSplit(element); if (splitted.length > 0) { //this is the completion *************** *** 1052,1056 **** String parentPackage = token.getParentPackage(); ! String[] moduleParts = FullRepIterable.dotSplit(parentPackage); String relative = null; if(moduleParts.length > level){ --- 1053,1057 ---- String parentPackage = token.getParentPackage(); ! String[] moduleParts = StringUtils.dotSplit(parentPackage); String relative = null; if(moduleParts.length > level){ Index: PythonPathHelper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/PythonPathHelper.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PythonPathHelper.java 13 Apr 2008 16:55:23 -0000 1.9 --- PythonPathHelper.java 18 May 2008 20:02:16 -0000 1.10 *************** *** 269,273 **** //this means that more than 1 module is specified, so, in order to get it, //we have to go and see if all the folders to that module have __init__.py in it... ! String[] modulesParts = FullRepIterable.dotSplit(s); if (modulesParts.length > 1 && isFile) { --- 269,273 ---- //this means that more than 1 module is specified, so, in order to get it, //we have to go and see if all the folders to that module have __init__.py in it... ! String[] modulesParts = StringUtils.dotSplit(s); if (modulesParts.length > 1 && isFile) { |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors Modified Files: HeuristicFindAttrs.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: HeuristicFindAttrs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/HeuristicFindAttrs.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HeuristicFindAttrs.java 8 Jul 2007 21:14:54 -0000 1.2 --- HeuristicFindAttrs.java 18 May 2008 20:02:16 -0000 1.3 *************** *** 8,13 **** import java.util.Stack; - import org.python.pydev.core.FullRepIterable; import org.python.pydev.core.ICompletionState; import org.python.pydev.parser.jython.SimpleNode; import org.python.pydev.parser.jython.ast.Assign; --- 8,13 ---- import java.util.Stack; import org.python.pydev.core.ICompletionState; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.parser.jython.SimpleNode; import org.python.pydev.parser.jython.ast.Assign; *************** *** 103,107 **** if(entryPointCorrect == false && methodCall.length() > 0){ entryPointCorrect = true; ! String[] c = FullRepIterable.dotSplit(methodCall); --- 103,107 ---- if(entryPointCorrect == false && methodCall.length() > 0){ entryPointCorrect = true; ! String[] c = StringUtils.dotSplit(methodCall); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyCompletionProposal.java Log Message: Created structure to help dealing with imports in files, even if the file does not have a correct AST Refactor: Moved methods from FullRepIterable to StringUtils Index: PyCompletionProposal.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCompletionProposal.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyCompletionProposal.java 3 Apr 2008 17:48:19 -0000 1.4 --- PyCompletionProposal.java 18 May 2008 20:02:17 -0000 1.5 *************** *** 224,228 **** /** ! * @param curr * @return the behavior when faced with a given proposal (that has the same internal representation) */ --- 224,228 ---- /** ! * @param curr another completion that has the same internal representation. * @return the behavior when faced with a given proposal (that has the same internal representation) */ |