[Pydev-cvs] org.python.pydev/src/org/python/pydev/plugin/nature PythonNatureStore.java, 1.22, 1.23
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/plugin/nature Modified Files: PythonNatureStore.java PythonNature.java SystemPythonNature.java PythonPathNature.java AbstractPythonNature.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: SystemPythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/SystemPythonNature.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SystemPythonNature.java 2 May 2008 23:24:14 -0000 1.12 --- SystemPythonNature.java 28 Sep 2008 12:45:40 -0000 1.13 *************** *** 19,110 **** public class SystemPythonNature extends AbstractPythonNature implements IPythonNature{ ! private IInterpreterManager manager; ! private SystemASTManager systemASTManager; ! public SystemPythonNature(IInterpreterManager manager){ ! this.manager = manager; ! } ! public String getVersion() throws CoreException { ! if(this.manager.isPython()){ ! return IPythonNature.PYTHON_VERSION_LATEST; ! }else if(this.manager.isJython()){ ! return IPythonNature.JYTHON_VERSION_LATEST; ! }else{ ! throw new RuntimeException("Not python nor jython?"); ! } ! } ! public String getDefaultVersion() { ! try { return getVersion(); } catch (CoreException e) { throw new RuntimeException(e); } ! } ! public void setVersion(String version) throws CoreException { ! throw new RuntimeException("Not Implemented: the system nature is read-only."); ! } ! public boolean isJython() throws CoreException { ! return manager.isJython(); ! } ! public boolean isPython() throws CoreException { ! return manager.isPython(); ! } ! public int getRelatedId() throws CoreException { ! return PythonNature.getRelatedId(this); ! } ! public File getCompletionsCacheDir() { ! throw new RuntimeException("Not Implemented"); ! } ! public void saveAstManager() { ! throw new RuntimeException("Not Implemented: system nature is only transient."); ! } ! public IPythonPathNature getPythonPathNature() { ! throw new RuntimeException("Not Implemented"); ! } ! public String resolveModule(String file) { ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); if(info == null){ return null; } ! return info.getModulesManager().resolveModule(file); ! } ! public ICodeCompletionASTManager getAstManager() { ! if(systemASTManager == null){ ! systemASTManager = new SystemASTManager(this.manager, this); ! } ! return systemASTManager; ! } ! public void configure() throws CoreException { ! } ! public void deconfigure() throws CoreException { ! } ! public IProject getProject() { ! return null; ! } ! public void setProject(IProject project) { ! } ! public void rebuildPath() { ! throw new RuntimeException("Not Implemented"); ! } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! throw new RuntimeException("Not Implemented"); ! } public IInterpreterManager getRelatedInterpreterManager() { --- 19,110 ---- public class SystemPythonNature extends AbstractPythonNature implements IPythonNature{ ! private IInterpreterManager manager; ! private SystemASTManager systemASTManager; ! public SystemPythonNature(IInterpreterManager manager){ ! this.manager = manager; ! } ! public String getVersion() throws CoreException { ! if(this.manager.isPython()){ ! return IPythonNature.PYTHON_VERSION_LATEST; ! }else if(this.manager.isJython()){ ! return IPythonNature.JYTHON_VERSION_LATEST; ! }else{ ! throw new RuntimeException("Not python nor jython?"); ! } ! } ! public String getDefaultVersion() { ! try { return getVersion(); } catch (CoreException e) { throw new RuntimeException(e); } ! } ! public void setVersion(String version) throws CoreException { ! throw new RuntimeException("Not Implemented: the system nature is read-only."); ! } ! public boolean isJython() throws CoreException { ! return manager.isJython(); ! } ! public boolean isPython() throws CoreException { ! return manager.isPython(); ! } ! public int getRelatedId() throws CoreException { ! return PythonNature.getRelatedId(this); ! } ! public File getCompletionsCacheDir() { ! throw new RuntimeException("Not Implemented"); ! } ! public void saveAstManager() { ! throw new RuntimeException("Not Implemented: system nature is only transient."); ! } ! public IPythonPathNature getPythonPathNature() { ! throw new RuntimeException("Not Implemented"); ! } ! public String resolveModule(String file) { ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); if(info == null){ return null; } ! return info.getModulesManager().resolveModule(file); ! } ! public ICodeCompletionASTManager getAstManager() { ! if(systemASTManager == null){ ! systemASTManager = new SystemASTManager(this.manager, this); ! } ! return systemASTManager; ! } ! public void configure() throws CoreException { ! } ! public void deconfigure() throws CoreException { ! } ! public IProject getProject() { ! return null; ! } ! public void setProject(IProject project) { ! } ! public void rebuildPath() { ! throw new RuntimeException("Not Implemented"); ! } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! throw new RuntimeException("Not Implemented"); ! } public IInterpreterManager getRelatedInterpreterManager() { *************** *** 116,140 **** private IToken[] builtinCompletions; ! public IToken[] getBuiltinCompletions() { ! return builtinCompletions; ! } ! public void setBuiltinCompletions(IToken[] toks) { ! this.builtinCompletions = toks; ! } ! ! ! //builtin mod ! private IModule builtinMod; ! public IModule getBuiltinMod() { ! return builtinMod; ! } ! public void setBuiltinMod(IModule mod) { ! this.builtinMod = mod; ! } ! public int getGrammarVersion() { IInterpreterInfo info = manager.getDefaultInterpreterInfo(new NullProgressMonitor()); --- 116,140 ---- private IToken[] builtinCompletions; ! public IToken[] getBuiltinCompletions() { ! return builtinCompletions; ! } ! public void setBuiltinCompletions(IToken[] toks) { ! this.builtinCompletions = toks; ! } ! ! ! //builtin mod ! private IModule builtinMod; ! public IModule getBuiltinMod() { ! return builtinMod; ! } ! public void setBuiltinMod(IModule mod) { ! this.builtinMod = mod; ! } ! public int getGrammarVersion() { IInterpreterInfo info = manager.getDefaultInterpreterInfo(new NullProgressMonitor()); Index: PythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNature.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** PythonNature.java 31 Jul 2008 01:47:36 -0000 1.67 --- PythonNature.java 28 Sep 2008 12:45:39 -0000 1.68 *************** *** 88,101 **** JobProgressComunicator jobProgressComunicator = new JobProgressComunicator(monitorArg, "Rebuilding modules", IProgressMonitor.UNKNOWN, this); try { ! ICodeCompletionASTManager tempAstManager = astManager; if (tempAstManager == null) { ! tempAstManager = new ASTManager(); } synchronized(tempAstManager){ ! astManager = tempAstManager; ! tempAstManager.setProject(getProject(), PythonNature.this, false); //it is a new manager, so, remove all deltas //begins task automatically ! tempAstManager.changePythonPath(paths, project, jobProgressComunicator, defaultSelectedInterpreter); saveAstManager(); --- 88,101 ---- JobProgressComunicator jobProgressComunicator = new JobProgressComunicator(monitorArg, "Rebuilding modules", IProgressMonitor.UNKNOWN, this); try { ! ICodeCompletionASTManager tempAstManager = astManager; if (tempAstManager == null) { ! tempAstManager = new ASTManager(); } synchronized(tempAstManager){ ! astManager = tempAstManager; ! tempAstManager.setProject(getProject(), PythonNature.this, false); //it is a new manager, so, remove all deltas //begins task automatically ! tempAstManager.changePythonPath(paths, project, jobProgressComunicator, defaultSelectedInterpreter); saveAstManager(); *************** *** 105,109 **** observer.notifyProjectPythonpathRestored(PythonNature.this, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { ! //let's keep it safe PydevPlugin.log(e); } --- 105,109 ---- observer.notifyProjectPythonpathRestored(PythonNature.this, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { ! //let's keep it safe PydevPlugin.log(e); } *************** *** 214,250 **** */ 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. ! } } --- 214,250 ---- */ 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. ! } } *************** *** 253,265 **** public static synchronized IPythonNature addNature(IEditorInput element) { if(element instanceof FileEditorInput){ ! IFile file = (IFile)((FileEditorInput)element).getAdapter(IFile.class); ! if (file != null){ ! try { ! return PythonNature.addNature(file.getProject(), null, null, null); ! } catch (CoreException e) { ! PydevPlugin.log(e); ! } ! } ! } return null; } --- 253,265 ---- public static synchronized IPythonNature addNature(IEditorInput element) { if(element instanceof FileEditorInput){ ! IFile file = (IFile)((FileEditorInput)element).getAdapter(IFile.class); ! if (file != null){ ! try { ! return PythonNature.addNature(file.getProject(), null, null, null); ! } catch (CoreException e) { ! PydevPlugin.log(e); ! } ! } ! } return null; } *************** *** 392,451 **** @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 --- 392,451 ---- @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 *************** *** 461,465 **** ! /** * Returns the directory that should store completions. * --- 461,465 ---- ! /** * Returns the directory that should store completions. * *************** *** 492,508 **** */ public void rebuildPath() { ! this.rebuildPath(null, new NullProgressMonitor()); } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! try { ! clearCaches(); ! String paths = this.pythonPathNature.getOnlyProjectPythonPathStr(); ! this.rebuildPath(defaultSelectedInterpreter, paths); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } --- 492,508 ---- */ public void rebuildPath() { ! this.rebuildPath(null, new NullProgressMonitor()); } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! try { ! clearCaches(); ! String paths = this.pythonPathNature.getOnlyProjectPythonPathStr(); ! this.rebuildPath(defaultSelectedInterpreter, paths); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } *************** *** 524,541 **** public ICodeCompletionASTManager getAstManager() { if(astManager == null){ ! //this is needed because it may not be restarted already... ! //also, this will only happen when initializing eclipse with some editors already open ! ! for(int i=0; i<10 && astManager == null && !initializationFinished; i++){ //we will wait 10 seconds for it ! try { ! Thread.sleep(1000); ! } catch (InterruptedException e) { //ignore ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! //next time we won't wait as long. ! initializationFinished = true; } --- 524,541 ---- public ICodeCompletionASTManager getAstManager() { if(astManager == null){ ! //this is needed because it may not be restarted already... ! //also, this will only happen when initializing eclipse with some editors already open ! ! for(int i=0; i<10 && astManager == null && !initializationFinished; i++){ //we will wait 10 seconds for it ! try { ! Thread.sleep(1000); ! } catch (InterruptedException e) { //ignore ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! //next time we won't wait as long. ! initializationFinished = true; } *************** *** 563,583 **** */ public static List<IPythonNature> getAllPythonNatures() { ! List<IPythonNature> natures = new ArrayList<IPythonNature>(); ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! IProject[] projects = root.getProjects(); ! for (IProject project : projects) { ! PythonNature nature = getPythonNature(project); ! if(nature != null){ ! natures.add(nature); ! } ! } ! return natures; } public static PythonNature getPythonNature(IResource resource) { ! if(resource == null){ ! return null; ! } ! return getPythonNature(resource.getProject()); } --- 563,583 ---- */ public static List<IPythonNature> getAllPythonNatures() { ! List<IPythonNature> natures = new ArrayList<IPythonNature>(); ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! IProject[] projects = root.getProjects(); ! for (IProject project : projects) { ! PythonNature nature = getPythonNature(project); ! if(nature != null){ ! natures.add(nature); ! } ! } ! return natures; } public static PythonNature getPythonNature(IResource resource) { ! if(resource == null){ ! return null; ! } ! return getPythonNature(resource.getProject()); } *************** *** 615,626 **** public String getVersion() throws CoreException { if(project != null){ ! if (versionPropertyCache == null) { ! String storeVersion = getStore().getPropertyFromXml(getPythonProjectVersionQualifiedName()); ! if(storeVersion == null){ //there is no such property set (let's set it to the default) ! setVersion(getDefaultVersion()); //will set the versionPropertyCache too ! }else{ ! versionPropertyCache = storeVersion; } ! } } return versionPropertyCache; --- 615,626 ---- public String getVersion() throws CoreException { if(project != null){ ! if (versionPropertyCache == null) { ! String storeVersion = getStore().getPropertyFromXml(getPythonProjectVersionQualifiedName()); ! if(storeVersion == null){ //there is no such property set (let's set it to the default) ! setVersion(getDefaultVersion()); //will set the versionPropertyCache too ! }else{ ! versionPropertyCache = storeVersion; } ! } } return versionPropertyCache; *************** *** 632,638 **** */ public void setVersion(String version) throws CoreException{ ! clearCaches(); if(project != null){ ! this.versionPropertyCache = version; getStore().setPropertyToXml(getPythonProjectVersionQualifiedName(), version, true); } --- 632,638 ---- */ public void setVersion(String version) throws CoreException{ ! clearCaches(); if(project != null){ ! this.versionPropertyCache = version; getStore().setPropertyToXml(getPythonProjectVersionQualifiedName(), version, true); } *************** *** 656,671 **** public void saveAstManager() { ! if(astManager == null){ ! REF.writeToFile(null, getAstOutputFile()); ! ! }else{ ! synchronized(astManager){ ! REF.writeToFile(astManager, getAstOutputFile()); ! } ! } } public int getRelatedId() throws CoreException { ! return getRelatedId(this); } --- 656,671 ---- public void saveAstManager() { ! if(astManager == null){ ! REF.writeToFile(null, getAstOutputFile()); ! ! }else{ ! synchronized(astManager){ ! REF.writeToFile(astManager, getAstOutputFile()); ! } ! } } public int getRelatedId() throws CoreException { ! return getRelatedId(this); } *************** *** 723,741 **** Boolean isJython = null; //cache ! public void setBuiltinCompletions(IToken[] comps) { ! this.getRelatedInterpreterManager().setBuiltinCompletions(comps); ! } ! public IToken[] getBuiltinCompletions() { ! return this.getRelatedInterpreterManager().getBuiltinCompletions(); ! } ! public IModule getBuiltinMod() { ! return this.getRelatedInterpreterManager().getBuiltinMod(); ! } ! public void setBuiltinMod(IModule mod) { ! this.getRelatedInterpreterManager().setBuiltinMod(mod); ! } public static List<IPythonNature> getPythonNaturesRelatedTo(int relatedTo) { --- 723,741 ---- Boolean isJython = null; //cache ! public void setBuiltinCompletions(IToken[] comps) { ! this.getRelatedInterpreterManager().setBuiltinCompletions(comps); ! } ! public IToken[] getBuiltinCompletions() { ! return this.getRelatedInterpreterManager().getBuiltinCompletions(); ! } ! public IModule getBuiltinMod() { ! return this.getRelatedInterpreterManager().getBuiltinMod(); ! } ! public void setBuiltinMod(IModule mod) { ! this.getRelatedInterpreterManager().setBuiltinMod(mod); ! } public static List<IPythonNature> getPythonNaturesRelatedTo(int relatedTo) { *************** *** 775,779 **** protected IPythonNatureStore getStore(){ ! return pythonNatureStore; } --- 775,779 ---- protected IPythonNatureStore getStore(){ ! return pythonNatureStore; } Index: AbstractPythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/AbstractPythonNature.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractPythonNature.java 7 Jul 2007 18:03:07 -0000 1.2 --- AbstractPythonNature.java 28 Sep 2008 12:45:40 -0000 1.3 *************** *** 19,39 **** */ public boolean isResourceInPythonpath(IResource resource) { ! return resolveModule(resource) != null; } public boolean isResourceInPythonpath(String absPath) { ! return resolveModule(absPath) != null; } ! /** * @param resource the resource we want to get the name from * @return the name of the module in the environment */ public String resolveModule(IResource resource) { ! return resolveModule(PydevPlugin.getIResourceOSString(resource)); } public String resolveModule(File file) { ! return resolveModule(REF.getFileAbsolutePath(file)); } --- 19,39 ---- */ public boolean isResourceInPythonpath(IResource resource) { ! return resolveModule(resource) != null; } public boolean isResourceInPythonpath(String absPath) { ! return resolveModule(absPath) != null; } ! /** * @param resource the resource we want to get the name from * @return the name of the module in the environment */ public String resolveModule(IResource resource) { ! return resolveModule(PydevPlugin.getIResourceOSString(resource)); } public String resolveModule(File file) { ! return resolveModule(REF.getFileAbsolutePath(file)); } *************** *** 48,71 **** */ public synchronized boolean startRequests() { ! ICodeCompletionASTManager astManager = this.getAstManager(); ! if(astManager == null){ ! return false; ! } ! IModulesManager modulesManager = astManager.getModulesManager(); ! if(modulesManager == null){ ! return false; ! } ! synchronized (modulesManagerStack) { ! modulesManagerStack.push(modulesManager); ! return modulesManager.startCompletionCache(); } ! } ! /** * End a request for an ast manager (end caching things) */ ! public synchronized void endRequests() { ! synchronized (modulesManagerStack) { ! try { IModulesManager modulesManager = modulesManagerStack.pop(); modulesManager.endCompletionCache(); --- 48,71 ---- */ public synchronized boolean startRequests() { ! ICodeCompletionASTManager astManager = this.getAstManager(); ! if(astManager == null){ ! return false; } ! IModulesManager modulesManager = astManager.getModulesManager(); ! if(modulesManager == null){ ! return false; ! } ! synchronized (modulesManagerStack) { ! modulesManagerStack.push(modulesManager); ! return modulesManager.startCompletionCache(); ! } ! } ! /** * End a request for an ast manager (end caching things) */ ! public synchronized void endRequests() { ! synchronized (modulesManagerStack) { ! try { IModulesManager modulesManager = modulesManagerStack.pop(); modulesManager.endCompletionCache(); *************** *** 73,79 **** PydevPlugin.log(e); } ! } ! } ! } --- 73,79 ---- PydevPlugin.log(e); } ! } ! } ! } Index: PythonPathNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonPathNature.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PythonPathNature.java 31 Jul 2008 01:47:36 -0000 1.30 --- PythonPathNature.java 28 Sep 2008 12:45:40 -0000 1.31 *************** *** 128,135 **** if(ResourcesPlugin.getPlugin() == null){ ! //in tests ! buf.append(strings[i]); ! buf.append("|"); ! continue; } --- 128,135 ---- if(ResourcesPlugin.getPlugin() == null){ ! //in tests ! buf.append(strings[i]); ! buf.append("|"); ! continue; } *************** *** 150,175 **** }else if(r instanceof IFile){ //zip/jar/egg file ! String extension = r.getFileExtension(); ! if(extension == null || FileTypesPreferencesPage.isValidZipFile("."+extension) == false){ ! PydevPlugin.log("Error: the path "+strings[i]+" is a file but is not a recognized zip file."); ! ! }else{ ! buf.append(REF.getFileAbsolutePath(r.getLocation().toFile())); ! buf.append("|"); ! } }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("|"); ! } } --- 150,175 ---- }else if(r instanceof IFile){ //zip/jar/egg file ! String extension = r.getFileExtension(); ! if(extension == null || FileTypesPreferencesPage.isValidZipFile("."+extension) == false){ ! PydevPlugin.log("Error: the path "+strings[i]+" is a file but is not a recognized zip file."); ! ! }else{ ! buf.append(REF.getFileAbsolutePath(r.getLocation().toFile())); ! buf.append("|"); ! } }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("|"); ! } } *************** *** 247,252 **** String projectSourcePath = nature.getStore().getPathProperty(PythonPathNature.getProjectSourcePathQualifiedName()); if(projectSourcePath == null){ ! //has not been set ! return ""; } //we have to validate it, because as we store the values relative to the workspace, and not to the --- 247,252 ---- String projectSourcePath = nature.getStore().getPathProperty(PythonPathNature.getProjectSourcePathQualifiedName()); if(projectSourcePath == null){ ! //has not been set ! return ""; } //we have to validate it, because as we store the values relative to the workspace, and not to the *************** *** 292,300 **** synchronized(project){ //no need to validate because those are always 'file-system' related ! String extPath = nature.getStore().getPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName()); if(extPath == null){ ! extPath = ""; } ! return extPath; } } --- 292,300 ---- synchronized(project){ //no need to validate because those are always 'file-system' related ! String extPath = nature.getStore().getPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName()); if(extPath == null){ ! extPath = ""; } ! return extPath; } } Index: PythonNatureStore.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNatureStore.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PythonNatureStore.java 13 Aug 2008 21:12:15 -0000 1.22 --- PythonNatureStore.java 28 Sep 2008 12:45:39 -0000 1.23 *************** *** 98,102 **** public String getLastLoadedContents(){ ! return lastLoadedContents; } --- 98,102 ---- public String getLastLoadedContents(){ ! return lastLoadedContents; } *************** *** 138,154 **** }else{ traceFunc("setProject - ", project.getName()); ! try{ ! this.project = project; ! this.xmlFile = project.getFile(STORE_FILE_NAME); ! try { ! loadFromFile(); ! } catch (CoreException e) { ! throw new RuntimeException("Error loading project: "+project, e); ! } ! if (!ProjectModulesManager.IN_TESTS) { ! project.getWorkspace().addResourceChangeListener(this); ! } }finally{ ! loaded = true; } traceFunc("END setProject - ", project.getName()); --- 138,154 ---- }else{ traceFunc("setProject - ", project.getName()); ! try{ ! this.project = project; ! this.xmlFile = project.getFile(STORE_FILE_NAME); ! try { ! loadFromFile(); ! } catch (CoreException e) { ! throw new RuntimeException("Error loading project: "+project, e); ! } ! if (!ProjectModulesManager.IN_TESTS) { ! project.getWorkspace().addResourceChangeListener(this); ! } }finally{ ! loaded = true; } traceFunc("END setProject - ", project.getName()); *************** *** 161,165 **** */ private synchronized void checkLoad(String function) { ! if(!loaded){ PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); } --- 161,165 ---- */ private synchronized void checkLoad(String function) { ! if(!loaded){ PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); } *************** *** 173,177 **** return ""; } ! checkLoad("getPathProperty"); String ret = getPathStringFromArray(getPathPropertyFromXml(key)); traceFunc("END getPathProperty - ", key, ret); --- 173,177 ---- return ""; } ! checkLoad("getPathProperty"); String ret = getPathStringFromArray(getPathPropertyFromXml(key)); traceFunc("END getPathProperty - ", key, ret); *************** *** 179,187 **** } ! /* (non-Javadoc) * @see org.python.pydev.plugin.nature.IPythonNatureStore#setPathProperty(org.eclipse.core.runtime.QualifiedName, java.lang.String) */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! checkLoad("setPathProperty"); setPathPropertyToXml(key, getArrayFromPathString(value), true); } --- 179,187 ---- } ! /* (non-Javadoc) * @see org.python.pydev.plugin.nature.IPythonNatureStore#setPathProperty(org.eclipse.core.runtime.QualifiedName, java.lang.String) */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! checkLoad("setPathProperty"); setPathPropertyToXml(key, getArrayFromPathString(value), true); } *************** *** 226,239 **** } } 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); } --- 226,239 ---- } } 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); } *************** *** 246,257 **** * @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 { --- 246,257 ---- * @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 { *************** *** 289,293 **** private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); Node ret = null; --- 289,293 ---- private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); Node ret = null; *************** *** 446,450 **** traceFunc("getPropertyFromXml - ", key); synchronized (this) { ! checkLoad("getPropertyFromXml"); try { Node propertyNode = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); --- 446,450 ---- traceFunc("getPropertyFromXml - ", key); synchronized (this) { ! checkLoad("getPropertyFromXml"); try { Node propertyNode = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); *************** *** 471,477 **** traceFunc(StringUtils.format("setPropertyToXml key:%s value:%s store:%s", key, value, store)); synchronized (this) { ! if(store){ ! checkLoad("setPropertyToXml"); ! } try { Node child = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); --- 471,477 ---- traceFunc(StringUtils.format("setPropertyToXml key:%s value:%s store:%s", key, value, store)); synchronized (this) { ! if(store){ ! checkLoad("setPropertyToXml"); ! } try { Node child = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); *************** *** 493,501 **** }else{ ! store = false; } if (store) { ! doStore(); } --- 493,501 ---- }else{ ! store = false; } if (store) { ! doStore(); } *************** *** 575,579 **** boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; traceFunc("END hasTextContent ", ret); --- 575,579 ---- boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; traceFunc("END hasTextContent ", ret); *************** *** 638,646 **** } }else{ ! store = false; } if (store) { ! doStore(); } --- 638,646 ---- } }else{ ! store = false; } if (store) { ! doStore(); } *************** *** 745,772 **** } ! File file = getRawXmlFileLocation(); ! ! 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(file == null){ ! if (!ProjectModulesManager.IN_TESTS) { ! //if we're not in tests, let's log this, as it'd be an error. ! PydevPlugin.log("Error: xml file should only be null in tests (when no workspace is available)"); ! } ! return Status.OK_STATUS; ! } ! ! 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"); --- 745,772 ---- } ! File file = getRawXmlFileLocation(); ! ! 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(file == null){ ! if (!ProjectModulesManager.IN_TESTS) { ! //if we're not in tests, let's log this, as it'd be an error. ! PydevPlugin.log("Error: xml file should only be null in tests (when no workspace is available)"); ! } ! return Status.OK_STATUS; ! } ! ! 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"); |