[Pydev-cvs] org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited ASTM
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8061/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ASTManager.java ModulesManager.java ProjectModulesManager.java PythonPathHelper.java Log Message: Synching from mercurial: - Pydev debugger watch working in eclipse 3.4 - Pydev debugger breakpoint properties accept new lines and tabs - Incremental find backspace works correctly - Interactive console Fixed problem when more attempts to connect were needed - Launch icons: Transparent background (thanks to Radim Kubacki) - Creating workbench test for debugger Index: PythonPathHelper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/PythonPathHelper.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PythonPathHelper.java 14 Jun 2008 22:14:55 -0000 1.11 --- PythonPathHelper.java 13 Aug 2008 21:12:15 -0000 1.12 *************** *** 25,30 **** --- 25,32 ---- import org.python.pydev.editor.codecompletion.revisited.ModulesFoundStructure.ZipContents; import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.plugin.nature.IPythonPathHelper; import org.python.pydev.ui.filetypes.FileTypesPreferencesPage; import org.python.pydev.utils.PyFileListing; + import org.python.pydev.utils.PyFileListing.PyFileInfo; /** *************** *** 34,38 **** * @author Fabio Zadrozny */ ! public class PythonPathHelper implements Serializable { private static final long serialVersionUID = 1L; --- 36,40 ---- * @author Fabio Zadrozny */ ! public class PythonPathHelper implements IPythonPathHelper, Serializable { private static final long serialVersionUID = 1L; *************** *** 57,60 **** --- 59,64 ---- } + public PythonPathHelper() {} + /** * This method returns all modules that can be obtained from a root File. *************** *** 63,67 **** * May return null if the passed file does not exist or is not a directory (e.g.: zip file) */ ! public PyFileListing.PyFileListingInfo getModulesBelow(File root, IProgressMonitor monitor) { if (!root.exists()) { return null; --- 67,71 ---- * May return null if the passed file does not exist or is not a directory (e.g.: zip file) */ ! public PyFileListing getModulesBelow(File root, IProgressMonitor monitor) { if (!root.exists()) { return null; *************** *** 93,97 **** * @return a list with the name of the found modules in the jar */ ! private static ModulesFoundStructure.ZipContents getFromJar(File root, IProgressMonitor monitor) { String fileName = root.getName(); --- 97,101 ---- * @return a list with the name of the found modules in the jar */ ! protected static ModulesFoundStructure.ZipContents getFromJar(File root, IProgressMonitor monitor) { String fileName = root.getName(); *************** *** 234,242 **** final File moduleFile = new File(fullPath); ! if (requireFileToExist) { ! if (moduleFile.exists() == false) { return null; } - } boolean isFile = moduleFile.isFile(); --- 238,244 ---- final File moduleFile = new File(fullPath); ! if (requireFileToExist && !moduleFile.exists()) { return null; } boolean isFile = moduleFile.isFile(); *************** *** 333,337 **** //ok, it was not found in any existing way, so, if we don't require the file to exist, let's just do some simpler search and get the //first match (if any)... this is useful if the file we are looking for has just been deleted ! if (requireFileToExist == false) { //we have to remove the last part (.py, .pyc, .pyw) for (String element : pythonpath) { --- 335,339 ---- //ok, it was not found in any existing way, so, if we don't require the file to exist, let's just do some simpler search and get the //first match (if any)... this is useful if the file we are looking for has just been deleted ! if (!requireFileToExist) { //we have to remove the last part (.py, .pyc, .pyw) for (String element : pythonpath) { *************** *** 371,375 **** * @return true if it is a folder with an __init__ python file */ ! private boolean isFileOrFolderWithInit(File root) { //check for an __init__ in a dir (we do not check if it is a file, becase if it is, it should return null) String[] items = root.list(new FilenameFilter() { --- 373,377 ---- * @return true if it is a folder with an __init__ python file */ ! protected boolean isFileOrFolderWithInit(File root) { //check for an __init__ in a dir (we do not check if it is a file, becase if it is, it should return null) String[] items = root.list(new FilenameFilter() { *************** *** 402,406 **** * @return */ ! private boolean isValidModule(String s) { return s.indexOf("-") == -1 && s.indexOf(" ") == -1 && s.indexOf(".") == -1; } --- 404,408 ---- * @return */ ! protected static boolean isValidModule(String s) { return s.indexOf("-") == -1 && s.indexOf(" ") == -1 && s.indexOf(".") == -1; } *************** *** 410,418 **** * @return */ ! public List<String> setPythonPath(String string) { synchronized (pythonpath) { pythonpath.clear(); ! getPythonPathFromStr(string, pythonpath); ! return new ArrayList<String>(pythonpath); } } --- 412,419 ---- * @return */ ! public void setPythonPath(String string) { synchronized (pythonpath) { pythonpath.clear(); ! parsePythonPathFromStr(string, pythonpath); } } *************** *** 422,426 **** * @param lPath OUT: this list is filled with the pythonpath. */ ! public static void getPythonPathFromStr(String string, List<String> lPath) { String[] strings = string.split("\\|"); for (int i = 0; i < strings.length; i++) { --- 423,427 ---- * @param lPath OUT: this list is filled with the pythonpath. */ ! private static void parsePythonPathFromStr(String string, List<String> lPath) { String[] strings = string.split("\\|"); for (int i = 0; i < strings.length; i++) { *************** *** 438,442 **** public List<String> getPythonpath() { ! return new ArrayList<String>(this.pythonpath); } --- 439,445 ---- public List<String> getPythonpath() { ! synchronized (pythonpath) { ! return new ArrayList<String>(pythonpath); ! } } *************** *** 445,473 **** * about the files that are related to python modules. */ ! public ModulesFoundStructure getModulesFoundStructure(List<String> pythonpathList, IProgressMonitor monitor) { ModulesFoundStructure ret = new ModulesFoundStructure(); ! for (Iterator<String> iter = pythonpathList.iterator(); iter.hasNext() && monitor.isCanceled() == false;) { String element = iter.next(); //the slow part is getting the files... not much we can do (I think). File root = new File(element); ! PyFileListing.PyFileListingInfo below = getModulesBelow(root, monitor); if (below != null) { ! Iterator<File> e1 = below.filesFound.iterator(); ! Iterator<String> e2 = below.fileParentPathNamesRelativeToRoot.iterator(); ! //both must have the same size... so, just check hasNext in one of those while (e1.hasNext()) { ! File o1 = e1.next(); ! String o2 = e2.next(); String modName; ! if (o2.length() != 0) { ! modName = new StringBuffer(o2).append(".").append(stripExtension(o1.getName())).toString(); } else { ! modName = stripExtension(o1.getName()); } ! ret.regularModules.put(o1, modName); } --- 448,481 ---- * about the files that are related to python modules. */ ! public ModulesFoundStructure getModulesFoundStructure(IProgressMonitor monitor) { ! List<String> pythonpathList = getPythonpath(); ! ModulesFoundStructure ret = new ModulesFoundStructure(); ! for (Iterator<String> iter = pythonpathList.iterator(); iter.hasNext();) { String element = iter.next(); + if (monitor.isCanceled()) { + break; + } + //the slow part is getting the files... not much we can do (I think). File root = new File(element); ! PyFileListing below = getModulesBelow(root, monitor); if (below != null) { ! Iterator<PyFileInfo> e1 = below.getFoundPyFileInfos().iterator(); while (e1.hasNext()) { ! PyFileInfo pyFileInfo = e1.next(); ! File file = pyFileInfo.getFile(); ! String scannedModuleName = pyFileInfo.getModuleName(); String modName; ! if (scannedModuleName.length() != 0) { ! modName = new StringBuffer(scannedModuleName).append('.').append(stripExtension(file.getName())).toString(); } else { ! modName = stripExtension(file.getName()); } ! ret.regularModules.put(file, modName); } Index: ASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ASTManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ASTManager.java 31 Jul 2008 01:47:36 -0000 1.3 --- ASTManager.java 13 Aug 2008 21:12:15 -0000 1.4 *************** *** 11,22 **** --- 11,28 ---- import java.io.ObjectInputStream; import java.io.Serializable; + import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.IDocument; + import org.python.pydev.core.ExtensionHelper; import org.python.pydev.core.ICodeCompletionASTManager; import org.python.pydev.core.IModulesManager; import org.python.pydev.core.IProjectModulesManager; import org.python.pydev.core.IPythonNature; + import org.python.pydev.editor.codecompletion.IASTManagerObserver; + import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.plugin.nature.PythonNature; + import org.python.pydev.ui.interpreters.IInterpreterObserver; *************** *** 39,42 **** --- 45,50 ---- protected static final long serialVersionUID = 10L; + public ASTManager() {} + /** * Set the project this ast manager works with. *************** *** 44,47 **** --- 52,64 ---- public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas){ getProjectModulesManager().setProject(project, nature, restoreDeltas); + List<IASTManagerObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_MANAGER_OBSERVER); + for (IASTManagerObserver observer : participants) { + try { + observer.notifyASTManagerAttached(this); + } catch (Exception e) { + //let's keep it safe + PydevPlugin.log(e); + } + } } Index: ProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ProjectModulesManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ProjectModulesManager.java 31 Jul 2008 01:47:36 -0000 1.17 --- ProjectModulesManager.java 13 Aug 2008 21:12:15 -0000 1.18 *************** *** 69,72 **** --- 69,74 ---- private transient DeltaSaver<ModulesKey> deltaSaver; + public ProjectModulesManager() {} + /** * @see org.python.pydev.core.IProjectModulesManager#setProject(org.eclipse.core.resources.IProject, boolean) *************** *** 363,373 **** /** - * @see org.python.pydev.core.IProjectModulesManager#changePythonPath(java.lang.String, org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor) - */ - public void changePythonPath(String pythonpath, IProject project, IProgressMonitor monitor, String defaultSelectedInterpreter) { - super.changePythonPath(pythonpath, project, monitor, defaultSelectedInterpreter); - } - - /** * @see org.python.pydev.core.IProjectModulesManager#getSize(boolean) */ --- 365,368 ---- Index: ModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ModulesManager.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ModulesManager.java 14 Jun 2008 22:14:55 -0000 1.23 --- ModulesManager.java 13 Aug 2008 21:12:15 -0000 1.24 *************** *** 148,151 **** --- 148,158 ---- } + public void setPythonPathHelper(Object pathHelper) { + if (!(pathHelper instanceof PythonPathHelper)) { + throw new IllegalArgumentException(); + } + pythonPathHelper = (PythonPathHelper)pathHelper; + } + /** * The version for deserialization *************** *** 222,227 **** */ public void changePythonPath(String pythonpath, final IProject project, IProgressMonitor monitor, String defaultSelectedInterpreter) { ! List<String> pythonpathList = pythonPathHelper.setPythonPath(pythonpath); ! ModulesFoundStructure modulesFound = pythonPathHelper.getModulesFoundStructure(pythonpathList, monitor); //now, on to actually filling the module keys --- 229,234 ---- */ public void changePythonPath(String pythonpath, final IProject project, IProgressMonitor monitor, String defaultSelectedInterpreter) { ! pythonPathHelper.setPythonPath(pythonpath); ! ModulesFoundStructure modulesFound = pythonPathHelper.getModulesFoundStructure(monitor); //now, on to actually filling the module keys |