[Pydev-cvs] org.python.pydev/src/org/python/pydev/plugin PythonNature.java,1.7,1.8
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2004-12-20 18:16:50
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16145/src/org/python/pydev/plugin Modified Files: PythonNature.java Log Message: Still on code completion... Index: PythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PythonNature.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PythonNature.java 1 Dec 2004 16:59:15 -0000 1.7 --- PythonNature.java 20 Dec 2004 18:16:34 -0000 1.8 *************** *** 7,25 **** package org.python.pydev.plugin; - import java.io.File; - import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectNature; - import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; - import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; ! import org.eclipse.jface.text.IDocument; ! import org.python.pydev.editor.codecompletion.revisited.ASTManager; import org.python.pydev.ui.PyProjectProperties; import org.python.pydev.utils.JobProgressComunicator; --- 7,21 ---- package org.python.pydev.plugin; import org.eclipse.core.resources.ICommand; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; ! import org.python.pydev.editor.codecompletion.revisited.ASTManagerFactory; ! import org.python.pydev.editor.codecompletion.revisited.IASTManager; import org.python.pydev.ui.PyProjectProperties; import org.python.pydev.utils.JobProgressComunicator; *************** *** 58,62 **** * This is the completions cache for the nature represented by this object (it is associated with a project). */ ! private ASTManager astManager; /** --- 54,58 ---- * This is the completions cache for the nature represented by this object (it is associated with a project). */ ! private IASTManager astManager; /** *************** *** 171,197 **** protected IStatus run(IProgressMonitor monitor) { - File dir = getCompletionsCacheDir(); - - //this is ok, just set it directly... (if it is still null anyway, - //some error happened). - astManager = ASTManager.restoreASTManager(dir, monitor, this); ! //failed if still null. ! if (astManager == null) { ! ASTManager tempAstManager = new ASTManager(); ! try { ! IProgressMonitor comunicator = new JobProgressComunicator(monitor, "Rebuilding modules", 500, this); ! comunicator.worked(1); ! comunicator.setTaskName("Rebuilding modules."); ! String pathStr = PyProjectProperties.getProjectPythonPathStr(project); ! tempAstManager.rebuildModules(pathStr, comunicator); ! astManager = tempAstManager; //only make it available after it is all loaded (better than synchronizing it). ! saveIt(); //after rebuilding it, save it. ! comunicator.done(); ! } catch (CoreException e) { ! e.printStackTrace(); ! PydevPlugin.log(e); ! } } return Status.OK_STATUS; } --- 167,179 ---- protected IStatus run(IProgressMonitor monitor) { ! String pythonpath = null; ! try { ! pythonpath = PyProjectProperties.getProjectPythonPathStr(project); ! } catch (CoreException e) { ! e.printStackTrace(); } + astManager = ASTManagerFactory.restoreASTManager(project, pythonpath, monitor); + return Status.OK_STATUS; } *************** *** 202,247 **** } - /** - * @return the file that should be used to store the completions. - */ - private File getCompletionsCacheDir() { - IProject p = project; - return getCompletionsCacheDir(p); - } - /** - * @param p - * @return - */ - public static File getCompletionsCacheDir(IProject p) { - IPath location = p.getWorkingLocation(PydevPlugin.getPluginID()); - IPath path = location;//.addTrailingSeparator().append(name + ".pydevcompletions"); - - File file = new File(path.toOSString()); - return file; - } - - /** - * This method puts the completions cache in a dump file, so that we can restore it later. We do this ourselves because we don't want - * this to be stored as a xml, as it is not an optimized format (the object dump should be much faster). - * - * This can be used from time to time to store what we have (you never know when a crash might occur). - */ - private void saveIt() { - Job myJob = new Job("Pydev code completion (saving tokens)") { - - protected IStatus run(IProgressMonitor monitor) { - if (astManager != null) { - //synchronize it!! - synchronized (astManager) { - //write completions cache to outputstream. - astManager.saveASTManager(getCompletionsCacheDir(), new JobProgressComunicator(monitor, "Save ast manager", astManager.getSize()+10, this)); - } - } - return Status.OK_STATUS; - } - }; - myJob.schedule(); - } /** --- 184,188 ---- *************** *** 254,261 **** protected IStatus run(IProgressMonitor monitor) { ! astManager.rebuildModules(paths, new JobProgressComunicator(monitor, "Rebuilding modules", 500, this)); ! if(monitor.isCanceled() == false){ ! saveIt(); //after rebuilding, save it. ! } return Status.OK_STATUS; } --- 195,199 ---- protected IStatus run(IProgressMonitor monitor) { ! astManager.changePythonPath(paths, project, new JobProgressComunicator(monitor, "Rebuilding modules", 500, this)); return Status.OK_STATUS; } *************** *** 266,287 **** /** - * Updates the ast for the resource (that has the given document). - * @param resource - * @param document - */ - public void rebuildDelta(final IResource resource, final IDocument document){ - IPath location = resource.getLocation(); - - if (astManager != null){ - astManager.rebuildModule(new File(location.toOSString()), document, resource.getProject()); - } - - } - - - /** * @return Returns the completionsCache. */ ! public ASTManager getAstManager() { return astManager; } --- 204,210 ---- /** * @return Returns the completionsCache. */ ! public IASTManager getAstManager() { return astManager; } |