pydev-cvs Mailing List for PyDev for Eclipse (Page 18)
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-18 20:02:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/wizards/files In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475/src/org/python/pydev/ui/wizards/files Modified Files: PythonPackageWizard.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: PythonPackageWizard.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/wizards/files/PythonPackageWizard.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PythonPackageWizard.java 22 Oct 2007 00:28:51 -0000 1.6 --- PythonPackageWizard.java 18 May 2008 20:02:16 -0000 1.7 *************** *** 12,16 **** import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; ! import org.python.pydev.core.FullRepIterable; import org.python.pydev.ui.filetypes.FileTypesPreferencesPage; --- 12,16 ---- import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; ! import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.ui.filetypes.FileTypesPreferencesPage; *************** *** 49,53 **** IContainer parent = validatedSourceFolder; String validatedName = filePage.getValidatedName(); ! String[] packageParts = FullRepIterable.dotSplit(validatedName); for (String packagePart : packageParts) { IFolder folder = parent.getFolder(new Path(packagePart)); --- 49,53 ---- IContainer parent = validatedSourceFolder; String validatedName = filePage.getValidatedName(); ! String[] packageParts = StringUtils.dotSplit(validatedName); for (String packagePart : packageParts) { IFolder folder = parent.getFolder(new Path(packagePart)); |
From: Fabio Z. <fa...@us...> - 2008-05-18 20:02:04
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/importsconf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28114/src/org/python/pydev/ui/importsconf Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/importsconf added to the repository |
From: Fabio Z. <fa...@us...> - 2008-05-17 14:26:50
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17511/src/org/python/pydev/core/docutils Modified Files: PyDocIterator.java Added Files: PyImportsIterator.java ImportHandle.java PyImportsHandling.java Log Message: Created better utilities to handle imports. --- NEW FILE: PyImportsIterator.java --- package org.python.pydev.core.docutils; import java.util.Iterator; import org.eclipse.jface.text.IDocument; /** * Iterator through imports that yields tuples with the import itself, the initial line of the import * and the final line of the import. * * @author Fabio */ public class PyImportsIterator implements Iterator<ImportHandle> { /** * Helper to iterate in the document */ private PyDocIterator docIterator; /** * Variable holding whether hasNext should return true or not */ private boolean hasNext = true; /** * Variable holding the next return value */ private ImportHandle nextImport; /** * Delimiter to be used to add new lines in the imports found. */ private String delimiter; /** * Document used in the iteration */ private IDocument doc; /** * Constructor * * @param doc the document from where the import should be gathered. */ public PyImportsIterator(IDocument doc) { this.doc = doc; delimiter = PySelection.getDelimiter(doc); this.docIterator = new PyDocIterator(doc, false, false, false, true); //gather the 1st import calcNext(); } /** * Pre-calculates the next return value and whether there is a next value to be returned. */ private void calcNext(){ if(!hasNext){ //only pre-calculate if there's something to pre-calculate. return; } String importFound = null; int startFoundLine=-1; int endFoundLine=-1; while(docIterator.hasNext()){ String str = docIterator.next(); if((str.startsWith("import ") || str.startsWith("from "))){ startFoundLine = docIterator.getLastReturnedLine(); if(str.indexOf('(') != -1){ //we have something like from os import (pipe,\nfoo) while(docIterator.hasNext() && str.indexOf(')') == -1){ str += delimiter+docIterator.next(); } } if(WordUtils.endsWith(str, '\\')){ while(docIterator.hasNext() && WordUtils.endsWith(str, '\\')){ str += delimiter+docIterator.next(); } } importFound = str; endFoundLine = docIterator.getLastReturnedLine(); break; //ok, import found } } hasNext = importFound != null; if(hasNext){ nextImport = new ImportHandle(doc, importFound, startFoundLine, endFoundLine); }else{ nextImport = null; } } /** * From the iterator interface */ public boolean hasNext() { return this.hasNext; } /** * From the iterator interface */ public ImportHandle next() { ImportHandle ret = this.nextImport; calcNext(); //pre-compute the next step return ret; } /** * From the iterator interface (not implemented) */ public void remove() { throw new RuntimeException("Not implemented"); } } --- NEW FILE: ImportHandle.java --- package org.python.pydev.core.docutils; import org.eclipse.jface.text.IDocument; /** * Class that represents an import found in a document. * * @author Fabio */ public class ImportHandle { /** * Document where the import was found */ public IDocument doc; /** * The import string found. Note: it may contain comments and multi-lines. */ public String importFound; /** * The initial line where the import was found */ public int startFoundLine; /** * The final line where the import was found */ public int endFoundLine; /** * Constructor. * * Assigns parameters to fields. */ public ImportHandle(IDocument doc, String importFound, int startFoundLine, int endFoundLine) { this.doc = doc; this.importFound = importFound; this.startFoundLine = startFoundLine; this.endFoundLine = endFoundLine; } } --- NEW FILE: PyImportsHandling.java --- package org.python.pydev.core.docutils; import java.util.Iterator; import org.eclipse.jface.text.IDocument; /** * This class is responsible for gathering information about imports and has utilities to help using them later on. * * @author Fabio */ public class PyImportsHandling implements Iterable<ImportHandle>{ private IDocument doc; public PyImportsHandling(IDocument doc) { this.doc = doc; } /** * @return an iterator that will yield the imports available */ public Iterator<ImportHandle> iterator() { return new PyImportsIterator(this.doc); } } Index: PyDocIterator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PyDocIterator.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyDocIterator.java 23 Feb 2008 18:58:22 -0000 1.7 --- PyDocIterator.java 17 May 2008 14:26:57 -0000 1.8 *************** *** 32,35 **** --- 32,36 ---- * @param returnNewLinesOnLiterals whether we should return the new lines found in the literals (not the char, but the line itself) * @param changeLiteralsForSpaces whether we should replace the literals with spaces (so that we don't loose offset information) + * @param addComments if true, comments found will be yielded (otherwise, no comments will be shown) */ public PyDocIterator(IDocument doc, boolean addNewLinesToRet, boolean returnNewLinesOnLiterals, boolean changeLiteralsForSpaces, boolean addComments) { |
From: Fabio Z. <fa...@us...> - 2008-05-17 14:26:50
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17511/tests/org/python/pydev/core/docutils Added Files: PyImportsHandlingTest.java Log Message: Created better utilities to handle imports. --- NEW FILE: PyImportsHandlingTest.java --- package org.python.pydev.core.docutils; import java.util.Iterator; import org.eclipse.jface.text.Document; import org.python.pydev.core.Tuple3; import junit.framework.TestCase; public class PyImportsHandlingTest extends TestCase { public static void main(String[] args) { try { PyImportsHandlingTest test = new PyImportsHandlingTest(); test.setUp(); test.testPyImportHandling2(); test.tearDown(); junit.textui.TestRunner.run(PyImportsHandlingTest.class); } catch (Throwable e) { e.printStackTrace(); } } protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public void testPyImportHandling() throws Exception { Document doc = new Document("from xxx import yyy"); PyImportsHandling importsHandling = new PyImportsHandling(doc); Iterator<ImportHandle> it = importsHandling.iterator(); assertTrue(it.hasNext()); ImportHandle next = it.next(); assertEquals("from xxx import yyy", next.importFound); assertEquals(0, next.startFoundLine); assertEquals(0, next.endFoundLine); assertFalse(it.hasNext()); } public void testPyImportHandling2() throws Exception { Document doc = new Document("from xxx import yyy\nfrom y import (a, \nb,\nc)"); PyImportsHandling importsHandling = new PyImportsHandling(doc); Iterator<ImportHandle> it = importsHandling.iterator(); assertTrue(it.hasNext()); ImportHandle next = it.next(); assertEquals("from xxx import yyy", next.importFound); assertEquals(0, next.startFoundLine); assertEquals(0, next.endFoundLine); assertTrue(it.hasNext()); next = it.next(); assertEquals("from y import (a, \nb,\nc)", next.importFound); assertEquals(1, next.startFoundLine); assertEquals(3, next.endFoundLine); } } |
From: Fabio Z. <fa...@us...> - 2008-05-17 14:26:47
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17496 Modified Files: TODO.txt Log Message: Created better utilities to handle imports. Index: TODO.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/TODO.txt,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** TODO.txt 12 May 2008 11:34:00 -0000 1.68 --- TODO.txt 17 May 2008 14:26:52 -0000 1.69 *************** *** 1,2 **** --- 1,8 ---- + - Context insensitive completions: + - Don't bring imports for completions already in the document + - Make new imports from the same module use the same from xxx import yyy (when xxx is the same) + - Organize imports should pass all the not defined vars and show the imports available for them + - Organize imports should merge imports with the same 'xxx' in from xxx import yyy, bbb, etc + - Change all calls to Runtime.exec(String) to Runtime.exec(String[]) |
From: Fabio Z. <fa...@us...> - 2008-05-17 14:26:46
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17496/src/org/python/pydev/editor/actions Modified Files: PyOrganizeImports.java Log Message: Created better utilities to handle imports. Index: PyOrganizeImports.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOrganizeImports.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyOrganizeImports.java 4 Aug 2007 16:01:11 -0000 1.12 --- PyOrganizeImports.java 17 May 2008 14:26:52 -0000 1.13 *************** *** 19,25 **** import org.eclipse.jface.text.IDocumentExtension4; import org.python.pydev.core.ExtensionHelper; ! import org.python.pydev.core.docutils.PyDocIterator; import org.python.pydev.core.docutils.PySelection; - import org.python.pydev.core.docutils.WordUtils; import org.python.pydev.editor.PyEdit; import org.python.pydev.plugin.PydevPlugin; --- 19,25 ---- import org.eclipse.jface.text.IDocumentExtension4; import org.python.pydev.core.ExtensionHelper; ! import org.python.pydev.core.docutils.ImportHandle; ! import org.python.pydev.core.docutils.PyImportsHandling; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.editor.PyEdit; import org.python.pydev.plugin.PydevPlugin; *************** *** 95,125 **** ArrayList list = new ArrayList(); int firstImport = -1; ! PyDocIterator it = new PyDocIterator(doc, false, false, false, true); ! while(it.hasNext()){ ! String str = it.next(); ! ! if((str.startsWith("import ") || str.startsWith("from "))){ ! int iToAdd = it.getLastReturnedLine(); ! if(str.indexOf('(') != -1){ //we have something like from os import (pipe,\nfoo) ! while(it.hasNext() && str.indexOf(')') == -1){ ! String str1 = it.next(); ! str += endLineDelim+str1; ! } ! } ! if(WordUtils.endsWith(str, '\\')){ ! while(it.hasNext() && WordUtils.endsWith(str, '\\')){ ! //we have to get all until there are no more back-slashes ! String str1 = it.next(); ! str += endLineDelim+str1; ! } ! } ! list.add( new Object[]{iToAdd, str} ); ! ! if(firstImport == -1){ ! firstImport = iToAdd; ! } ! } ! } //check if we had any import --- 95,109 ---- ArrayList list = new ArrayList(); + //Gather imports in a structure we can work on. + PyImportsHandling pyImportsHandling = new PyImportsHandling(doc); int firstImport = -1; ! for(ImportHandle imp:pyImportsHandling){ ! list.add( new Object[]{imp.startFoundLine, imp.importFound} ); ! ! if(firstImport == -1){ ! firstImport = imp.startFoundLine; ! } ! } ! //check if we had any import |
From: Fabio Z. <fa...@us...> - 2008-05-12 15:36:34
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31046 Modified Files: Changes.txt Log Message: Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.391 retrieving revision 1.392 diff -C2 -d -r1.391 -r1.392 *** Changes.txt 12 May 2008 11:47:03 -0000 1.391 --- Changes.txt 12 May 2008 15:36:35 -0000 1.392 *************** *** 2,15 **** Pydev ! <li><strong>Pydev Package Explorer</strong>: projects that had the project folder in the pythonpath did not show children.</li> <li><strong>Debugger</strong>: Disable all works. Patch from: Oldrich Jedlicka</li> ! <li><strong>Debugger</strong>: Problem when making a step return</li> <li><strong>Code-completion</strong>: Working for attributes found in a superclass imported with a relative import</li> Patches from Felix Schwarz: ! [Patch] Add missing variables to TestDependent templates ! [PATCH] Allow to configure an interpreter even if the workspace path name contains spaces ! [PATCH] completion server does not work when the eclipse directory contains spaces ! [PATCH] Fix deletion of resources in PyDev package explorer after 1.3.15 --- 2,17 ---- Pydev ! <li><strong>Pydev Package Explorer</strong>: projects that had the project folder in the pythonpath did not show children items correctly.</li> <li><strong>Debugger</strong>: Disable all works. Patch from: Oldrich Jedlicka</li> ! <li><strong>Debugger</strong>: Problem when making a step return / step over</li> <li><strong>Code-completion</strong>: Working for attributes found in a superclass imported with a relative import</li> + <ul> Patches from Felix Schwarz: ! <li>Allow to configure an interpreter even if the workspace path name contains spaces</li> ! <li>Completion server does not work when the eclipse directory contains spaces</li> ! <li>Fix deletion of resources in pydev package explorer in Eclipse 3.4</li> ! </ul> ! after 1.3.15 |
From: Fabio Z. <fa...@us...> - 2008-05-12 15:36:26
|
Update of /cvsroot/pydev/org.python.pydev.site In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31030 Modified Files: site.xml Log Message: Index: site.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.site/site.xml,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** site.xml 7 May 2008 13:57:47 -0000 1.72 --- site.xml 12 May 2008 15:36:31 -0000 1.73 *************** *** 21,24 **** --- 21,30 ---- + <feature url="features/org.python.pydev.feature_1.3.17.jar" id="org.python.pydev.feature" version="1.3.17"> + <category name="Pydev"/> + </feature> + + + <feature url="features/org.python.pydev.feature_1.3.16.jar" id="org.python.pydev.feature" version="1.3.16"> <category name="Pydev"/> |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:46:59
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5195 Modified Files: Changes.txt Log Message: Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.390 retrieving revision 1.391 diff -C2 -d -r1.390 -r1.391 *** Changes.txt 10 May 2008 00:45:30 -0000 1.390 --- Changes.txt 12 May 2008 11:47:03 -0000 1.391 *************** *** 6,9 **** --- 6,15 ---- <li><strong>Debugger</strong>: Problem when making a step return</li> <li><strong>Code-completion</strong>: Working for attributes found in a superclass imported with a relative import</li> + Patches from Felix Schwarz: + + [Patch] Add missing variables to TestDependent templates + [PATCH] Allow to configure an interpreter even if the workspace path name contains spaces + [PATCH] completion server does not work when the eclipse directory contains spaces + [PATCH] Fix deletion of resources in PyDev package explorer after 1.3.15 |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:42:55
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3690/src_navigator/org/python/pydev/navigator/actions Modified Files: PyDeleteResourceAction.java Log Message: [PATCH] Fix deletion of resources in PyDev package explorer Index: PyDeleteResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyDeleteResourceAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyDeleteResourceAction.java 24 Mar 2007 11:48:29 -0000 1.2 --- PyDeleteResourceAction.java 12 May 2008 11:43:00 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; + import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.DeleteResourceAction; *************** *** 70,73 **** --- 71,85 ---- } + + @Override + public IStructuredSelection getStructuredSelection() { + ISelection selection = provider.getSelection(); + if (!selection.isEmpty()) { + IStructuredSelection sSelection = (IStructuredSelection) selection; + return sSelection; + } + return new StructuredSelection(); + } + @Override protected List getSelectedResources() { |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:39:06
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2535/src/org/python/pydev/runners Modified Files: SimpleRunner.java SimplePythonRunner.java Log Message: [PATCH] completion server does not work when the eclipse directory contains spaces Index: SimpleRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners/SimpleRunner.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SimpleRunner.java 12 May 2008 11:34:00 -0000 1.23 --- SimpleRunner.java 12 May 2008 11:39:06 -0000 1.24 *************** *** 40,43 **** --- 40,47 ---- } + public Process createProcess(String[] parameters, File workingDir) throws IOException { + return Runtime.getRuntime().exec(parameters, null, workingDir); + } + /** * THIS CODE IS COPIED FROM org.eclipse.debug.internal.core.LaunchManager *************** *** 297,300 **** --- 301,308 ---- } + public Tuple<String,String> runAndGetOutput(String[] arguments, File workingDir, IProject project) { + return runAndGetOutput(arguments, workingDir, project, new NullProgressMonitor()); + } + /** * shortcut Index: SimplePythonRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners/SimplePythonRunner.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SimplePythonRunner.java 12 May 2008 11:34:00 -0000 1.10 --- SimplePythonRunner.java 12 May 2008 11:39:06 -0000 1.11 *************** *** 42,47 **** */ public Tuple<String,String> runAndGetOutput(String script, String[] args, File workingDir, IProject project) { ! String executionString = makeExecutableCommandStr(script, args); ! return runAndGetOutput(executionString, workingDir, project); } --- 42,47 ---- */ public Tuple<String,String> runAndGetOutput(String script, String[] args, File workingDir, IProject project) { ! String[] parameters = addInterpreterToArgs(script, args); ! return runAndGetOutput(parameters, workingDir, project); } *************** *** 52,60 **** */ public static String makeExecutableCommandStr(String script, String[] args) { ! String interpreter = PydevPlugin.getPythonInterpreterManager().getDefaultInterpreter(); ! String[] s = preparePythonCallParameters(interpreter, script, args); return getCommandLineAsString(s, args); } /** * Execute the string and format for windows if we have spaces... --- 52,64 ---- */ public static String makeExecutableCommandStr(String script, String[] args) { ! String[] s = addInterpreterToArgs(script, args); return getCommandLineAsString(s, args); } + private static String[] addInterpreterToArgs(String script, String[] args) { + String interpreter = PydevPlugin.getPythonInterpreterManager().getDefaultInterpreter(); + return preparePythonCallParameters(interpreter, script, args); + } + /** * Execute the string and format for windows if we have spaces... |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:39:06
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/shell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2535/src_completions/org/python/pydev/editor/codecompletion/shell Modified Files: PythonShell.java Log Message: [PATCH] completion server does not work when the eclipse directory contains spaces Index: PythonShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/shell/PythonShell.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonShell.java 16 Sep 2007 21:16:59 -0000 1.2 --- PythonShell.java 12 May 2008 11:39:06 -0000 1.3 *************** *** 49,53 **** execMsg = interpreter+" "+REF.getFileAbsolutePath(serverFile)+" "+pWrite+" "+pRead; } ! process = new SimplePythonRunner().createProcess(execMsg, serverFile.getParentFile()); return execMsg; --- 49,54 ---- execMsg = interpreter+" "+REF.getFileAbsolutePath(serverFile)+" "+pWrite+" "+pRead; } ! String[] parameters = {interpreter, REF.getFileAbsolutePath(serverFile), ""+pWrite, ""+pRead}; ! process = new SimplePythonRunner().createProcess(parameters, serverFile.getParentFile()); return execMsg; |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:33:56
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv318 Modified Files: TODO.txt Log Message: Patch from Felix Schwarz [PATCH] Allow to configure an interpreter even if the workspace path name contains spaces Index: TODO.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/TODO.txt,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** TODO.txt 3 May 2008 14:07:38 -0000 1.67 --- TODO.txt 12 May 2008 11:34:00 -0000 1.68 *************** *** 1,2 **** --- 1,4 ---- + - Change all calls to Runtime.exec(String) to Runtime.exec(String[]) + - hierarchy view: show with f4 / close / open view / f4 (will not work) |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:33:55
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv318/src/org/python/pydev/runners Modified Files: SimpleRunner.java SimplePythonRunner.java Log Message: Patch from Felix Schwarz [PATCH] Allow to configure an interpreter even if the workspace path name contains spaces Index: SimpleRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners/SimpleRunner.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SimpleRunner.java 13 Apr 2008 16:55:23 -0000 1.22 --- SimpleRunner.java 12 May 2008 11:34:00 -0000 1.23 *************** *** 304,320 **** } ! /** ! * This is the method that actually does the running (all others are just 'shortcuts' to this one). ! * ! * @param executionString this is the string that will be executed ! * @param workingDir this is the directory where the execution will happen ! * @param project this is the project that is related to the run (it is used to get the environment for the shell we are going to ! * execute with the correct pythonpath environment variable). ! * @param monitor this is the monitor used to communicate the progress to the user ! * ! * @return the string that is the output of the process (stdout) and the stderr (o2) ! */ ! public Tuple<String,String> runAndGetOutput(String executionString, File workingDir, IProject project, IProgressMonitor monitor) { ! monitor.setTaskName("Executing: "+executionString); monitor.worked(5); Process process = null; --- 304,311 ---- } ! ! public Tuple<String, String> runAndGetOutput(String[] arguments, File workingDir, IProject project, IProgressMonitor monitor) { ! String executionString = getCommandLineAsString(arguments); ! monitor.setTaskName("Executing: "+executionString); monitor.worked(5); Process process = null; *************** *** 328,337 **** } } ! process = Runtime.getRuntime().exec(executionString, envp, workingDir); } catch (Exception e) { throw new RuntimeException(e); } ! if (process != null) { try { --- 319,339 ---- } } ! process = Runtime.getRuntime().exec(arguments, envp, workingDir); } catch (Exception e) { throw new RuntimeException(e); } ! return getProcessOutput(process, executionString, monitor); ! } ! ! /** ! * @param process process from where the output should be gotten ! * @param executionString string to execute (only for errors) ! * @param monitor monitor for giving progress ! * @return a tuple with the output of stdout and stderr ! */ ! private Tuple<String, String> getProcessOutput(Process process, ! String executionString, IProgressMonitor monitor) { ! if (process != null) { try { *************** *** 377,380 **** --- 379,416 ---- } return new Tuple<String, String>("","Error creating process - got null process("+ executionString + ")"); //no output + } + + + /** + * This is the method that actually does the running (all others are just 'shortcuts' to this one). + * + * @param executionString this is the string that will be executed + * @param workingDir this is the directory where the execution will happen + * @param project this is the project that is related to the run (it is used to get the environment for the shell we are going to + * execute with the correct pythonpath environment variable). + * @param monitor this is the monitor used to communicate the progress to the user + * + * @return the string that is the output of the process (stdout) and the stderr (o2) + */ + public Tuple<String,String> runAndGetOutput(String executionString, File workingDir, IProject project, IProgressMonitor monitor) { + monitor.setTaskName("Executing: "+executionString); + monitor.worked(5); + Process process = null; + + try { + monitor.setTaskName("Making pythonpath environment..."+executionString); + String[] envp = getEnvironment(PythonNature.getPythonNature(project), null); //should get the environment for the default interpreter and the given project + monitor.setTaskName("Making exec..."+executionString); + if(workingDir != null){ + if(!workingDir.isDirectory()){ + throw new RuntimeException(StringUtils.format("Working dir must be an existing directory (received: %s)", workingDir)); + } + } + process = Runtime.getRuntime().exec(executionString, envp, workingDir); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return getProcessOutput(process, executionString, monitor); } Index: SimplePythonRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners/SimplePythonRunner.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SimplePythonRunner.java 26 Jun 2006 23:40:46 -0000 1.9 --- SimplePythonRunner.java 12 May 2008 11:34:00 -0000 1.10 *************** *** 52,61 **** */ public static String makeExecutableCommandStr(String script, String[] args) { ! String[] s = new String[]{ ! PydevPlugin.getPythonInterpreterManager().getDefaultInterpreter() , ! "-u" , ! script , ! }; ! return getCommandLineAsString(s, args); } --- 52,57 ---- */ public static String makeExecutableCommandStr(String script, String[] args) { ! String interpreter = PydevPlugin.getPythonInterpreterManager().getDefaultInterpreter(); ! String[] s = preparePythonCallParameters(interpreter, script, args); return getCommandLineAsString(s, args); } *************** *** 73,77 **** * @return the stdout of the run (if any) */ ! public Tuple<String,String> runAndGetOutputWithInterpreter(String interpreter, String script, String[] args, File workingDir, IProject project, IProgressMonitor monitor) { monitor.setTaskName("Mounting executable string..."); monitor.worked(5); --- 69,73 ---- * @return the stdout of the run (if any) */ ! public Tuple<String,String> runAndGetOutputWithInterpreter(String interpreter, String script, String[] args, File workingDir, IProject project, IProgressMonitor monitor) { monitor.setTaskName("Mounting executable string..."); monitor.worked(5); *************** *** 82,95 **** } ! String[] s = new String[]{ ! interpreter, ! "-u" , ! script , ! }; ! monitor.worked(1); ! return runAndGetOutput(getCommandLineAsString(s,args), workingDir, project, monitor); } --- 78,106 ---- } ! String[] s = preparePythonCallParameters(interpreter, script, args); monitor.worked(1); ! return runAndGetOutput(s, workingDir, project, monitor); } + /** + * Creates array with what should be passed to Runtime.exec to run python. + * + * @param interpreter interpreter that should do the run + * @param script python script to execute + * @param args additional arguments to pass to python + * @return the created array + */ + private static String[] preparePythonCallParameters(String interpreter, String script, String[] args) { + if (args == null) { + args = new String[0]; + } + + String[] s = new String[3 + args.length]; + s[0] = interpreter; + s[1] = "-u"; + s[2] = script; + System.arraycopy(args, 0, s, 3, args.length); + return s; + } |
From: Fabio Z. <fa...@us...> - 2008-05-12 11:01:03
|
Update of /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20721/tests/org/python/pydev/core Modified Files: TestDependent.windows.template TestDependent.linux.template Log Message: Felix Schwartz: [Patch] Add missing variables to TestDependent templates Index: TestDependent.windows.template =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.windows.template,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestDependent.windows.template 8 Aug 2007 10:59:36 -0000 1.1 --- TestDependent.windows.template 12 May 2008 11:01:06 -0000 1.2 *************** *** 49,54 **** public static final boolean HAS_SWT_ON_PATH = false; public static final boolean HAS_NUMARRAY_INSTALLED = false; ! public static final boolean HAS_MX_DATETIME = true; public static boolean HAS_CYGWIN = false; public static String CYGWIN_PYTHON_EXE="E:/install/Utils.Cygwin/bin/python2.4.exe"; --- 49,60 ---- public static final boolean HAS_SWT_ON_PATH = false; public static final boolean HAS_NUMARRAY_INSTALLED = false; ! public static final boolean HAS_MX_DATETIME = false; ! public static final boolean HAS_NUMPY_INSTALLED = false; ! ! public static final String PYTHON_MX_PACKAGES = null; ! public static final String PYTHON_PIL_PACKAGES = null; ! public static final String PYTHON_NUMPY_PACKAGES = null; + public static final boolean HAS_PIL = false; public static boolean HAS_CYGWIN = false; public static String CYGWIN_PYTHON_EXE="E:/install/Utils.Cygwin/bin/python2.4.exe"; Index: TestDependent.linux.template =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/tests/org/python/pydev/core/TestDependent.linux.template,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestDependent.linux.template 8 Aug 2007 00:29:27 -0000 1.1 --- TestDependent.linux.template 12 May 2008 11:01:06 -0000 1.2 *************** *** 50,57 **** --- 50,61 ---- public static final boolean HAS_NUMARRAY_INSTALLED = false; public static final boolean HAS_MX_DATETIME = false; + public static final boolean HAS_NUMPY_INSTALLED = false; public static final String PYTHON_MX_PACKAGES = null; + public static final String PYTHON_PIL_PACKAGES = null; + public static final String PYTHON_NUMPY_PACKAGES = null; + public static final boolean HAS_PIL = false; public static boolean HAS_CYGWIN = false; public static String CYGWIN_PYTHON_EXE="E:/install/Utils.Cygwin/bin/python2.4.exe"; *************** *** 59,62 **** public static final String CYGWIN_UNIX_CYGPATH_LOCATION = "/usr/bin/cygpath.exe"; public static final boolean HAS_PYTHON_TESTS = false; - } --- 63,65 ---- |
From: Fabio Z. <fa...@us...> - 2008-05-10 18:05:00
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15736/pysrc Modified Files: pydevd_file_utils.py Log Message: Comments on pydevd_file_utils.py Index: pydevd_file_utils.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_file_utils.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pydevd_file_utils.py 6 Mar 2008 11:33:04 -0000 1.4 --- pydevd_file_utils.py 10 May 2008 17:55:33 -0000 1.5 *************** *** 1,8 **** ''' ! This module provides utilities to get the absolute filenames so that we can be sure that ! the case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit). ! ! It also provides means for the user to make path conversions when doing a remote debugging session in ! one machine and debugging in another. To do that, the PATHS_FROM_CLIENT_TO_SERVER constant must be filled with the appropriate paths. --- 1,7 ---- ''' ! This module provides utilities to get the absolute filenames so that we can be sure that: ! - The case of a file will match the actual file in the filesystem (otherwise breakpoints won't be hit). ! - Providing means for the user to make path conversions when doing a remote debugging session in ! one machine and debugging in another. To do that, the PATHS_FROM_CLIENT_TO_SERVER constant must be filled with the appropriate paths. *************** *** 32,37 **** @note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible ! through the PYTHONPATH (and the PATHS_FROM_CLIENT_TO_SERVER only need to be set on the target ! machine as needed). ''' --- 31,36 ---- @note: for doing a remote debugging session, all the pydevd_ files must be on the server accessible ! through the PYTHONPATH (and the PATHS_FROM_CLIENT_TO_SERVER only needs to be set on the target ! machine for the paths that'll actually have breakpoints). ''' |
From: Fabio Z. <fa...@us...> - 2008-05-10 17:36:21
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8592/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ProjectModulesManager.java Log Message: Comments Index: ProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ProjectModulesManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ProjectModulesManager.java 5 May 2008 01:31:21 -0000 1.15 --- ProjectModulesManager.java 10 May 2008 17:36:22 -0000 1.16 *************** *** 418,421 **** --- 418,422 ---- } + //get the projects 1st if(project != null){ HashSet<IProject> projs = new HashSet<IProject>(); *************** *** 426,433 **** list.add(this); ! //the system is the last one we add. if(checkSystemManager && systemModulesManager != null){ list.add(systemModulesManager); } IModulesManager[] ret = (IModulesManager[]) list.toArray(new IModulesManager[list.size()]); if(this.completionCache != null){ --- 427,436 ---- list.add(this); ! //the system is the last one we add ! //http://sourceforge.net/tracker/index.php?func=detail&aid=1687018&group_id=85796&atid=577329 if(checkSystemManager && systemModulesManager != null){ list.add(systemModulesManager); } + IModulesManager[] ret = (IModulesManager[]) list.toArray(new IModulesManager[list.size()]); if(this.completionCache != null){ |
From: Fabio Z. <fa...@us...> - 2008-05-10 17:31:12
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc/tests_python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6683/pysrc/tests_python Modified Files: test_debugger.py Log Message: Step-return skips breakpoints. Index: test_debugger.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/tests_python/test_debugger.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_debugger.py 10 May 2008 16:30:03 -0000 1.15 --- test_debugger.py 10 May 2008 17:31:13 -0000 1.16 *************** *** 138,142 **** time.sleep(1) if i >= 10: ! raise AssertionError('After %s seconds, a break was not hit.' % i) #we have something like <xml><thread id="12152656" stop_reason="111"><frame id="12453120" ... --- 138,143 ---- time.sleep(1) if i >= 10: ! raise AssertionError('After %s seconds, a break with reason: %s was not hit. Found: %s' % \ ! (i, reason, self.readerThread.lastReceived)) #we have something like <xml><thread id="12152656" stop_reason="111"><frame id="12453120" ... *************** *** 203,206 **** --- 204,236 ---- #======================================================================================================================= + # WriterThreadCase12 + #====================================================================================================================== + class WriterThreadCase12(AbstractWriterThread): + + TEST_FILE = NormFile('_debugger_case10.py') + + def run(self): + self.StartSocket() + self.WriteAddBreakpoint(2, 'Method1') + self.WriteAddBreakpoint(11, 'Method2') + self.WriteMakeInitialRun() + + threadId, frameId = self.WaitForBreakpointHit('111') + + self.WriteStepReturn(threadId) + + threadId, frameId, line = self.WaitForBreakpointHit('111', True) #not a return (it stopped in the other breakpoint) + + assert line == 2, 'Expected return to be in line 2, was: %s' % line + + self.WriteRunThread(threadId) + + assert 11 == self._sequence, 'Expected 11. Had: %s' % self._sequence + + self.finishedOk = True + + + + #======================================================================================================================= # WriterThreadCase11 #====================================================================================================================== *************** *** 687,690 **** --- 717,723 ---- def testCase11(self): self.CheckCase(WriterThreadCase11) + + def testCase12(self): + self.CheckCase(WriterThreadCase12) *************** *** 722,725 **** --- 755,761 ---- self.CheckCase(WriterThreadCase11, False) + def testCase12a(self): + self.CheckCase(WriterThreadCase12, False) + *************** *** 731,735 **** # suite = unittest.TestSuite() ! # suite.addTest(Test('testCase11')) unittest.TextTestRunner(verbosity=1).run(suite) --- 767,771 ---- # suite = unittest.TestSuite() ! # suite.addTest(Test('testCase12')) unittest.TextTestRunner(verbosity=1).run(suite) |
From: Fabio Z. <fa...@us...> - 2008-05-10 17:31:12
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6683/pysrc Modified Files: pydevd_frame.py Log Message: Step-return skips breakpoints. Index: pydevd_frame.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd_frame.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** pydevd_frame.py 12 Apr 2008 20:15:17 -0000 1.26 --- pydevd_frame.py 10 May 2008 17:31:14 -0000 1.27 *************** *** 97,101 **** # if thread has a suspend flag, we suspend with a busy wait ! if info.pydev_state == STATE_SUSPEND and info.pydev_step_cmd != CMD_STEP_RETURN: self.doWaitSuspend(thread, frame, event, arg) return self.trace_dispatch --- 97,101 ---- # if thread has a suspend flag, we suspend with a busy wait ! if info.pydev_state == STATE_SUSPEND: self.doWaitSuspend(thread, frame, event, arg) return self.trace_dispatch |
From: Fabio Z. <fa...@us...> - 2008-05-10 16:30:02
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc/tests_python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16476/pysrc/tests_python Modified Files: test_debugger.py Log Message: Step over stepping correctly. Index: test_debugger.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/tests_python/test_debugger.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_debugger.py 9 May 2008 22:22:05 -0000 1.14 --- test_debugger.py 10 May 2008 16:30:03 -0000 1.15 *************** *** 203,206 **** --- 203,247 ---- #======================================================================================================================= + # WriterThreadCase11 + #====================================================================================================================== + class WriterThreadCase11(AbstractWriterThread): + + TEST_FILE = NormFile('_debugger_case10.py') + + def run(self): + self.StartSocket() + self.WriteAddBreakpoint(2, 'Method1') + self.WriteMakeInitialRun() + + threadId, frameId = self.WaitForBreakpointHit('111') + + self.WriteStepOver(threadId) + + threadId, frameId, line = self.WaitForBreakpointHit('108', True) + + assert line == 3, 'Expected return to be in line 3, was: %s' % line + + self.WriteStepOver(threadId) + + threadId, frameId, line = self.WaitForBreakpointHit('108', True) + + assert line == 11, 'Expected return to be in line 11, was: %s' % line + + self.WriteStepOver(threadId) + + threadId, frameId, line = self.WaitForBreakpointHit('108', True) + + assert line == 12, 'Expected return to be in line 12, was: %s' % line + + self.WriteRunThread(threadId) + + assert 13 == self._sequence, 'Expected 13. Had: %s' % self._sequence + + self.finishedOk = True + + + + + #======================================================================================================================= # WriterThreadCase10 #====================================================================================================================== *************** *** 643,646 **** --- 684,690 ---- def testCase10(self): self.CheckCase(WriterThreadCase10) + + def testCase11(self): + self.CheckCase(WriterThreadCase11) *************** *** 675,678 **** --- 719,725 ---- self.CheckCase(WriterThreadCase10, False) + def testCase11a(self): + self.CheckCase(WriterThreadCase11, False) + *************** *** 684,688 **** # suite = unittest.TestSuite() ! # suite.addTest(Test('testCase10')) unittest.TextTestRunner(verbosity=1).run(suite) --- 731,735 ---- # suite = unittest.TestSuite() ! # suite.addTest(Test('testCase11')) unittest.TextTestRunner(verbosity=1).run(suite) |
From: Fabio Z. <fa...@us...> - 2008-05-10 16:30:01
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16476/pysrc Modified Files: pydevd.py Log Message: Step over stepping correctly. Index: pydevd.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd.py,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** pydevd.py 9 May 2008 22:22:05 -0000 1.95 --- pydevd.py 10 May 2008 16:30:03 -0000 1.96 *************** *** 534,537 **** --- 534,539 ---- elif info.pydev_step_cmd == CMD_STEP_OVER: info.pydev_step_stop = frame + frame.f_trace = self.trace_dispatch + SetTraceForParents(frame, self.trace_dispatch) elif info.pydev_step_cmd == CMD_STEP_RETURN: |
From: Fabio Z. <fa...@us...> - 2008-05-10 16:29:33
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16453/src_navigator/org/python/pydev/navigator Modified Files: PythonModelProvider.java PythonBaseModelProvider.java Log Message: Pydev model provider for project explorer: Better handling of null objects when intercepting them / interaction with other models. Index: PythonModelProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/PythonModelProvider.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PythonModelProvider.java 9 May 2008 01:10:13 -0000 1.13 --- PythonModelProvider.java 10 May 2008 16:29:24 -0000 1.14 *************** *** 224,233 **** //add the current to the found - found.push(parentContainer); - parentContainer = parentContainer.getParent(); if(parentContainer == null){ break; } if(parentContainer instanceof IProject){ //we got to the project without finding any part of a python model already there, so, let's see --- 224,232 ---- //add the current to the found if(parentContainer == null){ break; } + found.push(parentContainer); if(parentContainer instanceof IProject){ //we got to the project without finding any part of a python model already there, so, let's see *************** *** 259,264 **** --- 258,265 ---- } + parentContainer = parentContainer.getParent(); } + wrapChildren(parentInWrap, sourceFolderInWrap, modification.getChildren(), isAdd); *************** *** 295,306 **** for(Iterator<Object> it = found.topDownIterator();it.hasNext();){ Object child = it.next(); ! if(child instanceof IFolder){ if(pythonSourceFolder == null){ ! pythonSourceFolder = tryWrapSourceFolder(currentParent, (IFolder) child, sourcePathSet); if(pythonSourceFolder != null){ currentParent = pythonSourceFolder; }else if(child instanceof IContainer){ currentParent = (IContainer) child; } //just go on (if we found the source folder or not, because if we found, that's ok, and if //we didn't, then the children will not be in the python model anyway) --- 296,311 ---- for(Iterator<Object> it = found.topDownIterator();it.hasNext();){ Object child = it.next(); ! if(child instanceof IFolder || child instanceof IProject){ if(pythonSourceFolder == null){ ! pythonSourceFolder = tryWrapSourceFolder(currentParent, (IContainer) child, sourcePathSet); ! if(pythonSourceFolder != null){ currentParent = pythonSourceFolder; + }else if(child instanceof IContainer){ currentParent = (IContainer) child; + } + //just go on (if we found the source folder or not, because if we found, that's ok, and if //we didn't, then the children will not be in the python model anyway) *************** *** 308,311 **** --- 313,318 ---- } } + + if(pythonSourceFolder != null){ IWrappedResource r = doWrap(currentParent, pythonSourceFolder, child); *************** *** 340,343 **** --- 347,356 ---- Object child = childrenItr.next(); + if(child == null){ + //only case when a child is removed and another one is not added (null) + childrenItr.remove(); + continue; + } + //yeap, it may be an object that's not an actual resource (created by some other plugin... just continue) if(!(child instanceof IResource)){ *************** *** 390,394 **** protected IWrappedResource doWrap(Object parent, PythonSourceFolder pythonSourceFolder, Object child) { if (child instanceof IProject){ ! //do nothing (because a project is never going to be an IWrappedResource) if(pythonSourceFolder == null && parent != null){ PythonSourceFolder f = doWrapPossibleSourceFolder(parent, (IProject)child); --- 403,407 ---- protected IWrappedResource doWrap(Object parent, PythonSourceFolder pythonSourceFolder, Object child) { if (child instanceof IProject){ ! //ok, let's see if the child is a source folder (as the default project can be the actual source folder) if(pythonSourceFolder == null && parent != null){ PythonSourceFolder f = doWrapPossibleSourceFolder(parent, (IProject)child); *************** *** 471,475 **** sourceFolder = new PythonProjectSourceFolder(parent, (IProject)container); }else{ ! throw new RuntimeException("Shouldn't get here: "+container.getClass()); } //System.out.println("Created source folder: "+ret[i]+" - "+folder.getProject()+" - "+folder.getProjectRelativePath()); --- 484,488 ---- sourceFolder = new PythonProjectSourceFolder(parent, (IProject)container); }else{ ! return null; //some other container we don't know how to treat! } //System.out.println("Created source folder: "+ret[i]+" - "+folder.getProject()+" - "+folder.getProjectRelativePath()); *************** *** 491,494 **** --- 504,514 ---- for (Iterator childrenItr = currentChildren.iterator(); childrenItr.hasNext();) { Object child = childrenItr.next(); + + if(child == null){ + //only case when a child is removed and another one is not added (null) + childrenItr.remove(); + continue; + } + if(child instanceof IResource && !(child instanceof IWrappedResource)){ IResource res = (IResource) child; *************** *** 510,522 **** if(pythonParent instanceof IWrappedResource){ IWrappedResource parent = (IWrappedResource) pythonParent; if (res instanceof IProject){ ! //do nothing (because a project is never going to be an IWrappedResource) ! throw new RuntimeException("Shouldn't be here..."); }else if(res instanceof IFolder){ childrenItr.remove(); convertedChildren.add(new PythonFolder(parent, (IFolder) res, parent.getSourceFolder())); }else if(res instanceof IFile){ childrenItr.remove(); convertedChildren.add(new PythonFile(parent, (IFile) res, parent.getSourceFolder())); }else if (child instanceof IResource){ childrenItr.remove(); --- 530,545 ---- if(pythonParent instanceof IWrappedResource){ IWrappedResource parent = (IWrappedResource) pythonParent; + if (res instanceof IProject){ ! throw new RuntimeException("A project's parent should never be an IWrappedResource!"); ! }else if(res instanceof IFolder){ childrenItr.remove(); convertedChildren.add(new PythonFolder(parent, (IFolder) res, parent.getSourceFolder())); + }else if(res instanceof IFile){ childrenItr.remove(); convertedChildren.add(new PythonFile(parent, (IFile) res, parent.getSourceFolder())); + }else if (child instanceof IResource){ childrenItr.remove(); Index: PythonBaseModelProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/PythonBaseModelProvider.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PythonBaseModelProvider.java 27 Apr 2008 17:28:05 -0000 1.11 --- PythonBaseModelProvider.java 10 May 2008 16:29:24 -0000 1.12 *************** *** 309,313 **** //if we don't have a python nature in this project, there is no way we can have a PythonSourceFolder ! Object[] ret = new Object[childrenToReturn.length]; for (int i=0; i < childrenToReturn.length; i++) { PythonNature localNature = nature; --- 309,313 ---- //if we don't have a python nature in this project, there is no way we can have a PythonSourceFolder ! List<Object> ret = new ArrayList<Object>(childrenToReturn.length); for (int i=0; i < childrenToReturn.length; i++) { PythonNature localNature = nature; *************** *** 316,324 **** //now, first we have to try to get it (because it might already be created) Object child = childrenToReturn[i]; ! if(!(child instanceof IResource)){ continue; } child = getResourceInPythonModel((IResource) child); ! ret[i] = child; //if it is a folder (that is not already a PythonSourceFolder, it might be that we have to create a PythonSourceFolder) --- 316,339 ---- //now, first we have to try to get it (because it might already be created) Object child = childrenToReturn[i]; ! ! if(child == null){ ! continue; ! } ! ! //only add it if it wasn't null ! ret.add(child); ! ! if(!(child instanceof IResource)){ ! //not an element that we can treat in pydev (but still, it was already added) continue; } child = getResourceInPythonModel((IResource) child); ! ! if(child == null){ ! //ok, it was not in the python model (but it was already added with the original representation, so, that's ok) ! continue; ! }else{ ! ret.set(ret.size()-1, child); //replace the element added for the one in the python model ! } //if it is a folder (that is not already a PythonSourceFolder, it might be that we have to create a PythonSourceFolder) *************** *** 348,360 **** IPath fullPath = container.getFullPath(); if(sourcePathSet.contains(fullPath.toString())){ if(container instanceof IFolder){ ! ret[i] = new PythonSourceFolder(parentElement, (IFolder)container); }else if(container instanceof IProject){ ! ret[i] = new PythonProjectSourceFolder(parentElement, (IProject)container); }else{ throw new RuntimeException("Should not get here."); } Set<PythonSourceFolder> sourceFolders = getProjectSourceFolders(localProject); ! sourceFolders.add((PythonSourceFolder) ret[i]); } } catch (CoreException e) { --- 363,377 ---- IPath fullPath = container.getFullPath(); if(sourcePathSet.contains(fullPath.toString())){ + PythonSourceFolder createdSourceFolder; if(container instanceof IFolder){ ! createdSourceFolder = new PythonSourceFolder(parentElement, (IFolder)container); }else if(container instanceof IProject){ ! createdSourceFolder = new PythonProjectSourceFolder(parentElement, (IProject)container); }else{ throw new RuntimeException("Should not get here."); } + ret.set(ret.size()-1, createdSourceFolder); //replace the element added for the one in the python model Set<PythonSourceFolder> sourceFolders = getProjectSourceFolders(localProject); ! sourceFolders.add(createdSourceFolder); } } catch (CoreException e) { *************** *** 363,367 **** } } ! return ret; } --- 380,384 ---- } } ! return ret.toArray(); } *************** *** 456,486 **** */ protected Object[] wrapChildren(IWrappedResource parent, PythonSourceFolder pythonSourceFolder, Object[] children) { ! Object[] childrenToReturn; ! Object[] ret = new Object[children.length]; for (int i = 0; i < children.length; i++) { Object object = children[i]; ! Object existing = getResourceInPythonModel((IResource) object, true); ! if(existing == null){ ! if(object instanceof IFolder){ ! IFolder folder = (IFolder) object; ! ret[i] = new PythonFolder(parent, folder, pythonSourceFolder); ! ! }else if(object instanceof IFile){ ! IFile file = (IFile) object; ! ret[i] = new PythonFile(parent, file, pythonSourceFolder); ! ! }else if(object instanceof IResource){ ! ret[i] = new PythonResource(parent, (IResource) object, pythonSourceFolder); ! }else{ ! ret[i] = existing; } }else{ ! ret[i] = existing; } } ! childrenToReturn = ret; ! return childrenToReturn; } --- 473,507 ---- */ protected Object[] wrapChildren(IWrappedResource parent, PythonSourceFolder pythonSourceFolder, Object[] children) { ! List<Object> ret = new ArrayList<Object>(children.length); for (int i = 0; i < children.length; i++) { Object object = children[i]; ! ! if(object instanceof IResource){ ! Object existing = getResourceInPythonModel((IResource) object, true); ! if(existing == null){ ! if(object instanceof IFolder){ ! object = new PythonFolder(parent, ((IFolder) object), pythonSourceFolder); ! ! }else if(object instanceof IFile){ ! object = new PythonFile(parent, ((IFile) object), pythonSourceFolder); ! ! }else if(object instanceof IResource){ ! object = new PythonResource(parent, (IResource) object, pythonSourceFolder); ! } ! }else{ //existing != null ! object = existing; } + } + + if(object == null){ + continue; }else{ ! ret.add(object); } + } ! return ret.toArray(); } |
From: Fabio Z. <fa...@us...> - 2008-05-10 16:29:33
|
Update of /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16453/tests_navigator/org/python/pydev/navigator Modified Files: PythonModelProviderTest.java ProjectStub.java Log Message: Pydev model provider for project explorer: Better handling of null objects when intercepting them / interaction with other models. Index: ProjectStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator/ProjectStub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ProjectStub.java 8 Sep 2007 16:36:12 -0000 1.4 --- ProjectStub.java 10 May 2008 16:29:24 -0000 1.5 *************** *** 5,8 **** --- 5,9 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.List; import java.util.Map; *************** *** 43,51 **** --- 44,66 ---- private IContainer parent; + + private boolean addNullChild; + + private List<Object> additionalChildren; public ProjectStub(File file, IPythonNature nature) { + this(file, nature, false); + } + + public ProjectStub(File file, IPythonNature nature, boolean addNullChild) { + this(file, nature, addNullChild, new ArrayList<Object>()); + } + + public ProjectStub(File file, IPythonNature nature, boolean addNullChild, List<Object> additionalChildren) { Assert.isTrue(file.exists() && file.isDirectory()); this.projectRoot = file; this.nature = nature; + this.addNullChild = addNullChild; + this.additionalChildren = additionalChildren; } *************** *** 605,609 **** throw new RuntimeException("Shouldn't happen"); } ! ArrayList<IResource> ret = new ArrayList<IResource>(); for(File file:folder.listFiles()){ if(file.getName().toLowerCase().equals("cvs")){ --- 620,624 ---- throw new RuntimeException("Shouldn't happen"); } ! ArrayList<Object> ret = new ArrayList<Object>(); for(File file:folder.listFiles()){ if(file.getName().toLowerCase().equals("cvs")){ *************** *** 616,619 **** --- 631,638 ---- } } + if(addNullChild){ + ret.add(null); + } + ret.addAll(this.additionalChildren); return ret.toArray(); } Index: PythonModelProviderTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator/PythonModelProviderTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PythonModelProviderTest.java 9 May 2008 01:10:13 -0000 1.9 --- PythonModelProviderTest.java 10 May 2008 16:29:24 -0000 1.10 *************** *** 28,32 **** PythonModelProviderTest test = new PythonModelProviderTest(); test.setUp(); ! test.testCreateChildrenInWrappedResource(); test.tearDown(); --- 28,32 ---- PythonModelProviderTest test = new PythonModelProviderTest(); test.setUp(); ! test.testProjectIsRoot2(); test.tearDown(); *************** *** 56,63 **** HashSet<Object> files = new HashSet<Object>(); files.add(file); provider.interceptAdd(new PipelinedShapeModification(file.getParent(), files)); ! assertEquals(1, files.size()); ! Object wrappedResource = files.iterator().next(); ! assertTrue(wrappedResource instanceof IWrappedResource); } --- 56,68 ---- HashSet<Object> files = new HashSet<Object>(); files.add(file); + files.add(null); + files.add("string"); provider.interceptAdd(new PipelinedShapeModification(file.getParent(), files)); ! assertEquals(2, files.size()); ! for(Object wrappedResource:files){ ! assertTrue((wrappedResource instanceof IWrappedResource && ! ((IWrappedResource)wrappedResource).getActualObject() == file)|| ! wrappedResource.equals("string")); ! } } *************** *** 73,81 **** PipelinedViewerUpdate update = new PipelinedViewerUpdate(); ! Set<IResource> refreshTargets = update.getRefreshTargets(); refreshTargets.add(project); provider.interceptRefresh(update); ! IResource wrappedResource = refreshTargets.iterator().next(); ! assertTrue(wrappedResource == project); } --- 78,90 ---- PipelinedViewerUpdate update = new PipelinedViewerUpdate(); ! Set<Object> refreshTargets = update.getRefreshTargets(); refreshTargets.add(project); + refreshTargets.add(null); + refreshTargets.add("string"); provider.interceptRefresh(update); ! assertEquals(2, refreshTargets.size()); ! for (Object wrappedResource:refreshTargets){ ! assertTrue(wrappedResource == project || wrappedResource.equals("string")); ! } } *************** *** 83,86 **** --- 92,125 ---- * Test if setting the project root as a source folder will return an object from the python model. */ + public void testProjectIsRoot2() throws Exception { + String pythonpathLoc = TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"; + final HashSet<String> pythonPathSet = new HashSet<String>(); + pythonPathSet.add(pythonpathLoc); + + PythonNature nature = createNature(pythonPathSet); + + WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub(); + project = new ProjectStub(new File(pythonpathLoc), nature); + provider = new PythonModelProvider(); + FolderStub folder = new FolderStub(project, new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source")); + + workspaceRootStub.addChild(project); + project.setParent(workspaceRootStub); + + HashSet<Object> folders = new HashSet<Object>(); + folders.add(folder); + PipelinedShapeModification addModification = new PipelinedShapeModification(project, folders); + addModification.setParent(project); + provider.interceptAdd(addModification); + + assertEquals(1, addModification.getChildren().size()); + //it should've been wrapped + assertTrue(addModification.getChildren().iterator().next() instanceof IWrappedResource); + } + + + /** + * Test if setting the project root as a source folder will return an object from the python model. + */ public void testProjectIsRoot() throws Exception { String pythonpathLoc = TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"; *************** *** 95,103 **** workspaceRootStub.addChild(project); project.setParent(workspaceRootStub); Object[] children1 = provider.getChildren(workspaceRootStub); ! assertEquals(1, children1.length); ! assertTrue("Expecting source folder. Received: "+children1[0].getClass().getName(), children1[0] instanceof PythonSourceFolder); //now, let's go and change the pythonpath location to a folder within the project and see if it changes... --- 134,162 ---- workspaceRootStub.addChild(project); + workspaceRootStub.addChild(null); + workspaceRootStub.addChild("other"); project.setParent(workspaceRootStub); + Object[] children1 = provider.getChildren(workspaceRootStub); ! assertEquals(2, children1.length); ! int stringsFound=0; ! int projectSourceFoldersFound=0; ! for (Object c : children1) { ! if(c instanceof String){ ! stringsFound+=1; ! ! }else if(c instanceof PythonProjectSourceFolder){ ! projectSourceFoldersFound+=1; ! ! }else{ ! fail("Expecting source folder or string. Received: "+c.getClass().getName()); ! } ! } ! assertEquals(1, stringsFound); ! assertEquals(1, projectSourceFoldersFound); ! ! ! //now, let's go and change the pythonpath location to a folder within the project and see if it changes... *************** *** 108,114 **** children1 = provider.getChildren(workspaceRootStub); ! assertEquals(1, children1.length); ! assertTrue("Expecting IProject. Received: "+children1[0].getClass().getName(), children1[0] instanceof IProject); ! //set to be the root again pythonPathSet.clear(); --- 167,188 ---- children1 = provider.getChildren(workspaceRootStub); ! assertEquals(2, children1.length); ! stringsFound=0; ! int projectsFound=0; ! for (Object c : children1) { ! if(c instanceof String){ ! stringsFound+=1; ! ! }else if(c instanceof IProject){ ! projectsFound+=1; ! ! }else{ ! fail("Expecting source folder or string. Received: "+c.getClass().getName()); ! } ! } ! assertEquals(1, stringsFound); ! assertEquals(1, projectsFound); ! ! //set to be the root again pythonPathSet.clear(); *************** *** 149,155 **** final HashSet<String> pythonPathSet = new HashSet<String>(); pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source"); PythonNature nature = createNature(pythonPathSet); ! project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature); provider = new PythonModelProvider(); Object[] children1 = provider.getChildren(project); --- 223,230 ---- final HashSet<String> pythonPathSet = new HashSet<String>(); pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source"); + pythonPathSet.add("invalid"); PythonNature nature = createNature(pythonPathSet); ! project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature, true); provider = new PythonModelProvider(); Object[] children1 = provider.getChildren(project); *************** *** 221,225 **** WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub(); ! project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature); workspaceRootStub.addChild(project); project.setParent(workspaceRootStub); --- 296,302 ---- WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub(); ! ArrayList<Object> additionalChildren = new ArrayList<Object>(); ! additionalChildren.add("string"); ! project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature, true, additionalChildren); workspaceRootStub.addChild(project); project.setParent(workspaceRootStub); *************** *** 230,233 **** --- 307,311 ---- HashSet<Object> currentChildren = new HashSet<Object>(); currentChildren.add(project); + currentChildren.add(null); provider.getPipelinedChildren(workspaceRootStub, currentChildren); *************** *** 236,241 **** --- 314,350 ---- currentChildren = new HashSet<Object>(); + currentChildren.add(null); provider.getPipelinedChildren(projectSourceFolder, currentChildren); + assertEquals(2, currentChildren.size()); + } + + public void testNullElements() throws Exception { + final HashSet<String> pythonPathSet = new HashSet<String>(); + pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"); //root is the source + PythonNature nature = createNature(pythonPathSet); + + + WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub(); + project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature); + workspaceRootStub.addChild(project); + project.setParent(workspaceRootStub); + + + provider = new PythonModelProvider(); + + HashSet<Object> currentChildren = new HashSet<Object>(); + currentChildren.add(project); + currentChildren.add(null); + provider.getPipelinedChildren(workspaceRootStub, currentChildren); + + assertEquals(1, currentChildren.size()); + PythonProjectSourceFolder projectSourceFolder = (PythonProjectSourceFolder) currentChildren.iterator().next(); + + currentChildren = new HashSet<Object>(); + currentChildren.add(null); + currentChildren.add(null); + provider.getPipelinedChildren(projectSourceFolder, currentChildren); + assertEquals(1, currentChildren.size()); } |
From: Fabio Z. <fa...@us...> - 2008-05-10 00:45:25
|
Update of /cvsroot/pydev/org.python.pydev/tests/pysrc/extendable/relative_with_sub In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27110/tests/pysrc/extendable/relative_with_sub Added Files: aa.py bb.py __init__.py Log Message: <strong>Code-completion</strong>: Working for attributes found in a superclass imported with a relative import bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1961017&group_id=85796&atid=577329 --- NEW FILE: aa.py --- class XXX(object): def yyy(self): pass class AA(object): def __init__(self): self.xxx = XXX() --- NEW FILE: __init__.py --- --- NEW FILE: bb.py --- from aa import AA class BB(AA): def __init__(self): self.xxx.y |
From: Fabio Z. <fa...@us...> - 2008-05-10 00:45:24
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27110/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java Log Message: <strong>Code-completion</strong>: Working for attributes found in a superclass imported with a relative import bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1961017&group_id=85796&atid=577329 Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyCodeCompletion.java 26 May 2007 15:33:09 -0000 1.4 --- PyCodeCompletion.java 10 May 2008 00:45:30 -0000 1.5 *************** *** 6,9 **** --- 6,10 ---- package org.python.pydev.editor.codecompletion; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; *************** *** 423,427 **** IRegion region = request.doc.getLineInformationOfOffset(request.documentOffset); int col = request.documentOffset - region.getOffset(); ! IModule module = AbstractModule.createModuleFromDoc("", null, request.doc, request.nature, line); ASTManager astMan = ((ASTManager)request.nature.getAstManager()); --- 424,440 ---- IRegion region = request.doc.getLineInformationOfOffset(request.documentOffset); int col = request.documentOffset - region.getOffset(); ! ! ! //ok, try our best shot at getting the module name of the current buffer used in the request. ! String modName = ""; ! File requestFile = request.editorFile; ! if(request.editorFile != null){ ! String resolveModule = request.nature.resolveModule(requestFile); ! if(resolveModule != null){ ! modName = resolveModule; ! } ! } ! ! IModule module = AbstractModule.createModuleFromDoc(modName, requestFile, request.doc, request.nature, line); ASTManager astMan = ((ASTManager)request.nature.getAstManager()); |