Thread: [Pydev-cvs] org.python.pydev/src/org/python/pydev/utils PyFileListing.java, 1.3, 1.4
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-08-13 21:12:07
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8061/src/org/python/pydev/utils Modified Files: PyFileListing.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: PyFileListing.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils/PyFileListing.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyFileListing.java 14 Jun 2008 22:14:57 -0000 1.3 --- PyFileListing.java 13 Aug 2008 21:12:15 -0000 1.4 *************** *** 4,7 **** --- 4,8 ---- import java.io.FileFilter; import java.util.ArrayList; + import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; *************** *** 25,75 **** public class PyFileListing { ! /** ! * Class containing the information we discovered when searching for valid files beneath some folder. ! * ! * @author Fabio ! */ ! public static class PyFileListingInfo{ ! ! /** ! * The files we found as being valid for the given filter ! */ ! public List<File> filesFound = new ArrayList<File>(); ! ! /** ! * The folders we found as being valid for the given filter ! */ ! public List<File> foldersFound = new ArrayList<File>(); ! ! /** ! * The relative path (composed with the parent folder names) where the file was found ! * (from the root passed) -- we should be able to determine the name of the module ! * of the corresponding file in the filesFound from this info. ! * ! * For each file found a string should be added in this list (so, the same path will be added ! * multiple times for different files). ! */ ! public List<String> fileParentPathNamesRelativeToRoot = new ArrayList<String>(); ! ! /** ! * Add the info from the passed listing to this one. ! */ ! public void extendWith(PyFileListingInfo other) { ! filesFound.addAll(other.filesFound); ! foldersFound.addAll(other.foldersFound); ! ! fileParentPathNamesRelativeToRoot.addAll(other.fileParentPathNamesRelativeToRoot); ! }; ! } /** ! * Returns the directories and python files in a list. ! * ! * @param file ! * @param addSubFolders: indicates if sub-folders should be added ! * @return tuple with files in pos 0 and folders in pos 1 ! */ @SuppressWarnings("unchecked") ! public static PyFileListingInfo getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, int level, boolean checkHasInit, String currModuleRep) { --- 26,64 ---- public class PyFileListing { ! /** ! * Information about a python file found (the actual file and the way it was resolved as a python module) ! */ ! public static final class PyFileInfo { ! ! private final String relPath; ! ! private final File file; ! ! public PyFileInfo(File file, String relPath) { ! this.file = file; ! this.relPath = relPath; ! } ! ! /** File object. */ ! public File getFile() { ! return file; ! } ! ! /** Returns fully qualified name of module. */ ! public String getModuleName() { ! return relPath; ! } ! } /** ! * Returns the directories and python files in a list. ! * ! * @param file ! * @param addSubFolders ! * indicates if sub-folders should be added ! * @return tuple with files in pos 0 and folders in pos 1 ! */ @SuppressWarnings("unchecked") ! private static PyFileListing getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, int level, boolean checkHasInit, String currModuleRep) { *************** *** 79,83 **** } ! PyFileListingInfo ret = new PyFileListingInfo(); if (file != null && file.exists()) { --- 68,72 ---- } ! PyFileListing ret = new PyFileListing(); if (file != null && file.exists()) { *************** *** 110,115 **** if(file2.isFile()){ ! ret.filesFound.add(file2); ! ret.fileParentPathNamesRelativeToRoot.add(currModuleRep); monitor.worked(1); --- 99,103 ---- if(file2.isFile()){ ! ret.addPyFileInfo(new PyFileInfo(file2, currModuleRep)); monitor.worked(1); *************** *** 145,150 **** } else if (file.isFile()) { ! ret.fileParentPathNamesRelativeToRoot.add(currModuleRep); ! ret.filesFound.add(file); } else{ --- 133,137 ---- } else if (file.isFile()) { ! ret.addPyFileInfo(new PyFileInfo(file, currModuleRep)); } else{ *************** *** 156,164 **** } ! public static PyFileListingInfo getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, boolean checkHasInit) { return getPyFilesBelow(file, filter, monitor, addSubFolders, 0, checkHasInit, ""); } ! public static PyFileListingInfo getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean checkHasInit) { return getPyFilesBelow(file, filter, monitor, true, checkHasInit); } --- 143,151 ---- } ! private static PyFileListing getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, boolean checkHasInit) { return getPyFilesBelow(file, filter, monitor, addSubFolders, 0, checkHasInit, ""); } ! public static PyFileListing getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean checkHasInit) { return getPyFilesBelow(file, filter, monitor, true, checkHasInit); } *************** *** 200,204 **** * @return tuple with files in pos 0 and folders in pos 1 */ ! public static PyFileListingInfo getPyFilesBelow(File file, IProgressMonitor monitor, final boolean includeDirs, boolean checkHasInit) { FileFilter filter = getPyFilesFileFilter(includeDirs); return getPyFilesBelow(file, filter, monitor, true, checkHasInit); --- 187,191 ---- * @return tuple with files in pos 0 and folders in pos 1 */ ! public static PyFileListing getPyFilesBelow(File file, IProgressMonitor monitor, final boolean includeDirs, boolean checkHasInit) { FileFilter filter = getPyFilesFileFilter(includeDirs); return getPyFilesBelow(file, filter, monitor, true, checkHasInit); *************** *** 228,230 **** --- 215,249 ---- } + /** + * The files we found as being valid for the given filter + */ + private final List<PyFileInfo> pyFileInfos = new ArrayList<PyFileInfo>(); + + /** + * The folders we found as being valid for the given filter + */ + private List<File> foldersFound = new ArrayList<File>(); + + public PyFileListing() { + } + + public Collection<PyFileInfo> getFoundPyFileInfos() { + return pyFileInfos; + } + + public Collection<File> getFoundFolders() { + return foldersFound; + } + + private void addPyFileInfo(PyFileInfo info) { + pyFileInfos.add(info); + } + + /** + * Add the info from the passed listing to this one. + */ + private void extendWith(PyFileListing other) { + pyFileInfos.addAll(other.pyFileInfos); + foldersFound.addAll(other.foldersFound); + } } |