pydev-cvs Mailing List for PyDev for Eclipse (Page 9)
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-07-31 01:47:31
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyCodeCompletion.java 10 May 2008 00:45:30 -0000 1.5 --- PyCodeCompletion.java 31 Jul 2008 01:47:37 -0000 1.6 *************** *** 17,20 **** --- 17,21 ---- import org.eclipse.core.runtime.CoreException; + import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; *************** *** 47,50 **** --- 48,53 ---- import org.python.pydev.parser.jython.ast.NameTok; import org.python.pydev.parser.visitors.NodeUtils; + import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.ui.NotConfiguredInterpreterException; /** *************** *** 104,110 **** //list of Object[], IToken or ICompletionProposal List<Object> tokensList = new ArrayList<Object>(); ! lazyStartShell(request); ! ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); --- 107,116 ---- //list of Object[], IToken or ICompletionProposal List<Object> tokensList = new ArrayList<Object>(); ! try { ! lazyStartShell(request); ! } catch (NotConfiguredInterpreterException e) { ! Log.log(IStatus.WARNING, "Warning: unable to get code-completion for builtins: No interpreter configured.", null); ! } ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); *************** *** 327,330 **** --- 333,338 ---- Log.toLogFile(this,"END AbstractShell.getServerShell"); } + } catch (RuntimeException e) { + throw e; } catch (Exception e) { throw new RuntimeException(e); |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:30
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519 Modified Files: Changes.txt Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.410 retrieving revision 1.411 diff -C2 -d -r1.410 -r1.411 *** Changes.txt 28 Jul 2008 15:53:31 -0000 1.410 --- Changes.txt 31 Jul 2008 01:47:37 -0000 1.411 *************** *** 5,8 **** --- 5,9 ---- <li><strong>Code Analysis</strong>: Not all unused imports are shown in the message anymore (could give problems saving workspace).</li> <li><strong>Code Analysis</strong>: Fixed problem on double cycle in list comprehension.</li> + <li><strong>Interpreter config</strong>: The initial parse of the modules is much faster.</li> </ul> *************** *** 12,15 **** --- 13,17 ---- <li><strong>Eclipse 3.2</strong>: Interactive console working / fixed some incompatibilities</li> <li><strong>Eclipse 3.4</strong>: Hyperlinks working</li> + <li><strong>Eclipse 3.4</strong>: Move / rename working</li> <li><strong>raw_input() and input()</strong>: functions are now changed when a program is launched from eclipse to consider a trailing '\r'</li> <li><strong>Pydev package explorer</strong>: Link working with compare editor</li> *************** *** 20,25 **** --- 22,31 ---- <li>Improved code formatter to handle '=' differently inside function calls / keyword args</li> <li>Applied patch that fixes race condition in PythonNatureStore (thanks to Radim Kubacki)</li> + <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li>Fixed bug related to having multiple editors with the same file (while having the spell service on)</li> <li>Applying a template could have the wrong end line delimiter applied</li> + <li>Fixed NPE when creating editor with no interpreter configured</li> + <li>Hyperlink works in the same way that F3 (saves file before search)</li> + <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> </ul> |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/interpreters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src/org/python/pydev/ui/interpreters Modified Files: AbstractInterpreterManager.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: AbstractInterpreterManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/interpreters/AbstractInterpreterManager.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** AbstractInterpreterManager.java 14 Jun 2008 22:14:55 -0000 1.39 --- AbstractInterpreterManager.java 31 Jul 2008 01:47:36 -0000 1.40 *************** *** 32,36 **** import org.python.pydev.core.structure.FastStringBuffer; import org.python.pydev.plugin.PydevPlugin; - import org.python.pydev.plugin.nature.PythonNature; import org.python.pydev.ui.NotConfiguredInterpreterException; import org.python.pydev.ui.pythonpathconf.InterpreterInfo; --- 32,35 ---- *************** *** 453,468 **** } ! //update the natures... ! List<IPythonNature> pythonNatures = PythonNature.getAllPythonNatures(); ! for (IPythonNature nature : pythonNatures) { ! try { ! //if they have the same type of the interpreter manager. ! if (this.isPython() == nature.isPython() || this.isJython() == nature.isJython()) { ! nature.rebuildPath(defaultSelectedInterpreter, monitor); ! } ! } catch (Throwable e) { ! PydevPlugin.log(e); ! } ! } } } --- 452,486 ---- } ! //Commented out: this is not really needed, as the information on the interpreter is mainly kept separated ! //from the projects info (this was initially done on an attempt to track dependencies through different ! //modules, but it proved too time consuming in a dynamic language such as python). ! ! // final Boolean[] restoreNatures = new Boolean[]{false}; ! // ! // final Display def = Display.getDefault(); ! // def.syncExec(new Runnable(){ ! // ! // public void run() { ! // Shell shell = def.getActiveShell(); ! // restoreNatures[0] = MessageDialog.openQuestion(shell, "Interpreter info changed", ! // "The interpreter info has been changed, do you want to make a full build?\n" + ! // "(the same thing can be later achieved through the menu: Project > Clean)"); ! // } ! // }); ! // ! // //update the natures... ! // if(restoreNatures[0]){ ! // List<IPythonNature> pythonNatures = PythonNature.getAllPythonNatures(); ! // for (IPythonNature nature : pythonNatures) { ! // try { ! // //if they have the same type of the interpreter manager. ! // if (this.isPython() == nature.isPython() || this.isJython() == nature.isJython()) { ! // nature.rebuildPath(defaultSelectedInterpreter, monitor); ! // } ! // } catch (Throwable e) { ! // PydevPlugin.log(e); ! // } ! // } ! // } } } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:30
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/tests_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ProjectStub.java CodeCompletionTestsBase.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: ProjectStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/ProjectStub.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ProjectStub.java 28 Jun 2008 13:29:19 -0000 1.3 --- ProjectStub.java 31 Jul 2008 01:47:36 -0000 1.4 *************** *** 259,263 **** public IPath getFullPath() { ! throw new RuntimeException("not impl"); } --- 259,263 ---- public IPath getFullPath() { ! return null; } Index: CodeCompletionTestsBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/CodeCompletionTestsBase.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CodeCompletionTestsBase.java 4 May 2008 16:49:31 -0000 1.11 --- CodeCompletionTestsBase.java 31 Jul 2008 01:47:36 -0000 1.12 *************** *** 208,212 **** ASTManager astManager = ((ASTManager)pNature.getAstManager()); astManager.setNature(pNature); ! astManager.setProject(projectStub, false); astManager.changePythonPath(path, projectStub, getProgressMonitor(),null); } --- 208,212 ---- ASTManager astManager = ((ASTManager)pNature.getAstManager()); astManager.setNature(pNature); ! astManager.setProject(projectStub, pNature, false); astManager.changePythonPath(path, projectStub, getProgressMonitor(),null); } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:29
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src/org/python/pydev/editor Modified Files: PyEdit.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** PyEdit.java 28 Jun 2008 13:29:19 -0000 1.131 --- PyEdit.java 31 Jul 2008 01:47:36 -0000 1.132 *************** *** 1124,1127 **** --- 1124,1128 ---- } + /** * @return the python nature associated with this editor. *************** *** 1133,1148 **** } IPythonNature pythonNature = PythonNature.getPythonNature(project); ! if(pythonNature == null){ ! Tuple<SystemPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(getEditorFile()); ! if(infoForFile == null){ ! NotConfiguredInterpreterException e = new NotConfiguredInterpreterException(); ! ErrorDialog.openError(PyAction.getShell(), ! "Error: no interpreter configured", "Interpreter not configured\n(Please, Configure it under window->preferences->PyDev)", ! PydevPlugin.makeStatus(IStatus.ERROR, e.getMessage(), e)); ! throw e; ! ! } ! pythonNature = infoForFile.o1; } return pythonNature; } --- 1134,1158 ---- } IPythonNature pythonNature = PythonNature.getPythonNature(project); ! if(pythonNature != null){ ! return pythonNature; } + + //if it's an external file, there's the possibility that it won't be added even here. + pythonNature = PythonNature.addNature(this.getEditorInput()); + + if(pythonNature != null){ + return pythonNature; + } + + Tuple<SystemPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(getEditorFile()); + if(infoForFile == null){ + NotConfiguredInterpreterException e = new NotConfiguredInterpreterException(); + ErrorDialog.openError(PyAction.getShell(), + "Error: no interpreter configured", "Interpreter not configured\n(Please, Configure it under window->preferences->PyDev)", + PydevPlugin.makeStatus(IStatus.ERROR, e.getMessage(), e)); + throw e; + + } + pythonNature = infoForFile.o1; return pythonNature; } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:29
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src_navigator/org/python/pydev/navigator Modified Files: PythonBaseModelProvider.java PythonModelProvider.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PythonModelProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/PythonModelProvider.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PythonModelProvider.java 19 Jun 2008 15:29:46 -0000 1.15 --- PythonModelProvider.java 31 Jul 2008 01:47:37 -0000 1.16 *************** *** 554,557 **** --- 554,580 ---- convertedChildren.add(new PythonResource(parent, (IResource) child, parent.getSourceFolder())); } + + }else if(res instanceof IFolder){ + //ok, still not in the model... could it be a PythonSourceFolder + IFolder folder = (IFolder) res; + IProject project = folder.getProject(); + if(project == null){ + continue; + } + PythonNature nature = PythonNature.getPythonNature(project); + if(nature== null){ + continue; + } + Set<String> sourcePathSet = new HashSet<String>(); + try { + sourcePathSet = nature.getPythonPathNature().getProjectSourcePathSet(); + } catch (CoreException e) { + PydevPlugin.log(e); + } + PythonSourceFolder wrapped = tryWrapSourceFolder(p, folder, sourcePathSet); + if(wrapped != null){ + childrenItr.remove(); + convertedChildren.add(wrapped); + } } } Index: PythonBaseModelProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/PythonBaseModelProvider.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PythonBaseModelProvider.java 10 May 2008 16:29:24 -0000 1.12 --- PythonBaseModelProvider.java 31 Jul 2008 01:47:37 -0000 1.13 *************** *** 100,103 **** --- 100,106 ---- */ public void notifyPythonPathRebuilt(IProject project, List<String> projectPythonpath) { + if(project == null){ + return; + } internalDoNotifyPythonPathRebuilt(project, projectPythonpath); } |
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ASTManager.java SystemASTManager.java AbstractASTManager.java ProjectModulesManager.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: AbstractASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/AbstractASTManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractASTManager.java 18 May 2008 20:02:16 -0000 1.16 --- AbstractASTManager.java 31 Jul 2008 01:47:36 -0000 1.17 *************** *** 87,91 **** ! public abstract void setProject(IProject project, boolean restoreDeltas) ; public abstract void rebuildModule(File file, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature) ; --- 87,91 ---- ! public abstract void setProject(IProject project, IPythonNature nature, boolean restoreDeltas) ; public abstract void rebuildModule(File file, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature) ; Index: ASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ASTManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ASTManager.java 2 Nov 2007 13:26:29 -0000 1.2 --- ASTManager.java 31 Jul 2008 01:47:36 -0000 1.3 *************** *** 42,47 **** * Set the project this ast manager works with. */ ! public void setProject(IProject project, boolean restoreDeltas){ ! getProjectModulesManager().setProject(project, restoreDeltas); } --- 42,47 ---- * Set the project this ast manager works with. */ ! public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas){ ! getProjectModulesManager().setProject(project, nature, restoreDeltas); } Index: SystemASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/SystemASTManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SystemASTManager.java 5 Jul 2007 00:32:12 -0000 1.2 --- SystemASTManager.java 31 Jul 2008 01:47:36 -0000 1.3 *************** *** 23,27 **** } ! public void setProject(IProject project, boolean restoreDeltas) { throw new RuntimeException("Not implemented"); } --- 23,27 ---- } ! public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas) { throw new RuntimeException("Not implemented"); } Index: ProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ProjectModulesManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ProjectModulesManager.java 10 May 2008 17:36:22 -0000 1.16 --- ProjectModulesManager.java 31 Jul 2008 01:47:36 -0000 1.17 *************** *** 21,24 **** --- 21,25 ---- import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.python.pydev.core.DeltaSaver; *************** *** 36,39 **** --- 37,41 ---- import org.python.pydev.core.REF; import org.python.pydev.core.Tuple; + import org.python.pydev.core.log.Log; import org.python.pydev.editor.codecompletion.revisited.javaintegration.JavaProjectModulesManagerCreator; import org.python.pydev.editor.codecompletion.revisited.javaintegration.ModulesKeyForJava; *************** *** 41,44 **** --- 43,47 ---- import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.nature.PythonNature; + import org.python.pydev.ui.NotConfiguredInterpreterException; import org.python.pydev.ui.pythonpathconf.InterpreterInfo; *************** *** 69,75 **** * @see org.python.pydev.core.IProjectModulesManager#setProject(org.eclipse.core.resources.IProject, boolean) */ ! public void setProject(IProject project, boolean restoreDeltas){ this.project = project; ! this.nature = PythonNature.getPythonNature(project); this.deltaSaver = new DeltaSaver<ModulesKey>(this.nature.getCompletionsCacheDir(), "astdelta", new ICallback<Object, ObjectInputStream>(){ --- 72,78 ---- * @see org.python.pydev.core.IProjectModulesManager#setProject(org.eclipse.core.resources.IProject, boolean) */ ! public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas){ this.project = project; ! this.nature = nature; this.deltaSaver = new DeltaSaver<ModulesKey>(this.nature.getCompletionsCacheDir(), "astdelta", new ICallback<Object, ObjectInputStream>(){ *************** *** 189,193 **** IInterpreterManager iMan = PydevPlugin.getInterpreterManager(nature); if(defaultSelectedInterpreter == null){ ! defaultSelectedInterpreter = iMan.getDefaultInterpreter(); } InterpreterInfo info = (InterpreterInfo) iMan.getInterpreterInfo(defaultSelectedInterpreter, new NullProgressMonitor()); --- 192,200 ---- IInterpreterManager iMan = PydevPlugin.getInterpreterManager(nature); if(defaultSelectedInterpreter == null){ ! try { ! defaultSelectedInterpreter = iMan.getDefaultInterpreter(); ! } catch (NotConfiguredInterpreterException e) { ! return null; //not configured ! } } InterpreterInfo info = (InterpreterInfo) iMan.getInterpreterInfo(defaultSelectedInterpreter, new NullProgressMonitor()); *************** *** 414,418 **** if(systemModulesManager == null){ //may happen in initialization ! PydevPlugin.log("System modules manager still not available (still initializing)."); return new IModulesManager[]{}; } --- 421,425 ---- if(systemModulesManager == null){ //may happen in initialization ! // PydevPlugin.log("System modules manager still not available (still initializing or not set)."); return new IModulesManager[]{}; } *************** *** 490,493 **** --- 497,502 ---- list.add((IModulesManager) projectModulesManager); } + }else{ + Log.log(IStatus.WARNING, "No ast manager configured for :"+project.getName(), null); } } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:29
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src_navigator/org/python/pydev/navigator/actions Modified Files: PyRenameResourceAction.java PyMoveResourceAction.java PyCopyResourceAction.java PyPasteAction.java PyDeleteResourceAction.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PyPasteAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyPasteAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyPasteAction.java 24 Mar 2007 11:48:29 -0000 1.2 --- PyPasteAction.java 31 Jul 2008 01:47:36 -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.dnd.Clipboard; import org.eclipse.swt.widgets.Shell; *************** *** 67,70 **** --- 68,77 ---- } + @Override + public IStructuredSelection getStructuredSelection() { + return new StructuredSelection(selected); + } + + /* * (non-Javadoc) Method declared on IAction. Index: PyDeleteResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyDeleteResourceAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyDeleteResourceAction.java 12 May 2008 11:43:00 -0000 1.3 --- PyDeleteResourceAction.java 31 Jul 2008 01:47:36 -0000 1.4 *************** *** 72,84 **** - @Override - public IStructuredSelection getStructuredSelection() { - ISelection selection = provider.getSelection(); - if (!selection.isEmpty()) { - IStructuredSelection sSelection = (IStructuredSelection) selection; - return sSelection; - } - return new StructuredSelection(); - } @Override --- 72,75 ---- *************** *** 87,90 **** --- 78,87 ---- } + @Override + public IStructuredSelection getStructuredSelection() { + return new StructuredSelection(selected); + } + + /* * (non-Javadoc) Method declared on IAction. Index: PyCopyResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyCopyResourceAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCopyResourceAction.java 24 Mar 2007 11:48:29 -0000 1.2 --- PyCopyResourceAction.java 31 Jul 2008 01:47:36 -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.dnd.Clipboard; import org.eclipse.swt.widgets.Shell; *************** *** 66,69 **** --- 67,75 ---- } + @Override + public IStructuredSelection getStructuredSelection() { + return new StructuredSelection(selected); + } + /* * (non-Javadoc) Method declared on IAction. Index: PyRenameResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyRenameResourceAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyRenameResourceAction.java 10 Mar 2007 14:32:43 -0000 1.1 --- PyRenameResourceAction.java 31 Jul 2008 01:47:36 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- 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.RenameResourceAction; *************** *** 112,115 **** --- 113,121 ---- } + @Override + public IStructuredSelection getStructuredSelection() { + return new StructuredSelection(selected); + } + /* * (non-Javadoc) Method declared on IAction. Index: PyMoveResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyMoveResourceAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyMoveResourceAction.java 24 Mar 2007 11:48:29 -0000 1.2 --- PyMoveResourceAction.java 31 Jul 2008 01:47:36 -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.MoveResourceAction; *************** *** 65,68 **** --- 66,74 ---- } + @Override + public IStructuredSelection getStructuredSelection() { + return new StructuredSelection(selected); + } + /* * (non-Javadoc) Method declared on IAction. |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src/org/python/pydev/plugin/nature Modified Files: PythonNatureStore.java PythonPathNature.java PythonNature.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNature.java,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** PythonNature.java 28 Feb 2008 01:44:48 -0000 1.66 --- PythonNature.java 31 Jul 2008 01:47:36 -0000 1.67 *************** *** 11,15 **** --- 11,17 ---- import java.util.ArrayList; import java.util.Arrays; + import java.util.HashMap; import java.util.List; + import java.util.Map; import org.eclipse.core.resources.ICommand; *************** *** 62,76 **** */ protected class RebuildPythonNatureModules extends Job { ! private String paths; ! ! private String defaultSelectedInterpreter; ! ! private PythonNature nature; ! protected RebuildPythonNatureModules(String name, String paths, String defaultSelectedInterpreter, PythonNature nature) { ! super(name); ! this.paths = paths; ! this.defaultSelectedInterpreter = defaultSelectedInterpreter; ! this.nature = nature; } --- 64,77 ---- */ protected class RebuildPythonNatureModules extends Job { ! private String submittedPaths; ! private String submittedInterpreter; ! protected RebuildPythonNatureModules() { ! super("Python Nature: rebuilding modules"); ! } ! ! public synchronized void setParams(String paths, String defaultSelectedInterpreter) { ! submittedPaths = paths; ! submittedInterpreter = defaultSelectedInterpreter; } *************** *** 78,81 **** --- 79,88 ---- protected IStatus run(IProgressMonitor monitorArg) { + String paths, defaultSelectedInterpreter; + synchronized (this) { + paths = submittedPaths; + defaultSelectedInterpreter = submittedInterpreter; + } + try { JobProgressComunicator jobProgressComunicator = new JobProgressComunicator(monitorArg, "Rebuilding modules", IProgressMonitor.UNKNOWN, this); *************** *** 87,91 **** synchronized(tempAstManager){ astManager = tempAstManager; ! tempAstManager.setProject(getProject(), false); //it is a new manager, so, remove all deltas //begins task automatically --- 94,98 ---- synchronized(tempAstManager){ astManager = tempAstManager; ! tempAstManager.setProject(getProject(), PythonNature.this, false); //it is a new manager, so, remove all deltas //begins task automatically *************** *** 96,100 **** for (IInterpreterObserver observer : participants) { try { ! observer.notifyProjectPythonpathRestored(nature, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { //let's keep it safe --- 103,107 ---- for (IInterpreterObserver observer : participants) { try { ! observer.notifyProjectPythonpathRestored(PythonNature.this, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { //let's keep it safe *************** *** 108,118 **** initializationFinished = true; ! PythonNatureListenersManager.notifyPythonPathRebuilt(project, nature.pythonPathNature.getCompleteProjectPythonPath(null)); //default //end task jobProgressComunicator.done(); }catch (Exception e) { Log.log(e); - } finally { - rebuildJob = null; } return Status.OK_STATUS; --- 115,123 ---- initializationFinished = true; ! PythonNatureListenersManager.notifyPythonPathRebuilt(project, PythonNature.this.pythonPathNature.getCompleteProjectPythonPath(null)); //default //end task jobProgressComunicator.done(); }catch (Exception e) { Log.log(e); } return Status.OK_STATUS; *************** *** 200,203 **** --- 205,210 ---- return project; } + + private static Map<IProject, Job> jobs = new HashMap<IProject, Job>(); /** *************** *** 206,213 **** * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) */ ! public void setProject(IProject project) { ! this.getStore().setProject(project); ! this.pythonPathNature.setProject(project); ! this.project = project; } --- 213,252 ---- * @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject) */ ! public void setProject(final IProject project) { ! getStore().setProject(project); ! this.project = project; ! this.pythonPathNature.setProject(project, this); ! ! if(project != null && !initializationStarted && !initializationFinished){ ! synchronized (jobs) { ! Job job = jobs.get(project); ! if(job != null){ ! job.cancel(); ! } ! job = new Job("PyDev: Restoring projects python nature") { ! ! protected IStatus run(IProgressMonitor monitor) { ! try { ! if(monitor.isCanceled()){ ! return Status.OK_STATUS; ! } ! init(null, null, monitor); ! synchronized (jobs) { ! if(jobs.get(project) == this){ ! jobs.remove(project); ! } ! } ! } catch (Throwable t) { ! PydevPlugin.log(t); ! } ! return Status.OK_STATUS; ! } ! ! }; ! jobs.put(project, job); ! job.schedule(250L); //wait to see if we've more than 1 request. ! } ! } ! } *************** *** 248,252 **** try { //we have to remove the project from the pythonpath nature too... ! nature.pythonPathNature.setProject(null); } catch (Exception e) { PydevPlugin.log(e); --- 287,291 ---- try { //we have to remove the project from the pythonpath nature too... ! nature.pythonPathNature.setProject(null, null); } catch (Exception e) { PydevPlugin.log(e); *************** *** 319,323 **** } ! IProjectNature n = project.getNature(PYTHON_NATURE_ID); if (n instanceof PythonNature) { PythonNature nature = (PythonNature) n; --- 358,362 ---- } ! IProjectNature n = getPythonNature(project); if (n instanceof PythonNature) { PythonNature nature = (PythonNature) n; *************** *** 353,424 **** @SuppressWarnings("unchecked") private void init(String version, String projectPythonpath, IProgressMonitor monitor) { ! synchronized (this) { ! if(version != null || projectPythonpath != null){ ! this.getStore().startInit(); ! try { ! if(projectPythonpath != null){ ! this.getPythonPathNature().setProjectSourcePath(projectPythonpath); ! } ! if(version != null){ ! this.setVersion(version); ! } ! } catch (CoreException e) { ! PydevPlugin.log(e); ! }finally{ ! this.getStore().endInit(); ! } ! }else{ ! //Change: 1.3.10: it could be reloaded more than once... (when it shouldn't) ! if(astManager != null){ ! return; //already initialized... ! } ! } ! ! final PythonNature nature = this; ! if (initializationStarted == false) { ! initializationStarted = true; ! ! //Change: 1.3.10: no longer in a Job... should already be called in a job if that's needed. ! ! try { ! astManager = (ICodeCompletionASTManager) ASTManager.loadFromFile(getAstOutputFile()); ! if (astManager != null) { ! synchronized (astManager) { ! astManager.setProject(getProject(), true); // this is the project related to it, restore the deltas (we may have some crash) ! ! //just a little validation so that we restore the needed info if we did not get the modules ! if (astManager.getModulesManager().getOnlyDirectModules().length < 5) { ! astManager = null; ! } ! ! if (astManager != null) { ! List<IInterpreterObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_INTERPRETER_OBSERVER); ! for (IInterpreterObserver observer : participants) { ! try { ! observer.notifyNatureRecreated(nature, monitor); ! } catch (Exception e) { ! //let's not fail because of other plugins ! PydevPlugin.log(e); ! } ! } ! } ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! astManager = null; } ! ! //errors can happen when restoring it ! if(astManager == null){ ! try { ! rebuildPath(null, monitor); ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } ! initializationFinished = true; } } } --- 392,461 ---- @SuppressWarnings("unchecked") private void init(String version, String projectPythonpath, IProgressMonitor monitor) { ! if(version != null || projectPythonpath != null){ ! this.getStore().startInit(); ! try { ! if(projectPythonpath != null){ ! this.getPythonPathNature().setProjectSourcePath(projectPythonpath); } ! if(version != null){ ! this.setVersion(version); ! } ! } catch (CoreException e) { ! PydevPlugin.log(e); ! }finally{ ! this.getStore().endInit(); ! } ! }else{ ! //Change: 1.3.10: it could be reloaded more than once... (when it shouldn't) ! if(astManager != null){ ! return; //already initialized... ! } ! } ! ! if(initializationStarted || monitor.isCanceled()){ ! return; ! } ! ! initializationStarted = true; ! //Change: 1.3.10: no longer in a Job... should already be called in a job if that's needed. ! ! try { ! astManager = (ICodeCompletionASTManager) ASTManager.loadFromFile(getAstOutputFile()); ! if (astManager != null) { ! synchronized (astManager) { ! astManager.setProject(getProject(), this, true); // this is the project related to it, restore the deltas (we may have some crash) ! ! //just a little validation so that we restore the needed info if we did not get the modules ! if (astManager.getModulesManager().getOnlyDirectModules().length < 5) { ! astManager = null; ! } ! ! if (astManager != null) { ! List<IInterpreterObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_INTERPRETER_OBSERVER); ! for (IInterpreterObserver observer : participants) { ! try { ! observer.notifyNatureRecreated(this, monitor); ! } catch (Exception e) { ! //let's not fail because of other plugins ! PydevPlugin.log(e); ! } ! } ! } ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! astManager = null; ! } ! ! //errors can happen when restoring it ! if(astManager == null){ ! try { ! rebuildPath(null, monitor); ! } catch (Exception e) { ! PydevPlugin.log(e); } } + initializationFinished = true; } *************** *** 470,474 **** ! private volatile Job rebuildJob; /** --- 507,511 ---- ! private RebuildPythonNatureModules rebuildJob = new RebuildPythonNatureModules(); /** *************** *** 476,486 **** */ private synchronized void rebuildPath(final String defaultSelectedInterpreter, final String paths) { ! if(rebuildJob != null){ ! return;//already in rebuild ! } ! final PythonNature nature = this; ! rebuildJob = new RebuildPythonNatureModules("Python Nature: rebuilding modules", paths, defaultSelectedInterpreter, nature); ! rebuildJob.schedule(); } /** --- 513,521 ---- */ private synchronized void rebuildPath(final String defaultSelectedInterpreter, final String paths) { ! rebuildJob.cancel(); ! rebuildJob.setParams(paths, defaultSelectedInterpreter); ! rebuildJob.schedule(20L); } + /** *************** *** 545,550 **** } return getPythonNature(resource.getProject()); - } /** * @param project the project we want to know about (if it is null, null is returned) --- 580,586 ---- } return getPythonNature(resource.getProject()); } + + /** * @param project the project we want to know about (if it is null, null is returned) Index: PythonPathNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonPathNature.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** PythonPathNature.java 15 Jun 2008 17:39:16 -0000 1.29 --- PythonPathNature.java 31 Jul 2008 01:47:36 -0000 1.30 *************** *** 20,29 **** --- 20,32 ---- import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; + import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.python.pydev.core.ExtensionHelper; import org.python.pydev.core.IModulesManager; + import org.python.pydev.core.IPythonNature; import org.python.pydev.core.IPythonPathNature; import org.python.pydev.core.REF; + import org.python.pydev.core.log.Log; import org.python.pydev.core.structure.FastStringBuffer; import org.python.pydev.plugin.PydevPlugin; *************** *** 36,39 **** --- 39,43 ---- private IProject project; + private PythonNature nature; *************** *** 60,65 **** ! public void setProject(IProject project){ this.project = project; if(project == null){ this.projectSourcePathSet = null;//empty --- 64,70 ---- ! public void setProject(IProject project, IPythonNature nature){ this.project = project; + this.nature = (PythonNature) nature; if(project == null){ this.projectSourcePathSet = null;//empty *************** *** 86,91 **** return null; } - PythonNature nature = PythonNature.getPythonNature(project); - if(nature == null) { return null; --- 91,94 ---- *************** *** 123,126 **** --- 126,137 ---- if(strings[i].trim().length()>0){ IPath p = new Path(strings[i]); + + if(ResourcesPlugin.getPlugin() == null){ + //in tests + buf.append(strings[i]); + buf.append("|"); + continue; + } + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); *************** *** 149,155 **** }else{ ! //not in workspace?... maybe it was removed, so, do nothing, but let the user know about it ! PydevPlugin.log("Unable to find the path "+strings[i]+" in the project were it's \n" + ! "added as a source folder for pydev (project: "+project.getName()+") member:"+r); } } --- 160,175 ---- }else{ ! if(root.isSynchronized(IResource.DEPTH_INFINITE)){ ! //if it's synchronized, it really doesn't exist (let's warn about it) ! //not in workspace?... maybe it was removed, so, do nothing, but let the user know about it ! Log.log(IStatus.WARNING, "Unable to find the path "+strings[i]+" in the project were it's \n" + ! "added as a source folder for pydev (project: "+project.getName()+") member:"+r, null); ! } ! ! IPath rootLocation = root.getRawLocation(); ! //still, let's add it there (this'll be cached for later use) ! buf.append(REF.getFileAbsolutePath(rootLocation.append(strings[i].trim()).toFile())); ! buf.append("|"); ! } } *************** *** 192,196 **** synchronized(project){ projectSourcePathSet = null; - PythonNature nature = PythonNature.getPythonNature(project); nature.getStore().setPathProperty(PythonPathNature.getProjectSourcePathQualifiedName(), newSourcePath); } --- 212,215 ---- *************** *** 199,203 **** public void setProjectExternalSourcePath(String newExternalSourcePath) throws CoreException { synchronized(project){ - PythonNature nature = PythonNature.getPythonNature(project); nature.getStore().setPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName(), newExternalSourcePath); } --- 218,221 ---- *************** *** 227,231 **** synchronized(project){ boolean restore = false; - PythonNature nature = PythonNature.getPythonNature(project); String projectSourcePath = nature.getStore().getPathProperty(PythonPathNature.getProjectSourcePathQualifiedName()); if(projectSourcePath == null){ --- 245,248 ---- *************** *** 244,248 **** } IPath projectPath = project.getFullPath(); ! if(!projectPath.isPrefixOf(p)){ p = p.removeFirstSegments(1); p = projectPath.append(p); --- 261,265 ---- } IPath projectPath = project.getFullPath(); ! if(projectPath != null && !projectPath.isPrefixOf(p)){ p = p.removeFirstSegments(1); p = projectPath.append(p); *************** *** 275,279 **** synchronized(project){ //no need to validate because those are always 'file-system' related - PythonNature nature = PythonNature.getPythonNature(project); String extPath = nature.getStore().getPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName()); if(extPath == null){ --- 292,295 ---- Index: PythonNatureStore.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNatureStore.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PythonNatureStore.java 19 Jul 2008 20:18:14 -0000 1.20 --- PythonNatureStore.java 31 Jul 2008 01:47:36 -0000 1.21 *************** *** 9,16 **** import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; - import java.util.Collections; - import java.util.LinkedList; import java.util.List; --- 9,15 ---- import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; + import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; *************** *** 26,30 **** import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; - import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; --- 25,28 ---- *************** *** 33,42 **** import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; ! import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; - import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; ! import org.eclipse.core.runtime.jobs.Job; import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.structure.FastStringBuffer; --- 31,39 ---- import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; ! import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; ! import org.python.pydev.core.REF; import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.structure.FastStringBuffer; *************** *** 60,96 **** class PythonNatureStore implements IResourceChangeListener, IPythonNatureStore { - /** - * This is the class that does the store job. - * - * @author Fabio - */ - private final class PythonNatureStoreJob extends Job { - - private PythonNatureStoreJob(String name) { - super(name); - } - @Override - protected IStatus run(IProgressMonitor monitor) { - synchronized(saveLock){ - ByteArrayInputStream is = (ByteArrayInputStream)pydevprojectStreams.remove(0); // remove() when it becomes queue - try{ - onIgnoreRefresh++; - if (!xmlFile.exists()) { - xmlFile.create(is, true, monitor); - } else { - xmlFile.setContents(is, true, false, monitor); - } - modStamp = xmlFile.getModificationStamp(); - xmlFile.refreshLocal(IResource.DEPTH_ZERO, monitor); - }catch(Exception e){ - PydevPlugin.log(e); - }finally{ - onIgnoreRefresh--; - } - } - return Status.OK_STATUS; - } - } private final static String STORE_FILE_NAME = ".pydevproject"; --- 57,61 ---- *************** *** 108,128 **** private volatile IProject project = null; - private volatile IFile xmlFile = null; - - private volatile long modStamp = IFile.NULL_STAMP; - - private volatile int onIgnoreRefresh = 0; - - private final Object saveLock = new Object(); - - // use Queue and ConcurrentLinkedQueue with 1.5 - private final List<ByteArrayInputStream> pydevprojectStreams = - Collections.synchronizedList(new LinkedList<ByteArrayInputStream>()); - /** ! * 0 means we're not in a store job */ ! private volatile int onStoreJob = 0; /** * Whether the file has already been loaded --- 73,84 ---- private volatile IProject project = null; /** ! * We have an IFile, but the access is mostly through the actual File (because we don't want to deal with any refresh ! * from eclipse and its caching mechanism) */ ! private volatile IFile xmlFile = null; + private volatile String lastLoadedContents = null; + /** * Whether the file has already been loaded *************** *** 136,139 **** --- 92,96 ---- private static final boolean TRACE_PYTHON_NATURE_STORE = false; + private StringBuffer indent = new StringBuffer(); *************** *** 200,208 **** */ private synchronized void checkLoad(String function) { ! traceFunc("checkLoad"); ! if(!loaded){ ! PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); ! } ! traceFunc("END checkLoad"); } --- 157,163 ---- */ private synchronized void checkLoad(String function) { ! if(!loaded){ ! PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); ! } } *************** *** 214,222 **** return ""; } ! traceFunc("getPathProperty - ", key); ! checkLoad("getPathProperty"); ! String ret = getPathStringFromArray(getPathPropertyFromXml(key)); ! traceFunc("END getPathProperty - ", ret); ! return ret; } --- 169,176 ---- return ""; } ! checkLoad("getPathProperty"); ! String ret = getPathStringFromArray(getPathPropertyFromXml(key)); ! traceFunc("END getPathProperty - ", key, ret); ! return ret; } *************** *** 225,232 **** */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! traceFunc("setPathProperty"); ! checkLoad("setPathProperty"); ! setPathPropertyToXml(key, getArrayFromPathString(value), true); ! traceFunc("END setPathProperty"); } --- 179,184 ---- */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! checkLoad("setPathProperty"); ! setPathPropertyToXml(key, getArrayFromPathString(value), true); } *************** *** 240,298 **** private synchronized boolean loadFromFile() throws CoreException { if(this.project == null){ ! return false; //deconfigured... } traceFunc("loadFromFile"); ! boolean ret; ! try { ! DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); ! try{ ! onIgnoreRefresh++; ! xmlFile.refreshLocal(IResource.DEPTH_ZERO, null); ! }finally{ ! onIgnoreRefresh--; ! } ! if (!xmlFile.exists()) { ! if (document != null) { ! // Someone removed the project descriptor, store it from the memory model ! doStore(); ! ret = true; ! } else { ! // The document never existed ! document = parser.newDocument(); ! ProcessingInstruction version = document.createProcessingInstruction("eclipse-pydev", "version=\"1.0\""); //$NON-NLS-1$ //$NON-NLS-2$ ! document.appendChild(version); ! Element configRootElement = document.createElement(PYDEV_PROJECT_DESCRIPTION); ! document.appendChild(configRootElement); ! ! migrateProperty(PythonNature.getPythonProjectVersionQualifiedName()); ! migratePath(PythonPathNature.getProjectSourcePathQualifiedName()); ! migratePath(PythonPathNature.getProjectExternalSourcePathQualifiedName()); ! doStore(); ! ret = true; ! } } else { ! try{ ! onIgnoreRefresh++; ! xmlFile.refreshLocal(0, new NullProgressMonitor()); ! }catch(Exception e){ ! PydevPlugin.log(e); ! }finally{ ! onIgnoreRefresh--; ! } ! document = parser.parse(xmlFile.getContents()); ! modStamp = xmlFile.getModificationStamp(); ! ret = true; } ! } catch (Exception e) { ! e.printStackTrace(); ! IStatus status = new Status(IStatus.ERROR, "PythonNatureStore", -1, e.toString(), e); ! throw new CoreException(status); } ! traceFunc("END loadFromFile"); ! return ret; } private synchronized void migrateProperty(QualifiedName key) throws CoreException { traceFunc("migrateProperty"); --- 192,254 ---- private synchronized boolean loadFromFile() throws CoreException { if(this.project == null){ ! return false; //not configured... } traceFunc("loadFromFile"); ! ! try { ! DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); ! ! File file = getRawXmlFileLocation(); ! ! if (file == null || !file.exists()) { ! if (document != null) { ! // Someone removed the project descriptor, store it from the memory model ! doStore(); ! return true; } else { ! // The document never existed (create the default) ! document = parser.newDocument(); ! ProcessingInstruction version = document.createProcessingInstruction("eclipse-pydev", "version=\"1.0\""); //$NON-NLS-1$ //$NON-NLS-2$ ! document.appendChild(version); ! Element configRootElement = document.createElement(PYDEV_PROJECT_DESCRIPTION); ! document.appendChild(configRootElement); ! ! migrateProperty(PythonNature.getPythonProjectVersionQualifiedName()); ! migratePath(PythonPathNature.getProjectSourcePathQualifiedName()); ! migratePath(PythonPathNature.getProjectExternalSourcePathQualifiedName()); ! doStore(); ! return true; } ! } else { ! String fileContents = REF.getFileContents(file); ! if(lastLoadedContents != null && fileContents.equals(lastLoadedContents)){ ! return false; ! } ! lastLoadedContents = fileContents; ! document = parser.parse(new ByteArrayInputStream(fileContents.getBytes())); ! return true; } ! } catch (Exception e) { ! PydevPlugin.log("Error loading contents from .pydevproject", e); ! } ! traceFunc("END loadFromFile"); ! return false; } + + /** + * @return the actual file from the IFile we have + */ + private File getRawXmlFileLocation() { + IPath rawLocation = xmlFile.getRawLocation(); + File file = null; + if(rawLocation != null){ + file = rawLocation.toFile(); + } + return file; + } + private synchronized void migrateProperty(QualifiedName key) throws CoreException { traceFunc("migrateProperty"); *************** *** 310,321 **** private synchronized void migratePath(QualifiedName key) throws CoreException { traceFunc("migratePath"); ! // Try to migrate from persistent property ! String[] propertyVal = getArrayFromPathString(project.getPersistentProperty(key)); ! if (propertyVal != null) { ! // set in the xml ! setPathPropertyToXml(key, propertyVal, false); ! // and remove from the project ! project.setPersistentProperty(key, (String) null); ! } traceFunc("END migratePath"); } --- 266,277 ---- private synchronized void migratePath(QualifiedName key) throws CoreException { traceFunc("migratePath"); ! // Try to migrate from persistent property ! String[] propertyVal = getArrayFromPathString(project.getPersistentProperty(key)); ! if (propertyVal != null) { ! // set in the xml ! setPathPropertyToXml(key, propertyVal, false); ! // and remove from the project ! project.setPersistentProperty(key, (String) null); ! } traceFunc("END migratePath"); } *************** *** 329,345 **** private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); ! NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); ! Node ret = null; ! if (nodeList != null && nodeList.getLength() > 0) { ! ret = nodeList.item(0); ! } ! ! traceFunc("END getRootNodeInXml -- ", ret); ! if(ret != null){ ! return ret; ! } ! throw new RuntimeException(StringUtils.format("Error. Unable to get the %s tag by its name. Project: %s", PYDEV_PROJECT_DESCRIPTION, project)); } /** --- 285,301 ---- private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); ! NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); ! Node ret = null; ! if (nodeList != null && nodeList.getLength() > 0) { ! ret = nodeList.item(0); ! } ! ! traceFunc("END getRootNodeInXml -- ", ret); ! if(ret != null){ ! return ret; } + throw new RuntimeException(StringUtils.format("Error. Unable to get the %s tag by its name. Project: %s", PYDEV_PROJECT_DESCRIPTION, project)); + } /** *************** *** 351,359 **** private synchronized String getKeyString(QualifiedName key) { traceFunc("getKeyString"); ! String keyString = key.getQualifier() != null ? key.getQualifier() : ""; ! String ret = keyString + "." + key.getLocalName(); ! traceFunc("END getKeyString"); ! return ret; ! } /** --- 307,315 ---- private synchronized String getKeyString(QualifiedName key) { traceFunc("getKeyString"); ! String keyString = key.getQualifier() != null ? key.getQualifier() : ""; ! String ret = keyString + "." + key.getLocalName(); ! traceFunc("END getKeyString"); ! return ret; ! } /** *************** *** 367,391 **** private synchronized Node findPropertyNodeInXml(String type, QualifiedName key) { traceFunc("findPropertyNodeInXml"); ! Node root = getRootNodeInXml(); ! NodeList childNodes = root.getChildNodes(); ! if (childNodes != null && childNodes.getLength() > 0) { ! String keyString = getKeyString(key); ! for (int i = 0; i < childNodes.getLength(); i++) { ! Node child = childNodes.item(i); ! if (child.getNodeName().equals(type)) { ! NamedNodeMap attrs = child.getAttributes(); ! if (attrs != null && attrs.getLength() > 0) { ! String name = attrs.getNamedItem(PYDEV_NATURE_PROPERTY_NAME).getNodeValue(); ! if (name != null && name.equals(keyString)) { ! traceFunc("END findPropertyNodeInXml - ", child); ! return child; ! } } } } } - traceFunc("END findPropertyNodeInXml (null)"); - return null; } /** --- 323,347 ---- private synchronized Node findPropertyNodeInXml(String type, QualifiedName key) { traceFunc("findPropertyNodeInXml"); ! Node root = getRootNodeInXml(); ! NodeList childNodes = root.getChildNodes(); ! if (childNodes != null && childNodes.getLength() > 0) { ! String keyString = getKeyString(key); ! for (int i = 0; i < childNodes.getLength(); i++) { ! Node child = childNodes.item(i); ! if (child.getNodeName().equals(type)) { ! NamedNodeMap attrs = child.getAttributes(); ! if (attrs != null && attrs.getLength() > 0) { ! String name = attrs.getNamedItem(PYDEV_NATURE_PROPERTY_NAME).getNodeValue(); ! if (name != null && name.equals(keyString)) { ! traceFunc("END findPropertyNodeInXml - ", child); ! return child; } } } } } + traceFunc("END findPropertyNodeInXml (null)"); + return null; + } /** *************** *** 398,417 **** private String[] getChildValuesWithType(Node node, String type) { traceFunc("getChildValuesWithType"); ! NodeList childNodes = node.getChildNodes(); ! if (childNodes != null && childNodes.getLength() > 0) { ! List<String> result = new ArrayList<String>(); ! for (int i = 0; i < childNodes.getLength(); i++) { ! Node child = childNodes.item(i); ! if (child.getNodeName().equals(type)) { ! result.add(getTextContent(child)); ! } } - String[] retval = new String[result.size()]; - traceFunc("END getChildValuesWithType"); - return result.toArray(retval); } ! traceFunc("END getChildValuesWithType (null)"); ! return null; } /** --- 354,373 ---- private String[] getChildValuesWithType(Node node, String type) { traceFunc("getChildValuesWithType"); ! NodeList childNodes = node.getChildNodes(); ! if (childNodes != null && childNodes.getLength() > 0) { ! List<String> result = new ArrayList<String>(); ! for (int i = 0; i < childNodes.getLength(); i++) { ! Node child = childNodes.item(i); ! if (child.getNodeName().equals(type)) { ! result.add(getTextContent(child)); } } ! String[] retval = new String[result.size()]; ! traceFunc("END getChildValuesWithType"); ! return result.toArray(retval); } + traceFunc("END getChildValuesWithType (null)"); + return null; + } /** *************** *** 424,435 **** private void addChildValuesWithType(Node node, String type, String[] values) { traceFunc("addChildValuesWithType"); ! assert (node != null); ! assert (values != null); ! assert (type != null); ! for (int i = 0; i < values.length; i++) { ! Node child = document.createElement(type); ! setTextContent(values[i], child); ! node.appendChild(child); ! } traceFunc("END addChildValuesWithType"); } --- 380,391 ---- private void addChildValuesWithType(Node node, String type, String[] values) { traceFunc("addChildValuesWithType"); ! assert (node != null); ! assert (values != null); ! assert (type != null); ! for (int i = 0; i < values.length; i++) { ! Node child = document.createElement(type); ! setTextContent(values[i], child); ! node.appendChild(child); ! } traceFunc("END addChildValuesWithType"); } *************** *** 443,459 **** private String getPathStringFromArray(String[] pathArray) { traceFunc("getPathStringFromArray"); ! if (pathArray != null) { ! FastStringBuffer s = new FastStringBuffer(); ! for (int i = 0; i < pathArray.length; i++) { ! if (i > 0) { ! s.append('|'); ! } ! s.append(pathArray[i]); } ! traceFunc("END getPathStringFromArray"); ! return s.toString(); } ! traceFunc("END getPathStringFromArray (null)"); ! return null; } --- 399,415 ---- private String getPathStringFromArray(String[] pathArray) { traceFunc("getPathStringFromArray"); ! if (pathArray != null) { ! FastStringBuffer s = new FastStringBuffer(); ! for (int i = 0; i < pathArray.length; i++) { ! if (i > 0) { ! s.append('|'); } ! s.append(pathArray[i]); } ! traceFunc("END getPathStringFromArray"); ! return s.toString(); ! } ! traceFunc("END getPathStringFromArray (null)"); ! return null; } *************** *** 523,527 **** setTextContent(value, child); } - doStore(); } else if (value != null) { // The property is not in the file and we need to set it --- 479,482 ---- *************** *** 533,541 **** getRootNodeInXml().appendChild(property); ! if (store) { ! doStore(); ! } } } catch (Exception e) { traceFunc("END setPropertyToXml (EXCEPTION)"); --- 488,499 ---- getRootNodeInXml().appendChild(property); ! }else{ ! store = false; } + if (store) { + doStore(); + } + } catch (Exception e) { traceFunc("END setPropertyToXml (EXCEPTION)"); *************** *** 553,565 **** private void setTextContent(String textContent, Node self) throws DOMException { traceFunc("setTextContent"); ! // get rid of any existing children ! Node child; ! while ((child = self.getFirstChild()) != null) { ! self.removeChild(child); ! } ! // create a Text node to hold the given content ! if (textContent != null && textContent.length() != 0) { ! self.appendChild(document.createTextNode(textContent)); ! } traceFunc("END setTextContent"); } --- 511,523 ---- private void setTextContent(String textContent, Node self) throws DOMException { traceFunc("setTextContent"); ! // get rid of any existing children ! Node child; ! while ((child = self.getFirstChild()) != null) { ! self.removeChild(child); ! } ! // create a Text node to hold the given content ! if (textContent != null && textContent.length() != 0) { ! self.appendChild(document.createTextNode(textContent)); ! } traceFunc("END setTextContent"); } *************** *** 568,593 **** private String getTextContent(Node self) throws DOMException { traceFunc("getTextContent"); ! FastStringBuffer fBufferStr = new FastStringBuffer(); ! Node child = self.getFirstChild(); ! if (child != null) { ! Node next = child.getNextSibling(); ! if (next == null) { ! if(hasTextContent(child)){ ! String nodeValue = child.getNodeValue(); ! if(nodeValue != null){ ! traceFunc("END getTextContent - ", nodeValue); ! return nodeValue; ! } } - traceFunc("END getTextContent - EMPTY"); - return ""; } ! fBufferStr.clear(); ! getTextContent(fBufferStr, self); ! traceFunc("END getTextContent - ", fBufferStr); ! return fBufferStr.toString(); } ! traceFunc("END getTextContent - EMPTY"); ! return ""; } --- 526,551 ---- private String getTextContent(Node self) throws DOMException { traceFunc("getTextContent"); ! FastStringBuffer fBufferStr = new FastStringBuffer(); ! Node child = self.getFirstChild(); ! if (child != null) { ! Node next = child.getNextSibling(); ! if (next == null) { ! if(hasTextContent(child)){ ! String nodeValue = child.getNodeValue(); ! if(nodeValue != null){ ! traceFunc("END getTextContent - ", nodeValue); ! return nodeValue; } } ! traceFunc("END getTextContent - EMPTY"); ! return ""; } ! fBufferStr.clear(); ! getTextContent(fBufferStr, self); ! traceFunc("END getTextContent - ", fBufferStr); ! return fBufferStr.toString(); ! } ! traceFunc("END getTextContent - EMPTY"); ! return ""; } *************** *** 611,618 **** private boolean hasTextContent(Node child) { traceFunc("hasTextContent"); ! boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; ! traceFunc("END hasTextContent ", ret); ! return ret; } --- 569,578 ---- private boolean hasTextContent(Node child) { traceFunc("hasTextContent"); ! ! boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; ! ! traceFunc("END hasTextContent ", ret); ! return ret; } *************** *** 661,665 **** if (oldChild != null && paths == null) { getRootNodeInXml().removeChild(oldChild); - doStore(); } else if (paths != null) { // The property is not in the file and we need to set it --- 621,624 ---- *************** *** 674,680 **** getRootNodeInXml().replaceChild(property, oldChild); } ! if (store) { ! doStore(); ! } } --- 633,642 ---- getRootNodeInXml().replaceChild(property, oldChild); } ! }else{ ! store = false; ! } ! ! if (store) { ! doStore(); } *************** *** 716,735 **** } ! /** ! * Stores the internal Xml representation as a project resource. ! * ! */ ! private synchronized void doStore() { ! traceFunc("doStore"); ! synchronized (this) { ! try { ! doStore(new NullProgressMonitor()); ! } catch (Exception e) { ! throw new RuntimeException("Error storing pydev project descriptor:"+project, e); ! } ! } ! traceFunc("END doStore"); ! } ! public void resourceChanged(IResourceChangeEvent event) { if(project == null){ --- 678,682 ---- } ! public void resourceChanged(IResourceChangeEvent event) { if(project == null){ *************** *** 744,759 **** //not synched -- called when a file is changed boolean doRebuild = false; - if (onIgnoreRefresh != 0) { - traceFunc("END resourceChanged (on ignore refresh)"); - return; - } - - if (onStoreJob != 0) { - traceFunc("END resourceChanged (on store)"); - return; // we're on a store job from the store itself, this means that we must - // call the rebuildPath programatically (and that the resource change - // is actually already reflected in our document and file) - } - if(!project.isOpen()){ traceFunc("END resourceChanged (!open)"); --- 691,694 ---- *************** *** 769,781 **** IResourceDelta delta = eventDelta.findMember(xmlFile.getFullPath()); if (delta != null) { ! if (xmlFile.getModificationStamp() != modStamp) { ! try { ! if (loadFromFile()) { ! doRebuild = true; ! } ! } catch (CoreException e) { ! traceFunc("END resourceChanged (EXCEPTION)"); ! throw new RuntimeException(e); } } } --- 704,714 ---- IResourceDelta delta = eventDelta.findMember(xmlFile.getFullPath()); if (delta != null) { ! try { ! if (loadFromFile()) { //it'll only return true if the contents really changed. ! doRebuild = true; } + } catch (CoreException e) { + traceFunc("END resourceChanged (EXCEPTION)"); + throw new RuntimeException(e); } } *************** *** 792,796 **** * This is the function that actually stores the contents of the xml into the file with the configurations. */ ! private synchronized IStatus doStore(IProgressMonitor monitor) throws IOException, TransformerException, CoreException { if(this.project == null){ return Status.OK_STATUS; --- 725,729 ---- * This is the function that actually stores the contents of the xml into the file with the configurations. */ ! private synchronized IStatus doStore() { if(this.project == null){ return Status.OK_STATUS; *************** *** 803,834 **** } synchronized (this) { ! try { ! // that's because while we're in a store job, we don't want to listen to resource changes (we just ! // want resource changes from the user). ! if (onStoreJob != 0) { ! traceFunc("END doStore (already in store)"); ! return Status.OK_STATUS; ! } ! ! onStoreJob++; ! if (document == null) { ! traceFunc("END doStore (document == null)"); ! return new Status(Status.ERROR, "PythonNatureStore.doStore", -2, "document == null", new RuntimeException("document == null")); ! } ! ! pydevprojectStreams.add(new ByteArrayInputStream(serializeDocument(document))); ! ! PythonNatureStoreJob job = new PythonNatureStoreJob("Save .pydevproject"); ! ! if (ProjectModulesManager.IN_TESTS){ ! job.run(new NullProgressMonitor()); ! }else{ ! job.schedule(); ! } ! traceFunc("END doStore"); ! return Status.OK_STATUS; ! } finally { ! onStoreJob--; } } } --- 736,766 ---- } synchronized (this) { ! if (document == null) { ! traceFunc("END doStore (document == null)"); ! return new Status(Status.ERROR, "PythonNatureStore.doStore", -2, "document == null", new RuntimeException("document == null")); } + + File file = getRawXmlFileLocation(); + if(file == null){ + //that's ok... in tests + return Status.OK_STATUS; + } + try { + //Ok, we may receive multiple requests at once (e.g.: when updating the version and the pythonpath together), but + //as the file is pretty small, there should be no problems in writing it directly (if that proves a problem later on, we + //could have a *very* simple mechanism for saving it after some millis) + + String str = new String(serializeDocument(document)); + lastLoadedContents = str; + if(TRACE_PYTHON_NATURE_STORE){ + System.out.println("Writing to file: "+file+" "+str); + } + REF.writeStrToFile(str, file); + } catch (Exception e) { + PydevPlugin.log("Unable to write contents of file: "+file, e); + } + + traceFunc("END doStore"); + return Status.OK_STATUS; } } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src/org/python/pydev/plugin Modified Files: PydevPlugin.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PydevPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** PydevPlugin.java 30 Mar 2008 21:45:12 -0000 1.88 --- PydevPlugin.java 31 Jul 2008 01:47:36 -0000 1.89 *************** *** 190,217 **** setJythonInterpreterManager(new JythonInterpreterManager(preferences)); ! //restore the nature for all python projects ! new Job("PyDev: Restoring projects python nature"){ ! ! protected IStatus run(IProgressMonitor monitor) { ! try{ ! ! IProject[] projects = getWorkspace().getRoot().getProjects(); ! for (int i = 0; i < projects.length; i++) { ! IProject project = projects[i]; ! try { ! if (project.isOpen() && project.hasNature(PythonNature.PYTHON_NATURE_ID)) { ! PythonNature.addNature(project, monitor, null, null); ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } ! }catch(Throwable t){ ! t.printStackTrace(); ! } ! return Status.OK_STATUS; ! } ! ! }.schedule(); } --- 190,217 ---- setJythonInterpreterManager(new JythonInterpreterManager(preferences)); ! //restore the nature for all python projects -- that's done when the project is set now. ! // new Job("PyDev: Restoring projects python nature"){ ! // ! // protected IStatus run(IProgressMonitor monitor) { ! // try{ ! // ! // IProject[] projects = getWorkspace().getRoot().getProjects(); ! // for (int i = 0; i < projects.length; i++) { ! // IProject project = projects[i]; ! // try { ! // if (project.isOpen() && project.hasNature(PythonNature.PYTHON_NATURE_ID)) { ! // PythonNature.addNature(project, monitor, null, null); ! // } ! // } catch (Exception e) { ! // PydevPlugin.log(e); ! // } ! // } ! // }catch(Throwable t){ ! // t.printStackTrace(); ! // } ! // return Status.OK_STATUS; ! // } ! // ! // }.schedule(); } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:28
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/plugin/nature In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/tests/org/python/pydev/plugin/nature Added Files: SaveFileWithoutNatureTestWorkbench.java ProjectImportedHasAstManagerTestWorkbench.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> --- NEW FILE: SaveFileWithoutNatureTestWorkbench.java --- package org.python.pydev.plugin.nature; import java.io.ByteArrayInputStream; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; import org.python.pydev.core.REF; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.codecompletion.revisited.javaintegration.AbstractJavaIntegrationTestWorkbench; import org.python.pydev.plugin.PydevPlugin; public class SaveFileWithoutNatureTestWorkbench extends AbstractJavaIntegrationTestWorkbench{ protected void setUp() throws Exception { //no setup (because we won't have the nature in this test) } public void testEditWithNoNature() throws Exception { NullProgressMonitor monitor = new NullProgressMonitor(); IProject project = createProject(monitor, "pydev_no_nature_project"); IFile myFile = project.getFile("my_file.py"); String contents = ""; String newContents = "class Foo(object):\n pass"; myFile.create(new ByteArrayInputStream(contents.getBytes()), true, monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); try { editor = (PyEdit) PydevPlugin.doOpenEditor(myFile, true); editor.getDocument().set(newContents); editor.doSave(monitor); } finally { editor.close(true); editor = null; } assertEquals(newContents, REF.getDocFromResource(myFile).get()); } } --- NEW FILE: ProjectImportedHasAstManagerTestWorkbench.java --- package org.python.pydev.plugin.nature; import java.io.File; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.jobs.IJobManager; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.python.pydev.core.REF; import org.python.pydev.editor.codecompletion.revisited.PythonPathHelper; import org.python.pydev.editor.codecompletion.revisited.javaintegration.AbstractJavaIntegrationTestWorkbench; public class ProjectImportedHasAstManagerTestWorkbench extends AbstractJavaIntegrationTestWorkbench{ protected void setUp() throws Exception { //no setup (because we won't have the nature in this test) } public void testEditWithNoNature() throws Exception { NullProgressMonitor monitor = new NullProgressMonitor(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IPath workspaceLoc = root.getRawLocation(); IProject project = root.getProject("pydev_nature_pre_configured"); if(project.exists()){ project.delete(true, monitor); } //let's create its structure IPath projectLoc = workspaceLoc.append("pydev_nature_pre_configured"); projectLoc.toFile().mkdir(); writeProjectFile(projectLoc.append(".project")); writePydevProjectFile(projectLoc.append(".pydevproject")); File srcLocFile = projectLoc.append("src").toFile(); srcLocFile.mkdir(); assertTrue(!project.exists()); project.create(monitor); project.open(monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); IJobManager jobManager = Job.getJobManager(); jobManager.resume(); PythonNature nature = (PythonNature) PythonNature.addNature(project, null, null, null); //Let's give it some time to run the jobs that restore the nature long finishAt = System.currentTimeMillis()+5000; //5 secs is the max tie Display display = Display.getCurrent(); if(display == null){ display = Display.getDefault(); } Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); while (!shell.isDisposed()) { if (!display.readAndDispatch()){ display.sleep(); } if(finishAt<System.currentTimeMillis()){ break; } if(nature != null){ if(nature.getAstManager() != null){ break; } } } assertTrue(nature != null); assertTrue(nature.getAstManager() != null); PythonPathHelper pythonPathHelper = (PythonPathHelper) nature.getAstManager().getModulesManager().getPythonPathHelper(); List<String> lst = new ArrayList<String>(); lst.add(REF.getFileAbsolutePath(srcLocFile)); assertEquals(lst, pythonPathHelper.getPythonpath()); } private void writePydevProjectFile(IPath path) { String str = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + "<?eclipse-pydev version=\"1.0\"?>\n" + "<pydev_project>\n" + "<pydev_pathproperty name=\"org.python.pydev.PROJECT_SOURCE_PATH\">\n" + "<path>/pydev_nature_pre_configured/src</path>\n" + "</pydev_pathproperty>\n" + "<pydev_property name=\"org.python.pydev.PYTHON_PROJECT_VERSION\">python 2.4</pydev_property>\n" + "</pydev_project>\n" + ""; REF.writeStrToFile(str, path.toFile()); } private void writeProjectFile(IPath path) { String str = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<projectDescription>\n" + " <name>test_python</name>\n" + " <comment></comment>\n" + " <projects>\n" + " <project>4DLM</project>\n" + " </projects>\n" + " <buildSpec>\n" + " <buildCommand>\n" + " <name>org.python.pydev.PyDevBuilder</name>\n" + " <arguments>\n" + " </arguments>\n" + " </buildCommand>\n" + " </buildSpec>\n" + " <natures>\n" + " <nature>org.python.pydev.pythonNature</nature>\n" + " </natures>\n" + "</projectDescription>\n" + ""; REF.writeStrToFile(str, path.toFile()); } } |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:27
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/hyperlink In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/src/org/python/pydev/editor/hyperlink Modified Files: PythonHyperlink.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PythonHyperlink.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/hyperlink/PythonHyperlink.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonHyperlink.java 4 Feb 2008 02:01:35 -0000 1.1 --- PythonHyperlink.java 31 Jul 2008 01:47:36 -0000 1.2 *************** *** 4,7 **** --- 4,9 ---- import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.hyperlink.IHyperlink; + import org.eclipse.ui.IWorkbench; + import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.python.pydev.core.docutils.PySelection; *************** *** 48,51 **** --- 50,63 ---- public void open() { IPyRefactoring pyRefactoring = PyRefactoring.getPyRefactoring(); + + //saves the dirty editors so that hyperlink is correct. + IWorkbench workbench = PlatformUI.getWorkbench(); + if(workbench != null){ + IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); + if(workbenchWindow != null){ + workbenchWindow.getActivePage().saveAllEditors(false); + } + } + RefactoringRequest refactoringRequest = PyRefactorAction.createRefactoringRequest(null, this.fEditor, new PySelection(this.fEditor)); try{ *************** *** 55,59 **** PyGoToDefinition.openDefinition(pointers, fEditor, fEditor.getSite().getShell()); }else{ ! PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); } }catch(Throwable t){ --- 67,71 ---- PyGoToDefinition.openDefinition(pointers, fEditor, fEditor.getSite().getShell()); }else{ ! workbench.getActiveWorkbenchWindow().getShell().getDisplay().beep(); } }catch(Throwable t){ |
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:06
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31511/src/org/python/pydev/parser Modified Files: PyParser.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** PyParser.java 27 Jan 2008 22:44:30 -0000 1.50 --- PyParser.java 31 Jul 2008 01:47:14 -0000 1.51 *************** *** 184,190 **** */ public PyParser(IPyEdit editorView) { ! this(editorView.getPythonNature()); } /** --- 184,208 ---- */ public PyParser(IPyEdit editorView) { ! this(getGrammarProviderFromEdit(editorView)); } + /** + * @param editorView this is the editor that we're getting in the parser + * @return a provider signaling the grammar to be used for the parser. + */ + private static IGrammarVersionProvider getGrammarProviderFromEdit(IPyEdit editorView) { + try { + return editorView.getPythonNature(); + } catch (RuntimeException e) { + //let's treat that correctly even if we do not have a default grammar (just log it) + return new IGrammarVersionProvider(){ + + public int getGrammarVersion() { + return IGrammarVersionProvider.LATEST_GRAMMAR_VERSION; + } + }; + } + } + /** |
From: Radim K. <ra...@ku...> - 2008-07-28 18:45:46
|
Hi, I noticed 'synching mercurial' messages. Two questions: 1. Is it some public mercurial repository used for this project now? Interesting. 2. Can you still commit with real messages explaining what changes were done? Maybe there are some bridges that can automate this. It would be helpfull for those people who want to extend or modify pydev. -Radim On Mon, Jul 28, 2008 at 8:53 AM, Fabio Zadrozny <fa...@us...> wrote: > Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1448/src/org/python/pydev/core/docutils > > Modified Files: > WordUtils.java StringUtils.java > Log Message: > synching mercurial > > Index: StringUtils.java > =================================================================== > RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/StringUtils.java,v > retrieving revision 1.16 > retrieving revision 1.17 > diff -C2 -d -r1.16 -r1.17 > *** StringUtils.java 5 Jul 2008 21:53:05 -0000 1.16 > --- StringUtils.java 28 Jul 2008 15:53:24 -0000 1.17 > *************** > *** 193,196 **** > --- 193,198 ---- > * @param string string to be splitted. > * @return list of strings where each string is a line. > + * > + * @note the new line characters are also added to the returned string. > */ > public static List<String> splitInLines(String string) { > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Pydev-cvs mailing list > Pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-cvs > |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:34
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1514/pysrc Modified Files: coverage.py Log Message: synching mercurial |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:23
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469/tests_completions/org/python/pydev/editor/codecompletion/templates Modified Files: PyDocumentTemplateContextTest.java Log Message: synching mercurial Index: PyDocumentTemplateContextTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/templates/PyDocumentTemplateContextTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDocumentTemplateContextTest.java 4 Aug 2007 16:01:10 -0000 1.1 --- PyDocumentTemplateContextTest.java 28 Jul 2008 15:53:32 -0000 1.2 *************** *** 44,47 **** --- 44,66 ---- + //let's check if we have a template with \n and a document with \r\n (it should be applied with \r\n) + doc = new Document("" + + "\r\n " + + ""); + context = new PyDocumentTemplateContext(new TemplateContextType(), doc, doc.getLength(), 0, " ", new TestIndentPrefs(true, 4)); + template = new Template("", "", "", "if a\n\tprint 'a: '", true); + buffer = context.evaluate(template); + assertEquals("if a\r\n print 'a: '", buffer.getString()); + + //let's check if we have a template with \r\n and a document with \r (it should be applied with \r) + doc = new Document("" + + "\r " + + ""); + context = new PyDocumentTemplateContext(new TemplateContextType(), doc, doc.getLength(), 0, " ", new TestIndentPrefs(true, 4)); + template = new Template("", "", "", "if a\r\n\tprint 'a: '", true); + buffer = context.evaluate(template); + assertEquals("if a\r print 'a: '", buffer.getString()); + + } } |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:23
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469/PySrc Modified Files: _pydev_xmlrpclib.py Log Message: synching mercurial |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469/src/org/python/pydev/editor/autoedit Modified Files: DefaultIndentPrefs.java AbstractIndentPrefs.java Log Message: synching mercurial Index: AbstractIndentPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/AbstractIndentPrefs.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractIndentPrefs.java 14 Jun 2008 22:14:57 -0000 1.5 --- AbstractIndentPrefs.java 28 Jul 2008 15:53:31 -0000 1.6 *************** *** 40,43 **** --- 40,46 ---- } + /** + * Converts spaces to tabs or vice-versa depending on the user preferences + */ public void convertToStd(IDocument document, DocumentCommand command){ try { *************** *** 129,136 **** private boolean isWhitespace(String s) { ! for (int i = s.length() - 1; i > -1 ; i--) ! if (!Character.isWhitespace(s.charAt(i))) return false; return true; } --- 132,151 ---- + /** + * Checks if the string is solely composed of spaces + * + * @param s the string analyzed + * @return true if it's only composed of spaces and false otherwise. + */ private boolean isWhitespace(String s) { ! int len = s.length(); ! ! //it's done backwards because the chance of finding a non-whitespace char is higher at the end of the string ! //than at the beggining ! for (int i = len - 1; i > -1 ; i--){ ! if (!Character.isWhitespace(s.charAt(i))){ return false; + } + } return true; } Index: DefaultIndentPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/DefaultIndentPrefs.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DefaultIndentPrefs.java 4 Aug 2007 16:01:11 -0000 1.12 --- DefaultIndentPrefs.java 28 Jul 2008 15:53:31 -0000 1.13 *************** *** 10,14 **** --- 10,18 ---- import org.python.pydev.plugin.PydevPrefs; + /** + * Provides indentation preferences from the preferences set in the preferences pages within eclipse. + */ public class DefaultIndentPrefs extends AbstractIndentPrefs { + /** * Cache for indentation string *************** *** 22,27 **** --- 26,37 ---- private static PyPreferencesCache cache; + /** + * Singleton instance for the preferences + */ private static IIndentPrefs indentPrefs; + /** + * @return the indentation preferences to be used + */ public synchronized static IIndentPrefs get() { if(indentPrefs == null){ *************** *** 31,34 **** --- 41,47 ---- } + /** + * @return a cache for the preferences. + */ private PyPreferencesCache getCache(){ if(cache == null){ |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:23
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469 Modified Files: Changes.txt Log Message: synching mercurial Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.409 retrieving revision 1.410 diff -C2 -d -r1.409 -r1.410 *** Changes.txt 20 Jul 2008 14:14:28 -0000 1.409 --- Changes.txt 28 Jul 2008 15:53:31 -0000 1.410 *************** *** 21,24 **** --- 21,25 ---- <li>Applied patch that fixes race condition in PythonNatureStore (thanks to Radim Kubacki)</li> <li>Fixed bug related to having multiple editors with the same file (while having the spell service on)</li> + <li>Applying a template could have the wrong end line delimiter applied</li> </ul> |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:23
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469/src_completions/org/python/pydev/editor/codecompletion/templates Modified Files: PyDocumentTemplateContext.java Log Message: synching mercurial Index: PyDocumentTemplateContext.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/templates/PyDocumentTemplateContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyDocumentTemplateContext.java 14 Jun 2008 22:14:56 -0000 1.2 --- PyDocumentTemplateContext.java 28 Jul 2008 15:53:31 -0000 1.3 *************** *** 16,19 **** --- 16,20 ---- import org.eclipse.jface.text.templates.TemplateTranslator; import org.python.pydev.core.docutils.DocUtils; + import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.structure.FastStringBuffer; *************** *** 117,129 **** } ! if(splitted.size() > 1 && indentTo != null && indentTo.length() > 0){ ! FastStringBuffer buffer = new FastStringBuffer(splitted.get(0), 128); ! for (int i=1; i<splitted.size();i++) { //we don't want to get the first line ! buffer.append(indentTo); ! buffer.append(splitted.get(i)); } //just to change the pattern... template = createNewTemplate(template, buffer.toString()); - } --- 118,155 ---- } ! String indentToStr = indentTo != null?indentTo:""; ! String endLineDelim = PySelection.getDelimiter(this.getDocument()); ! ! int size = splitted.size(); ! if(size > 0){ ! ! FastStringBuffer buffer = new FastStringBuffer("", (pattern.length()+(size*2))+((size+1)*indentToStr.length())); ! for (int i=0; i<size;i++) { //we don't want to get the first line ! ! if(i != 0){ ! //the 1st line is not indented (that's where the user requested the completion -- others should be indented to it) ! buffer.append(indentToStr); ! } ! ! String str = splitted.get(i); ! ! //we have to make the new line delimiter correct: ! //https://sourceforge.net/tracker/index.php?func=detail&aid=2019419&group_id=85796&atid=577329 ! boolean hasNewLine = false; ! if(str.endsWith("\r") || str.endsWith("\n")){ ! hasNewLine = true; ! if(str.endsWith("\r\n")){ ! str = str.substring(0, str.length()-2); ! }else{ ! str = str.substring(0, str.length()-1); ! } ! } ! buffer.append(str); ! if(hasNewLine){ ! buffer.append(endLineDelim); ! } } //just to change the pattern... template = createNewTemplate(template, buffer.toString()); } |
From: Fabio Z. <fa...@us...> - 2008-07-28 15:53:15
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1448/src/org/python/pydev/core/docutils Modified Files: WordUtils.java StringUtils.java Log Message: synching mercurial Index: StringUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/StringUtils.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** StringUtils.java 5 Jul 2008 21:53:05 -0000 1.16 --- StringUtils.java 28 Jul 2008 15:53:24 -0000 1.17 *************** *** 193,196 **** --- 193,198 ---- * @param string string to be splitted. * @return list of strings where each string is a line. + * + * @note the new line characters are also added to the returned string. */ public static List<String> splitInLines(String string) { |
From: Fabio Z. <fa...@us...> - 2008-07-20 14:14:20
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10981/src/org/python/pydev/editor Modified Files: PyReconciler.java Log Message: Fixed on deadlock involving PyReconciler -- spell service (and multiple editors on the same file) Bug: https://sourceforge.net/tracker/index.php?func=detail&aid=2013310&group_id=85796&atid=577329 Index: PyReconciler.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyReconciler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyReconciler.java 19 Jul 2008 22:50:16 -0000 1.2 --- PyReconciler.java 20 Jul 2008 14:14:28 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- import java.util.ArrayList; import java.util.HashMap; + import java.util.HashSet; import java.util.Iterator; import java.util.List; *************** *** 85,89 **** List toRemove = new ArrayList(); ! Object fLockObject; if (fAnnotationModel instanceof ISynchronizable){ --- 86,90 ---- List toRemove = new ArrayList(); ! Object fLockObject; if (fAnnotationModel instanceof ISynchronizable){ *************** *** 92,119 **** fLockObject = new Object(); } ! ! synchronized (fLockObject) { ! Iterator iter = fAnnotationModel.getAnnotationIterator(); ! while (iter.hasNext()) { ! Object n = iter.next(); ! if (n instanceof SpellingAnnotation) { ! toRemove.add(n); } } Annotation[] annotationsToRemove = (Annotation[]) toRemove.toArray(new Annotation[toRemove.size()]); ! if (fAnnotationModel instanceof IAnnotationModelExtension) { ! ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(annotationsToRemove, fAddAnnotations); ! } else { ! for (int i = 0; i < annotationsToRemove.length; i++) { ! fAnnotationModel.removeAnnotation(annotationsToRemove[i]); ! } ! for (iter = fAddAnnotations.keySet().iterator(); iter.hasNext();) { ! Annotation annotation = (Annotation) iter.next(); ! fAnnotationModel.addAnnotation(annotation, (Position) fAddAnnotations.get(annotation)); } } } - fAddAnnotations = null; } --- 93,141 ---- fLockObject = new Object(); } ! ! //let other threads execute before getting the lock on the annotation model ! Thread.yield(); ! ! Thread thread = Thread.currentThread(); ! int initiaThreadlPriority = thread.getPriority(); ! try{ ! //before getting the lock, let's execute with normal priority, to optimize the time that we'll ! //retain that object locked (the annotation model is used on lots of places, so, retaining the lock ! //on it on a minimum priority thread is not a good thing. ! thread.setPriority(Thread.NORM_PRIORITY); ! Iterator iter; ! ! synchronized (fLockObject) { ! iter = fAnnotationModel.getAnnotationIterator(); ! while (iter.hasNext()) { ! Object n = iter.next(); ! if (n instanceof SpellingAnnotation) { ! toRemove.add(n); ! } } + iter = null; } + Annotation[] annotationsToRemove = (Annotation[]) toRemove.toArray(new Annotation[toRemove.size()]); ! //let other threads execute before getting the lock (again) on the annotation model ! Thread.yield(); ! synchronized (fLockObject) { ! if (fAnnotationModel instanceof IAnnotationModelExtension) { ! ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(annotationsToRemove, fAddAnnotations); ! } else { ! for (int i = 0; i < annotationsToRemove.length; i++) { ! fAnnotationModel.removeAnnotation(annotationsToRemove[i]); ! } ! for (iter = fAddAnnotations.keySet().iterator(); iter.hasNext();) { ! Annotation annotation = (Annotation) iter.next(); ! fAnnotationModel.addAnnotation(annotation, (Position) fAddAnnotations.get(annotation)); ! } } } + + }finally{ + thread.setPriority(initiaThreadlPriority); } fAddAnnotations = null; } *************** *** 131,139 **** private SpellingService fSpellingService; - private ISpellingProblemCollector fSpellingProblemCollector; - /** The spelling context containing the Java source content type. */ private SpellingContext fSpellingContext; /** * Creates a new comment reconcile strategy. --- 153,170 ---- private SpellingService fSpellingService; /** The spelling context containing the Java source content type. */ private SpellingContext fSpellingContext; + + /** + * Set containing the models that are being checked at the current moment (this is used + * so that when there are multiple editors binded to the same model, we only make the check in one of those + * models -- the others don't need to do anything, as it's based on the annotation model that's shared + * among them) + * + * It's static so that we can share it among threads. + */ + private static HashSet<IAnnotationModel> modelBeingChecked = new HashSet<IAnnotationModel>(); + /** * Creates a new comment reconcile strategy. *************** *** 150,153 **** --- 181,185 ---- fSpellingContext.setContentType(getContentType()); } + /* *************** *** 176,183 **** */ public void reconcile(IRegion region) { ! if (fViewer.getAnnotationModel() == null || fSpellingProblemCollector == null) { return; } try { //we're not using incremental updates!!! -- that's why the region is ignored and fDocument.len is used. --- 208,227 ---- */ public void reconcile(IRegion region) { ! IAnnotationModel annotationModel = fViewer.getAnnotationModel(); ! ! if (annotationModel == null) { return; } + //Bug: https://sourceforge.net/tracker/index.php?func=detail&aid=2013310&group_id=85796&atid=577329 + //When having multiple editors for the same document, only one of the reconcilers actually needs to + //work (because the others are binded to the same annotation model, so, having one do the work is enough) + synchronized (modelBeingChecked) { + if(modelBeingChecked.contains(annotationModel)){ + return; + } + modelBeingChecked.add(annotationModel); + } + try { //we're not using incremental updates!!! -- that's why the region is ignored and fDocument.len is used. *************** *** 188,193 **** ArrayList<IRegion> regions = new ArrayList<IRegion>(); for (ITypedRegion partition : partitions) { ! if (fProgressMonitor != null && fProgressMonitor.isCanceled()) return; String type = partition.getType(); --- 232,238 ---- ArrayList<IRegion> regions = new ArrayList<IRegion>(); for (ITypedRegion partition : partitions) { ! if (fProgressMonitor != null && fProgressMonitor.isCanceled()){ return; + } String type = partition.getType(); *************** *** 201,205 **** int size = regions.size(); if (size > 0) { ! fSpellingService.check(fDocument, regions.toArray(new IRegion[size]), fSpellingContext, fSpellingProblemCollector, fProgressMonitor); } --- 246,252 ---- int size = regions.size(); if (size > 0) { ! //only create the collector when actually needed for the current model ! ISpellingProblemCollector spellingProblemCollector = new SpellingProblemCollector(annotationModel); ! fSpellingService.check(fDocument, regions.toArray(new IRegion[size]), fSpellingContext, spellingProblemCollector, fProgressMonitor); } *************** *** 207,210 **** --- 254,262 ---- } catch (Exception e) { PydevPlugin.log(e); + + }finally{ + synchronized (modelBeingChecked) { + modelBeingChecked.remove(annotationModel); + } } } *************** *** 226,235 **** fDocument = document; ! IAnnotationModel model = fViewer.getAnnotationModel(); ! if (model == null) { ! fSpellingProblemCollector = null; ! } else { ! fSpellingProblemCollector = new SpellingProblemCollector(model); ! } } --- 278,283 ---- fDocument = document; ! //Note: if we have multiple editors for the same doc, the document and the annotation model will be the same ! //for multiple reconcilers } |
From: Fabio Z. <fa...@us...> - 2008-07-20 14:14:20
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10981 Modified Files: Changes.txt Log Message: Fixed on deadlock involving PyReconciler -- spell service (and multiple editors on the same file) Bug: https://sourceforge.net/tracker/index.php?func=detail&aid=2013310&group_id=85796&atid=577329 Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.408 retrieving revision 1.409 diff -C2 -d -r1.408 -r1.409 *** Changes.txt 19 Jul 2008 20:19:04 -0000 1.408 --- Changes.txt 20 Jul 2008 14:14:28 -0000 1.409 *************** *** 20,23 **** --- 20,24 ---- <li>Improved code formatter to handle '=' differently inside function calls / keyword args</li> <li>Applied patch that fixes race condition in PythonNatureStore (thanks to Radim Kubacki)</li> + <li>Fixed bug related to having multiple editors with the same file (while having the spell service on)</li> </ul> |
From: Fabio Z. <fa...@us...> - 2008-07-19 22:50:08
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29212/src/org/python/pydev/editor Modified Files: PyReconciler.java Log Message: Checking lock on PyReconciler. Index: PyReconciler.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyReconciler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyReconciler.java 14 Dec 2007 00:09:06 -0000 1.1 --- PyReconciler.java 19 Jul 2008 22:50:16 -0000 1.2 *************** *** 52,58 **** private Map fAddAnnotations; - /** Lock object for modifying the annotations. */ - private Object fLockObject; - /** * Initializes this collector with the given annotation model. --- 52,55 ---- *************** *** 63,70 **** Assert.isLegal(annotationModel != null); fAnnotationModel = annotationModel; - if (fAnnotationModel instanceof ISynchronizable) - fLockObject = ((ISynchronizable) fAnnotationModel).getLockObject(); - else - fLockObject = fAnnotationModel; } --- 60,63 ---- *************** *** 93,96 **** --- 86,96 ---- List toRemove = new ArrayList(); + Object fLockObject; + if (fAnnotationModel instanceof ISynchronizable){ + fLockObject = ((ISynchronizable) fAnnotationModel).getLockObject(); + }else{ + fLockObject = new Object(); + } + synchronized (fLockObject) { Iterator iter = fAnnotationModel.getAnnotationIterator(); |
From: Fabio Z. <fa...@us...> - 2008-07-19 20:18:56
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5694 Modified Files: Changes.txt Log Message: Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.407 retrieving revision 1.408 diff -C2 -d -r1.407 -r1.408 *** Changes.txt 19 Jul 2008 19:53:31 -0000 1.407 --- Changes.txt 19 Jul 2008 20:19:04 -0000 1.408 *************** *** 19,22 **** --- 19,23 ---- <li>Improved code formatter to deal with operators (+, -, *, etc)</li> <li>Improved code formatter to handle '=' differently inside function calls / keyword args</li> + <li>Applied patch that fixes race condition in PythonNatureStore (thanks to Radim Kubacki)</li> </ul> |