Thread: [Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/codecoverage RunManyDialog.java,NONE,1
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13540/src/org/python/pydev/debug/codecoverage Modified Files: CoverageCache.java PyCodeCoverageView.java PyCoverage.java FileNode.java Added Files: RunManyDialog.java Log Message: making code coverage. Index: PyCodeCoverageView.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/PyCodeCoverageView.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCoverageView.java 13 Oct 2004 19:49:38 -0000 1.2 --- PyCodeCoverageView.java 15 Oct 2004 19:53:28 -0000 1.3 *************** *** 2,23 **** import java.io.File; ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.List; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; - import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; - import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; --- 2,26 ---- import java.io.File; ! import java.util.Iterator; + import org.eclipse.core.internal.resources.MarkerAttributeMap; + import org.eclipse.core.resources.IFile; + import org.eclipse.core.resources.IMarker; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; + import org.eclipse.jface.text.IDocument; + import org.eclipse.jface.text.IRegion; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; + import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; + import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; *************** *** 26,32 **** import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Text; ! import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.part.ViewPart; ! import org.python.pydev.editor.refactoring.PyRefactoring; import org.python.pydev.tree.AllowValidPathsFilter; import org.python.pydev.tree.FileTreeLabelProvider; --- 29,40 ---- import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Text; ! import org.eclipse.ui.IEditorInput; ! import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.part.ViewPart; ! import org.eclipse.ui.texteditor.MarkerUtilities; ! import org.python.pydev.editor.PyEdit; ! import org.python.pydev.editor.actions.PyOpenAction; ! import org.python.pydev.editor.model.ItemPointer; ! import org.python.pydev.editor.model.Location; import org.python.pydev.tree.AllowValidPathsFilter; import org.python.pydev.tree.FileTreeLabelProvider; *************** *** 48,72 **** */ ! public class PyCodeCoverageView extends ViewPart implements IPropertyListener, IStructuredContentProvider { ! private TreeViewer viewer; ! private Action doubleClickAction; ! private Action chooseAction; ! protected Action clearAction; private Button clearButton; ! private List elements = new ArrayList(); private Button chooseButton; ! private Composite rComposite; ! private Text text; ! protected String currentDir; /** --- 56,266 ---- */ ! public class PyCodeCoverageView extends ViewPart { ! private static final String NOT_EXECUTED_MARKER = "org.python.pydev.debug.notexecuted"; ! //layout stuff ! private Composite rComposite; ! //actions ! /** ! * double click the tree ! */ ! private DoubleClickTreeAction doubleClickAction = new DoubleClickTreeAction(); ! /** ! * changed selected element ! */ ! private SelectionChangedTreeAction selectionChangedAction = new SelectionChangedTreeAction(); ! /** ! * choose new dir ! */ ! private Action chooseAction = new ChooseAction(); + /** + * clear the results (and erase .coverage file) + */ + protected Action clearAction = new ClearAction();; + + /** + * get the new results from the .coverage file + */ + protected Action refreshAction = new RefreshAction();; + + //buttons private Button clearButton; ! private Button refreshButton; private Button chooseButton; ! //write the results here private Text text; ! //tree som that user can browse results. ! private TreeViewer viewer; ! ! /** ! * ! */ ! private File lastChosenFile; ! ! private SashForm s; ! ! //Actions ------------------------------ ! /** ! * In this action we have to go and refresh all the info based on the chosen ! * dir. ! * ! * @author Fabio Zadrozny ! */ ! private final class RefreshAction extends Action { ! public void run() { ! PyCoverage.getPyCoverage().refreshCoverageInfo(lastChosenFile); ! viewer.setInput(lastChosenFile); //new files may have been added. ! text.setText("Refreshed info."); ! } ! } ! ! /** ! * ! * @author Fabio Zadrozny ! */ ! private final class ClearAction extends Action { ! public void run() { ! ! PyCoverage.getPyCoverage().clearInfo(); ! ! MessageDialog.openInformation(getSite().getShell(), "Cleared", ! "All the coverage data has been cleared!"); ! ! text.setText("Data cleared (NOT REFRESHED)."); ! } ! } ! ! /** ! * ! * @author Fabio Zadrozny ! */ ! private final class SelectionChangedTreeAction extends Action { ! public void run() { ! run((IStructuredSelection) viewer.getSelection()); ! } ! ! /** ! * @param event ! */ ! public void runWithEvent(SelectionChangedEvent event) { ! run((IStructuredSelection) event.getSelection()); ! } ! ! public void run(IStructuredSelection selection) { ! Object obj = selection.getFirstElement(); ! ! if (obj == null) ! return; ! ! File realFile = new File(obj.toString()); ! if (realFile.exists()) { ! text.setText(PyCoverage.getPyCoverage().cache.getStatistics(realFile)); ! } ! } ! ! } ! ! /** ! * ! * @author Fabio Zadrozny ! */ ! private final class DoubleClickTreeAction extends Action { ! ! public void run() { ! run(viewer.getSelection()); ! } ! ! /** ! * @param event ! */ ! public void runWithEvent(DoubleClickEvent event) { ! run(event.getSelection()); ! } ! ! public void run(ISelection selection) { ! try { ! Object obj = ((IStructuredSelection) selection).getFirstElement(); ! ! File realFile = new File(obj.toString()); ! if (realFile.exists() && !realFile.isDirectory()) { ! System.out.println("opening file:" + obj.toString()); ! ItemPointer p = new ItemPointer(realFile, new Location(-1, -1), null); ! PyOpenAction act = new PyOpenAction(); ! act.run(p); ! ! if(act.editor instanceof PyEdit){ ! PyEdit e = (PyEdit) act.editor; ! IEditorInput input = e.getEditorInput(); ! IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; ! if (original == null) ! return; ! IDocument document = e.getDocumentProvider().getDocument(e.getEditorInput()); ! ! String type = NOT_EXECUTED_MARKER; ! type = IMarker.PROBLEM; ! original.deleteMarkers(type, false, 1); ! ! ! ! String message = "Not Executed"; ! ! FileNode cache = (FileNode) PyCoverage.getPyCoverage().cache.getFile(realFile); ! for(Iterator it = cache.notExecutedIterator();it.hasNext();){ ! MarkerAttributeMap map = new MarkerAttributeMap(); ! int errorLine = ((Integer)it.next()).intValue()-1; ! // System.out.println("adding at:"+errorLine); ! ! IRegion region = document.getLineInformation(errorLine); ! int errorEnd = region.getOffset(); ! int errorStart = region.getOffset()+region.getLength(); ! ! map.put(IMarker.MESSAGE, message); ! map.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); ! map.put(IMarker.LINE_NUMBER, new Integer(errorLine)); ! map.put(IMarker.CHAR_START, new Integer(errorStart)); ! map.put(IMarker.CHAR_END, new Integer(errorEnd)); ! map.put(IMarker.TRANSIENT, Boolean.valueOf(true)); ! map.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH)); ! ! MarkerUtilities.createMarker(original, map, type); ! } ! ! } ! } ! } catch (Exception e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } ! } ! } ! ! /** ! * ! * @author Fabio Zadrozny ! */ ! private final class ChooseAction extends Action { ! public void run() { ! DirectoryDialog dialog = new DirectoryDialog(getSite().getShell()); ! if (lastChosenFile != null && lastChosenFile.exists()) { ! dialog.setFilterPath(lastChosenFile.getParent()); ! } ! String string = dialog.open(); ! if (string != null) { ! File file = new File(string); ! lastChosenFile = file; ! refreshAction.run(); ! } ! } ! } ! ! // Class ------------------------------------------------------------------- /** *************** *** 86,89 **** --- 280,284 ---- */ public void createPartControl(Composite parent) { + GridLayout layout = new GridLayout(); layout.numColumns = 2; *************** *** 93,96 **** --- 288,301 ---- parent.setLayout(layout); + s = new SashForm(parent, SWT.HORIZONTAL); + GridData layoutData = new GridData(); + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + layoutData.horizontalAlignment = GridData.FILL; + layoutData.verticalAlignment = GridData.FILL; + s.setLayoutData(layoutData); + + parent = s; + rComposite = new Composite(parent, SWT.MULTI); layout = new GridLayout(); *************** *** 99,103 **** layout.marginWidth = 0; layout.marginHeight = 2; ! GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; --- 304,308 ---- layout.marginWidth = 0; layout.marginHeight = 2; ! layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; *************** *** 108,111 **** --- 313,321 ---- text = new Text(parent, SWT.MULTI); + try { + text.setFont(new Font(null, "Courier new", 10, 0)); + } catch (Exception e) { + //ok, might mot be available. + } layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; *************** *** 114,118 **** layoutData.verticalAlignment = GridData.FILL; text.setLayoutData(layoutData); - text.setEditable(false); parent = rComposite; --- 324,327 ---- *************** *** 120,133 **** //choose button chooseButton = new Button(parent, SWT.PUSH); - chooseAction = new Action() { - public void run() { - DirectoryDialog dialog = new DirectoryDialog(getSite().getShell()); - String string = dialog.open(); - if (string != null) { - text.setText("Chosen dir:" + string); - notifyDirChanged(string); - } - } - }; createButton(parent, chooseButton, "Choose dir!", chooseAction); //end choose button --- 329,332 ---- *************** *** 138,155 **** viewer.addFilter(new AllowValidPathsFilter()); - doubleClickAction = new Action() { - public void run() { - ISelection selection = viewer.getSelection(); - Object obj = ((IStructuredSelection) selection).getFirstElement(); - - File realFile = new File(obj.toString()); - if (realFile.exists()) { - System.out.println("opening file:" + obj.toString()); - // ItemPointer p = new ItemPointer(realFile, new - // Location(-1, -1), null); - // new PyOpenAction().run(p); - } - } - }; hookViewerActions(); --- 337,340 ---- *************** *** 163,195 **** //clear results button clearButton = new Button(parent, SWT.PUSH); - clearAction = new Action() { - public void run() { - - PyCoverage.getPyCoverage().clearInfo(); - - MessageDialog.openInformation(getSite().getShell(), "Cleared", - "All the coverage data has been cleared!"); - - text.setText(""); - } - }; createButton(parent, clearButton, "Clear coverage information!", clearAction); //end choose button ! this.refresh(); ! ! } ! /** ! * @param string ! */ ! protected void notifyDirChanged(String newDir) { ! File file = new File(newDir); ! PyCoverage.getPyCoverage().refreshCoverageInfo(file); ! viewer.setInput(file); } /** * @param parent * @param button --- 348,366 ---- //clear results button clearButton = new Button(parent, SWT.PUSH); createButton(parent, clearButton, "Clear coverage information!", clearAction); //end choose button ! //refresh button ! refreshButton = new Button(parent, SWT.PUSH); ! createButton(parent, refreshButton, "Refresh coverage information!", refreshAction); ! //end choose button ! this.refresh(); } /** + * Create button with hooked action. + * * @param parent * @param button *************** *** 216,223 **** } private void hookViewerActions() { viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ! doubleClickAction.run(); } }); --- 387,398 ---- } + /** + * + * Add the double click and selection changed action + */ private void hookViewerActions() { viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { ! doubleClickAction.runWithEvent(event); } }); *************** *** 226,234 **** public void selectionChanged(SelectionChangedEvent event) { ! IStructuredSelection selection = (IStructuredSelection) event.getSelection(); ! ! Object selected_file = selection.getFirstElement(); ! System.out.println("Number of items selected is " + selection.size()); ! System.out.println("selected_file = " + selected_file); } --- 401,405 ---- public void selectionChanged(SelectionChangedEvent event) { ! selectionChangedAction.runWithEvent(event); } *************** *** 243,270 **** } - public void propertyChanged(Object source, int propId) { - if (source == null) { - return; - } - - Object[] sources = (Object[]) source; - - if (sources[0] == null || sources[1] == null) { - return; - } - - if (sources[0] == PyRefactoring.getPyRefactoring() && propId == PyRefactoring.REFACTOR_RESULT) { - - elements.clear(); - elements.addAll((Collection) sources[1]); - } - } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - public Object[] getElements(Object parent) { - return elements.toArray(); - } - } \ No newline at end of file --- 414,416 ---- Index: FileNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/FileNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileNode.java 15 Oct 2004 12:09:53 -0000 1.1 --- FileNode.java 15 Oct 2004 19:53:28 -0000 1.2 *************** *** 7,10 **** --- 7,13 ---- import java.text.DecimalFormat; + import java.util.ArrayList; + import java.util.Iterator; + import java.util.List; /** *************** *** 79,82 **** --- 82,106 ---- } + /** + * + */ + public Iterator notExecutedIterator() { + List l = new ArrayList(); + + String[] toks = notExecuted.replaceAll(" ", "").split(","); + for (int i = 0; i < toks.length; i++) { + if(toks[i].indexOf("-") == -1){ + l.add(new Integer(toks[i])); + }else{ + String[] begEnd = toks[i].split("-"); + for (int j = Integer.parseInt(begEnd[0]) ; j <= Integer.parseInt(begEnd[1]); j++){ + l.add(new Integer(j)); + } + } + } + + return l.iterator(); + } + } Index: PyCoverage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/PyCoverage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCoverage.java 13 Oct 2004 19:49:38 -0000 1.2 --- PyCoverage.java 15 Oct 2004 19:53:28 -0000 1.3 *************** *** 37,60 **** */ public class PyCoverage { ! /** * This method contacts the python server so that we get the information on ! * the files that are below the directory passed as a parameter * ! * @param file2 */ public void refreshCoverageInfo(File file) { try { ! List pyFilesBelow = null; if (file.exists()) { pyFilesBelow = getPyFilesBelow(file); ! } else { ! pyFilesBelow = new ArrayList(); ! } ! if(pyFilesBelow.size() == 0){ return; } //now that we have the file information, we have to get the // coverage information on these files and --- 37,81 ---- */ public class PyCoverage { ! ! public CoverageCache cache = new CoverageCache(); ! ! /** * This method contacts the python server so that we get the information on ! * the files that are below the directory passed as a parameter and stores the information ! * needed on the cache. * ! * @param file should be the root folder from where we want cache info. */ public void refreshCoverageInfo(File file) { + cache.clear(); try { ! if(file.isDirectory() == false){ ! throw new RuntimeException("We can only get information on a dir."); ! } ! ! List pyFilesBelow[] = new List[]{new ArrayList(), new ArrayList()}; ! if (file.exists()) { pyFilesBelow = getPyFilesBelow(file); ! } ! if(pyFilesBelow[0].size() == 0){ //no files return; } + //add the folders to the cache + boolean added = false; + for (Iterator it = pyFilesBelow[1].iterator(); it.hasNext();) { + File f = (File) it.next(); + if(!added){ + cache.addFolder(f); + added = true; + }else{ + cache.addFolder(f, f.getParentFile()); + } + } + + //now that we have the file information, we have to get the // coverage information on these files and *************** *** 73,86 **** //python coverage.py -r -m files.... ! String[] cmdLine = new String[4+ pyFilesBelow.size()]; cmdLine[0] = PydevPrefs.getDefaultInterpreter(); cmdLine[1] = profileScript; ! cmdLine[2] = "-r"; ! cmdLine[3] = "-m"; ! int i = 4; ! for (Iterator iter = pyFilesBelow.iterator(); iter.hasNext();) { ! cmdLine[i] = iter.next().toString(); ! i++; ! } Process p=null; --- 94,102 ---- //python coverage.py -r -m files.... ! String[] cmdLine = new String[3]; cmdLine[0] = PydevPrefs.getDefaultInterpreter(); cmdLine[1] = profileScript; ! cmdLine[2] = "-waitfor"; ! Process p=null; *************** *** 94,106 **** BufferedReader eIn = new BufferedReader(new InputStreamReader(p.getErrorStream()), bufsize); p.getOutputStream().close(); String str = ""; while ((str = eIn.readLine()) != null) { ! System.out.println("STDERR: " + str); //ignore this... } eIn.close(); while ((str = in.readLine()) != null) { ! System.out.println("STDOUT: " + str);//get the data... StringTokenizer tokenizer = new StringTokenizer(str); if(tokenizer.countTokens() ==5){ --- 110,129 ---- BufferedReader eIn = new BufferedReader(new InputStreamReader(p.getErrorStream()), bufsize); + String files = ""; + + for (Iterator iter = pyFilesBelow[0].iterator(); iter.hasNext();) { + files += iter.next().toString()+" "; + } + files += "\r"; + p.getOutputStream().write(files.getBytes()); p.getOutputStream().close(); String str = ""; while ((str = eIn.readLine()) != null) { ! // System.out.println("STDERR: " + str); //ignore this... } eIn.close(); while ((str = in.readLine()) != null) { ! // System.out.println("STDOUT: " + str);//get the data... StringTokenizer tokenizer = new StringTokenizer(str); if(tokenizer.countTokens() ==5){ *************** *** 115,120 **** if(strings[1].equals("Stmts") == false){ //information in the format: D:\dev_programs\test\test1.py 11 0 0% 1,2,4-23 ! System.out.println("VALID: " + str);//get the data... ! } } --- 138,144 ---- if(strings[1].equals("Stmts") == false){ //information in the format: D:\dev_programs\test\test1.py 11 0 0% 1,2,4-23 ! // System.out.println("VALID: " + str);//get the data... ! File f = new File(strings[0]); ! cache.addFile(f, f.getParentFile(), Integer.parseInt(strings[1]), Integer.parseInt(strings[2]), strings[4]); } } *************** *** 123,126 **** --- 147,151 ---- System.out.println("waiting"); p.waitFor(); + System.out.println("finished"); } catch (Exception e) { if(p!=null){ *************** *** 138,141 **** --- 163,187 ---- } + + /** + * + */ + public void clearInfo() { + try { + String profileScript; + profileScript = PythonRunnerConfig.getProfileScript(); + String[] cmdLine = new String[3]; + cmdLine[0] = PydevPrefs.getDefaultInterpreter(); + cmdLine[1] = profileScript; + cmdLine[2] = "-e"; + Process p = execute(cmdLine); + p.waitFor(); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + + } + /** * @param cmdLine *************** *** 145,159 **** private Process execute(String[] cmdLine) throws IOException { Process p; - Properties properties = System.getProperties(); - Set set = properties.keySet(); ! String []envp = new String [set.size()]; ! int j = 0; ! for (Iterator iter = set.iterator(); iter.hasNext();) { ! Object element = (Object) iter.next(); ! envp[j] = element+"="+properties.getProperty(element.toString()).toString(); ! j++; ! } ! envp = PyCoverage.setCoverageFileEnviromentVariable(envp); p = Runtime.getRuntime().exec(cmdLine, envp); --- 191,196 ---- private Process execute(String[] cmdLine) throws IOException { Process p; ! String [] envp = PyCoverage.setCoverageFileEnviromentVariable(null); p = Runtime.getRuntime().exec(cmdLine, envp); *************** *** 162,185 **** - /** * * @param file */ ! private List getPyFilesBelow(File file) { List filesToReturn = new ArrayList(); if (file.exists() == true) { if (file.isDirectory()) { ! File[] files = file.listFiles(new FileFilter() { ! ! public boolean accept(File pathname) { ! return pathname.isDirectory() || pathname.toString().endsWith(".py"); ! } ! ! }); for (int i = 0; i < files.length; i++) { ! filesToReturn.addAll(getPyFilesBelow(files[i])); } } else if (file.isFile()) { --- 199,228 ---- /** + * Returns the directories and python files in a list. * * @param file + * @return tuple with files in pos 0 and folders in pos 1 */ ! public static List[] getPyFilesBelow(File file , FileFilter filter) { List filesToReturn = new ArrayList(); + List folders = new ArrayList(); if (file.exists() == true) { if (file.isDirectory()) { ! folders.add(file); ! File[] files = null; ! ! if(filter != null){ ! files = file.listFiles(filter); ! }else{ ! files = file.listFiles(); ! } ! for (int i = 0; i < files.length; i++) { ! List[] below = getPyFilesBelow(files[i]); ! filesToReturn.addAll(below[0]); ! folders.addAll(below[1]); } } else if (file.isFile()) { *************** *** 187,191 **** } } ! return filesToReturn; } --- 230,252 ---- } } ! return new List[]{filesToReturn, folders}; ! ! } ! ! /** ! * Returns the directories and python files in a list. ! * ! * @param file ! * @return tuple with files in pos 0 and folders in pos 1 ! */ ! public static List[] getPyFilesBelow(File file) { ! FileFilter filter = new FileFilter() { ! ! public boolean accept(File pathname) { ! return pathname.isDirectory() || pathname.toString().endsWith(".py"); ! } ! ! }; ! return getPyFilesBelow(file, filter); } *************** *** 216,219 **** --- 277,294 ---- */ public static String[] setCoverageFileEnviromentVariable(String[] envp) { + if(envp == null){ + Properties properties = System.getProperties(); + Set set = properties.keySet(); + + envp = new String [set.size()]; + int j = 0; + for (Iterator iter = set.iterator(); iter.hasNext();) { + Object element = (Object) iter.next(); + envp[j] = element+"="+properties.getProperty(element.toString()).toString(); + j++; + } + + } + boolean added = false; *************** *** 234,256 **** } - /** - * - */ - public void clearInfo() { - try { - String profileScript; - profileScript = PythonRunnerConfig.getProfileScript(); - String[] cmdLine = new String[3]; - cmdLine[0] = PydevPrefs.getDefaultInterpreter(); - cmdLine[1] = profileScript; - cmdLine[2] = "-e"; - Process p = execute(cmdLine); - p.waitFor(); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - - } } \ No newline at end of file --- 309,312 ---- Index: CoverageCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/CoverageCache.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CoverageCache.java 15 Oct 2004 12:09:53 -0000 1.1 --- CoverageCache.java 15 Oct 2004 19:53:28 -0000 1.2 *************** *** 45,54 **** */ public void addFolder(Object node, Object parent) { ! FolderNode parentNode = (FolderNode) folders.get(parent); FolderNode newNode = new FolderNode(); newNode.node = node; if(parentNode == null){ ! throw new RuntimeException("The folder being added didn't have its parent found."); } --- 45,54 ---- */ public void addFolder(Object node, Object parent) { ! FolderNode parentNode = (FolderNode) getFolder(parent); FolderNode newNode = new FolderNode(); newNode.node = node; if(parentNode == null){ ! throw new RuntimeException("The folder being added:"+node.toString()+" didn't have its parent found."); } *************** *** 57,60 **** --- 57,85 ---- } + public Object getFolder(Object obj){ + return getIt(obj,folders); + } + + public Object getFile(Object obj){ + return getIt(obj,files); + } + + /** + * @param obj + * @return + */ + private Object getIt(Object obj, Map m) { + Object object = m.get(obj); + if (object == null){ + for (Iterator iter = m.keySet().iterator(); iter.hasNext();) { + Object element = (Object) iter.next(); + if(element.equals(obj)){ + return m.get(element); + } + } + } + return object; + } + /** * *************** *** 66,70 **** */ public void addFile(Object node, Object parent, int stmts, int exec, String notExecuted) { ! FolderNode folderNode = (FolderNode) folders.get(parent); if (folderNode == null){ --- 91,95 ---- */ public void addFile(Object node, Object parent, int stmts, int exec, String notExecuted) { ! FolderNode folderNode = (FolderNode) getFolder(parent); if (folderNode == null){ *************** *** 83,89 **** public List getFiles(Object node){ ! FolderNode folderNode = (FolderNode) folders.get(node); if (folderNode == null){ ! FileNode fileNode = (FileNode) files.get(node); if (fileNode == null){ throw new RuntimeException("The node has not been found: "+node.toString()); --- 108,114 ---- public List getFiles(Object node){ ! FolderNode folderNode = (FolderNode) getFolder(node); if (folderNode == null){ ! FileNode fileNode = (FileNode) getFile(node); if (fileNode == null){ throw new RuntimeException("The node has not been found: "+node.toString()); *************** *** 157,160 **** --- 182,194 ---- return buffer.toString(); } + + /** + * + */ + public void clear() { + folders.clear(); + files.clear(); + + } --- NEW FILE: RunManyDialog.java --- /* * Created on Oct 15, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.debug.codecoverage; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; /** * @author Fabio Zadrozny */ public class RunManyDialog extends Dialog{ private String root; public Text textRootFolder; public Text textFilesThatMatch; public Text textWorkingDir; public Text textInterpreter; public String rootFolder; public String files; public String interpreter; public String working; /** * @param parentShell */ public RunManyDialog(Shell parentShell, String root) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE); this.root = root; } protected Control createDialogArea(Composite parent) { // create a composite with standard margins and spacing Composite composite = (Composite) super.createDialogArea(parent); GridData layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; Label label = new Label(composite, 0); label.setText("Root folder:"); label.setLayoutData(layoutData); layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; textRootFolder = new Text(composite, SWT.SINGLE); textRootFolder.setText(root); textRootFolder.setLayoutData(layoutData); //------- layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; Label label2 = new Label(composite, 0); label2.setText("Files that match:"); label2.setLayoutData(layoutData); layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; textFilesThatMatch = new Text(composite, SWT.SINGLE); textFilesThatMatch.setText("test*.py"); textFilesThatMatch.setLayoutData(layoutData); //-------- layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; Label label3 = new Label(composite, 0); label3.setText("Working Dir:"); label3.setLayoutData(layoutData); layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; textWorkingDir = new Text(composite, SWT.SINGLE); textWorkingDir.setText(this.root); textWorkingDir.setLayoutData(layoutData); //------- layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; Label label4 = new Label(composite, 0); label4.setText("Interpreter"); label4.setLayoutData(layoutData); layoutData = new GridData(); layoutData.grabExcessHorizontalSpace = true; layoutData.grabExcessVerticalSpace = true; layoutData.horizontalAlignment = GridData.FILL; layoutData.verticalAlignment = GridData.FILL; textInterpreter = new Text(composite, SWT.SINGLE); textInterpreter.setText("python"); textInterpreter.setLayoutData(layoutData); return composite; } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { rootFolder = textRootFolder.getText(); files = textFilesThatMatch.getText(); interpreter = textInterpreter.getText(); working = textWorkingDir.getText(); // TODO Auto-generated method stub super.okPressed(); } } |