[Pydev-cvs] org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/env IProcessFacto
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:42
|
Update of /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/env In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/src_console/org/python/pydev/debug/newconsole/env Modified Files: IProcessFactory.java ChooseProcessTypeDialog.java PydevSpawnedInterpreterProcess.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: ChooseProcessTypeDialog.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/env/ChooseProcessTypeDialog.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ChooseProcessTypeDialog.java 24 Mar 2008 01:53:27 -0000 1.2 --- ChooseProcessTypeDialog.java 27 Sep 2008 19:59:06 -0000 1.3 *************** *** 26,30 **** */ final class ChooseProcessTypeDialog extends Dialog { ! private Button checkboxForCurrentEditor; --- 26,30 ---- */ final class ChooseProcessTypeDialog extends Dialog { ! private Button checkboxForCurrentEditor; *************** *** 33,43 **** private Button checkboxJython; ! private PyEdit activeEditor; ! private Collection<String> pythonpath; ! private IInterpreterManager interpreterManager; ! ! private List<IPythonNature> natures = new ArrayList<IPythonNature>(); ChooseProcessTypeDialog(Shell shell, PyEdit activeEditor) { --- 33,43 ---- private Button checkboxJython; ! private PyEdit activeEditor; ! private Collection<String> pythonpath; ! private IInterpreterManager interpreterManager; ! ! private List<IPythonNature> natures = new ArrayList<IPythonNature>(); ChooseProcessTypeDialog(Shell shell, PyEdit activeEditor) { *************** *** 70,87 **** */ private void configureButton(Button checkBox, String python, IInterpreterManager interpreterManager) { ! boolean enabled = false; ! String text; ! try{ ! if(interpreterManager.getDefaultInterpreter() != null){ ! text = python+" console"; ! enabled = true; ! }else{ ! throw new NotConfiguredInterpreterException(); ! } ! }catch(NotConfiguredInterpreterException e){ ! text = "Unable to create console for "+python+" (interpreter not configured)"; ! } ! checkBox.setText(text); ! checkBox.setEnabled(enabled); } --- 70,87 ---- */ private void configureButton(Button checkBox, String python, IInterpreterManager interpreterManager) { ! boolean enabled = false; ! String text; ! try{ ! if(interpreterManager.getDefaultInterpreter() != null){ ! text = python+" console"; ! enabled = true; ! }else{ ! throw new NotConfiguredInterpreterException(); ! } ! }catch(NotConfiguredInterpreterException e){ ! text = "Unable to create console for "+python+" (interpreter not configured)"; ! } ! checkBox.setText(text); ! checkBox.setEnabled(enabled); } *************** *** 89,164 **** * Configures a button related to an editor. */ ! private void configureEditorButton() { ! boolean enabled = false; String text; try{ if(this.activeEditor != null){ ! IPythonNature nature = this.activeEditor.getPythonNature(); ! if(nature != null){ ! ! if(nature.getRelatedInterpreterManager().getDefaultInterpreter() != null){ ! text = "Console for currently active editor"; ! enabled = true; ! }else{ ! throw new NotConfiguredInterpreterException(); ! } ! }else{ ! text = "No python nature configured for the current editor"; ! } }else{ ! text = "Unable to create console for current editor (no active editor)"; } }catch(NotConfiguredInterpreterException e){ ! //expected ! text = "Unable to create console for current editor (interpreter not configured for the editor)"; } checkboxForCurrentEditor.setText(text); checkboxForCurrentEditor.setEnabled(enabled); ! } ! ! /** ! * Sets the internal pythonpath chosen. ! */ @Override protected void okPressed() { ! IInterpreterManager localInterpreterManager = null; ! if(checkboxForCurrentEditor.isEnabled() && checkboxForCurrentEditor.getSelection()){ ! IProject project = this.activeEditor.getProject(); ! PythonNature nature = PythonNature.getPythonNature(project); ! natures.add(nature); ! this.pythonpath = new ArrayList<String>(nature.getPythonPathNature().getCompleteProjectPythonPath( ! nature.getRelatedInterpreterManager().getDefaultInterpreter())); ! this.interpreterManager = nature.getRelatedInterpreterManager(); ! }else if(checkboxPython.isEnabled() && checkboxPython.getSelection()){ ! localInterpreterManager = PydevPlugin.getPythonInterpreterManager(); ! }else if(checkboxJython.isEnabled() && checkboxJython.getSelection()){ ! localInterpreterManager = PydevPlugin.getJythonInterpreterManager(); ! } if(localInterpreterManager != null){ ! this.interpreterManager = localInterpreterManager; ! String defaultInterpreter = localInterpreterManager.getDefaultInterpreter(); ! IWorkspace w = ResourcesPlugin.getWorkspace(); ! HashSet<String> pythonpath = new HashSet<String>(); ! for(IProject p:w.getRoot().getProjects()){ ! PythonNature nature = PythonNature.getPythonNature(p); ! try{ ! if(nature != null){ ! if(nature.getRelatedInterpreterManager() == localInterpreterManager){ ! natures.add(nature); ! pythonpath.addAll(nature.getPythonPathNature(). ! getCompleteProjectPythonPath(defaultInterpreter)); ! } ! } ! }catch(Exception e){ ! PydevPlugin.log(e); ! } ! } ! this.pythonpath = pythonpath; } --- 89,164 ---- * Configures a button related to an editor. */ ! private void configureEditorButton() { ! boolean enabled = false; String text; try{ if(this.activeEditor != null){ ! IPythonNature nature = this.activeEditor.getPythonNature(); ! if(nature != null){ ! ! if(nature.getRelatedInterpreterManager().getDefaultInterpreter() != null){ ! text = "Console for currently active editor"; ! enabled = true; ! }else{ ! throw new NotConfiguredInterpreterException(); ! } ! }else{ ! text = "No python nature configured for the current editor"; ! } }else{ ! text = "Unable to create console for current editor (no active editor)"; } }catch(NotConfiguredInterpreterException e){ ! //expected ! text = "Unable to create console for current editor (interpreter not configured for the editor)"; } checkboxForCurrentEditor.setText(text); checkboxForCurrentEditor.setEnabled(enabled); ! } ! ! /** ! * Sets the internal pythonpath chosen. ! */ @Override protected void okPressed() { ! IInterpreterManager localInterpreterManager = null; ! if(checkboxForCurrentEditor.isEnabled() && checkboxForCurrentEditor.getSelection()){ ! IProject project = this.activeEditor.getProject(); ! PythonNature nature = PythonNature.getPythonNature(project); ! natures.add(nature); ! this.pythonpath = new ArrayList<String>(nature.getPythonPathNature().getCompleteProjectPythonPath( ! nature.getRelatedInterpreterManager().getDefaultInterpreter())); ! this.interpreterManager = nature.getRelatedInterpreterManager(); ! }else if(checkboxPython.isEnabled() && checkboxPython.getSelection()){ ! localInterpreterManager = PydevPlugin.getPythonInterpreterManager(); ! }else if(checkboxJython.isEnabled() && checkboxJython.getSelection()){ ! localInterpreterManager = PydevPlugin.getJythonInterpreterManager(); ! } if(localInterpreterManager != null){ ! this.interpreterManager = localInterpreterManager; ! String defaultInterpreter = localInterpreterManager.getDefaultInterpreter(); ! IWorkspace w = ResourcesPlugin.getWorkspace(); ! HashSet<String> pythonpath = new HashSet<String>(); ! for(IProject p:w.getRoot().getProjects()){ ! PythonNature nature = PythonNature.getPythonNature(p); ! try{ ! if(nature != null){ ! if(nature.getRelatedInterpreterManager() == localInterpreterManager){ ! natures.add(nature); ! pythonpath.addAll(nature.getPythonPathNature(). ! getCompleteProjectPythonPath(defaultInterpreter)); ! } ! } ! }catch(Exception e){ ! PydevPlugin.log(e); ! } ! } ! this.pythonpath = pythonpath; } *************** *** 174,182 **** } ! public IInterpreterManager getInterpreterManager() { ! return this.interpreterManager; ! } ! ! public List<IPythonNature> getNatures() { return natures; } --- 174,182 ---- } ! public IInterpreterManager getInterpreterManager() { ! return this.interpreterManager; ! } ! ! public List<IPythonNature> getNatures() { return natures; } Index: IProcessFactory.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/env/IProcessFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IProcessFactory.java 31 Jul 2008 23:48:22 -0000 1.8 --- IProcessFactory.java 27 Sep 2008 19:59:06 -0000 1.9 *************** *** 63,67 **** public Tuple3<Launch, Process, Integer> createInteractiveLaunch() throws UserCanceledException, Exception { ! IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = workbenchWindow.getActivePage(); --- 63,67 ---- public Tuple3<Launch, Process, Integer> createInteractiveLaunch() throws UserCanceledException, Exception { ! IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IWorkbenchPage activePage = workbenchWindow.getActivePage(); *************** *** 76,119 **** ChooseProcessTypeDialog dialog = new ChooseProcessTypeDialog(getShell(), edit); if(dialog.open() == ChooseProcessTypeDialog.OK){ ! ! Collection<String> pythonpath = dialog.getPythonpath(); ! IInterpreterManager interpreterManager = dialog.getInterpreterManager(); ! ! if(pythonpath != null && interpreterManager != null){ ! naturesUsed = dialog.getNatures(); ! int port = SocketUtil.findUnusedLocalPort(); ! int clientPort = SocketUtil.findUnusedLocalPort(); ! ! final Launch launch = new Launch(null, "interactive", null); ! launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "false"); ! launch.setAttribute(INTERACTIVE_LAUNCH_PORT, ""+port); ! ! String pythonpathEnv = SimpleRunner.makePythonPathEnvFromPaths(pythonpath); ! String[] env = SimpleRunner.createEnvWithPythonpath(pythonpathEnv); ! ! File scriptWithinPySrc = PydevPlugin.getScriptWithinPySrc("pydevconsole.py"); ! String[] commandLine; ! if(interpreterManager.isPython()){ ! commandLine = SimplePythonRunner.makeExecutableCommandStr(scriptWithinPySrc.getAbsolutePath(), ! new String[]{String.valueOf(port), String.valueOf(clientPort)}); ! ! }else if(interpreterManager.isJython()){ ! String vmArgs = PydevDebugPlugin.getDefault().getPreferenceStore(). ! getString(PydevConsoleConstants.INTERACTIVE_CONSOLE_VM_ARGS); ! ! commandLine = SimpleJythonRunner.makeExecutableCommandStrWithVMArgs(scriptWithinPySrc.getAbsolutePath(), ! pythonpathEnv, vmArgs, new String[]{String.valueOf(port), String.valueOf(clientPort)}); ! ! }else{ ! throw new RuntimeException("Expected interpreter manager to be python or jython related."); ! } ! process = SimpleRunner.createProcess(commandLine, env, null); ! PydevSpawnedInterpreterProcess spawnedInterpreterProcess = ! new PydevSpawnedInterpreterProcess(process, launch); ! ! launch.addProcess(spawnedInterpreterProcess); ! ! return new Tuple3<Launch, Process, Integer>(launch, process, clientPort); ! } } return null; --- 76,119 ---- ChooseProcessTypeDialog dialog = new ChooseProcessTypeDialog(getShell(), edit); if(dialog.open() == ChooseProcessTypeDialog.OK){ ! ! Collection<String> pythonpath = dialog.getPythonpath(); ! IInterpreterManager interpreterManager = dialog.getInterpreterManager(); ! ! if(pythonpath != null && interpreterManager != null){ ! naturesUsed = dialog.getNatures(); ! int port = SocketUtil.findUnusedLocalPort(); ! int clientPort = SocketUtil.findUnusedLocalPort(); ! ! final Launch launch = new Launch(null, "interactive", null); ! launch.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "false"); ! launch.setAttribute(INTERACTIVE_LAUNCH_PORT, ""+port); ! ! String pythonpathEnv = SimpleRunner.makePythonPathEnvFromPaths(pythonpath); ! String[] env = SimpleRunner.createEnvWithPythonpath(pythonpathEnv); ! ! File scriptWithinPySrc = PydevPlugin.getScriptWithinPySrc("pydevconsole.py"); ! String[] commandLine; ! if(interpreterManager.isPython()){ ! commandLine = SimplePythonRunner.makeExecutableCommandStr(scriptWithinPySrc.getAbsolutePath(), ! new String[]{String.valueOf(port), String.valueOf(clientPort)}); ! ! }else if(interpreterManager.isJython()){ ! String vmArgs = PydevDebugPlugin.getDefault().getPreferenceStore(). ! getString(PydevConsoleConstants.INTERACTIVE_CONSOLE_VM_ARGS); ! ! commandLine = SimpleJythonRunner.makeExecutableCommandStrWithVMArgs(scriptWithinPySrc.getAbsolutePath(), ! pythonpathEnv, vmArgs, new String[]{String.valueOf(port), String.valueOf(clientPort)}); ! ! }else{ ! throw new RuntimeException("Expected interpreter manager to be python or jython related."); ! } ! process = SimpleRunner.createProcess(commandLine, env, null); ! PydevSpawnedInterpreterProcess spawnedInterpreterProcess = ! new PydevSpawnedInterpreterProcess(process, launch); ! ! launch.addProcess(spawnedInterpreterProcess); ! ! return new Tuple3<Launch, Process, Integer>(launch, process, clientPort); ! } } return null; Index: PydevSpawnedInterpreterProcess.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/env/PydevSpawnedInterpreterProcess.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PydevSpawnedInterpreterProcess.java 31 Mar 2008 01:50:12 -0000 1.3 --- PydevSpawnedInterpreterProcess.java 27 Sep 2008 19:59:06 -0000 1.4 *************** *** 21,33 **** private boolean terminated; ! private Process spawnedInterpreterProcess; ! private ILaunch launch; private HashMap<String, String> attributes; public PydevSpawnedInterpreterProcess(Process spawnedInterpreterProcess, ILaunch launch){ ! this.spawnedInterpreterProcess = spawnedInterpreterProcess; ! this.launch = launch; ! this.attributes = new HashMap<String, String>(); ! this.setAttribute(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); } --- 21,33 ---- private boolean terminated; ! private Process spawnedInterpreterProcess; ! private ILaunch launch; private HashMap<String, String> attributes; public PydevSpawnedInterpreterProcess(Process spawnedInterpreterProcess, ILaunch launch){ ! this.spawnedInterpreterProcess = spawnedInterpreterProcess; ! this.launch = launch; ! this.attributes = new HashMap<String, String>(); ! this.setAttribute(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); } *************** *** 44,48 **** public ILaunch getLaunch() { ! return this.launch; } --- 44,48 ---- public ILaunch getLaunch() { ! return this.launch; } *************** *** 76,87 **** public void terminate() throws DebugException { ! try { ! if(this.spawnedInterpreterProcess != null){ ! this.spawnedInterpreterProcess.destroy(); ! } ! } catch (RuntimeException e) { ! PydevPlugin.log(e); ! } ! this.spawnedInterpreterProcess = null; terminated = true; } --- 76,87 ---- public void terminate() throws DebugException { ! try { ! if(this.spawnedInterpreterProcess != null){ ! this.spawnedInterpreterProcess.destroy(); ! } ! } catch (RuntimeException e) { ! PydevPlugin.log(e); ! } ! this.spawnedInterpreterProcess = null; terminated = true; } |