pydev-cvs Mailing List for PyDev for Eclipse (Page 4)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:38
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/generateproperties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/ui/model/generateproperties Modified Files: TreeAttributeNode.java TreeClassNode.java PropertyTreeProvider.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: TreeClassNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/generateproperties/TreeClassNode.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TreeClassNode.java 20 Oct 2007 19:31:00 -0000 1.3 --- TreeClassNode.java 27 Sep 2008 20:00:50 -0000 1.4 *************** *** 18,47 **** public class TreeClassNode extends TreeNodeSimple<IClassDefAdapter> { ! public TreeClassNode(IClassDefAdapter adapter) { ! super(null, adapter); ! } ! @Override ! public Object[] getChildren() { ! List<ITreeNode> children = new ArrayList<ITreeNode>(); ! for (SimpleAdapter attribute : this.adapter.getAttributes()) { ! children.add(new TreeAttributeNode(this, attribute)); ! } ! return children.toArray(); ! } ! @Override ! public String getImageName() { ! return ITreeNode.NODE_CLASS; ! } ! @Override ! public String getLabel() { ! if (adapter.isNewStyleClass()) { ! return super.getLabel(); ! } else { ! return super.getLabel() + "(*)"; ! } ! } } --- 18,47 ---- public class TreeClassNode extends TreeNodeSimple<IClassDefAdapter> { ! public TreeClassNode(IClassDefAdapter adapter) { ! super(null, adapter); ! } ! @Override ! public Object[] getChildren() { ! List<ITreeNode> children = new ArrayList<ITreeNode>(); ! for (SimpleAdapter attribute : this.adapter.getAttributes()) { ! children.add(new TreeAttributeNode(this, attribute)); ! } ! return children.toArray(); ! } ! @Override ! public String getImageName() { ! return ITreeNode.NODE_CLASS; ! } ! @Override ! public String getLabel() { ! if (adapter.isNewStyleClass()) { ! return super.getLabel(); ! } else { ! return super.getLabel() + "(*)"; ! } ! } } Index: TreeAttributeNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/generateproperties/TreeAttributeNode.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TreeAttributeNode.java 20 Oct 2007 19:31:00 -0000 1.3 --- TreeAttributeNode.java 27 Sep 2008 20:00:50 -0000 1.4 *************** *** 20,45 **** public class TreeAttributeNode extends TreeNodeSimple<INodeAdapter> { ! public TreeAttributeNode(ITreeNode parent, INodeAdapter adapter) { ! super(parent, adapter); ! } ! @Override ! public Object[] getChildren() { ! List<ITreeNode> children = new ArrayList<ITreeNode>(); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.GETTER, ! Messages.generatePropertiesGetter))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.SETTER, ! Messages.generatePropertiesSetter))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.DELETE, ! Messages.generatePropertiesDelete))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.DOCSTRING, ! Messages.generatePropertiesDocString))); ! return children.toArray(); ! } ! @Override ! public String getImageName() { ! return ITreeNode.NODE_ATTRIBUTE; ! } } --- 20,45 ---- public class TreeAttributeNode extends TreeNodeSimple<INodeAdapter> { ! public TreeAttributeNode(ITreeNode parent, INodeAdapter adapter) { ! super(parent, adapter); ! } ! @Override ! public Object[] getChildren() { ! List<ITreeNode> children = new ArrayList<ITreeNode>(); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.GETTER, ! Messages.generatePropertiesGetter))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.SETTER, ! Messages.generatePropertiesSetter))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.DELETE, ! Messages.generatePropertiesDelete))); ! children.add(new TreeNodeSimple<PropertyTextAdapter>(this, new PropertyTextAdapter(PropertyTextAdapter.DOCSTRING, ! Messages.generatePropertiesDocString))); ! return children.toArray(); ! } ! @Override ! public String getImageName() { ! return ITreeNode.NODE_ATTRIBUTE; ! } } Index: PropertyTreeProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/generateproperties/PropertyTreeProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PropertyTreeProvider.java 20 Oct 2007 19:31:00 -0000 1.3 --- PropertyTreeProvider.java 27 Sep 2008 20:00:50 -0000 1.4 *************** *** 19,62 **** public class PropertyTreeProvider implements ITreeContentProvider { ! private List<IClassDefAdapter> adapters; ! public PropertyTreeProvider(List<IClassDefAdapter> adapters) { ! this.adapters = adapters; ! } ! public Object[] getChildren(Object parentElement) { ! if (parentElement instanceof ITreeNode) { ! return ((ITreeNode) parentElement).getChildren(); ! } ! return null; ! } ! public Object getParent(Object element) { ! return null; ! } ! public boolean hasChildren(Object element) { ! if (element instanceof ITreeNode) { ! ITreeNode node = (ITreeNode) element; ! return node.hasChildren(); ! } ! return false; ! } ! public Object[] getElements(Object inputElement) { ! Collection<TreeClassNode> elements = new ArrayList<TreeClassNode>(); ! for (IClassDefAdapter elem : adapters) { ! if (elem.hasAttributes()) { ! elements.add(new TreeClassNode(elem)); ! } ! } ! return elements.toArray(); ! } ! public void dispose() { ! } ! public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { ! } } --- 19,62 ---- public class PropertyTreeProvider implements ITreeContentProvider { ! private List<IClassDefAdapter> adapters; ! public PropertyTreeProvider(List<IClassDefAdapter> adapters) { ! this.adapters = adapters; ! } ! public Object[] getChildren(Object parentElement) { ! if (parentElement instanceof ITreeNode) { ! return ((ITreeNode) parentElement).getChildren(); ! } ! return null; ! } ! public Object getParent(Object element) { ! return null; ! } ! public boolean hasChildren(Object element) { ! if (element instanceof ITreeNode) { ! ITreeNode node = (ITreeNode) element; ! return node.hasChildren(); ! } ! return false; ! } ! public Object[] getElements(Object inputElement) { ! Collection<TreeClassNode> elements = new ArrayList<TreeClassNode>(); ! for (IClassDefAdapter elem : adapters) { ! if (elem.hasAttributes()) { ! elements.add(new TreeClassNode(elem)); ! } ! } ! return elements.toArray(); ! } ! public void dispose() { ! } ! public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { ! } } |
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/blocks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/src/org/python/pydev/debug/ui/blocks Modified Files: MainModuleBlock.java VMArgumentsBlock.java WorkingDirectoryBlock.java ProgramArgumentsBlock.java PythonPathBlock.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: MainModuleBlock.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/blocks/MainModuleBlock.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MainModuleBlock.java 17 Aug 2008 00:26:56 -0000 1.4 --- MainModuleBlock.java 27 Sep 2008 19:59:13 -0000 1.5 *************** *** 40,75 **** public class MainModuleBlock extends AbstractLaunchConfigurationTab { ! private Text fMainModuleText; ! private Button fMainModuleBrowseButton; ! private String fProjectName; ! private ModifyListener fProjectModifyListener; ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! Font font = parent.getFont(); ! Group group = new Group(parent, SWT.NONE); ! setControl(group); ! GridLayout topLayout = new GridLayout(); ! topLayout.numColumns = 2; ! group.setLayout(topLayout); ! GridData gd = new GridData(GridData.FILL_HORIZONTAL); ! group.setLayoutData(gd); ! group.setFont(font); ! group.setText("Main Module"); ! ! fMainModuleText = new Text(group, SWT.SINGLE | SWT.BORDER); ! gd = new GridData(GridData.FILL_HORIZONTAL); ! fMainModuleText.setLayoutData(gd); ! fMainModuleText.setFont(font); ! fMainModuleText.addModifyListener(new ModifyListener() { ! public void modifyText(ModifyEvent evt) { ! updateLaunchConfigurationDialog(); ! } ! }); ! final Composite lParent = parent; fMainModuleBrowseButton = createPushButton(group, "Browse...", null); fMainModuleBrowseButton.setText("Browse"); --- 40,75 ---- public class MainModuleBlock extends AbstractLaunchConfigurationTab { ! private Text fMainModuleText; ! private Button fMainModuleBrowseButton; ! private String fProjectName; ! private ModifyListener fProjectModifyListener; ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! Font font = parent.getFont(); ! Group group = new Group(parent, SWT.NONE); ! setControl(group); ! GridLayout topLayout = new GridLayout(); ! topLayout.numColumns = 2; ! group.setLayout(topLayout); ! GridData gd = new GridData(GridData.FILL_HORIZONTAL); ! group.setLayoutData(gd); ! group.setFont(font); ! group.setText("Main Module"); ! ! fMainModuleText = new Text(group, SWT.SINGLE | SWT.BORDER); ! gd = new GridData(GridData.FILL_HORIZONTAL); ! fMainModuleText.setLayoutData(gd); ! fMainModuleText.setFont(font); ! fMainModuleText.addModifyListener(new ModifyListener() { ! public void modifyText(ModifyEvent evt) { ! updateLaunchConfigurationDialog(); ! } ! }); ! final Composite lParent = parent; fMainModuleBrowseButton = createPushButton(group, "Browse...", null); fMainModuleBrowseButton.setText("Browse"); *************** *** 77,201 **** // On button click, this displays the python module picker dialog. fMainModuleBrowseButton.addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! IWorkspace workspace = ResourcesPlugin.getWorkspace(); ! IFile currentFile = getMainModuleFile(); ! IResource resource = workspace.getRoot().findMember(fProjectName); ! if (resource instanceof IProject) { ! IProject project = (IProject) resource; ! PythonModulePickerDialog dialog = new PythonModulePickerDialog( ! lParent.getShell(), ! "Main Module", ! "Choose Python module which starts execution", ! project); ! ! // Fixed request 1407469: main module browse button forgets path ! dialog.setInitialSelection(currentFile); ! int result = dialog.open(); ! if (result == PythonModulePickerDialog.OK) { ! Object results[] = dialog.getResult(); ! if ( (results != null) ! && (results.length > 0) ! && (results[0] instanceof IFile)) { ! IFile file = (IFile) results[0]; ! IPath path = file.getFullPath(); ! String containerName = path.makeRelative().toString(); ! fMainModuleText.setText("${workspace_loc:" + containerName + "}"); ! } ! } ! } ! } ! }); // Create a ModifyListener, used to listen for project modifications in the ProjectBlock. // This assumes that the Project is in a Text control... fProjectModifyListener = new ModifyListener() { ! public void modifyText(ModifyEvent e) { ! Widget widget = e.widget; ! if (widget instanceof Text) { ! Text text = (Text) widget; ! fProjectName = text.getText(); ! IWorkspace workspace = ResourcesPlugin.getWorkspace(); ! IResource resource = workspace.getRoot().findMember(fProjectName); ! boolean enabled = false; ! if ( (resource != null) ! && (resource instanceof IProject)) { ! IProject project = (IProject) resource; ! PythonNature nature = PythonNature.getPythonNature(project); ! enabled = (nature != null); ! } ! ! fMainModuleBrowseButton.setEnabled(enabled); ! } ! } }; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Main module"; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { ! ! // Initialize the location field ! String location = ""; ! try { ! location = configuration.getAttribute(Constants.ATTR_LOCATION, ""); } catch(CoreException e) { } ! fMainModuleText.setText(location); ! ! // Obtain a copy of the project name (not displayed) ! String projectName = ""; ! try { ! projectName = configuration.getAttribute(Constants.ATTR_PROJECT, ""); } catch(CoreException e) { } ! fProjectName = projectName; ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void performApply(ILaunchConfigurationWorkingCopy configuration) { String value = fMainModuleText.getText().trim(); setAttribute(configuration, Constants.ATTR_LOCATION, value); configuration.setMappedResources(new IResource[]{getMainModuleFile()}); ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { //no defaults to set ! } ! /** ! * Obtains an IFile that targets the current main module. ! * ! * This is used for initializing the module selection dialog. ! * ! * @return The main module file. ! */ ! private IFile getMainModuleFile() { ! String path = fMainModuleText.getText(); ! IFile file = null; ! if (path.length() > 0) { ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { path = manager.performStringSubstitution(path, false); IFile[] files = root.findFilesForLocation(new Path(path)); --- 77,201 ---- // On button click, this displays the python module picker dialog. fMainModuleBrowseButton.addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! IWorkspace workspace = ResourcesPlugin.getWorkspace(); ! IFile currentFile = getMainModuleFile(); ! IResource resource = workspace.getRoot().findMember(fProjectName); ! if (resource instanceof IProject) { ! IProject project = (IProject) resource; ! PythonModulePickerDialog dialog = new PythonModulePickerDialog( ! lParent.getShell(), ! "Main Module", ! "Choose Python module which starts execution", ! project); ! ! // Fixed request 1407469: main module browse button forgets path ! dialog.setInitialSelection(currentFile); ! int result = dialog.open(); ! if (result == PythonModulePickerDialog.OK) { ! Object results[] = dialog.getResult(); ! if ( (results != null) ! && (results.length > 0) ! && (results[0] instanceof IFile)) { ! IFile file = (IFile) results[0]; ! IPath path = file.getFullPath(); ! String containerName = path.makeRelative().toString(); ! fMainModuleText.setText("${workspace_loc:" + containerName + "}"); ! } ! } ! } ! } ! }); // Create a ModifyListener, used to listen for project modifications in the ProjectBlock. // This assumes that the Project is in a Text control... fProjectModifyListener = new ModifyListener() { ! public void modifyText(ModifyEvent e) { ! Widget widget = e.widget; ! if (widget instanceof Text) { ! Text text = (Text) widget; ! fProjectName = text.getText(); ! IWorkspace workspace = ResourcesPlugin.getWorkspace(); ! IResource resource = workspace.getRoot().findMember(fProjectName); ! boolean enabled = false; ! if ( (resource != null) ! && (resource instanceof IProject)) { ! IProject project = (IProject) resource; ! PythonNature nature = PythonNature.getPythonNature(project); ! enabled = (nature != null); ! } ! ! fMainModuleBrowseButton.setEnabled(enabled); ! } ! } }; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Main module"; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { ! ! // Initialize the location field ! String location = ""; ! try { ! location = configuration.getAttribute(Constants.ATTR_LOCATION, ""); } catch(CoreException e) { } ! fMainModuleText.setText(location); ! ! // Obtain a copy of the project name (not displayed) ! String projectName = ""; ! try { ! projectName = configuration.getAttribute(Constants.ATTR_PROJECT, ""); } catch(CoreException e) { } ! fProjectName = projectName; ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void performApply(ILaunchConfigurationWorkingCopy configuration) { String value = fMainModuleText.getText().trim(); setAttribute(configuration, Constants.ATTR_LOCATION, value); configuration.setMappedResources(new IResource[]{getMainModuleFile()}); ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { //no defaults to set ! } ! /** ! * Obtains an IFile that targets the current main module. ! * ! * This is used for initializing the module selection dialog. ! * ! * @return The main module file. ! */ ! private IFile getMainModuleFile() { ! String path = fMainModuleText.getText(); ! IFile file = null; ! if (path.length() > 0) { ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { path = manager.performStringSubstitution(path, false); IFile[] files = root.findFilesForLocation(new Path(path)); *************** *** 204,218 **** } } ! catch (CoreException e) {} ! } ! else { IFile[] files = root.findFilesForLocation(new Path(path)); if (files.length > 0) { file = files[0]; } ! } ! } ! return file; ! } /** --- 204,218 ---- } } ! catch (CoreException e) {} ! } ! else { IFile[] files = root.findFilesForLocation(new Path(path)); if (files.length > 0) { file = files[0]; } ! } ! } ! return file; ! } /** *************** *** 237,285 **** @Override public boolean isValid(ILaunchConfiguration launchConfig) { ! boolean result = super.isValid(launchConfig); ! ! if (result) { ! setMessage(null); ! setErrorMessage(null); ! IStringVariableManager stringVariableManager = VariablesPlugin.getDefault().getStringVariableManager(); ! String location = fMainModuleText.getText(); ! try { ! ! String identifier = launchConfig.getType().getIdentifier(); ! if(identifier.equals(Constants.ID_PYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE) || ! identifier.equals(Constants.ID_JYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE) || ! identifier.equals(Constants.ID_PYTHON_COVERAGE_LAUNCH_CONFIGURATION_TYPE)){ ! ! //may have multiple files selected for the run for unitest and code-coverage ! for(String loc:StringUtils.split(location, '|')){ ! String expandedLocation = stringVariableManager.performStringSubstitution(loc); ! File file = new File(expandedLocation); ! if(!file.exists()){ ! setErrorMessage(StringUtils.format("The file \"%s\" does not exist.", file)); ! result = false; ! break; ! } ! ! } ! }else{ ! String expandedLocation = stringVariableManager.performStringSubstitution(location); ! File file = new File(expandedLocation); ! if(!file.exists()){ ! setErrorMessage(StringUtils.format("The file \"%s\" does not exist.", file)); ! result = false; ! ! }else if(!file.isFile()) { ! setErrorMessage(StringUtils.format("The file \"%s\" does not actually map to a file.", file)); ! result = false; ! } ! } ! ! } catch (CoreException e) { ! setErrorMessage("Unable to resolve location"); ! result = false; ! } ! } ! return result; } --- 237,285 ---- @Override public boolean isValid(ILaunchConfiguration launchConfig) { ! boolean result = super.isValid(launchConfig); ! ! if (result) { ! setMessage(null); ! setErrorMessage(null); ! IStringVariableManager stringVariableManager = VariablesPlugin.getDefault().getStringVariableManager(); ! String location = fMainModuleText.getText(); ! try { ! ! String identifier = launchConfig.getType().getIdentifier(); ! if(identifier.equals(Constants.ID_PYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE) || ! identifier.equals(Constants.ID_JYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE) || ! identifier.equals(Constants.ID_PYTHON_COVERAGE_LAUNCH_CONFIGURATION_TYPE)){ ! ! //may have multiple files selected for the run for unitest and code-coverage ! for(String loc:StringUtils.split(location, '|')){ ! String expandedLocation = stringVariableManager.performStringSubstitution(loc); ! File file = new File(expandedLocation); ! if(!file.exists()){ ! setErrorMessage(StringUtils.format("The file \"%s\" does not exist.", file)); ! result = false; ! break; ! } ! ! } ! }else{ ! String expandedLocation = stringVariableManager.performStringSubstitution(location); ! File file = new File(expandedLocation); ! if(!file.exists()){ ! setErrorMessage(StringUtils.format("The file \"%s\" does not exist.", file)); ! result = false; ! ! }else if(!file.isFile()) { ! setErrorMessage(StringUtils.format("The file \"%s\" does not actually map to a file.", file)); ! result = false; ! } ! } ! ! } catch (CoreException e) { ! setErrorMessage("Unable to resolve location"); ! result = false; ! } ! } ! return result; } *************** *** 292,296 **** */ public ModifyListener getProjectModifyListener() { ! return fProjectModifyListener; } } --- 292,296 ---- */ public ModifyListener getProjectModifyListener() { ! return fProjectModifyListener; } } Index: WorkingDirectoryBlock.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/blocks/WorkingDirectoryBlock.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WorkingDirectoryBlock.java 9 Mar 2008 14:27:59 -0000 1.2 --- WorkingDirectoryBlock.java 27 Sep 2008 19:59:13 -0000 1.3 *************** *** 40,68 **** */ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { ! ! private static final String DEFAULT_WORKING_DIRECTORY_TEXT = "${project_loc}"; ! // Local directory ! private Button fWorkspaceButton; ! private Button fFileSystemButton; ! private Button fVariablesButton; ! ! //bug 29565 fix ! private Button fUseDefaultDirButton = null; ! private Button fUseOtherDirButton = null; ! private Text fOtherWorkingText = null; ! private Text fWorkingDirText; ! ! /** ! * The last launch config this tab was initialized from ! */ ! private ILaunchConfiguration fLaunchConfiguration; ! ! /** ! * A listener to update for text changes and widget selection ! */ ! private class WidgetListener extends SelectionAdapter implements ModifyListener { ! public void modifyText(ModifyEvent e) { if(e.getSource() == fOtherWorkingText){ ! File file = new File(fOtherWorkingText.getText()); if(!file.exists()){ --- 40,68 ---- */ public class WorkingDirectoryBlock extends AbstractLaunchConfigurationTab { ! ! private static final String DEFAULT_WORKING_DIRECTORY_TEXT = "${project_loc}"; ! // Local directory ! private Button fWorkspaceButton; ! private Button fFileSystemButton; ! private Button fVariablesButton; ! ! //bug 29565 fix ! private Button fUseDefaultDirButton = null; ! private Button fUseOtherDirButton = null; ! private Text fOtherWorkingText = null; ! private Text fWorkingDirText; ! ! /** ! * The last launch config this tab was initialized from ! */ ! private ILaunchConfiguration fLaunchConfiguration; ! ! /** ! * A listener to update for text changes and widget selection ! */ ! private class WidgetListener extends SelectionAdapter implements ModifyListener { ! public void modifyText(ModifyEvent e) { if(e.getSource() == fOtherWorkingText){ ! File file = new File(fOtherWorkingText.getText()); if(!file.exists()){ *************** *** 72,189 **** setErrorMessage("The directory in the location is not actually a directory."); } ! } ! updateLaunchConfigurationDialog(); ! } ! public void widgetSelected(SelectionEvent e) { ! Object source= e.getSource(); ! if (source == fWorkspaceButton) { ! handleWorkspaceDirBrowseButtonSelected(); ! } ! else if (source == fFileSystemButton) { ! handleWorkingDirBrowseButtonSelected(); ! } ! else if (source == fVariablesButton) { ! handleWorkingDirVariablesButtonSelected(); ! } ! else if(source == fUseDefaultDirButton) { ! //only perform the action if this is the button that was selected ! if(fUseDefaultDirButton.getSelection()) { ! setDefaultWorkingDir(); ! } ! } ! else if(source == fUseOtherDirButton) { ! //only perform the action if this is the button that was selected ! if(fUseOtherDirButton.getSelection()) { ! handleUseOtherWorkingDirButtonSelected(); ! } ! } ! } ! } ! ! private WidgetListener fListener = new WidgetListener(); ! ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! Font font = parent.getFont(); ! Group group = createGroup(parent, "Working directory:", 2, 1, GridData.FILL_HORIZONTAL); ! setControl(group); ! // PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); ! //default choice ! Composite comp = createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0); ! fUseDefaultDirButton = createRadioButton(comp, "Default:"); ! fUseDefaultDirButton.addSelectionListener(fListener); ! fWorkingDirText = createSingleText(comp, 1); ! fWorkingDirText.addModifyListener(fListener); ! fWorkingDirText.setEnabled(false); ! //user enter choice ! fUseOtherDirButton = createRadioButton(comp, "Other:"); ! fUseOtherDirButton.addSelectionListener(fListener); ! fOtherWorkingText = createSingleText(comp, 1); ! fOtherWorkingText.addModifyListener(fListener); ! //buttons ! Composite buttonComp = createComposite(comp, font, 3, 2, GridData.HORIZONTAL_ALIGN_END); ! GridLayout ld = (GridLayout)buttonComp.getLayout(); ! ld.marginHeight = 1; ! ld.marginWidth = 0; ! fWorkspaceButton = createPushButton(buttonComp, "Workspace...", null); ! fWorkspaceButton.addSelectionListener(fListener); ! fFileSystemButton = createPushButton(buttonComp, "File System...", null); ! fFileSystemButton.addSelectionListener(fListener); ! fVariablesButton = createPushButton(buttonComp, "Variables...", null); ! fVariablesButton.addSelectionListener(fListener); ! } ! ! /** ! * Show a dialog that lets the user select a working directory ! */ ! private void handleWorkingDirBrowseButtonSelected() { ! DirectoryDialog dialog = new DirectoryDialog(getShell()); ! dialog.setMessage("Select a working directory for the launch configuration:"); ! String currentWorkingDir = getWorkingDirectoryText(); ! if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$ ! File path = new File(currentWorkingDir); ! if (path.exists()) { ! dialog.setFilterPath(currentWorkingDir); ! } ! } ! String selectedDirectory = dialog.open(); ! if (selectedDirectory != null) { ! fOtherWorkingText.setText(selectedDirectory); ! } ! } ! /** ! * Show a dialog that lets the user select a working directory from ! * the workspace ! */ ! private void handleWorkspaceDirBrowseButtonSelected() { ! IContainer currentContainer= getContainer(); ! if (currentContainer == null) { ! currentContainer = ResourcesPlugin.getWorkspace().getRoot(); ! } ! ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), currentContainer, false, "Select a workspace relative working directory"); ! dialog.showClosedProjects(false); ! dialog.open(); ! Object[] results = dialog.getResult(); ! if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { ! IPath path = (IPath)results[0]; ! String containerName = path.makeRelative().toString(); ! setOtherWorkingDirectoryText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ ! } ! } ! ! /** ! * Returns the selected workspace container,or <code>null</code> ! */ ! protected IContainer getContainer() { ! String path = getWorkingDirectoryText(); ! if (path.length() > 0) { ! IResource res = null; ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { path = manager.performStringSubstitution(path, false); IContainer[] containers = root.findContainersForLocation(new Path(path)); --- 72,189 ---- setErrorMessage("The directory in the location is not actually a directory."); } ! } ! updateLaunchConfigurationDialog(); ! } ! public void widgetSelected(SelectionEvent e) { ! Object source= e.getSource(); ! if (source == fWorkspaceButton) { ! handleWorkspaceDirBrowseButtonSelected(); ! } ! else if (source == fFileSystemButton) { ! handleWorkingDirBrowseButtonSelected(); ! } ! else if (source == fVariablesButton) { ! handleWorkingDirVariablesButtonSelected(); ! } ! else if(source == fUseDefaultDirButton) { ! //only perform the action if this is the button that was selected ! if(fUseDefaultDirButton.getSelection()) { ! setDefaultWorkingDir(); ! } ! } ! else if(source == fUseOtherDirButton) { ! //only perform the action if this is the button that was selected ! if(fUseOtherDirButton.getSelection()) { ! handleUseOtherWorkingDirButtonSelected(); ! } ! } ! } ! } ! ! private WidgetListener fListener = new WidgetListener(); ! ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { ! Font font = parent.getFont(); ! Group group = createGroup(parent, "Working directory:", 2, 1, GridData.FILL_HORIZONTAL); ! setControl(group); ! // PlatformUI.getWorkbench().getHelpSystem().setHelp(group, IJavaDebugHelpContextIds.WORKING_DIRECTORY_BLOCK); ! //default choice ! Composite comp = createComposite(group, font, 2, 2, GridData.FILL_BOTH, 0, 0); ! fUseDefaultDirButton = createRadioButton(comp, "Default:"); ! fUseDefaultDirButton.addSelectionListener(fListener); ! fWorkingDirText = createSingleText(comp, 1); ! fWorkingDirText.addModifyListener(fListener); ! fWorkingDirText.setEnabled(false); ! //user enter choice ! fUseOtherDirButton = createRadioButton(comp, "Other:"); ! fUseOtherDirButton.addSelectionListener(fListener); ! fOtherWorkingText = createSingleText(comp, 1); ! fOtherWorkingText.addModifyListener(fListener); ! //buttons ! Composite buttonComp = createComposite(comp, font, 3, 2, GridData.HORIZONTAL_ALIGN_END); ! GridLayout ld = (GridLayout)buttonComp.getLayout(); ! ld.marginHeight = 1; ! ld.marginWidth = 0; ! fWorkspaceButton = createPushButton(buttonComp, "Workspace...", null); ! fWorkspaceButton.addSelectionListener(fListener); ! fFileSystemButton = createPushButton(buttonComp, "File System...", null); ! fFileSystemButton.addSelectionListener(fListener); ! fVariablesButton = createPushButton(buttonComp, "Variables...", null); ! fVariablesButton.addSelectionListener(fListener); ! } ! ! /** ! * Show a dialog that lets the user select a working directory ! */ ! private void handleWorkingDirBrowseButtonSelected() { ! DirectoryDialog dialog = new DirectoryDialog(getShell()); ! dialog.setMessage("Select a working directory for the launch configuration:"); ! String currentWorkingDir = getWorkingDirectoryText(); ! if (!currentWorkingDir.trim().equals("")) { //$NON-NLS-1$ ! File path = new File(currentWorkingDir); ! if (path.exists()) { ! dialog.setFilterPath(currentWorkingDir); ! } ! } ! String selectedDirectory = dialog.open(); ! if (selectedDirectory != null) { ! fOtherWorkingText.setText(selectedDirectory); ! } ! } ! /** ! * Show a dialog that lets the user select a working directory from ! * the workspace ! */ ! private void handleWorkspaceDirBrowseButtonSelected() { ! IContainer currentContainer= getContainer(); ! if (currentContainer == null) { ! currentContainer = ResourcesPlugin.getWorkspace().getRoot(); ! } ! ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), currentContainer, false, "Select a workspace relative working directory"); ! dialog.showClosedProjects(false); ! dialog.open(); ! Object[] results = dialog.getResult(); ! if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { ! IPath path = (IPath)results[0]; ! String containerName = path.makeRelative().toString(); ! setOtherWorkingDirectoryText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ ! } ! } ! ! /** ! * Returns the selected workspace container,or <code>null</code> ! */ ! protected IContainer getContainer() { ! String path = getWorkingDirectoryText(); ! if (path.length() > 0) { ! IResource res = null; ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! if (path.startsWith("${workspace_loc:")) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { path = manager.performStringSubstitution(path, false); IContainer[] containers = root.findContainersForLocation(new Path(path)); *************** *** 192,496 **** } } ! catch (CoreException e) {} ! } ! else { ! res = root.findMember(path); ! } ! if (res instanceof IContainer) { ! return (IContainer)res; ! } ! } ! return null; ! } ! ! /** ! * The default working dir radio button has been selected. ! */ ! private void handleUseDefaultWorkingDirButtonSelected() { ! fWorkspaceButton.setEnabled(false); ! fOtherWorkingText.setEnabled(false); ! fVariablesButton.setEnabled(false); ! fFileSystemButton.setEnabled(false); ! fUseOtherDirButton.setSelection(false); ! } ! /** ! * The other working dir radio button has been selected ! * ! * @since 3.2 ! */ ! private void handleUseOtherWorkingDirButtonSelected() { ! fOtherWorkingText.setEnabled(true); ! fWorkspaceButton.setEnabled(true); ! fVariablesButton.setEnabled(true); ! fFileSystemButton.setEnabled(true); ! updateLaunchConfigurationDialog(); ! } ! /** ! * The working dir variables button has been selected ! */ ! private void handleWorkingDirVariablesButtonSelected() { ! StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); ! dialog.open(); ! String variableText = dialog.getVariableExpression(); ! if (variableText != null) { ! fOtherWorkingText.insert(variableText); ! } ! } ! ! /** ! * Sets the default working directory ! */ ! protected void setDefaultWorkingDir() { ! ILaunchConfiguration config = getLaunchConfiguration(); ! if (config != null) { ! setDefaultWorkingDirectoryText(DEFAULT_WORKING_DIRECTORY_TEXT); ! return; ! } ! setDefaultWorkingDirectoryText(System.getProperty("user.dir")); //$NON-NLS-1$ ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public boolean isValid(ILaunchConfiguration launchConfig) { ! setErrorMessage(null); ! setMessage(null); ! // if variables are present, we cannot resolve the directory ! String workingDirPath = getWorkingDirectoryText(); ! if (workingDirPath.indexOf("${") >= 0) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { ! manager.validateStringVariables(workingDirPath); ! } ! catch (CoreException e) { ! setErrorMessage(e.getMessage()); ! return false; ! } ! } ! else if (workingDirPath.length() > 0) { ! IContainer container = getContainer(); ! if (container == null) { ! File dir = new File(workingDirPath); ! if (dir.isDirectory()) { ! return true; ! } ! setErrorMessage("Only directories can be selected"); ! return false; ! } ! } else if (workingDirPath.length() == 0) { ! setErrorMessage("A non-empty directory must be selected"); ! return false; ! } ! return true; ! } ! /** ! * Defaults are empty. ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void setDefaults(ILaunchConfigurationWorkingCopy config) { ! config.setAttribute(Constants.ATTR_WORKING_DIRECTORY, (String)null); ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { ! setLaunchConfiguration(configuration); ! try { ! String wd = configuration.getAttribute(Constants.ATTR_WORKING_DIRECTORY, (String) null); ! String owd = configuration.getAttribute(Constants.ATTR_OTHER_WORKING_DIRECTORY, (String) null); ! setDefaultWorkingDir(); ! if ( ( (wd != null) ! && (wd.equals(owd))) ! || (owd == null)) { ! setOtherWorkingDirectoryText(wd); ! } ! else { ! fOtherWorkingText.setText(owd); ! } ! } ! catch (CoreException e) { ! setErrorMessage("Exception occurred reading configuration" + e.getStatus().getMessage()); ! PydevPlugin.log(e); ! } ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void performApply(ILaunchConfigurationWorkingCopy configuration) { ! configuration.setAttribute(Constants.ATTR_OTHER_WORKING_DIRECTORY, fOtherWorkingText.getText().trim()); ! ! if(fUseDefaultDirButton.getSelection()) { ! configuration.setAttribute(Constants.ATTR_WORKING_DIRECTORY, (String) null); ! } ! else { ! configuration.setAttribute(Constants.ATTR_WORKING_DIRECTORY, getWorkingDirectoryText()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Working Directory"; ! } ! ! /** ! * gets the path from the text box that is selected ! * @return the working directory the user wishes to use ! * @since 3.2 ! */ ! protected String getWorkingDirectoryText() { ! if(fUseDefaultDirButton.getSelection()) { ! return fWorkingDirText.getText().trim(); ! } ! return fOtherWorkingText.getText().trim(); ! } ! ! /** ! * sets the default working directory text ! * @param dir the dir to set the widget to ! * @since 3.2 ! */ ! protected void setDefaultWorkingDirectoryText(String dir) { ! if(dir != null) { ! fWorkingDirText.setText(dir); ! fUseDefaultDirButton.setSelection(true); ! handleUseDefaultWorkingDirButtonSelected(); ! } ! } ! ! /** ! * sets the other dir text ! * @param dir the new text ! * @since 3.2 ! */ ! protected void setOtherWorkingDirectoryText(String dir) { ! if(dir != null) { ! fOtherWorkingText.setText(dir); ! fUseDefaultDirButton.setSelection(false); ! fUseOtherDirButton.setSelection(true); ! handleUseOtherWorkingDirButtonSelected(); ! } ! } ! ! /** ! * Sets the project currently specified by the ! * given launch config, if any. ! */ ! private void setLaunchConfiguration(ILaunchConfiguration config) { ! fLaunchConfiguration = config; ! } ! ! /** ! * Returns the current project context ! */ ! private ILaunchConfiguration getLaunchConfiguration() { ! return fLaunchConfiguration; ! } ! ! /** ! * Creates a new text widget ! * @param parent the parent composite to add this text widget to ! * @param hspan the horizontal span to take up on the parent composite ! * @return the new text widget ! */ ! private static Text createSingleText(Composite parent, int hspan) { ! Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); ! t.setFont(parent.getFont()); ! GridData gd = new GridData(GridData.FILL_HORIZONTAL); ! gd.horizontalSpan = hspan; ! t.setLayoutData(gd); ! return t; } ! ! /** ! * Creates a Group widget ! * @param parent the parent composite to add this group to ! * @param text the text for the heading of the group ! * @param columns the number of columns within the group ! * @param hspan the horizontal span the group should take up on the parent ! * @param fill the style for how this composite should fill into its parent ! * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> ! * @return the new group ! */ ! private static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) { ! Group g = new Group(parent, SWT.NONE); ! g.setLayout(new GridLayout(columns, false)); ! g.setText(text); ! g.setFont(parent.getFont()); ! GridData gd = new GridData(fill); ! gd.horizontalSpan = hspan; ! g.setLayoutData(gd); ! return g; } ! ! /** ! * Creates a Composite widget ! * @param parent the parent composite to add this composite to ! * @param columns the number of columns within the composite ! * @param hspan the horizontal span the composite should take up on the parent ! * @param fill the style for how this composite should fill into its parent ! * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> ! * @return the new group ! */ ! private static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) { ! Composite g = new Composite(parent, SWT.NONE); ! g.setLayout(new GridLayout(columns, false)); ! g.setFont(font); ! GridData gd = new GridData(fill); ! gd.horizontalSpan = hspan; ! g.setLayoutData(gd); ! return g; } - - /** - * Creates a Composite widget - * @param parent the parent composite to add this composite to - * @param columns the number of columns within the composite - * @param hspan the horizontal span the composite should take up on the parent - * @param fill the style for how this composite should fill into its parent - * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> - * @param marginwidth the width of the margin to place around the composite (default is 5, specified by GridLayout) - * @param marginheight the height of the margin to place around the composite (default is 5, specified by GridLayout) - * @return the new group - */ - private static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill, int marginwidth, int marginheight) { - Composite g = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(columns, false); - layout.marginWidth = marginwidth; - layout.marginHeight = marginheight; - g.setLayout(layout); - g.setFont(font); - GridData gd = new GridData(fill); - gd.horizontalSpan = hspan; - g.setLayoutData(gd); - return g; - } ! /** ! * Allows this entire block to be enabled/disabled ! * @param enabled whether to enable it or not ! */ ! protected void setEnabled(boolean enabled) { ! fUseDefaultDirButton.setEnabled(enabled); ! fUseOtherDirButton.setEnabled(enabled); ! if(fOtherWorkingText.isEnabled()) { ! fOtherWorkingText.setEnabled(enabled); ! fWorkspaceButton.setEnabled(enabled); ! fVariablesButton.setEnabled(enabled); ! fFileSystemButton.setEnabled(enabled); ! } ! // in the case where the 'other' text is selected and we want to enable ! if(fUseOtherDirButton.getSelection() && enabled == true) { ! fOtherWorkingText.setEnabled(enabled); ! } ! } } --- 192,496 ---- } } ! catch (CoreException e) {} ! } ! else { ! res = root.findMember(path); ! } ! if (res instanceof IContainer) { ! return (IContainer)res; ! } ! } ! return null; ! } ! ! /** ! * The default working dir radio button has been selected. ! */ ! private void handleUseDefaultWorkingDirButtonSelected() { ! fWorkspaceButton.setEnabled(false); ! fOtherWorkingText.setEnabled(false); ! fVariablesButton.setEnabled(false); ! fFileSystemButton.setEnabled(false); ! fUseOtherDirButton.setSelection(false); ! } ! /** ! * The other working dir radio button has been selected ! * ! * @since 3.2 ! */ ! private void handleUseOtherWorkingDirButtonSelected() { ! fOtherWorkingText.setEnabled(true); ! fWorkspaceButton.setEnabled(true); ! fVariablesButton.setEnabled(true); ! fFileSystemButton.setEnabled(true); ! updateLaunchConfigurationDialog(); ! } ! /** ! * The working dir variables button has been selected ! */ ! private void handleWorkingDirVariablesButtonSelected() { ! StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); ! dialog.open(); ! String variableText = dialog.getVariableExpression(); ! if (variableText != null) { ! fOtherWorkingText.insert(variableText); ! } ! } ! ! /** ! * Sets the default working directory ! */ ! protected void setDefaultWorkingDir() { ! ILaunchConfiguration config = getLaunchConfiguration(); ! if (config != null) { ! setDefaultWorkingDirectoryText(DEFAULT_WORKING_DIRECTORY_TEXT); ! return; ! } ! setDefaultWorkingDirectoryText(System.getProperty("user.dir")); //$NON-NLS-1$ ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public boolean isValid(ILaunchConfiguration launchConfig) { ! setErrorMessage(null); ! setMessage(null); ! // if variables are present, we cannot resolve the directory ! String workingDirPath = getWorkingDirectoryText(); ! if (workingDirPath.indexOf("${") >= 0) { //$NON-NLS-1$ ! IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); ! try { ! manager.validateStringVariables(workingDirPath); ! } ! catch (CoreException e) { ! setErrorMessage(e.getMessage()); ! return false; ! } ! } ! else if (workingDirPath.length() > 0) { ! IContainer container = getContainer(); ! if (container == null) { ! File dir = new File(workingDirPath); ! if (dir.isDirectory()) { ! return true; ! } ! setErrorMessage("Only directories can be selected"); ! return false; ! } ! } else if (workingDirPath.length() == 0) { ! setErrorMessage("A non-empty directory must be selected"); ! return false; ! } ! return true; ! } ! /** ! * Defaults are empty. ! * ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void setDefaults(ILaunchConfigurationWorkingCopy config) { ! config.setAttribute(Constants.ATTR_WORKING_DIRECTORY, (String)null); ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { ! setLaunchConfiguration(configuration); ! try { ! String wd = configuration.getAttribute(Constants.ATTR_WORKING_DIRECTORY, (String) null); ! String owd = configuration.getAttribute(Constants.ATTR_OTHER_WORKING_DIRECTORY, (String) null); ! setDefaultWorkingDir(); ! if ( ( (wd != null) ! && (wd.equals(owd))) ! || (owd == null)) { ! setOtherWorkingDirectoryText(wd); ! } ! else { ! fOtherWorkingText.setText(owd); ! } ! } ! catch (CoreException e) { ! setErrorMessage("Exception occurred reading configuration" + e.getStatus().getMessage()); ! PydevPlugin.log(e); ! } ! } ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void performApply(ILaunchConfigurationWorkingCopy configuration) { ! configuration.setAttribute(Constants.ATTR_OTHER_WORKING_DIRECTORY, fOtherWorkingText.getText().trim()); ! ! if(fUseDefaultDirButton.getSelection()) { ! configuration.setAttribute(Constants.ATTR_WORKING_DIRECTORY, (String) null); ! } ! else { ! configuration.setAttribute(Constants.ATTR_WORKING_DIRECTORY, getWorkingDirectoryText()); ! } } ! ! /* (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Working Directory"; } ! ! /** ! * gets the path from the text box that is selected ! * @return the working directory the user wishes to use ! * @since 3.2 ! */ ! protected String getWorkingDirectoryText() { ! if(fUseDefaultDirButton.getSelection()) { ! return fWorkingDirText.getText().trim(); ! } ! return fOtherWorkingText.getText().trim(); ! } ! ! /** ! * sets the default working directory text ! * @param dir the dir to set the widget to ! * @since 3.2 ! */ ! protected void setDefaultWorkingDirectoryText(String dir) { ! if(dir != null) { ! fWorkingDirText.setText(dir); ! fUseDefaultDirButton.setSelection(true); ! handleUseDefaultWorkingDirButtonSelected(); ! } ! } ! ! /** ! * sets the other dir text ! * @param dir the new text ! * @since 3.2 ! */ ! protected void setOtherWorkingDirectoryText(String dir) { ! if(dir != null) { ! fOtherWorkingText.setText(dir); ! fUseDefaultDirButton.setSelection(false); ! fUseOtherDirButton.setSelection(true); ! handleUseOtherWorkingDirButtonSelected(); ! } ! } ! ! /** ! * Sets the project currently specified by the ! * given launch config, if any. ! */ ! private void setLaunchConfiguration(ILaunchConfiguration config) { ! fLaunchConfiguration = config; ! } ! ! /** ! * Returns the current project context ! */ ! private ILaunchConfiguration getLaunchConfiguration() { ! return fLaunchConfiguration; ! } ! ! /** ! * Creates a new text widget ! * @param parent the parent composite to add this text widget to ! * @param hspan the horizontal span to take up on the parent composite ! * @return the new text widget ! */ ! private static Text createSingleText(Composite parent, int hspan) { ! Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); ! t.setFont(parent.getFont()); ! GridData gd = new GridData(GridData.FILL_HORIZONTAL); ! gd.horizontalSpan = hspan; ! t.setLayoutData(gd); ! return t; ! } ! ! /** ! * Creates a Group widget ! * @param parent the parent composite to add this group to ! * @param text the text for the heading of the group ! * @param columns the number of columns within the group ! * @param hspan the horizontal span the group should take up on the parent ! * @param fill the style for how this composite should fill into its parent ! * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> ! * @return the new group ! */ ! private static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) { ! Group g = new Group(parent, SWT.NONE); ! g.setLayout(new GridLayout(columns, false)); ! g.setText(text); ! g.setFont(parent.getFont()); ! GridData gd = new GridData(fill); ! gd.horizontalSpan = hspan; ! g.setLayoutData(gd); ! return g; ! } ! ! /** ! * Creates a Composite widget ! * @param parent the parent composite to add this composite to ! * @param columns the number of columns within the composite ! * @param hspan the horizontal span the composite should take up on the parent ! * @param fill the style for how this composite should fill into its parent ! * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> ! * @return the new group ! */ ! private static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) { ! Composite g = new Composite(parent, SWT.NONE); ! g.setLayout(new GridLayout(columns, false)); ! g.setFont(font); ! GridData gd = new GridData(fill); ! gd.horizontalSpan = hspan; ! g.setLayoutData(gd); ! return g; ! } ! ! /** ! * Creates a Composite widget ! * @param parent the parent composite to add this composite to ! * @param columns the number of columns within the composite ! * @param hspan the horizontal span the composite should take up on the parent ! * @param fill the style for how this composite should fill into its parent ! * Can be one of <code>GridData.FILL_HORIZONAL</code>, <code>GridData.FILL_BOTH</code> or <code>GridData.FILL_VERTICAL</code> ! * @param marginwidth the width of the margin to place around the composite (default is 5, specified by GridLayout) ! * @param marginheight the height of the margin to place around the composite (default is 5, specified by GridLayout) ! * @return the new group ! */ ! private static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill, int marginwidth, int marginheight) { ! Composite g = new Composite(parent, SWT.NONE); ! GridLayout layout = new GridLayout(columns, false); ! layout.marginWidth = marginwidth; ! layout.marginHeight = marginheight; ! g.setLayout(layout); ! g.setFont(font); ! GridData gd = new GridData(fill); ! gd.horizontalSpan = hspan; ! g.setLayoutData(gd); ! return g; } ! /** ! * Allows this entire block to be enabled/disabled ! * @param enabled whether to enable it or not ! */ ! protected void setEnabled(boolean enabled) { ! fUseDefaultDirButton.setEnabled(enabled); ! fUseOtherDirButton.setEnabled(enabled); ! if(fOtherWorkingText.isEnabled()) { ! fOtherWorkingText.setEnabled(enabled); ! fWorkspaceButton.setEnabled(enabled); ! fVariablesButton.setEnabled(enabled); ! fFileSystemButton.setEnabled(enabled); ! } ! // in the case where the 'other' text is selected and we want to enable ! if(fUseOtherDirButton.getSelection() && enabled == true) { ! fOtherWorkingText.setEnabled(enabled); ! } ! } } Index: PythonPathBlock.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/blocks/PythonPathBlock.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonPathBlock.java 13 Apr 2008 16:55:18 -0000 1.3 --- PythonPathBlock.java 27 Sep 2008 19:59:13 -0000 1.4 *************** *** 18,28 **** public class PythonPathBlock extends AbstractLaunchConfigurationTab { ! private List fPythonPathList; ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText("PYTHONPATH that will be used in the run:"); --- 18,28 ---- public class PythonPathBlock extends AbstractLaunchConfigurationTab { ! private List fPythonPathList; ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) ! */ ! public void createControl(Composite parent) { Label label = new Label(parent, SWT.NONE); label.setText("PYTHONPATH that will be used in the run:"); *************** *** 31,84 **** GridData gd = new GridData(GridData.FILL_BOTH); fPythonPathList.setLayoutData(gd); ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Python path"; ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { try { String pythonPath = PythonRunnerConfig.getPythonpathFromConfiguration(configuration); ! fPythonPathList.removeAll(); ! java.util.List<String> paths = SimpleRunner.splitPythonpath(pythonPath); ! for (String p:paths) { ! fPythonPathList.add(p); } } catch (Exception e) { ! // Exceptions here may have several reasons ! // - The interpreter is incorrectly configured ! // - The arguments use an unresolved variable. ! // In each case, the exception contains a meaningful message, that is displayed ! fPythonPathList.removeAll(); ! fPythonPathList.add(e.getMessage()); PydevPlugin.log(e); } ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void performApply(ILaunchConfigurationWorkingCopy configuration) { ! // Nothing to apply, this is a read-only control ! initializeFrom(configuration); ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ! */ ! public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { ! // No defaults to set ! } } --- 31,84 ---- GridData gd = new GridData(GridData.FILL_BOTH); fPythonPathList.setLayoutData(gd); ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() ! */ ! public String getName() { ! return "Python path"; ! } ! /* ! * (non-Javadoc) ! * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) ! */ ! public void initializeFrom(ILaunchConfiguration configuration) { try { String pythonPath = PythonRunnerConfig.getPythonpathFromConfiguration(configuration); ! fPythonPathList.removeAll(); ! java.util.List<String> paths = SimpleRunner.splitPythonpath(pythonPath); ! for (String p:paths) { ! fPythonPathList.add(p); } } catch (Exception e) { ! // Exceptions here may have several reasons ! // - The interpreter is incorrectly configured ! // - The arguments use an unresolved variable. ! // In each case, the exception contains a meaningful message, that is displayed ! fPythonPathList.removeAll(); ! fPythonPathList.add(e.getMessa... [truncated message content] |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:34
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring Modified Files: PepticLog.java PepticPlugin.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: PepticPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/PepticPlugin.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PepticPlugin.java 20 Oct 2007 19:31:01 -0000 1.2 --- PepticPlugin.java 27 Sep 2008 20:00:50 -0000 1.3 *************** *** 16,59 **** public class PepticPlugin extends AbstractUIPlugin { ! // The plug-in ID ! public static final String PLUGIN_ID = "org.python.pydev.refactoring"; ! // The shared instance ! private static PepticPlugin plugin = null; ! /** ! * The constructor ! */ ! public PepticPlugin() { ! plugin = this; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) ! */ ! public void stop(BundleContext context) throws Exception { ! plugin = null; ! super.stop(context); ! } ! /** ! * Returns the shared instance ! * ! * @return the shared instance ! */ ! public static PepticPlugin getDefault() { ! return plugin; ! } } --- 16,59 ---- public class PepticPlugin extends AbstractUIPlugin { ! // The plug-in ID ! public static final String PLUGIN_ID = "org.python.pydev.refactoring"; ! // The shared instance ! private static PepticPlugin plugin = null; ! /** ! * The constructor ! */ ! public PepticPlugin() { ! plugin = this; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) ! */ ! public void stop(BundleContext context) throws Exception { ! plugin = null; ! super.stop(context); ! } ! /** ! * Returns the shared instance ! * ! * @return the shared instance ! */ ! public static PepticPlugin getDefault() { ! return plugin; ! } } Index: PepticLog.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/PepticLog.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PepticLog.java 20 Oct 2007 19:31:01 -0000 1.3 --- PepticLog.java 27 Sep 2008 20:00:50 -0000 1.4 *************** *** 12,37 **** public class PepticLog { ! public static void log(int severity, int code, String message, Throwable exception) { ! log(createStatus(severity, code, message, exception)); ! } ! public static IStatus createStatus(int severity, int code, String message, Throwable exception) { ! return new Status(severity, PepticPlugin.PLUGIN_ID, code, message, exception); ! } ! public static void log(IStatus status) { ! PepticPlugin.getDefault().getLog().log(status); ! } ! public static void logInfo(String message) { ! log(IStatus.INFO, IStatus.OK, message, null); ! } ! public static void logError(Throwable exception) { ! logError("Unexpected Exception", exception); ! } ! public static void logError(String message, Throwable exception) { ! log(IStatus.ERROR, IStatus.OK, message, exception); ! } } --- 12,37 ---- public class PepticLog { ! public static void log(int severity, int code, String message, Throwable exception) { ! log(createStatus(severity, code, message, exception)); ! } ! public static IStatus createStatus(int severity, int code, String message, Throwable exception) { ! return new Status(severity, PepticPlugin.PLUGIN_ID, code, message, exception); ! } ! public static void log(IStatus status) { ! PepticPlugin.getDefault().getLog().log(status); ! } ! public static void logInfo(String message) { ! log(IStatus.INFO, IStatus.OK, message, null); ! } ! public static void logError(Throwable exception) { ! logError("Unexpected Exception", exception); ! } ! public static void logError(String message, Throwable exception) { ! log(IStatus.ERROR, IStatus.OK, message, exception); ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:09
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/tests/org/python/pydev/refactoring/tests/codegenerator Modified Files: AllTests.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: AllTests.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/AllTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AllTests.java 20 Oct 2007 19:31:06 -0000 1.3 --- AllTests.java 27 Sep 2008 20:00:51 -0000 1.4 *************** *** 14,26 **** public class AllTests { ! public static Test suite() { ! TestSuite suite = new TestSuite("Test for org.python.pydev.refactoring.tests.codegenerator"); ! // $JUnit-BEGIN$ ! suite.addTest(ConstructorFieldTestSuite.suite()); ! suite.addTest(OverrideMethodsTestSuite.suite()); ! suite.addTest(GeneratePropertiesTestSuite.suite()); ! // $JUnit-END$ ! return suite; ! } } --- 14,26 ---- public class AllTests { ! public static Test suite() { ! TestSuite suite = new TestSuite("Test for org.python.pydev.refactoring.tests.codegenerator"); ! // $JUnit-BEGIN$ ! suite.addTest(ConstructorFieldTestSuite.suite()); ! suite.addTest(OverrideMethodsTestSuite.suite()); ! suite.addTest(GeneratePropertiesTestSuite.suite()); ! // $JUnit-END$ ! return suite; ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:08
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/table In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/ui/model/table Modified Files: SimpleTableItem.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: SimpleTableItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ui/model/table/SimpleTableItem.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SimpleTableItem.java 20 Oct 2007 19:31:04 -0000 1.3 --- SimpleTableItem.java 27 Sep 2008 20:00:50 -0000 1.4 *************** *** 14,42 **** public class SimpleTableItem extends TableItem { ! private String realName; ! public SimpleTableItem(Table parent, String name) { ! super(parent, SWT.None); ! this.realName = name; ! setText(realName); ! } ! public SimpleTableItem(Table parent, String originalName, String text, int pos) { ! super(parent, SWT.None, pos); ! this.realName = originalName; ! setText(text); ! } ! public String getOriginalName() { ! return realName; ! } ! @Override ! protected void checkSubclass() { ! } ! public boolean hasNewName() { ! return this.realName.compareTo(getText()) != 0; ! } } --- 14,42 ---- public class SimpleTableItem extends TableItem { ! private String realName; ! public SimpleTableItem(Table parent, String name) { ! super(parent, SWT.None); ! this.realName = name; ! setText(realName); ! } ! public SimpleTableItem(Table parent, String originalName, String text, int pos) { ! super(parent, SWT.None, pos); ! this.realName = originalName; ! setText(text); ! } ! public String getOriginalName() { ! return realName; ! } ! @Override ! protected void checkSubclass() { ! } ! public boolean hasNewName() { ! return this.realName.compareTo(getText()) != 0; ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:01:02
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/position In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/ast/visitors/position Modified Files: LastLineVisitor.java IndentVisitor.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: IndentVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/position/IndentVisitor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndentVisitor.java 20 Oct 2007 19:31:03 -0000 1.2 --- IndentVisitor.java 27 Sep 2008 20:00:51 -0000 1.3 *************** *** 30,155 **** public class IndentVisitor extends VisitorBase { ! private static final int DEFAULT_INDENT = 4; ! private int indent; ! public IndentVisitor() { ! this.indent = DEFAULT_INDENT; ! } ! public int getIndent() { ! return indent; ! } ! private void handleDefault(SimpleNode node) { ! this.indent = node.beginColumn; ! } ! @Override ! public void traverse(SimpleNode node) throws Exception { ! // ignore ! } ! @Override ! protected Object unhandled_node(SimpleNode node) throws Exception { ! handleDefault(node); ! return null; ! } ! public void visit(SimpleNode node) throws Exception { ! if (node != null) ! node.accept(this); ! } ! public Object visitAssert(Assert node) throws Exception { ! handleDefault(node); ! this.indent -= 7; ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! visit(node.targets[0]); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! visit(node.value); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! visit(node.target); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! visit(node.left); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! visit(node.values[0]); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! visit(node.func); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! visit(node.left); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! handleDefault(node); ! this.indent -= 4; ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! visit(node); ! this.indent -= 5; ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! visit(node.value); ! return null; ! } ! public Object visitGeneratorExp(GeneratorExp node) throws Exception { ! visit(node.elt); ! return null; ! } ! @Override ! public Object visitImport(Import node) throws Exception { ! this.indent = 1; ! return null; ! } ! @Override ! public Object visitImportFrom(ImportFrom node) throws Exception { ! this.indent = 1; ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! handleDefault(node); ! this.indent -= 6; ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! visit(node.body[0]); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! handleDefault(node); ! return null; ! } } --- 30,155 ---- public class IndentVisitor extends VisitorBase { ! private static final int DEFAULT_INDENT = 4; ! private int indent; ! public IndentVisitor() { ! this.indent = DEFAULT_INDENT; ! } ! public int getIndent() { ! return indent; ! } ! private void handleDefault(SimpleNode node) { ! this.indent = node.beginColumn; ! } ! @Override ! public void traverse(SimpleNode node) throws Exception { ! // ignore ! } ! @Override ! protected Object unhandled_node(SimpleNode node) throws Exception { ! handleDefault(node); ! return null; ! } ! public void visit(SimpleNode node) throws Exception { ! if (node != null) ! node.accept(this); ! } ! public Object visitAssert(Assert node) throws Exception { ! handleDefault(node); ! this.indent -= 7; ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! visit(node.targets[0]); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! visit(node.value); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! visit(node.target); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! visit(node.left); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! visit(node.values[0]); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! visit(node.func); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! visit(node.left); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! handleDefault(node); ! this.indent -= 4; ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! visit(node); ! this.indent -= 5; ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! visit(node.value); ! return null; ! } ! public Object visitGeneratorExp(GeneratorExp node) throws Exception { ! visit(node.elt); ! return null; ! } ! @Override ! public Object visitImport(Import node) throws Exception { ! this.indent = 1; ! return null; ! } ! @Override ! public Object visitImportFrom(ImportFrom node) throws Exception { ! this.indent = 1; ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! handleDefault(node); ! this.indent -= 6; ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! visit(node.body[0]); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! handleDefault(node); ! return null; ! } } Index: LastLineVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/ast/visitors/position/LastLineVisitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LastLineVisitor.java 20 Oct 2007 19:31:03 -0000 1.3 --- LastLineVisitor.java 27 Sep 2008 20:00:51 -0000 1.4 *************** *** 20,45 **** public class LastLineVisitor extends VisitorBase { ! private int lastLine; ! public LastLineVisitor() { ! lastLine = 0; ! } ! @Override ! public void traverse(SimpleNode node) throws Exception { ! if (node != null) ! node.traverse(this); ! } ! @Override ! protected Object unhandled_node(SimpleNode node) throws Exception { ! if (node.beginLine > lastLine) ! lastLine = node.beginLine; ! return null; ! } ! public int getLastLine() { ! return lastLine; ! } } --- 20,45 ---- public class LastLineVisitor extends VisitorBase { ! private int lastLine; ! public LastLineVisitor() { ! lastLine = 0; ! } ! @Override ! public void traverse(SimpleNode node) throws Exception { ! if (node != null) ! node.traverse(this); ! } ! @Override ! protected Object unhandled_node(SimpleNode node) throws Exception { ! if (node.beginLine > lastLine) ! lastLine = node.beginLine; ! return null; ! } ! public int getLastLine() { ! return lastLine; ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:00:58
|
Update of /cvsroot/pydev/org.python.pydev.ast/src/org/python/pydev/ast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21596/src/org/python/pydev/ast Modified Files: AstPlugin.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: AstPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.ast/src/org/python/pydev/ast/AstPlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AstPlugin.java 25 Jun 2005 17:32:49 -0000 1.1 --- AstPlugin.java 27 Sep 2008 20:00:18 -0000 1.2 *************** *** 9,69 **** */ public class AstPlugin extends AbstractUIPlugin { ! //The shared instance. ! private static AstPlugin plugin; ! //Resource bundle. ! private ResourceBundle resourceBundle; ! ! /** ! * The constructor. ! */ ! public AstPlugin() { ! super(); ! plugin = this; ! try { ! resourceBundle = ResourceBundle.getBundle("org.python.pydev.ast.AstPluginResources"); ! } catch (MissingResourceException x) { ! resourceBundle = null; ! } ! } ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! } ! /** ! * Returns the shared instance. ! */ ! public static AstPlugin getDefault() { ! return plugin; ! } ! /** ! * Returns the string from the plugin's resource bundle, ! * or 'key' if not found. ! */ ! public static String getResourceString(String key) { ! ResourceBundle bundle = AstPlugin.getDefault().getResourceBundle(); ! try { ! return (bundle != null) ? bundle.getString(key) : key; ! } catch (MissingResourceException e) { ! return key; ! } ! } ! /** ! * Returns the plugin's resource bundle, ! */ ! public ResourceBundle getResourceBundle() { ! return resourceBundle; ! } } --- 9,69 ---- */ public class AstPlugin extends AbstractUIPlugin { ! //The shared instance. ! private static AstPlugin plugin; ! //Resource bundle. ! private ResourceBundle resourceBundle; ! ! /** ! * The constructor. ! */ ! public AstPlugin() { ! super(); ! plugin = this; ! try { ! resourceBundle = ResourceBundle.getBundle("org.python.pydev.ast.AstPluginResources"); ! } catch (MissingResourceException x) { ! resourceBundle = null; ! } ! } ! /** ! * This method is called upon plug-in activation ! */ ! public void start(BundleContext context) throws Exception { ! super.start(context); ! } ! /** ! * This method is called when the plug-in is stopped ! */ ! public void stop(BundleContext context) throws Exception { ! super.stop(context); ! } ! /** ! * Returns the shared instance. ! */ ! public static AstPlugin getDefault() { ! return plugin; ! } ! /** ! * Returns the string from the plugin's resource bundle, ! * or 'key' if not found. ! */ ! public static String getResourceString(String key) { ! ResourceBundle bundle = AstPlugin.getDefault().getResourceBundle(); ! try { ! return (bundle != null) ? bundle.getString(key) : key; ! } catch (MissingResourceException e) { ! return key; ! } ! } ! /** ! * Returns the plugin's resource bundle, ! */ ! public ResourceBundle getResourceBundle() { ! return resourceBundle; ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:00:32
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/src/org/python/pydev/debug/core Modified Files: PydevDebugPrefs.java Constants.java IConsoleInputListener.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: IConsoleInputListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/IConsoleInputListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IConsoleInputListener.java 9 Feb 2006 18:52:29 -0000 1.1 --- IConsoleInputListener.java 27 Sep 2008 19:59:09 -0000 1.2 *************** *** 9,28 **** public interface IConsoleInputListener { ! /** ! * This method is called whenever a new line is written in the console while debugging. ! * ! * @param lineReceived this is the line that was written. ! * @param target this is the target of the debug ! */ ! void newLineReceived(String lineReceived, AbstractDebugTarget target); ! /** ! * This method is called when there is a paste action in the console. ! * ! * @param text this is the text that was pasted ! * @param target this is the target of the debug ! */ ! void pasteReceived(String text, AbstractDebugTarget target); ! } --- 9,28 ---- public interface IConsoleInputListener { ! /** ! * This method is called whenever a new line is written in the console while debugging. ! * ! * @param lineReceived this is the line that was written. ! * @param target this is the target of the debug ! */ ! void newLineReceived(String lineReceived, AbstractDebugTarget target); ! /** ! * This method is called when there is a paste action in the console. ! * ! * @param text this is the text that was pasted ! * @param target this is the target of the debug ! */ ! void pasteReceived(String text, AbstractDebugTarget target); ! } Index: PydevDebugPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/PydevDebugPrefs.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PydevDebugPrefs.java 7 May 2004 21:51:00 -0000 1.2 --- PydevDebugPrefs.java 27 Sep 2008 19:59:09 -0000 1.3 *************** *** 23,67 **** */ public class PydevDebugPrefs extends FieldEditorPreferencePage ! implements IWorkbenchPreferencePage{ ! // Preferences ! public static final String GET_VARIABLE_TIMEOUT = "GET_VARIABLE_TIMEOUT";// GetVariable command timeout ! public static final int DEFAULT_GET_VARIABLE_TIMEOUT = 30; ! public static final String HIDE_PYDEVD_THREADS = "HIDE_PYDEVD_THREADS"; ! public static final boolean DEFAULT_HIDE_PYDEVD_THREADS = true; ! ! /** ! * Initializer sets the preference store ! */ ! public PydevDebugPrefs() { ! super(GRID); ! setPreferenceStore(PydevDebugPlugin.getDefault().getPreferenceStore()); ! } ! static public Preferences getPreferences() { ! return PydevDebugPlugin.getDefault().getPluginPreferences(); ! } ! ! public void init(IWorkbench workbench) { ! } ! ! /** ! * Creates the editors ! */ ! protected void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! IntegerFieldEditor ife = new IntegerFieldEditor( ! GET_VARIABLE_TIMEOUT, "Debugger get variable timeout (seconds)", p); ! ife.setValidRange(1, 180); ! // you can't restrict widget width on IntegerFieldEditor for now ! addField(ife); ! } ! ! /** ! * Sets default preference values ! */ ! protected static void initializeDefaultPreferences(Preferences prefs) { ! prefs.setDefault(GET_VARIABLE_TIMEOUT, DEFAULT_GET_VARIABLE_TIMEOUT); ! prefs.setDefault(HIDE_PYDEVD_THREADS, DEFAULT_HIDE_PYDEVD_THREADS); ! } } --- 23,67 ---- */ public class PydevDebugPrefs extends FieldEditorPreferencePage ! implements IWorkbenchPreferencePage{ ! // Preferences ! public static final String GET_VARIABLE_TIMEOUT = "GET_VARIABLE_TIMEOUT";// GetVariable command timeout ! public static final int DEFAULT_GET_VARIABLE_TIMEOUT = 30; ! public static final String HIDE_PYDEVD_THREADS = "HIDE_PYDEVD_THREADS"; ! public static final boolean DEFAULT_HIDE_PYDEVD_THREADS = true; ! ! /** ! * Initializer sets the preference store ! */ ! public PydevDebugPrefs() { ! super(GRID); ! setPreferenceStore(PydevDebugPlugin.getDefault().getPreferenceStore()); ! } ! static public Preferences getPreferences() { ! return PydevDebugPlugin.getDefault().getPluginPreferences(); ! } ! ! public void init(IWorkbench workbench) { ! } ! ! /** ! * Creates the editors ! */ ! protected void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! IntegerFieldEditor ife = new IntegerFieldEditor( ! GET_VARIABLE_TIMEOUT, "Debugger get variable timeout (seconds)", p); ! ife.setValidRange(1, 180); ! // you can't restrict widget width on IntegerFieldEditor for now ! addField(ife); ! } ! ! /** ! * Sets default preference values ! */ ! protected static void initializeDefaultPreferences(Preferences prefs) { ! prefs.setDefault(GET_VARIABLE_TIMEOUT, DEFAULT_GET_VARIABLE_TIMEOUT); ! prefs.setDefault(HIDE_PYDEVD_THREADS, DEFAULT_HIDE_PYDEVD_THREADS); ! } } Index: Constants.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/Constants.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Constants.java 9 Mar 2008 14:27:59 -0000 1.11 --- Constants.java 27 Sep 2008 19:59:09 -0000 1.12 *************** *** 11,47 **** public interface Constants { ! // Icons ! static final String MAIN_ICON = "icons/python.gif"; ! static final String ARGUMENTS_ICON = "icons/arguments.gif"; ! static final String PYTHON_ORG_ICON = "icons/python_16x16.png"; ! ! // Plugin constants ! static final String PLUGIN_ID = "org.python.pydev.debug"; ! static final String PYTHON_DEBUG_LAUNCH_GROUP = "org.python.pydev.debug.debug"; ! static final String PYTHON_RUN_LAUNCH_GROUP = "org.python.pydev.debug.run"; ! static final String PYTHON_COVERAGE_LAUNCH_GROUP = "org.python.pydev.debug.coverage"; ! static final String PYTHON_UNITTEST_LAUNCH_GROUP = "org.python.pydev.debug.unittest"; ! static final String ID_PYTHON_REGULAR_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.regularLaunchConfigurationType"; ! static final String ID_PYTHON_COVERAGE_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.coverageLaunchConfigurationType"; ! static final String ID_PYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.unittestLaunchConfigurationType"; ! static final String ID_JYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.jythonUnittestLaunchConfigurationType"; ! static final String ID_JYTHON_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.jythonLaunchConfigurationType"; ! static final String PROCESS_TYPE = "PYDEV.PYTHON"; ! ! static final String ATTR_VM_ARGUMENTS = "org.python.pydev.debug.vm.arguments"; ! static final String JAVA_NATURE = "org.eclipse.jdt.core.javanature"; ! // LaunchConfiguration properties // ATTR_* are copied from IExternalToolConstants, replicated since I have no access to originals ! static final String ATTR_LOCATION = "org.eclipse.ui.externaltools" + ".ATTR_LOCATION"; ! static final String ATTR_WORKING_DIRECTORY = "org.eclipse.ui.externaltools" + ".ATTR_WORKING_DIRECTORY"; ! static final String ATTR_OTHER_WORKING_DIRECTORY = "org.eclipse.ui.externaltools" + ".ATTR_OTHER_WORKING_DIRECTORY"; ! static final String ATTR_PROGRAM_ARGUMENTS = "org.eclipse.ui.externaltools" + ".ATTR_TOOL_ARGUMENTS"; ! static final String ATTR_INTERPRETER = PLUGIN_ID + ".ATTR_INTERPRETER"; ! static final String ATTR_INTERPRETER_DEFAULT = "__default"; //$NO-NLS-1$; ! static final String ATTR_PROJECT = PLUGIN_ID + ".ATTR_PROJECT"; ! static final String ATTR_RESOURCE_TYPE = PLUGIN_ID + ".ATTR_RESOURCE_TYPE"; ! ! } --- 11,51 ---- public interface Constants { ! // Icons ! static final String MAIN_ICON = "icons/python.gif"; ! static final String ARGUMENTS_ICON = "icons/arguments.gif"; ! static final String PYTHON_ORG_ICON = "icons/python_16x16.png"; ! ! // Plugin constants ! static final String PLUGIN_ID = "org.python.pydev.debug"; ! static final String PYTHON_DEBUG_LAUNCH_GROUP = "org.python.pydev.debug.debug"; ! static final String PYTHON_RUN_LAUNCH_GROUP = "org.python.pydev.debug.run"; ! static final String PYTHON_COVERAGE_LAUNCH_GROUP = "org.python.pydev.debug.coverage"; ! static final String PYTHON_UNITTEST_LAUNCH_GROUP = "org.python.pydev.debug.unittest"; ! static final String ID_PYTHON_REGULAR_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.regularLaunchConfigurationType"; ! static final String ID_PYTHON_COVERAGE_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.coverageLaunchConfigurationType"; ! static final String ID_PYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.unittestLaunchConfigurationType"; ! static final String ID_JYTHON_UNITTEST_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.jythonUnittestLaunchConfigurationType"; ! static final String ID_JYTHON_LAUNCH_CONFIGURATION_TYPE = "org.python.pydev.debug.jythonLaunchConfigurationType"; ! static final String PROCESS_TYPE = "PYDEV.PYTHON"; ! ! static final String ATTR_VM_ARGUMENTS = "org.python.pydev.debug.vm.arguments"; ! static final String JAVA_NATURE = "org.eclipse.jdt.core.javanature"; ! // LaunchConfiguration properties // ATTR_* are copied from IExternalToolConstants, replicated since I have no access to originals ! static final String ATTR_LOCATION = "org.eclipse.ui.externaltools" + ".ATTR_LOCATION"; ! /** Attribute holding alternate location that is used to actually run the resource. */ ! static final String ATTR_ALTERNATE_LOCATION = "org.python.pydev.debug.core" + ".ATTR_ALTERNATE_LOCATION"; ! /** Attribute to control if a wrapper for test runner should be used. */ ! static final String ATTR_NO_UNITTEST_WRAPPER = "org.python.pydev.debug.core" + ".ATTR_NO_UNITTEST_WRAPPER"; ! static final String ATTR_WORKING_DIRECTORY = "org.eclipse.ui.externaltools" + ".ATTR_WORKING_DIRECTORY"; ! static final String ATTR_OTHER_WORKING_DIRECTORY = "org.eclipse.ui.externaltools" + ".ATTR_OTHER_WORKING_DIRECTORY"; ! static final String ATTR_PROGRAM_ARGUMENTS = "org.eclipse.ui.externaltools" + ".ATTR_TOOL_ARGUMENTS"; ! static final String ATTR_INTERPRETER = PLUGIN_ID + ".ATTR_INTERPRETER"; ! static final String ATTR_INTERPRETER_DEFAULT = "__default"; //$NO-NLS-1$; ! static final String ATTR_PROJECT = PLUGIN_ID + ".ATTR_PROJECT"; ! static final String ATTR_RESOURCE_TYPE = PLUGIN_ID + ".ATTR_RESOURCE_TYPE"; ! ! } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:00:28
|
Update of /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/src_console/org/python/pydev/debug/newconsole Modified Files: PydevConsoleFactory.java PydevConsoleInterpreter.java PydevConsole.java PydevConsoleCompletionProcessor.java PydevConsoleCommunication.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: PydevConsoleCommunication.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleCommunication.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PydevConsoleCommunication.java 21 Aug 2008 20:56:33 -0000 1.12 --- PydevConsoleCommunication.java 27 Sep 2008 19:59:08 -0000 1.13 *************** *** 260,264 **** continue; }else{ ! break; } } --- 260,264 ---- continue; }else{ ! break; } } *************** *** 347,352 **** // ret.add(new PyCompletionProposal(name, ! // offset-length, length, name.length(), ! // PyCodeCompletionImages.getImageForType(type), name, null, docStr, priority)); int cursorPos = name.length(); --- 347,352 ---- // ret.add(new PyCompletionProposal(name, ! // offset-length, length, name.length(), ! // PyCodeCompletionImages.getImageForType(type), name, null, docStr, priority)); int cursorPos = name.length(); Index: PydevConsoleFactory.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PydevConsoleFactory.java 2 Apr 2008 01:07:49 -0000 1.7 --- PydevConsoleFactory.java 27 Sep 2008 19:59:08 -0000 1.8 *************** *** 42,48 **** PydevConsoleInterpreter interpreter = createDefaultPydevInterpreter(); if(interpreter != null){ ! PydevConsole console = new PydevConsole(interpreter); ! manager.add(console, true); ! return console; } } catch (Exception e) { --- 42,48 ---- PydevConsoleInterpreter interpreter = createDefaultPydevInterpreter(); if(interpreter != null){ ! PydevConsole console = new PydevConsole(interpreter); ! manager.add(console, true); ! return console; } } catch (Exception e) { Index: PydevConsole.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsole.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PydevConsole.java 17 Aug 2008 00:26:56 -0000 1.9 --- PydevConsole.java 27 Sep 2008 19:59:08 -0000 1.10 *************** *** 145,178 **** lineTracker.init(new IConsole(){ ! //IMPLEMENTATIONS FORWARDED TO OUTER CLASS ! public void addLink(IConsoleHyperlink link, int offset, int length) { ! PydevConsole.this.addLink(link, offset, length); ! } ! public void addLink(IHyperlink link, int offset, int length) { ! PydevConsole.this.addLink(link, offset, length); ! } ! public void addPatternMatchListener( ! IPatternMatchListener matchListener) { ! PydevConsole.this.addPatternMatchListener(matchListener); ! } ! public IDocument getDocument() { ! return PydevConsole.this.getDocument(); ! } ! public IRegion getRegion(IConsoleHyperlink link) { ! return PydevConsole.this.getRegion(link); ! } ! public IRegion getRegion(IHyperlink link) { ! return PydevConsole.this.getRegion(link); ! } ! public void removePatternMatchListener( ! IPatternMatchListener matchListener) { ! PydevConsole.this.removePatternMatchListener(matchListener); ! } ! ! //IMPLEMENTATIONS THAT AREN'T REALLY AVAILABLE IN THE PYDEV CONSOLE ! public void connect(IStreamsProxy streamsProxy) {/**EMPTY**/} ! public void connect(IStreamMonitor streamMonitor, String streamIdentifer) {/**EMPTY**/} ! public IProcess getProcess() {return null;/**EMPTY**/} ! public IOConsoleOutputStream getStream(String streamIdentifier) {return null;/**EMPTY**/} }); --- 145,178 ---- lineTracker.init(new IConsole(){ ! //IMPLEMENTATIONS FORWARDED TO OUTER CLASS ! public void addLink(IConsoleHyperlink link, int offset, int length) { ! PydevConsole.this.addLink(link, offset, length); ! } ! public void addLink(IHyperlink link, int offset, int length) { ! PydevConsole.this.addLink(link, offset, length); ! } ! public void addPatternMatchListener( ! IPatternMatchListener matchListener) { ! PydevConsole.this.addPatternMatchListener(matchListener); ! } ! public IDocument getDocument() { ! return PydevConsole.this.getDocument(); ! } ! public IRegion getRegion(IConsoleHyperlink link) { ! return PydevConsole.this.getRegion(link); ! } ! public IRegion getRegion(IHyperlink link) { ! return PydevConsole.this.getRegion(link); ! } ! public void removePatternMatchListener( ! IPatternMatchListener matchListener) { ! PydevConsole.this.removePatternMatchListener(matchListener); ! } ! ! //IMPLEMENTATIONS THAT AREN'T REALLY AVAILABLE IN THE PYDEV CONSOLE ! public void connect(IStreamsProxy streamsProxy) {/**EMPTY**/} ! public void connect(IStreamMonitor streamMonitor, String streamIdentifer) {/**EMPTY**/} ! public IProcess getProcess() {return null;/**EMPTY**/} ! public IOConsoleOutputStream getStream(String streamIdentifier) {return null;/**EMPTY**/} }); Index: PydevConsoleInterpreter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleInterpreter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PydevConsoleInterpreter.java 4 Apr 2008 02:54:42 -0000 1.6 --- PydevConsoleInterpreter.java 27 Sep 2008 19:59:08 -0000 1.7 *************** *** 39,51 **** @SuppressWarnings("unchecked") ! public PydevConsoleInterpreter() { List<Object> p = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_SIMPLE_ASSIST); ArrayList<ISimpleAssistParticipant2> list = new ArrayList<ISimpleAssistParticipant2>(); for(Object o:p){ ! if(o instanceof ISimpleAssistParticipant2){ ! list.add((ISimpleAssistParticipant2) o); ! } } ! this.simpleParticipants = list; } --- 39,51 ---- @SuppressWarnings("unchecked") ! public PydevConsoleInterpreter() { List<Object> p = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_SIMPLE_ASSIST); ArrayList<ISimpleAssistParticipant2> list = new ArrayList<ISimpleAssistParticipant2>(); for(Object o:p){ ! if(o instanceof ISimpleAssistParticipant2){ ! list.add((ISimpleAssistParticipant2) o); ! } } ! this.simpleParticipants = list; } Index: PydevConsoleCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleCompletionProcessor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PydevConsoleCompletionProcessor.java 12 Apr 2008 15:39:58 -0000 1.5 --- PydevConsoleCompletionProcessor.java 27 Sep 2008 19:59:08 -0000 1.6 *************** *** 48,52 **** public char[] getCompletionProposalAutoActivationCharacters() { return SimpleAssistProcessor.getStaticAutoActivationCharacters( ! PythonCompletionProcessor.getStaticCompletionProposalAutoActivationCharacters(), 0); } --- 48,52 ---- public char[] getCompletionProposalAutoActivationCharacters() { return SimpleAssistProcessor.getStaticAutoActivationCharacters( ! PythonCompletionProcessor.getStaticCompletionProposalAutoActivationCharacters(), 0); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 20:00:14
|
Update of /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/codecoverage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/tests/org/python/pydev/debug/codecoverage Modified Files: XmlRpcTest.java CoverageCacheTest.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: CoverageCacheTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/codecoverage/CoverageCacheTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CoverageCacheTest.java 13 Aug 2008 21:12:24 -0000 1.5 --- CoverageCacheTest.java 27 Sep 2008 19:59:07 -0000 1.6 *************** *** 76,89 **** String statistics = cache.getStatistics(folder1); assertEquals("" + ! "Name Stmts Exec Cover Missing\n" + ! "-----------------------------------------------------------------------------\n" + ! " b 20 10 50% 6-10\n" + ! " c 22 10 45,5% 6-10\n" + ! " d 24 10 41,7% 6-10\n" + ! " e 26 10 38,5% 6-10\n" + ! ".. ggggggggggggggggggggggggggggggggggggg 28 10 35,7% 6-10\n" + ! "-----------------------------------------------------------------------------\n" + ! " TOTAL 120 50 41,7% \n" + ! "", statistics); } --- 76,89 ---- String statistics = cache.getStatistics(folder1); assertEquals("" + ! "Name Stmts Exec Cover Missing\n" + ! "-----------------------------------------------------------------------------\n" + ! " b 20 10 50% 6-10\n" + ! " c 22 10 45,5% 6-10\n" + ! " d 24 10 41,7% 6-10\n" + ! " e 26 10 38,5% 6-10\n" + ! ".. ggggggggggggggggggggggggggggggggggggg 28 10 35,7% 6-10\n" + ! "-----------------------------------------------------------------------------\n" + ! " TOTAL 120 50 41,7% \n" + ! "", statistics); } Index: XmlRpcTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/codecoverage/XmlRpcTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XmlRpcTest.java 13 Aug 2008 21:12:24 -0000 1.4 --- XmlRpcTest.java 27 Sep 2008 19:59:07 -0000 1.5 *************** *** 74,84 **** public static void main(String[] args) throws MalformedURLException, XmlRpcException { try{ ! XmlRpcTest xmlRpcTest = new XmlRpcTest(); ! xmlRpcTest.setUp(); ! xmlRpcTest.testXmlRpcServerPython(); ! xmlRpcTest.tearDown(); ! junit.textui.TestRunner.run(XmlRpcTest.class); }catch(Throwable e){ ! e.printStackTrace(); } } --- 74,84 ---- public static void main(String[] args) throws MalformedURLException, XmlRpcException { try{ ! XmlRpcTest xmlRpcTest = new XmlRpcTest(); ! xmlRpcTest.setUp(); ! xmlRpcTest.testXmlRpcServerPython(); ! xmlRpcTest.tearDown(); ! junit.textui.TestRunner.run(XmlRpcTest.class); }catch(Throwable e){ ! e.printStackTrace(); } } *************** *** 155,162 **** try{ ! int exitValue = process.exitValue(); ! fail("Already exited with val: "+exitValue); }catch(IllegalThreadStateException e){ ! //that's ok } --- 155,162 ---- try{ ! int exitValue = process.exitValue(); ! fail("Already exited with val: "+exitValue); }catch(IllegalThreadStateException e){ ! //that's ok } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:50
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/src/org/python/pydev/debug/codecoverage Modified Files: PyCodeCoverageView.java CoverageCache.java FileNode.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: PyCodeCoverageView.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/PyCodeCoverageView.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyCodeCoverageView.java 15 Jun 2008 01:15:13 -0000 1.11 --- PyCodeCoverageView.java 27 Sep 2008 19:59:13 -0000 1.12 *************** *** 262,266 **** File file = null; if(folderFolLocation != null){ ! IPath loc = folderFolLocation.getRawLocation(); if(loc == null){ loc = folderFolLocation.getLocation(); --- 262,266 ---- File file = null; if(folderFolLocation != null){ ! IPath loc = folderFolLocation.getRawLocation(); if(loc == null){ loc = folderFolLocation.getLocation(); *************** *** 268,272 **** file = loc.toFile(); }else{ ! file = p.toFile().getAbsoluteFile(); } lastChosenFile = file; --- 268,272 ---- file = loc.toFile(); }else{ ! file = p.toFile().getAbsoluteFile(); } lastChosenFile = file; Index: FileNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/FileNode.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FileNode.java 17 Aug 2008 00:26:56 -0000 1.7 --- FileNode.java 27 Sep 2008 19:59:13 -0000 1.8 *************** *** 103,109 **** String tok = toks[i].trim(); if(tok.length() == 0){ ! continue; } ! if(tok.indexOf("-") == -1){ l.add(new Integer(tok)); }else{ --- 103,109 ---- String tok = toks[i].trim(); if(tok.length() == 0){ ! continue; } ! if(tok.indexOf("-") == -1){ l.add(new Integer(tok)); }else{ Index: CoverageCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/codecoverage/CoverageCache.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CoverageCache.java 13 Aug 2008 21:12:24 -0000 1.7 --- CoverageCache.java 27 Sep 2008 19:59:13 -0000 1.8 *************** *** 167,180 **** } ! private List<Object> sortCollectionWithToString(Collection<Object> collection) { ! List<Object> vals = new ArrayList<Object>(collection); ! Collections.sort(vals, new Comparator<Object>(){ ! public int compare(Object o1, Object o2) { ! return o1.toString().compareTo(o2.toString()); ! }} ! ); ! return vals; ! } --- 167,180 ---- } ! private List<Object> sortCollectionWithToString(Collection<Object> collection) { ! List<Object> vals = new ArrayList<Object>(collection); ! Collections.sort(vals, new Comparator<Object>(){ ! public int compare(Object o1, Object o2) { ! return o1.toString().compareTo(o2.toString()); ! }} ! ); ! return vals; ! } *************** *** 210,215 **** buffer.append(element.toString()).append("\n"); if(element instanceof FileNode){ //it may have been an error node... ! totalExecuted += ((FileNode)element).exec; ! totalStmts += ((FileNode)element).stmts; } } --- 210,215 ---- buffer.append(element.toString()).append("\n"); if(element instanceof FileNode){ //it may have been an error node... ! totalExecuted += ((FileNode)element).exec; ! totalStmts += ((FileNode)element).stmts; } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:46
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/prettyprinter Modified Files: WriteState.java AuxSpecials.java IWriterEraser.java PrettyPrinter.java PrettyPrinterUtils.java WriterEraser.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: PrettyPrinterUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/PrettyPrinterUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrettyPrinterUtils.java 11 Jun 2007 00:07:53 -0000 1.1 --- PrettyPrinterUtils.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 277,292 **** } ! protected void genericAfter(SimpleNode node, boolean needIndent, boolean isNewScope) throws IOException { ! state.popInStmt(); afterNode(node, isNewScope); ! } ! protected void genericBefore(SimpleNode node, boolean requiresNewLine) throws IOException { ! if(requiresNewLine){ fixNewStatementCondition(); } beforeNode(node); state.pushInStmt(node); ! } public Object superGlobal(Global node) throws Exception { --- 277,292 ---- } ! protected void genericAfter(SimpleNode node, boolean needIndent, boolean isNewScope) throws IOException { ! state.popInStmt(); afterNode(node, isNewScope); ! } ! protected void genericBefore(SimpleNode node, boolean requiresNewLine) throws IOException { ! if(requiresNewLine){ fixNewStatementCondition(); } beforeNode(node); state.pushInStmt(node); ! } public Object superGlobal(Global node) throws Exception { *************** *** 331,335 **** public Object superReturn(Return node) throws Exception { ! return super.visitReturn(node); } --- 331,335 ---- public Object superReturn(Return node) throws Exception { ! return super.visitReturn(node); } *************** *** 343,351 **** public Object superDelete(Delete node) throws Exception { ! return super.visitDelete(node); } public Object superListComp(ListComp node) throws Exception { ! return super.visitListComp(node); } --- 343,351 ---- public Object superDelete(Delete node) throws Exception { ! return super.visitDelete(node); } public Object superListComp(ListComp node) throws Exception { ! return super.visitListComp(node); } Index: WriteState.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/WriteState.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WriteState.java 13 Jun 2007 00:20:54 -0000 1.2 --- WriteState.java 27 Sep 2008 19:58:43 -0000 1.3 *************** *** 76,96 **** } ! public void pushInStmt(SimpleNode node) { ! stmtStack.push(node); ! } ! public SimpleNode popInStmt() { ! return stmtStack.pop(); ! } ! public boolean inStmt() { ! return stmtStack.size() > 0; ! } ! public void eraseIndent() { ! if(indentation.toString().length() > 0){ ! writer.erase(prefs.getIndent()); ! } ! } public void write(String o) { --- 76,96 ---- } ! public void pushInStmt(SimpleNode node) { ! stmtStack.push(node); ! } ! public SimpleNode popInStmt() { ! return stmtStack.pop(); ! } ! public boolean inStmt() { ! return stmtStack.size() > 0; ! } ! public void eraseIndent() { ! if(indentation.toString().length() > 0){ ! writer.erase(prefs.getIndent()); ! } ! } public void write(String o) { Index: PrettyPrinter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/PrettyPrinter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PrettyPrinter.java 5 Jul 2008 21:53:00 -0000 1.3 --- PrettyPrinter.java 27 Sep 2008 19:58:43 -0000 1.4 *************** *** 173,177 **** @Override public Object visitAssign(Assign node) throws Exception { ! state.pushInStmt(node); auxComment.writeSpecialsBefore(node); for (int i = 0; i < node.targets.length; i++) { --- 173,177 ---- @Override public Object visitAssign(Assign node) throws Exception { ! state.pushInStmt(node); auxComment.writeSpecialsBefore(node); for (int i = 0; i < node.targets.length; i++) { *************** *** 322,326 **** @Override public Object visitDelete(Delete node) throws Exception { ! return visitGeneric(node, "visitDelete", false); } --- 322,326 ---- @Override public Object visitDelete(Delete node) throws Exception { ! return visitGeneric(node, "visitDelete", false); } *************** *** 333,337 **** } afterNode(node); ! return null; } --- 333,337 ---- } afterNode(node); ! return null; } *************** *** 519,523 **** @Override public Object visitReturn(Return node) throws Exception { ! return visitGeneric(node, "visitReturn", true); } --- 519,523 ---- @Override public Object visitReturn(Return node) throws Exception { ! return visitGeneric(node, "visitReturn", true); } *************** *** 575,580 **** state.writeIndentString(); } ! ! //write the body and dedent for (SimpleNode n : node.body){ n.accept(this); --- 575,580 ---- state.writeIndentString(); } ! ! //write the body and dedent for (SimpleNode n : node.body){ n.accept(this); *************** *** 584,588 **** if(node.orelse != null && node.orelse.length > 0){ ! boolean inElse = false; auxComment.writeSpecialsAfter(node); --- 584,588 ---- if(node.orelse != null && node.orelse.length > 0){ ! boolean inElse = false; auxComment.writeSpecialsAfter(node); *************** *** 590,595 **** //but if it is an 'else:' we will have to make the indent again if(node.specialsAfter != null && node.specialsAfter.contains(new SpecialStr("else:",0,0))){ //the SpecialStr only compares with its String ! inElse = true; ! state.indent(); if(!fixNewStatementCondition()){ state.writeIndentString(); --- 590,595 ---- //but if it is an 'else:' we will have to make the indent again if(node.specialsAfter != null && node.specialsAfter.contains(new SpecialStr("else:",0,0))){ //the SpecialStr only compares with its String ! inElse = true; ! state.indent(); if(!fixNewStatementCondition()){ state.writeIndentString(); *************** *** 600,604 **** } if(inElse){ ! dedent(); } } --- 600,604 ---- } if(inElse){ ! dedent(); } } *************** *** 618,631 **** } ! @Override public Object visitStr(Str node) throws Exception { ! auxComment.writeSpecialsBefore(node); ! state.write(NodeUtils.getStringToPrint(node)); ! if(!state.inStmt()){ fixNewStatementCondition(); ! } ! auxComment.writeSpecialsAfter(node); ! return null; } --- 618,631 ---- } ! @Override public Object visitStr(Str node) throws Exception { ! auxComment.writeSpecialsBefore(node); ! state.write(NodeUtils.getStringToPrint(node)); ! if(!state.inStmt()){ fixNewStatementCondition(); ! } ! auxComment.writeSpecialsAfter(node); ! return null; } *************** *** 646,650 **** state.indent(); { ! auxComment.writeSpecialsAfter(name); if(node.bases.length > 0){ --- 646,650 ---- state.indent(); { ! auxComment.writeSpecialsAfter(name); if(node.bases.length > 0){ *************** *** 721,727 **** { ! //arguments ! makeArgs(node.args.args, node.args); ! //end arguments if(!fixNewStatementCondition()){ if(lastWrite == state.getLastWrite()){ --- 721,727 ---- { ! //arguments ! makeArgs(node.args.args, node.args); ! //end arguments if(!fixNewStatementCondition()){ if(lastWrite == state.getLastWrite()){ *************** *** 769,776 **** if(completeArgs.vararg != null){ ! completeArgs.vararg.accept(this); } if(completeArgs.kwarg != null){ ! completeArgs.kwarg.accept(this); } --- 769,776 ---- if(completeArgs.vararg != null){ ! completeArgs.vararg.accept(this); } if(completeArgs.kwarg != null){ ! completeArgs.kwarg.accept(this); } Index: IWriterEraser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/IWriterEraser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IWriterEraser.java 11 Jun 2007 00:07:53 -0000 1.1 --- IWriterEraser.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 3,9 **** public interface IWriterEraser { ! public void write(String o); ! ! public void erase(String o); public void pushTempBuffer(); --- 3,9 ---- public interface IWriterEraser { ! public void write(String o); ! ! public void erase(String o); public void pushTempBuffer(); Index: WriterEraser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/WriterEraser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WriterEraser.java 11 Jun 2007 00:07:53 -0000 1.1 --- WriterEraser.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 5,31 **** public class WriterEraser implements IWriterEraser{ ! FastStack<StringBuffer> buf = new FastStack<StringBuffer>(); ! public WriterEraser(){ pushTempBuffer(); //this is the initial buffer (should never be removed) } ! public void write(String o) { ! buf.peek().append(o); ! } ! public void erase(String o) { StringBuffer buffer = buf.peek(); if(buffer.toString().endsWith(o)){ //only delete if it ends with what was passed ! int len = o.length(); ! int bufLen = buffer.length(); buffer.delete(bufLen-len, bufLen); } ! } ! public StringBuffer getBuffer() { ! return buf.peek(); ! } public void pushTempBuffer() { --- 5,31 ---- public class WriterEraser implements IWriterEraser{ ! FastStack<StringBuffer> buf = new FastStack<StringBuffer>(); ! public WriterEraser(){ pushTempBuffer(); //this is the initial buffer (should never be removed) } ! public void write(String o) { ! buf.peek().append(o); ! } ! public void erase(String o) { StringBuffer buffer = buf.peek(); if(buffer.toString().endsWith(o)){ //only delete if it ends with what was passed ! int len = o.length(); ! int bufLen = buffer.length(); buffer.delete(bufLen-len, bufLen); } ! } ! public StringBuffer getBuffer() { ! return buf.peek(); ! } public void pushTempBuffer() { Index: AuxSpecials.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/AuxSpecials.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AuxSpecials.java 13 Jun 2007 00:20:54 -0000 1.2 --- AuxSpecials.java 27 Sep 2008 19:58:43 -0000 1.3 *************** *** 45,52 **** } }else if(c instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) c; ! String str = s.str; ! if(canWrite(str, ignore, write)){ ! state.write(prefs.getReplacement(str)); } }else{ --- 45,52 ---- } }else if(c instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) c; ! String str = s.str; ! if(canWrite(str, ignore, write)){ ! state.write(prefs.getReplacement(str)); } }else{ *************** *** 81,92 **** public void writeSpecialsAfter(SimpleNode node) throws IOException { ! writeSpecialsAfter(node, true); } public void writeSpecialsAfter(SimpleNode node, boolean isNewScope) throws IOException { ! int line = node.beginLine; ! if(node.specialsAfter == null){ ! return; } --- 81,92 ---- public void writeSpecialsAfter(SimpleNode node) throws IOException { ! writeSpecialsAfter(node, true); } public void writeSpecialsAfter(SimpleNode node, boolean isNewScope) throws IOException { ! int line = node.beginLine; ! if(node.specialsAfter == null){ ! return; } *************** *** 95,109 **** commentType c = (commentType)o; if(c.beginLine > line){ ! if(state.writeNewLine(false)){ ! if(isNewScope){ ! state.writeIndent(1); ! }else{ ! state.writeIndent(); ! } } }else{ state.writeSpacesBeforeComment(); } ! state.write(c.id); state.writeNewLine(); line = c.beginLine + 1; --- 95,109 ---- commentType c = (commentType)o; if(c.beginLine > line){ ! if(state.writeNewLine(false)){ ! if(isNewScope){ ! state.writeIndent(1); ! }else{ ! state.writeIndent(); ! } } }else{ state.writeSpacesBeforeComment(); } ! state.write(c.id); state.writeNewLine(); line = c.beginLine + 1; *************** *** 112,119 **** }else if(o instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) o; ! state.write(prefs.getReplacement(s.str)); ! line = s.beginLine; ! }else if(o instanceof String){ state.write(prefs.getReplacement((String)o)); --- 112,119 ---- }else if(o instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) o; ! state.write(prefs.getReplacement(s.str)); ! line = s.beginLine; ! }else if(o instanceof String){ state.write(prefs.getReplacement((String)o)); *************** *** 132,136 **** state.write(prefs.getReplacement((String)o)); }else if(o instanceof SpecialStr){ ! state.write(prefs.getReplacement(o.toString())); } } --- 132,136 ---- state.write(prefs.getReplacement((String)o)); }else if(o instanceof SpecialStr){ ! state.write(prefs.getReplacement(o.toString())); } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:45
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/pysrc Modified Files: pydevd.py 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: pydevd.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/pysrc/pydevd.py,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** pydevd.py 17 Aug 2008 00:26:56 -0000 1.98 --- pydevd.py 27 Sep 2008 19:59:12 -0000 1.99 *************** *** 674,678 **** #now, the local directory has to be added to the pythonpath ! sys.path.insert(0, os.getcwd()) # for completness, we'll register the pydevd.reader & pydevd.writer threads net = NetCommand(str(CMD_THREAD_CREATE), 0, '<xml><thread name="pydevd.reader" id="-1"/></xml>') --- 674,682 ---- #now, the local directory has to be added to the pythonpath ! #sys.path.insert(0, os.getcwd()) ! #Changed: it's not the local directory, but the directory of the file launched ! #The file being run ust be in the pythonpath (even if it was not before) ! sys.path.insert(0, os.path.split(file)[0]) ! # for completness, we'll register the pydevd.reader & pydevd.writer threads net = NetCommand(str(CMD_THREAD_CREATE), 0, '<xml><thread name="pydevd.reader" id="-1"/></xml>') |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:42
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604 Modified Files: plugin.xml 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: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** plugin.xml 17 Aug 2008 00:26:56 -0000 1.76 --- plugin.xml 27 Sep 2008 19:59:11 -0000 1.77 *************** *** 481,484 **** --- 481,493 ---- </extension> + <extension point="org.eclipse.ui.preferencePages"> + <page + name="Source Locator" + category="org.python.pydev.prefs.debugPage" + class="org.python.pydev.debug.ui.SourceLocatorPrefsPage" + id="org.python.pydev.prefs.debugPage.SourceLocatorPrefsPage"> + </page> + </extension> + <extension point="org.python.pydev.pydev_pyedit_listener"> <pyedit_listener_participant class="org.python.pydev.debug.ui.PyEditBreakpointSync"/> |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:38
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser Modified Files: PyParserTest.java PyParserTestBase.java PyParser25Test.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: PyParser25Test.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParser25Test.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyParser25Test.java 14 Mar 2008 00:23:16 -0000 1.12 --- PyParser25Test.java 27 Sep 2008 19:58:43 -0000 1.13 *************** *** 24,28 **** PyParser25Test test = new PyParser25Test(); test.setUp(); ! test.testNewWithStmt4(); test.tearDown(); System.out.println("Finished"); --- 24,28 ---- PyParser25Test test = new PyParser25Test(); test.setUp(); ! test.testImportFails(); test.tearDown(); System.out.println("Finished"); *************** *** 111,114 **** --- 111,129 ---- } + public void testNewRelativeImport4(){ + setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); + String str = "from ...bar import foo\n"; + Module mod = (Module) parseLegalDocStr(str); + ImportFrom f = (ImportFrom) mod.body[0]; + assertEquals(3, f.level); + assertEquals("bar", ((NameTok)f.module).id); + } + + public void testImportFails(){ + setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); + String str = "from import foo\n"; + parseILegalDoc(new Document(str)); + } + public void testNewWithStmt(){ setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); Index: PyParserTestBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParserTestBase.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyParserTestBase.java 16 Jun 2007 17:12:54 -0000 1.18 --- PyParserTestBase.java 27 Sep 2008 19:58:43 -0000 1.19 *************** *** 52,109 **** } ! /** ! * @param s ! * @return ! */ ! protected static SimpleNode parseLegalDocStr(String s, Object ... additionalErrInfo) { ! Document doc = new Document(s); //by default always use the last version for parsing ! return parseLegalDoc(doc, additionalErrInfo, parser); ! } ! protected SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo) { ! return parseLegalDoc(doc, additionalErrInfo, parser); } ! protected ParseException parseILegalDoc(IDocument doc) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err == null){ ! fail("Expected a ParseException and the doc was successfully parsed."); } ! if(!(err instanceof ParseException)){ ! fail("Expected a ParseException and received:"+err.getClass()); ! } ! return (ParseException) err; } /** ! * @param additionalErrInfo can be used to add additional errors to the fail message if the doc is not parseable ! * @param parser the parser to be used to do the parsing. ! */ ! protected static SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo, PyParser parser) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err != null){ ! String s = ""; ! for (int i = 0; i < additionalErrInfo.length; i++) { ! s += additionalErrInfo[i]; ! } ! if (err instanceof ParseException) { ! ParseException parseErr = (ParseException) err; parseErr.printStackTrace(); ! ! Token token = parseErr.currentToken; ! if(token != null){ ! fail("Expected no error, received: "+parseErr.getMessage()+" "+s+" line:"+token.beginLine+ " col:"+token.beginColumn); ! } ! } ! ! fail("Expected no error, received: "+err+" "+s); ! } ! assertNotNull(objects.o1); ! return objects.o1; ! } public void testEmpty() { --- 52,109 ---- } ! /** ! * @param s ! * @return ! */ ! protected static SimpleNode parseLegalDocStr(String s, Object ... additionalErrInfo) { ! Document doc = new Document(s); //by default always use the last version for parsing ! return parseLegalDoc(doc, additionalErrInfo, parser); ! } ! protected SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo) { ! return parseLegalDoc(doc, additionalErrInfo, parser); } ! protected ParseException parseILegalDoc(IDocument doc) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err == null){ ! fail("Expected a ParseException and the doc was successfully parsed."); } ! if(!(err instanceof ParseException)){ ! fail("Expected a ParseException and received:"+err.getClass()); ! } ! return (ParseException) err; } /** ! * @param additionalErrInfo can be used to add additional errors to the fail message if the doc is not parseable ! * @param parser the parser to be used to do the parsing. ! */ ! protected static SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo, PyParser parser) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err != null){ ! String s = ""; ! for (int i = 0; i < additionalErrInfo.length; i++) { ! s += additionalErrInfo[i]; ! } ! if (err instanceof ParseException) { ! ParseException parseErr = (ParseException) err; parseErr.printStackTrace(); ! ! Token token = parseErr.currentToken; ! if(token != null){ ! fail("Expected no error, received: "+parseErr.getMessage()+" "+s+" line:"+token.beginLine+ " col:"+token.beginColumn); ! } ! } ! ! fail("Expected no error, received: "+err+" "+s); ! } ! assertNotNull(objects.o1); ! return objects.o1; ! } public void testEmpty() { Index: PyParserTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParserTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** PyParserTest.java 15 Jun 2008 22:59:22 -0000 1.38 --- PyParserTest.java 27 Sep 2008 19:58:43 -0000 1.39 *************** *** 49,54 **** @Override protected void setUp() throws Exception { ! super.setUp(); ! PyParser.USE_FAST_STREAM = true; } --- 49,54 ---- @Override protected void setUp() throws Exception { ! super.setUp(); ! PyParser.USE_FAST_STREAM = true; } *************** *** 141,177 **** public void testMultilineStr() { ! String s = "" + ! "a = '''\n" + ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n" + ! "really really big string\n" + ! "really really big string\n" + ! "'''"; ! parseLegalDocStr(s); } public void testErr() { ! String s = "" + ! "def m():\n" + ! " call(a,"; ! parseILegalDoc(new Document(s)); } --- 141,177 ---- public void testMultilineStr() { ! String s = "" + ! "a = '''\n" + ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n" + ! "really really big string\n" + ! "really really big string\n" + ! "'''"; ! parseLegalDocStr(s); } public void testErr() { ! String s = "" + ! "def m():\n" + ! " call(a,"; ! parseILegalDoc(new Document(s)); } *************** *** 214,224 **** public void testYield2() { setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_4); ! String s = "" + ! "class Generator:\n" + ! " def __iter__(self): \n" + ! " for a in range(10):\n" + ! " yield foo(a)\n" + ! ""; ! parseLegalDocStr(s); } --- 214,224 ---- public void testYield2() { setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_4); ! String s = "" + ! "class Generator:\n" + ! " def __iter__(self): \n" + ! " for a in range(10):\n" + ! " yield foo(a)\n" + ! ""; ! parseLegalDocStr(s); } *************** *** 338,350 **** // not removed completely because we may still want to debug it later... // public void testOnCsv() { ! // PyParser.USE_FAST_STREAM = false; ! // String loc = TestDependent.PYTHON_LIB+"csv.py"; ! // String s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); ! // ! // PyParser.USE_FAST_STREAM = true; ! // loc = TestDependent.PYTHON_LIB+"csv.py"; ! // s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); // } --- 338,350 ---- // not removed completely because we may still want to debug it later... // public void testOnCsv() { ! // PyParser.USE_FAST_STREAM = false; ! // String loc = TestDependent.PYTHON_LIB+"csv.py"; ! // String s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); ! // ! // PyParser.USE_FAST_STREAM = true; ! // loc = TestDependent.PYTHON_LIB+"csv.py"; ! // s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); // } *************** *** 380,386 **** public void testOnTestContextLib() { if(TestDependent.HAS_PYTHON_TESTS){ ! String loc = TestDependent.PYTHON_LIB+"test/test_contextlib.py"; ! String s = REF.getFileContents(new File(loc)); ! parseLegalDocStr(s,"(file: test_contextlib.py)"); } } --- 380,386 ---- public void testOnTestContextLib() { if(TestDependent.HAS_PYTHON_TESTS){ ! String loc = TestDependent.PYTHON_LIB+"test/test_contextlib.py"; ! String s = REF.getFileContents(new File(loc)); ! parseLegalDocStr(s,"(file: test_contextlib.py)"); } } *************** *** 544,554 **** */ public void testParser10() { ! String s = "" + ! "l = [ \"encode\", \"decode\" ] \n"+ ! "\n"; ! SimpleNode node = parseLegalDocStr(s); ! List<ASTEntry> strs = SequencialASTIteratorVisitor.create(node).getAsList(new Class[]{Str.class}); ! assertEquals(7, strs.get(0).node.beginColumn); ! assertEquals(17, strs.get(1).node.beginColumn); } --- 544,554 ---- */ public void testParser10() { ! String s = "" + ! "l = [ \"encode\", \"decode\" ] \n"+ ! "\n"; ! SimpleNode node = parseLegalDocStr(s); ! List<ASTEntry> strs = SequencialASTIteratorVisitor.create(node).getAsList(new Class[]{Str.class}); ! assertEquals(7, strs.get(0).node.beginColumn); ! assertEquals(17, strs.get(1).node.beginColumn); } |
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/jython Modified Files: ReaderCharStream.java SpecialStr.java FastCharStream.java Token.java ICompilerAPI.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: ReaderCharStream.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ReaderCharStream.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReaderCharStream.java 28 Apr 2006 13:43:41 -0000 1.4 --- ReaderCharStream.java 27 Sep 2008 19:58:42 -0000 1.5 *************** *** 6,271 **** public final class ReaderCharStream implements CharStream { ! int bufsize; ! int available; ! int tokenBegin; ! public int bufpos = -1; ! private int bufline[]; ! private int bufcolumn[]; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private char[] buffer; ! private int maxNextCharInd = 0; ! private int inBuf = 0; ! ! private static final boolean DEBUG = false; ! private final void ExpandBuff(boolean wrapAround) { ! char[] newbuffer = new char[bufsize + 2048]; ! int newbufline[] = new int[bufsize + 2048]; ! int newbufcolumn[] = new int[bufsize + 2048]; ! try { ! if (wrapAround) { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos += (bufsize - tokenBegin)); ! } else { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos -= tokenBegin); ! } ! } catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! bufsize += 2048; ! available = bufsize; ! tokenBegin = 0; ! } ! private final void FillBuff() throws java.io.IOException { ! if (maxNextCharInd == available) { ! if (available == bufsize) { ! if (tokenBegin > 2048) { ! bufpos = maxNextCharInd = 0; ! available = tokenBegin; ! } else if (tokenBegin < 0) ! bufpos = maxNextCharInd = 0; ! else ! ExpandBuff(false); ! } else if (available > tokenBegin) ! available = bufsize; ! else if ((tokenBegin - available) < 2048) ! ExpandBuff(true); ! else ! available = tokenBegin; ! } ! int i; ! try { ! if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { ! inputStream.close(); ! throw new java.io.IOException(); ! } else ! maxNextCharInd += i; ! return; ! } catch (java.io.IOException e) { ! --bufpos; ! backup(0); ! if (tokenBegin == -1) ! tokenBegin = bufpos; ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBegin = -1; ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("ReaderCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } else ! line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! // ok, this was commented out because the position would not reflect correctly the positions found in the ast. ! // this may have other problems, but they have to be analyzed better to see the problems this may bring ! // (files that mix tabs and spaces may suffer, but I could not find out very well the problems -- anyway, ! // restricting the analysis to files that have only tabs or only spaces seems reasonable -- shortcuts are available ! // so that we can convert a file from one type to another, so, what remains is making some lint analysis to be sure of it). ! // case '\t' : ! // column--; ! // column += (8 - (column & 07)); ! // break; ! default: ! break; ! } ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! } ! public final char readChar() throws java.io.IOException { ! if (inBuf > 0) { ! --inBuf; ! return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]; ! } ! if (++bufpos >= maxNextCharInd) ! FillBuff(); ! char c = buffer[bufpos]; ! UpdateLineColumn(c); ! if(DEBUG){ ! System.out.println("ReaderCharStream: readChar >>"+(int)c+"<<"); ! } ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("ReaderCharStream: backup >>"+amount+"<<"); ! } ! inBuf += amount; ! if ((bufpos -= amount) < 0) ! bufpos += bufsize; ! } ! public ReaderCharStream(java.io.Reader dstream) { ! inputStream = dstream; ! line = 1; ! column = 0; ! available = bufsize = 4096; ! buffer = new char[bufsize]; ! bufline = new int[bufsize]; ! bufcolumn = new int[bufsize]; ! } ! public final String GetImage() { ! String s = null; ! if (bufpos >= tokenBegin) ! s = new String(buffer, tokenBegin, bufpos - tokenBegin + 1); ! else ! s = new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); ! ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetImage >>"+s+"<<"); ! } ! return s; ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((bufpos + 1) >= len) ! System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); ! else { ! System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); ! System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); ! } ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } --- 6,271 ---- public final class ReaderCharStream implements CharStream { ! int bufsize; ! int available; ! int tokenBegin; ! public int bufpos = -1; ! private int bufline[]; ! private int bufcolumn[]; ! private int column = 0; ! private int line = 1; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private java.io.Reader inputStream; ! private char[] buffer; ! private int maxNextCharInd = 0; ! private int inBuf = 0; ! ! private static final boolean DEBUG = false; ! private final void ExpandBuff(boolean wrapAround) { ! char[] newbuffer = new char[bufsize + 2048]; ! int newbufline[] = new int[bufsize + 2048]; ! int newbufcolumn[] = new int[bufsize + 2048]; ! try { ! if (wrapAround) { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos += (bufsize - tokenBegin)); ! } else { ! System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); ! buffer = newbuffer; ! System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); ! bufline = newbufline; ! System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); ! bufcolumn = newbufcolumn; ! maxNextCharInd = (bufpos -= tokenBegin); ! } ! } catch (Throwable t) { ! throw new Error(t.getMessage()); ! } ! bufsize += 2048; ! available = bufsize; ! tokenBegin = 0; ! } ! private final void FillBuff() throws java.io.IOException { ! if (maxNextCharInd == available) { ! if (available == bufsize) { ! if (tokenBegin > 2048) { ! bufpos = maxNextCharInd = 0; ! available = tokenBegin; ! } else if (tokenBegin < 0) ! bufpos = maxNextCharInd = 0; ! else ! ExpandBuff(false); ! } else if (available > tokenBegin) ! available = bufsize; ! else if ((tokenBegin - available) < 2048) ! ExpandBuff(true); ! else ! available = tokenBegin; ! } ! int i; ! try { ! if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) { ! inputStream.close(); ! throw new java.io.IOException(); ! } else ! maxNextCharInd += i; ! return; ! } catch (java.io.IOException e) { ! --bufpos; ! backup(0); ! if (tokenBegin == -1) ! tokenBegin = bufpos; ! throw e; ! } ! } ! public final char BeginToken() throws java.io.IOException { ! tokenBegin = -1; ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("ReaderCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! private final void UpdateLineColumn(char c) { ! column++; ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! } else if (prevCharIsCR) { ! prevCharIsCR = false; ! if (c == '\n') { ! prevCharIsLF = true; ! } else ! line += (column = 1); ! } ! switch (c) { ! case '\r': ! prevCharIsCR = true; ! break; ! case '\n': ! prevCharIsLF = true; ! break; ! // ok, this was commented out because the position would not reflect correctly the positions found in the ast. ! // this may have other problems, but they have to be analyzed better to see the problems this may bring ! // (files that mix tabs and spaces may suffer, but I could not find out very well the problems -- anyway, ! // restricting the analysis to files that have only tabs or only spaces seems reasonable -- shortcuts are available ! // so that we can convert a file from one type to another, so, what remains is making some lint analysis to be sure of it). ! // case '\t' : ! // column--; ! // column += (8 - (column & 07)); ! // break; ! default: ! break; ! } ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! } ! public final char readChar() throws java.io.IOException { ! if (inBuf > 0) { ! --inBuf; ! return buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]; ! } ! if (++bufpos >= maxNextCharInd) ! FillBuff(); ! char c = buffer[bufpos]; ! UpdateLineColumn(c); ! if(DEBUG){ ! System.out.println("ReaderCharStream: readChar >>"+(int)c+"<<"); ! } ! return (c); ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("ReaderCharStream: backup >>"+amount+"<<"); ! } ! inBuf += amount; ! if ((bufpos -= amount) < 0) ! bufpos += bufsize; ! } ! public ReaderCharStream(java.io.Reader dstream) { ! inputStream = dstream; ! line = 1; ! column = 0; ! available = bufsize = 4096; ! buffer = new char[bufsize]; ! bufline = new int[bufsize]; ! bufcolumn = new int[bufsize]; ! } ! public final String GetImage() { ! String s = null; ! if (bufpos >= tokenBegin) ! s = new String(buffer, tokenBegin, bufpos - tokenBegin + 1); ! else ! s = new String(buffer, tokenBegin, bufsize - tokenBegin) + new String(buffer, 0, bufpos + 1); ! ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetImage >>"+s+"<<"); ! } ! return s; ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if ((bufpos + 1) >= len) ! System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); ! else { ! System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1); ! System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); ! } ! if(DEBUG){ ! System.out.println("ReaderCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } Index: Token.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/Token.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Token.java 7 Jun 2006 13:25:19 -0000 1.2 --- Token.java 27 Sep 2008 19:58:42 -0000 1.3 *************** *** 73,77 **** public static final Token newToken(int ofKind) { ! throw new RuntimeException("It should be initialized directly."); // switch(ofKind) // { --- 73,77 ---- public static final Token newToken(int ofKind) { ! throw new RuntimeException("It should be initialized directly."); // switch(ofKind) // { Index: SpecialStr.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/SpecialStr.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SpecialStr.java 20 Mar 2006 19:37:35 -0000 1.1 --- SpecialStr.java 27 Sep 2008 19:58:42 -0000 1.2 *************** *** 2,31 **** public class SpecialStr { ! public String str; ! public int beginLine; ! public int beginCol; ! public SpecialStr(String str, int beginLine, int beginCol){ ! this.str = str; ! this.beginLine = beginLine; ! this.beginCol = beginCol; ! } ! ! @Override ! public String toString() { ! return str; ! } ! @Override ! public int hashCode() { ! return str.hashCode(); ! } ! ! @Override ! public boolean equals(Object obj) { ! if(!(obj instanceof SpecialStr)){ ! return false; ! } ! return str.equals(((SpecialStr)obj).str); ! } } --- 2,31 ---- public class SpecialStr { ! public String str; ! public int beginLine; ! public int beginCol; ! public SpecialStr(String str, int beginLine, int beginCol){ ! this.str = str; ! this.beginLine = beginLine; ! this.beginCol = beginCol; ! } ! ! @Override ! public String toString() { ! return str; ! } ! @Override ! public int hashCode() { ! return str.hashCode(); ! } ! ! @Override ! public boolean equals(Object obj) { ! if(!(obj instanceof SpecialStr)){ ! return false; ! } ! return str.equals(((SpecialStr)obj).str); ! } } Index: ICompilerAPI.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ICompilerAPI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ICompilerAPI.java 20 Mar 2006 19:37:35 -0000 1.1 --- ICompilerAPI.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 14,28 **** public interface ICompilerAPI { ! public Object newLong(String s); ! public Object newLong(java.math.BigInteger i); ! public Object newFloat(double v); ! ! public Object newImaginary(double v); ! ! public Object newInteger(int i); ! ! public String decode_UnicodeEscape(String str, int start, int end, ! String errors, boolean unicode); } --- 14,28 ---- public interface ICompilerAPI { ! public Object newLong(String s); ! public Object newLong(java.math.BigInteger i); ! public Object newFloat(double v); ! ! public Object newImaginary(double v); ! ! public Object newInteger(int i); ! ! public String decode_UnicodeEscape(String str, int start, int end, ! String errors, boolean unicode); } Index: FastCharStream.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/FastCharStream.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FastCharStream.java 2 Jul 2008 20:18:52 -0000 1.8 --- FastCharStream.java 27 Sep 2008 19:58:42 -0000 1.9 *************** *** 15,159 **** public final class FastCharStream implements CharStream { ! private char[] buffer; ! private int bufline[]; ! private int bufcolumn[]; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private int column = 0; ! private int line = 1; ! private int bufpos = -1; ! private int updatePos; ! ! private int tokenBegin; ! ! private static IOException ioException; ! private static final boolean DEBUG = false; ! public FastCharStream(char cs[]) { ! this.buffer = cs; ! this.bufline = new int[cs.length]; ! this.bufcolumn = new int[cs.length]; ! } ! public final char readChar() throws IOException { ! try { ! bufpos++; ! char r = this.buffer[bufpos]; ! ! if(bufpos >= updatePos){ ! updatePos++; ! ! //start UpdateLineCol ! column++; ! ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! ! } else if (prevCharIsCR) { ! ! prevCharIsCR = false; ! if (r == '\n') { ! prevCharIsLF = true; ! } else { ! line += (column = 1); ! } ! } ! ! if(r == '\r'){ ! prevCharIsCR = true; ! ! }else if(r == '\n'){ ! prevCharIsLF = true; ! ! } ! ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! //end UpdateLineCol ! } ! ! return r; ! } catch (ArrayIndexOutOfBoundsException e) { ! bufpos--; ! if (ioException == null){ ! ioException = new IOException(); ! } ! throw ioException; ! } ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("FastCharStream: backup >>"+amount+"<<"); ! } ! bufpos -= amount; ! } ! public final char BeginToken() throws IOException { ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("FastCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! public final String GetImage() { ! if (bufpos >= tokenBegin) { ! return new String(buffer, tokenBegin, bufpos - tokenBegin+1); ! } else { ! return new String(buffer, tokenBegin, buffer.length - tokenBegin+1); ! } ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if (len > 0) { ! try { int initial = bufpos - len +1; if(initial < 0){ --- 15,159 ---- public final class FastCharStream implements CharStream { ! private char[] buffer; ! private int bufline[]; ! private int bufcolumn[]; ! private boolean prevCharIsCR = false; ! private boolean prevCharIsLF = false; ! private int column = 0; ! private int line = 1; ! private int bufpos = -1; ! private int updatePos; ! ! private int tokenBegin; ! ! private static IOException ioException; ! private static final boolean DEBUG = false; ! public FastCharStream(char cs[]) { ! this.buffer = cs; ! this.bufline = new int[cs.length]; ! this.bufcolumn = new int[cs.length]; ! } ! public final char readChar() throws IOException { ! try { ! bufpos++; ! char r = this.buffer[bufpos]; ! ! if(bufpos >= updatePos){ ! updatePos++; ! ! //start UpdateLineCol ! column++; ! ! if (prevCharIsLF) { ! prevCharIsLF = false; ! line += (column = 1); ! ! } else if (prevCharIsCR) { ! ! prevCharIsCR = false; ! if (r == '\n') { ! prevCharIsLF = true; ! } else { ! line += (column = 1); ! } ! } ! ! if(r == '\r'){ ! prevCharIsCR = true; ! ! }else if(r == '\n'){ ! prevCharIsLF = true; ! ! } ! ! bufline[bufpos] = line; ! bufcolumn[bufpos] = column; ! //end UpdateLineCol ! } ! ! return r; ! } catch (ArrayIndexOutOfBoundsException e) { ! bufpos--; ! if (ioException == null){ ! ioException = new IOException(); ! } ! throw ioException; ! } ! } ! /** ! * @deprecated ! * @see #getEndColumn ! */ ! public final int getColumn() { ! return bufcolumn[bufpos]; ! } ! /** ! * @deprecated ! * @see #getEndLine ! */ ! public final int getLine() { ! return bufline[bufpos]; ! } ! public final int getEndColumn() { ! return bufcolumn[bufpos]; ! } ! public final int getEndLine() { ! return bufline[bufpos]; ! } ! public final int getBeginColumn() { ! return bufcolumn[tokenBegin]; ! } ! public final int getBeginLine() { ! return bufline[tokenBegin]; ! } ! public final void backup(int amount) { ! if(DEBUG){ ! System.out.println("FastCharStream: backup >>"+amount+"<<"); ! } ! bufpos -= amount; ! } ! public final char BeginToken() throws IOException { ! char c = readChar(); ! tokenBegin = bufpos; ! if(DEBUG){ ! System.out.println("FastCharStream: BeginToken >>"+(int)c+"<<"); ! } ! return c; ! } ! public final String GetImage() { ! if (bufpos >= tokenBegin) { ! return new String(buffer, tokenBegin, bufpos - tokenBegin+1); ! } else { ! return new String(buffer, tokenBegin, buffer.length - tokenBegin+1); ! } ! } ! public final char[] GetSuffix(int len) { ! char[] ret = new char[len]; ! if (len > 0) { ! try { int initial = bufpos - len +1; if(initial < 0){ *************** *** 165,183 **** System.arraycopy(buffer, initial, ret, 0, len); } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! if(DEBUG){ ! System.out.println("FastCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public final void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } --- 165,183 ---- System.arraycopy(buffer, initial, ret, 0, len); } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! if(DEBUG){ ! System.out.println("FastCharStream: GetSuffix:"+len+" >>"+new String(ret)+"<<"); ! } ! return ret; ! } ! public final void Done() { ! buffer = null; ! bufline = null; ! bufcolumn = null; ! } } |
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/visitors/scope Modified Files: EasyASTIteratorVisitor.java ASTEntry.java SequencialASTIteratorVisitor.java EasyAstIteratorBase.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: EasyASTIteratorVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/EasyASTIteratorVisitor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** EasyASTIteratorVisitor.java 12 Apr 2006 01:38:02 -0000 1.10 --- EasyASTIteratorVisitor.java 27 Sep 2008 19:58:43 -0000 1.11 *************** *** 74,78 **** Name n = (Name) a.value; if (n.id.equals("self")){ ! atomic(t); } } --- 74,78 ---- Name n = (Name) a.value; if (n.id.equals("self")){ ! atomic(t); } } Index: ASTEntry.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/ASTEntry.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ASTEntry.java 24 Feb 2008 00:25:28 -0000 1.16 --- ASTEntry.java 27 Sep 2008 19:58:43 -0000 1.17 *************** *** 108,113 **** buffer.append(((NameTok)names[i].name).id); if(names[i].asname != null){ ! buffer.append(" as "); ! buffer.append(((NameTok)names[i].asname).id); } } --- 108,113 ---- buffer.append(((NameTok)names[i].name).id); if(names[i].asname != null){ ! buffer.append(" as "); ! buffer.append(((NameTok)names[i].asname).id); } } *************** *** 164,168 **** } ! public SimpleNode getNameNode() { if (node instanceof ClassDef){ return ((ClassDef)node).name; --- 164,168 ---- } ! public SimpleNode getNameNode() { if (node instanceof ClassDef){ return ((ClassDef)node).name; *************** *** 172,231 **** } else{ ! return node; ! } ! } ! ! @Override ! public String toString() { ! StringBuffer buffer = new StringBuffer(); ! buffer.append("AstEntry<"); ! buffer.append(getName()); ! buffer.append(" ("); ! buffer.append(FullRepIterable.getLastPart(node.getClass().getName())); ! buffer.append(" L="); ! buffer.append(node.beginLine); ! buffer.append(" C="); ! buffer.append(node.beginColumn); ! buffer.append(")"); ! buffer.append(">"); ! return buffer.toString(); ! } ! @Override ! public int hashCode() { ! int i=31; ! String n = getName(); ! if(n != null){ ! i *= n.hashCode(); ! } ! i += node.beginLine; ! i *= node.beginColumn; ! return i; ! } ! ! @Override ! public boolean equals(Object obj) { ! if (!(obj instanceof ASTEntry)){ return false; } ! ASTEntry other = (ASTEntry) obj; ! ! if(node.beginColumn != other.node.beginColumn || node.beginLine != other.node.beginLine || endCol != other.endCol || endLine != other.endLine){ ! return false; ! } ! ! ! //compare names (cannot be null) ! String n = getName(); ! String oN = other.getName(); if(!n.equals(oN)){ return false; } ! return true; ! } ! } --- 172,231 ---- } else{ ! return node; ! } ! } ! ! @Override ! public String toString() { ! StringBuffer buffer = new StringBuffer(); ! buffer.append("AstEntry<"); ! buffer.append(getName()); ! buffer.append(" ("); ! buffer.append(FullRepIterable.getLastPart(node.getClass().getName())); ! buffer.append(" L="); ! buffer.append(node.beginLine); ! buffer.append(" C="); ! buffer.append(node.beginColumn); ! buffer.append(")"); ! buffer.append(">"); ! return buffer.toString(); ! } ! @Override ! public int hashCode() { ! int i=31; ! String n = getName(); ! if(n != null){ ! i *= n.hashCode(); ! } ! i += node.beginLine; ! i *= node.beginColumn; ! return i; ! } ! ! @Override ! public boolean equals(Object obj) { ! if (!(obj instanceof ASTEntry)){ return false; } ! ASTEntry other = (ASTEntry) obj; ! ! if(node.beginColumn != other.node.beginColumn || node.beginLine != other.node.beginLine || endCol != other.endCol || endLine != other.endLine){ ! return false; ! } ! ! ! //compare names (cannot be null) ! String n = getName(); ! String oN = other.getName(); if(!n.equals(oN)){ return false; } ! return true; ! } ! } Index: EasyAstIteratorBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/EasyAstIteratorBase.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** EasyAstIteratorBase.java 8 Apr 2008 23:05:44 -0000 1.22 --- EasyAstIteratorBase.java 27 Sep 2008 19:58:43 -0000 1.23 *************** *** 80,86 **** */ protected ASTEntry before(SimpleNode node) { ! ASTEntry entry; ! entry = createEntry(); ! entry.node = node; --- 80,86 ---- */ protected ASTEntry before(SimpleNode node) { ! ASTEntry entry; ! entry = createEntry(); ! entry.node = node; *************** *** 165,170 **** */ protected ASTEntry atomic(SimpleNode node) { ! ASTEntry entry; ! entry = createEntry(); entry.node = node; entry.endLine = NodeUtils.getLineEnd(node); --- 165,170 ---- */ protected ASTEntry atomic(SimpleNode node) { ! ASTEntry entry; ! entry = createEntry(); entry.node = node; entry.endLine = NodeUtils.getLineEnd(node); *************** *** 179,186 **** ASTEntry entry; if(parents.size() > 0){ ! entry = new ASTEntry(parents.peek()); ! }else{ ! entry = new ASTEntry(null); ! } return entry; } --- 179,186 ---- ASTEntry entry; if(parents.size() > 0){ ! entry = new ASTEntry(parents.peek()); ! }else{ ! entry = new ASTEntry(null); ! } return entry; } Index: SequencialASTIteratorVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/scope/SequencialASTIteratorVisitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SequencialASTIteratorVisitor.java 15 May 2006 13:47:28 -0000 1.3 --- SequencialASTIteratorVisitor.java 27 Sep 2008 19:58:43 -0000 1.4 *************** *** 6,12 **** protected Object unhandled_node(SimpleNode node) throws Exception { ! atomic(node); ! super.unhandled_node(node); ! return null; } --- 6,12 ---- protected Object unhandled_node(SimpleNode node) throws Exception { ! atomic(node); ! super.unhandled_node(node); ! return null; } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:26
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/profile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/profile Modified Files: ParseBigFile.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: ParseBigFile.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/profile/ParseBigFile.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ParseBigFile.java 28 Apr 2006 13:43:41 -0000 1.4 --- ParseBigFile.java 27 Sep 2008 19:58:43 -0000 1.5 *************** *** 14,75 **** public class ParseBigFile extends PyParserTestBase { ! public static void main(String[] args) { ! junit.textui.TestRunner.run(ParseBigFile.class); ! } ! protected void setUp() throws Exception { ! super.setUp(); ! } ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! /** ! * Initial times with 5 iterations: ! * ! * Took: 1.625 secs ! * Took: 0.797 secs ! * Took: 0.828 secs ! * Took: 0.766 secs ! * Took: 0.765 secs ! * ! * After using the FastCharStream: ! * ! * Took: 0.453 secs ! * Took: 0.14 secs ! * Took: 0.14 secs ! * Took: 0.141 secs ! * Took: 0.14 secs ! * ! * (impressive hum?) ! * ! * -- note that this is directly proportional to the size of the string, so, while in small streams ! * there will be no noticeable change, in longer files the changes will be dramatical. E.g. A file ! * with 3MB of code would take about 3 minutes with the previous approach and would take 2 seconds with ! * the new approach. ! * ! * @throws Exception ! */ ! public void testBigFileParsing() throws Exception { String loc = TestDependent.TEST_PYDEV_PARSER_PLUGIN_LOC+"/tests/pysrc/data_string.py"; String s = REF.getFileContents(new File(loc)); for (int i = 0; i < 5; i++) { ! @SuppressWarnings("unused") long curr = System.currentTimeMillis(); ! SimpleNode node = parseLegalDocStr(s); ! ! PyParser.USE_FAST_STREAM = true; ! //uncomment line below to see the time for parsing ! //System.out.println(StringUtils.format("Took: %s secs", (System.currentTimeMillis()-curr)/1000.0)); ! SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor.create(node); ! ! ASTEntry entry = visitor.getAsList(Str.class).get(0); ! String s0 = ((Str)entry.node).s; ! assertEquals(42, entry.node.beginLine); ! assertEquals(8, entry.node.beginColumn); ! assertTrue("Expecting big string. Received"+s0, s0.length() > 100 ); ! ! } ! } } --- 14,75 ---- public class ParseBigFile extends PyParserTestBase { ! public static void main(String[] args) { ! junit.textui.TestRunner.run(ParseBigFile.class); ! } ! protected void setUp() throws Exception { ! super.setUp(); ! } ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! /** ! * Initial times with 5 iterations: ! * ! * Took: 1.625 secs ! * Took: 0.797 secs ! * Took: 0.828 secs ! * Took: 0.766 secs ! * Took: 0.765 secs ! * ! * After using the FastCharStream: ! * ! * Took: 0.453 secs ! * Took: 0.14 secs ! * Took: 0.14 secs ! * Took: 0.141 secs ! * Took: 0.14 secs ! * ! * (impressive hum?) ! * ! * -- note that this is directly proportional to the size of the string, so, while in small streams ! * there will be no noticeable change, in longer files the changes will be dramatical. E.g. A file ! * with 3MB of code would take about 3 minutes with the previous approach and would take 2 seconds with ! * the new approach. ! * ! * @throws Exception ! */ ! public void testBigFileParsing() throws Exception { String loc = TestDependent.TEST_PYDEV_PARSER_PLUGIN_LOC+"/tests/pysrc/data_string.py"; String s = REF.getFileContents(new File(loc)); for (int i = 0; i < 5; i++) { ! @SuppressWarnings("unused") long curr = System.currentTimeMillis(); ! SimpleNode node = parseLegalDocStr(s); ! ! PyParser.USE_FAST_STREAM = true; ! //uncomment line below to see the time for parsing ! //System.out.println(StringUtils.format("Took: %s secs", (System.currentTimeMillis()-curr)/1000.0)); ! SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor.create(node); ! ! ASTEntry entry = visitor.getAsList(Str.class).get(0); ! String s0 = ((Str)entry.node).s; ! assertEquals(42, entry.node.beginLine); ! assertEquals(8, entry.node.beginColumn); ! assertTrue("Expecting big string. Received"+s0, s0.length() > 100 ); ! ! } ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:25
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/jython/ast Modified Files: listcompType.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: listcompType.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/jython/ast/listcompType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** listcompType.java 20 Mar 2006 19:37:35 -0000 1.1 --- listcompType.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 7,69 **** public class listcompType extends SimpleNode { ! /** * */ private static final long serialVersionUID = 971434004466657577L; public exprType target; ! public exprType iter; ! public exprType[] ifs; ! public listcompType(exprType target, exprType iter, exprType[] ifs) { ! this.target = target; ! this.iter = iter; ! this.ifs = ifs; ! } ! public listcompType(exprType target, exprType iter, exprType[] ifs, ! SimpleNode parent) { ! this(target, iter, ifs); ! this.beginLine = parent.beginLine; ! this.beginColumn = parent.beginColumn; ! } ! public String toString() { ! StringBuffer sb = new StringBuffer("listcomp["); ! sb.append("target="); ! sb.append(dumpThis(this.target)); ! sb.append(", "); ! sb.append("iter="); ! sb.append(dumpThis(this.iter)); ! sb.append(", "); ! sb.append("ifs="); ! sb.append(dumpThis(this.ifs)); ! sb.append("]"); ! return sb.toString(); ! } ! public void pickle(DataOutputStream ostream) throws IOException { ! pickleThis(48, ostream); ! pickleThis(this.target, ostream); ! pickleThis(this.iter, ostream); ! pickleThis(this.ifs, ostream); ! } ! public Object accept(VisitorIF visitor) throws Exception { ! traverse(visitor); ! return null; ! } ! public void traverse(VisitorIF visitor) throws Exception { ! if (target != null) ! target.accept(visitor); ! if (iter != null) ! iter.accept(visitor); ! if (ifs != null) { ! for (int i = 0; i < ifs.length; i++) { ! if (ifs[i] != null) ! ifs[i].accept(visitor); ! } ! } ! } } --- 7,69 ---- public class listcompType extends SimpleNode { ! /** * */ private static final long serialVersionUID = 971434004466657577L; public exprType target; ! public exprType iter; ! public exprType[] ifs; ! public listcompType(exprType target, exprType iter, exprType[] ifs) { ! this.target = target; ! this.iter = iter; ! this.ifs = ifs; ! } ! public listcompType(exprType target, exprType iter, exprType[] ifs, ! SimpleNode parent) { ! this(target, iter, ifs); ! this.beginLine = parent.beginLine; ! this.beginColumn = parent.beginColumn; ! } ! public String toString() { ! StringBuffer sb = new StringBuffer("listcomp["); ! sb.append("target="); ! sb.append(dumpThis(this.target)); ! sb.append(", "); ! sb.append("iter="); ! sb.append(dumpThis(this.iter)); ! sb.append(", "); ! sb.append("ifs="); ! sb.append(dumpThis(this.ifs)); ! sb.append("]"); ! return sb.toString(); ! } ! public void pickle(DataOutputStream ostream) throws IOException { ! pickleThis(48, ostream); ! pickleThis(this.target, ostream); ! pickleThis(this.iter, ostream); ! pickleThis(this.ifs, ostream); ! } ! public Object accept(VisitorIF visitor) throws Exception { ! traverse(visitor); ! return null; ! } ! public void traverse(VisitorIF visitor) throws Exception { ! if (target != null) ! target.accept(visitor); ! if (iter != null) ! iter.accept(visitor); ! if (ifs != null) { ! for (int i = 0; i < ifs.length; i++) { ! if (ifs[i] != null) ! ifs[i].accept(visitor); ! } ! } ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:23
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/prettyprinter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/prettyprinter Modified Files: PrettyPrinterTest.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: PrettyPrinterTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/prettyprinter/PrettyPrinterTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PrettyPrinterTest.java 13 Jun 2007 00:20:54 -0000 1.2 --- PrettyPrinterTest.java 27 Sep 2008 19:58:44 -0000 1.3 *************** *** 40,50 **** public void testIfs() throws Exception { String s = "" + ! "def method1():\n" + ! " if idx > 2:\n" + ! " print ''\n" + ! " else:\n" + ! " print ''\n" + ! " if idx == 5:\n" + ! " print 'nothing!'\n"; checkPrettyPrintEqual(s); } --- 40,50 ---- public void testIfs() throws Exception { String s = "" + ! "def method1():\n" + ! " if idx > 2:\n" + ! " print ''\n" + ! " else:\n" + ! " print ''\n" + ! " if idx == 5:\n" + ! " print 'nothing!'\n"; checkPrettyPrintEqual(s); } *************** *** 75,85 **** "class MyClass:\n" + " __metaclass__ = MyMeta\n" + ! "print type(foox)\n" + ! "# after print type\n" + ! "class A(object):# on-line\n" + ! " # foo test\n" + ! " def met(self):\n" + ! " print 'A'\n" + ! ""; checkPrettyPrintEqual(str); --- 75,85 ---- "class MyClass:\n" + " __metaclass__ = MyMeta\n" + ! "print type(foox)\n" + ! "# after print type\n" + ! "class A(object):# on-line\n" + ! " # foo test\n" + ! " def met(self):\n" + ! " print 'A'\n" + ! ""; checkPrettyPrintEqual(str); *************** *** 88,96 **** public void testComment5() throws Exception { String str = "" + ! "class CoolApproach(object):\n" + ! " # this tests also a tuple \"special case\"\n" + ! " def foodeco(**arg5):\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(str); --- 88,96 ---- public void testComment5() throws Exception { String str = "" + ! "class CoolApproach(object):\n" + ! " # this tests also a tuple \"special case\"\n" + ! " def foodeco(**arg5):\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(str); *************** *** 99,107 **** public void testDecoration() throws Exception { String str = "" + ! "class Foo:\n" + ! " @foodeco(('arg_3',),2,a=2,b=3)\n" + ! " def __init__(self,arg_1,(arg_2,arg_3),arg_4,arg_5):\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(str); } --- 99,107 ---- public void testDecoration() throws Exception { String str = "" + ! "class Foo:\n" + ! " @foodeco(('arg_3',),2,a=2,b=3)\n" + ! " def __init__(self,arg_1,(arg_2,arg_3),arg_4,arg_5):\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(str); } *************** *** 109,117 **** public void testComments6() throws Exception { String str = "" + ! "class FooApproach(CoolApproach):\n" + ! " def __init__(self,arg_1,(arg_2,arg_3),*arg_4,**arg_5):\n" + ! " # .. at this point all parameters except for 'arg_3' have been\n" + ! " # copied to object attributes\n" + ! " pass\n" + ""; checkPrettyPrintEqual(str); --- 109,117 ---- public void testComments6() throws Exception { String str = "" + ! "class FooApproach(CoolApproach):\n" + ! " def __init__(self,arg_1,(arg_2,arg_3),*arg_4,**arg_5):\n" + ! " # .. at this point all parameters except for 'arg_3' have been\n" + ! " # copied to object attributes\n" + ! " pass\n" + ""; checkPrettyPrintEqual(str); *************** *** 525,573 **** public void testComment() throws Exception { ! String s = ""+ ! "# comment1\n" + ! "# comment2\n" + ! "# comment3\n" + ! "# comment4\n" + ! "'''str'''\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testStarArgs() throws Exception { ! String s = ""+ ! "def recv(self,*args):\n" + ! " pass\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testListComp() throws Exception { ! String s = ""+ ! "print [x for x in tbinfo]\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testSub() throws Exception { ! String s = ""+ ! "print tbinfo[-1]\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testDel() throws Exception { ! String s = ""+ ! "del foo\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPar2() throws Exception { ! String s = ""+ ! "def log(self,message):\n" + ! " sys.stderr.write('log: %s' % str(message))\n" + ! ""; ! checkPrettyPrintEqual(s); } --- 525,573 ---- public void testComment() throws Exception { ! String s = ""+ ! "# comment1\n" + ! "# comment2\n" + ! "# comment3\n" + ! "# comment4\n" + ! "'''str'''\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testStarArgs() throws Exception { ! String s = ""+ ! "def recv(self,*args):\n" + ! " pass\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testListComp() throws Exception { ! String s = ""+ ! "print [x for x in tbinfo]\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testSub() throws Exception { ! String s = ""+ ! "print tbinfo[-1]\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testDel() throws Exception { ! String s = ""+ ! "del foo\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPar2() throws Exception { ! String s = ""+ ! "def log(self,message):\n" + ! " sys.stderr.write('log: %s' % str(message))\n" + ! ""; ! checkPrettyPrintEqual(s); } *************** *** 580,588 **** public void testSimpleFunc() throws Exception { ! String s = ""+ ! "def a():\n" + ! " pass\n" + ! ""; ! checkPrettyPrintEqual(s); } --- 580,588 ---- public void testSimpleFunc() throws Exception { ! String s = ""+ ! "def a():\n" + ! " pass\n" + ! ""; ! checkPrettyPrintEqual(s); } *************** *** 1013,1022 **** public void testYield4() throws Exception { ! String s = ""+ ! "def foo():\n" + ! " yield ((a + b) / 2)#comment1\n" + ! " print 'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } --- 1013,1022 ---- public void testYield4() throws Exception { ! String s = ""+ ! "def foo():\n" + ! " yield ((a + b) / 2)#comment1\n" + ! " print 'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } *************** *** 1026,1052 **** } public void testFuncComment() throws Exception { ! String s = ""+ ! "def foo():\n" + ! " #comment0\n" + ! " print 'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPrint() throws Exception { ! String s = ""+ ! "print >> a,'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPrintComment() throws Exception { ! String s = ""+ ! "def test():#comm1\n" + ! " print >> (a,#comm2\n" + ! " 'foo')#comm3\n" + ! ""; ! checkPrettyPrintEqual(s); } --- 1026,1052 ---- } public void testFuncComment() throws Exception { ! String s = ""+ ! "def foo():\n" + ! " #comment0\n" + ! " print 'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPrint() throws Exception { ! String s = ""+ ! "print >> a,'foo'\n" + ! ""; ! checkPrettyPrintEqual(s); } public void testPrintComment() throws Exception { ! String s = ""+ ! "def test():#comm1\n" + ! " print >> (a,#comm2\n" + ! " 'foo')#comm3\n" + ! ""; ! checkPrettyPrintEqual(s); } *************** *** 1087,1094 **** public void testSubscript() throws Exception { ! String s = ""+ ! "print a[0]\n" + ! ""; ! checkPrettyPrintEqual(s); } --- 1087,1094 ---- public void testSubscript() throws Exception { ! String s = ""+ ! "print a[0]\n" + ! ""; ! checkPrettyPrintEqual(s); } *************** *** 1128,1142 **** public void testDocStrings() throws Exception { ! String s = ""+ ! "class Class1:\n" + ! " '''docstring1'''\n" + ! " a = '''str1'''\n" + ! " def met1(self,a):\n" + ! " '''docstring2\n" + ! " foo\n" + ! " '''\n" + ! " pass\n" + ""; ! checkPrettyPrintEqual(s); } --- 1128,1142 ---- public void testDocStrings() throws Exception { ! String s = ""+ ! "class Class1:\n" + ! " '''docstring1'''\n" + ! " a = '''str1'''\n" + ! " def met1(self,a):\n" + ! " '''docstring2\n" + ! " foo\n" + ! " '''\n" + ! " pass\n" + ""; ! checkPrettyPrintEqual(s); } *************** *** 1215,1255 **** } public void testIfElse2() throws Exception { ! String s = ""+ ! "if a:\n"+ ! " a = 1#comment1\n"+ ! "elif b:\n"+ ! " b = 2#comment2\n"+ ! "elif c:\n"+ ! " c = 3#comment3\n"+ ! "else:\n"+ ! " d = 4#comment4\n"; ! checkPrettyPrintEqual(s); } public void testIfElse3() throws Exception { ! String s = ! "#commentbefore\n"+ //1 ! "if a:#commentIf\n"+ //2 ! " a = 1\n"+ //3 ! "elif b:#commentElif\n"+ //4 ! " b = 2\n"+ //5 ! "elif c:\n"+ //6 ! " c = 3\n"+ //7 ! "else:#commentElse\n"+ //8 ! " d = 4\n" + //9 ! "outOfIf = True\n"; //10 ! checkPrettyPrintEqual(s); } public void testCommentAndIf() throws Exception { String s = "" + ! "def initiate_send():\n" + ! " if 10:\n" + ! " # try to send the buffer\n" + ! " try:\n" + ! " num_sent = 10\n" + ! " except:\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(s); } --- 1215,1255 ---- } public void testIfElse2() throws Exception { ! String s = ""+ ! "if a:\n"+ ! " a = 1#comment1\n"+ ! "elif b:\n"+ ! " b = 2#comment2\n"+ ! "elif c:\n"+ ! " c = 3#comment3\n"+ ! "else:\n"+ ! " d = 4#comment4\n"; ! checkPrettyPrintEqual(s); } public void testIfElse3() throws Exception { ! String s = ! "#commentbefore\n"+ //1 ! "if a:#commentIf\n"+ //2 ! " a = 1\n"+ //3 ! "elif b:#commentElif\n"+ //4 ! " b = 2\n"+ //5 ! "elif c:\n"+ //6 ! " c = 3\n"+ //7 ! "else:#commentElse\n"+ //8 ! " d = 4\n" + //9 ! "outOfIf = True\n"; //10 ! checkPrettyPrintEqual(s); } public void testCommentAndIf() throws Exception { String s = "" + ! "def initiate_send():\n" + ! " if 10:\n" + ! " # try to send the buffer\n" + ! " try:\n" + ! " num_sent = 10\n" + ! " except:\n" + ! " pass\n" + ! ""; checkPrettyPrintEqual(s); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:18
|
Update of /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20604/tests/org/python/pydev/debug/ui Modified Files: DebuggerTestWorkbench.java Added Files: SourceLocatorTestWorkbench.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: DebuggerTestWorkbench.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/tests/org/python/pydev/debug/ui/DebuggerTestWorkbench.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DebuggerTestWorkbench.java 13 Aug 2008 21:12:25 -0000 1.1 --- DebuggerTestWorkbench.java 27 Sep 2008 19:59:11 -0000 1.2 *************** *** 32,327 **** public class DebuggerTestWorkbench extends AbstractWorkbenchTestCase { ! /** ! * File used to debug ! */ ! private IFile debugFile; ! ! /** ! * The editor that'll be created on debug ! */ ! private PyEdit debugEditor; ! ! /** ! * Maximum number of loops (used with the timeout) ! */ ! private final int MAX_LOOPS = 300; ! ! /** ! * Maximum time for each loop in millis ! */ ! private final int STEP_TIMEOUT = 100; ! ! /** ! * Number of steps in the tests that will have busy loops until some condition is hit. ! */ ! private final int TOTAL_STEPS = 3; ! ! /** ! * Total time in millis that the test has for finishing ! */ ! private final int TOTAL_TIME_FOR_TESTS = MAX_LOOPS*STEP_TIMEOUT*(TOTAL_STEPS+1); ! ! /** ! * Used for having wait() ! */ ! private Object lock = new Object(); ! ! /** ! * An exception that occurred that was thrown and didn't let the tests finish ! */ ! private Throwable failException = null; ! ! /** ! * Only true when the test finishes without exceptions. ! */ ! private boolean finished = false; ! ! /** ! * Creates the debug file and editor. ! */ ! @Override ! protected void setUp() throws Exception { ! super.setUp(); ! debugFile = initFile.getParent().getFile(new Path("debug_file.py")); ! String mod1Contents = "from pack1.pack2 import mod1\nprint mod1\nprint 'now'\n"; ! debugFile.create(new ByteArrayInputStream(mod1Contents.getBytes()), true, null); ! debugFile.refreshLocal(IResource.DEPTH_ZERO, null); ! ! debugEditor = (PyEdit) PyOpenEditor.doOpenEditor(debugFile); ! } ! ! /** ! * Removes the debug file and closes the debug editor ! */ ! @Override ! protected void tearDown() throws Exception { ! super.tearDown(); ! if(debugFile != null){ ! debugFile.delete(true, null); ! } ! if(debugEditor != null){ ! debugEditor.close(false); ! } ! } ! ! ! /** ! * In this test, a thread is started and then we wait on a busy loop until the thread finishes with the tests. ! */ ! public void testDebugger() throws Exception { ! //start the thread that'll do the test ! threadTest.start(); ! ! //wait on a busy loop until the test is finished or an exception is thrown. ! goToManual(TOTAL_TIME_FOR_TESTS, new org.python.pydev.core.ICallback<Boolean, Object>(){ ! public Boolean call(Object arg) { ! return finished || failException != null; ! }} ! ); ! //Make it fail if we encountered some problem ! if(failException != null){ ! failException.printStackTrace(); ! fail(failException.getMessage()); ! } ! if(!finished){ ! if(failException == null){ ! fail("The test didn't finish in the available time: "+TOTAL_TIME_FOR_TESTS/1000+ " secs."); ! } ! } ! } ! /** ! * This is the thread that'll make the test. ! */ ! Thread threadTest = new Thread(){ ! @Override ! public void run() { ! try{ ! //make a launch for debugging ! launchEditorInDebug(); ! ! //switch to debug perspective, because otherwise, when we hit a breakpoint it'll ask if we want to show it. ! switchToPerspective("org.eclipse.debug.ui.DebugPerspective"); ! BreakpointRulerAction createAddBreakPointAction = createAddBreakPointAction(1); ! createAddBreakPointAction.run(); ! ! ILaunch launch = waitForLaunchAvailable(); ! PyDebugTarget target = (PyDebugTarget) waitForDebugTargetAvailable(launch); ! IThread suspendedThread = waitForSuspendedThread(target); ! assertEquals("MainThread", suspendedThread.getName()); ! IStackFrame topStackFrame = suspendedThread.getTopStackFrame(); ! assertTrue("Was not expecting: "+topStackFrame.getName(), topStackFrame.getName().indexOf("debug_file.py:2") != 0); ! IVariable[] variables = topStackFrame.getVariables(); ! ! HashSet<String> varNames = new HashSet<String>(); ! for (IVariable variable : variables) { ! PyVariable var = (PyVariable) variable; ! varNames.add(var.getName()); ! } ! HashSet<String> expected = new HashSet<String>(); ! expected.add("Globals"); ! expected.add("__doc__"); ! expected.add("__file__"); ! expected.add("__name__"); ! expected.add("mod1"); ! assertEquals(expected, varNames); ! ! assertTrue(target.canTerminate()); ! target.terminate(); ! ! finished = true; ! }catch(Throwable e){ ! failException = e; ! } ! } ! }; ! ! ! /** ! * Creates a run in debug mode for the debug editor ! */ ! private void launchEditorInDebug() { ! final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench(); ! Display display = workBench.getDisplay(); ! // Make sure to run the UI thread. ! display.syncExec( new Runnable(){ ! public void run(){ ! JythonLaunchShortcut launchShortcut = new JythonLaunchShortcut(); ! launchShortcut.launch(debugEditor, "debug"); ! } ! }); ! } ! /** ! * @return an action that can be run to create a breakpoint in the given line ! */ ! private BreakpointRulerAction createAddBreakPointAction(final int line) { ! BreakpointRulerAction ret = new BreakpointRulerAction(debugEditor, new IVerticalRulerInfo(){ ! public int getLineOfLastMouseButtonActivity() { ! return line; ! } ! ! public Control getControl() { ! throw new RuntimeException("Not Implemented"); ! } ! public int getWidth() { ! throw new RuntimeException("Not Implemented"); ! } ! public int toDocumentLineNumber(int y_coordinate) { ! throw new RuntimeException("Not Implemented"); ! }}); ! ret.update(); ! return ret; ! } ! ! ! /** ! * This method can be used to switch to a given perspective ! * @param perspectiveId the id of the perspective that should be activated. ! */ ! protected void switchToPerspective(final String perspectiveId) { ! final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench(); ! Display display = workBench.getDisplay(); ! // Make sure to run the UI thread. ! display.syncExec( new Runnable(){ ! public void run(){ ! IWorkbenchWindow window = workBench.getActiveWorkbenchWindow(); ! try { ! workBench.showPerspective(perspectiveId, window); ! } catch (WorkbenchException e) { ! failException = e; ! } ! } ! }); ! } ! ! /** ! * Waits until some thread is suspended. ! */ ! protected IThread waitForSuspendedThread(final PyDebugTarget target) throws Throwable { ! final IThread[] ret = new IThread[1]; ! ! waitForCondition(new ICallback(){ ! public Object call(Object args) throws Exception { ! IThread[] threads = target.getThreads(); ! for (IThread thread : threads) { ! if(thread.isSuspended()){ ! ret[0] = thread; ! return true; ! } ! } ! return false; ! }} ! ); ! return ret[0]; ! } ! /** ! * Waits until a launch becomes available ! * @return the launch that was found ! */ ! private ILaunch waitForLaunchAvailable() throws Throwable { ! final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ! waitForCondition(new ICallback(){ ! ! public Object call(Object args) throws Exception { ! ILaunch[] launches = launchManager.getLaunches(); ! return launches.length > 0; ! }}); ! return launchManager.getLaunches()[0]; ! } ! ! ! /** ! * Waits until a debug target is available in the passed launch ! * @return the debug target found ! */ ! private IDebugTarget waitForDebugTargetAvailable(final ILaunch launch) throws Throwable { ! waitForCondition(new ICallback(){ ! public Object call(Object args) throws Exception { ! return launch.getDebugTarget() != null; ! }}); ! ! return launch.getDebugTarget(); ! } ! ! ! /** ! * Keeps on a busy loop with a timeout until the given callback returns true (otherwise, an ! * exception is thrown when the total time is elapsed). ! */ ! private void waitForCondition(ICallback callback) throws Throwable { ! if(failException != null){ ! throw failException; ! } ! ! int loops = MAX_LOOPS; ! for(int i=0;i<loops;i++){ ! if((Boolean)callback.call(new Object[]{})){ ! return; ! } ! synchronized (lock) { ! try { ! Thread.yield(); ! lock.wait(STEP_TIMEOUT); ! } catch (InterruptedException e) { ! } ! } ! } ! fail("Unable to get to condition after "+(loops*STEP_TIMEOUT)/1000+" seconds."); ! } --- 32,327 ---- public class DebuggerTestWorkbench extends AbstractWorkbenchTestCase { ! /** ! * File used to debug ! */ ! private IFile debugFile; ! ! /** ! * The editor that'll be created on debug ! */ ! private PyEdit debugEditor; ! ! /** ! * Maximum number of loops (used with the timeout) ! */ ! private final int MAX_LOOPS = 300; ! ! /** ! * Maximum time for each loop in millis ! */ ! private final int STEP_TIMEOUT = 100; ! ! /** ! * Number of steps in the tests that will have busy loops until some condition is hit. ! */ ! private final int TOTAL_STEPS = 3; ! ! /** ! * Total time in millis that the test has for finishing ! */ ! private final int TOTAL_TIME_FOR_TESTS = MAX_LOOPS*STEP_TIMEOUT*(TOTAL_STEPS+1); ! ! /** ! * Used for having wait() ! */ ! private Object lock = new Object(); ! ! /** ! * An exception that occurred that was thrown and didn't let the tests finish ! */ ! private Throwable failException = null; ! ! /** ! * Only true when the test finishes without exceptions. ! */ ! private boolean finished = false; ! ! /** ! * Creates the debug file and editor. ! */ ! @Override ! protected void setUp() throws Exception { ! super.setUp(); ! debugFile = initFile.getParent().getFile(new Path("debug_file.py")); ! String mod1Contents = "from pack1.pack2 import mod1\nprint mod1\nprint 'now'\n"; ! debugFile.create(new ByteArrayInputStream(mod1Contents.getBytes()), true, null); ! debugFile.refreshLocal(IResource.DEPTH_ZERO, null); ! ! debugEditor = (PyEdit) PyOpenEditor.doOpenEditor(debugFile); ! } ! ! /** ! * Removes the debug file and closes the debug editor ! */ ! @Override ! protected void tearDown() throws Exception { ! super.tearDown(); ! if(debugFile != null){ ! debugFile.delete(true, null); ! } ! if(debugEditor != null){ ! debugEditor.close(false); ! } ! } ! ! ! /** ! * In this test, a thread is started and then we wait on a busy loop until the thread finishes with the tests. ! */ ! public void testDebugger() throws Exception { ! //start the thread that'll do the test ! threadTest.start(); ! ! //wait on a busy loop until the test is finished or an exception is thrown. ! goToManual(TOTAL_TIME_FOR_TESTS, new org.python.pydev.core.ICallback<Boolean, Object>(){ ! public Boolean call(Object arg) { ! return finished || failException != null; ! }} ! ); ! //Make it fail if we encountered some problem ! if(failException != null){ ! failException.printStackTrace(); ! fail(failException.getMessage()); ! } ! if(!finished){ ! if(failException == null){ ! fail("The test didn't finish in the available time: "+TOTAL_TIME_FOR_TESTS/1000+ " secs."); ! } ! } ! } ! /** ! * This is the thread that'll make the test. ! */ ! Thread threadTest = new Thread(){ ! @Override ! public void run() { ! try{ ! //make a launch for debugging ! launchEditorInDebug(); ! ! //switch to debug perspective, because otherwise, when we hit a breakpoint it'll ask if we want to show it. ! switchToPerspective("org.eclipse.debug.ui.DebugPerspective"); ! BreakpointRulerAction createAddBreakPointAction = createAddBreakPointAction(1); ! createAddBreakPointAction.run(); ! ! ILaunch launch = waitForLaunchAvailable(); ! PyDebugTarget target = (PyDebugTarget) waitForDebugTargetAvailable(launch); ! IThread suspendedThread = waitForSuspendedThread(target); ! assertEquals("MainThread", suspendedThread.getName()); ! IStackFrame topStackFrame = suspendedThread.getTopStackFrame(); ! assertTrue("Was not expecting: "+topStackFrame.getName(), topStackFrame.getName().indexOf("debug_file.py:2") != 0); ! IVariable[] variables = topStackFrame.getVariables(); ! ! HashSet<String> varNames = new HashSet<String>(); ! for (IVariable variable : variables) { ! PyVariable var = (PyVariable) variable; ! varNames.add(var.getName()); ! } ! HashSet<String> expected = new HashSet<String>(); ! expected.add("Globals"); ! expected.add("__doc__"); ! expected.add("__file__"); ! expected.add("__name__"); ! expected.add("mod1"); ! assertEquals(expected, varNames); ! ! assertTrue(target.canTerminate()); ! target.terminate(); ! ! finished = true; ! }catch(Throwable e){ ! failException = e; ! } ! } ! }; ! ! ! /** ! * Creates a run in debug mode for the debug editor ! */ ! private void launchEditorInDebug() { ! final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench(); ! Display display = workBench.getDisplay(); ! // Make sure to run the UI thread. ! display.syncExec( new Runnable(){ ! public void run(){ ! JythonLaunchShortcut launchShortcut = new JythonLaunchShortcut(); ! launchShortcut.launch(debugEditor, "debug"); ! } ! }); ! } ! /** ! * @return an action that can be run to create a breakpoint in the given line ! */ ! private BreakpointRulerAction createAddBreakPointAction(final int line) { ! BreakpointRulerAction ret = new BreakpointRulerAction(debugEditor, new IVerticalRulerInfo(){ ! public int getLineOfLastMouseButtonActivity() { ! return line; ! } ! ! public Control getControl() { ! throw new RuntimeException("Not Implemented"); ! } ! public int getWidth() { ! throw new RuntimeException("Not Implemented"); ! } ! public int toDocumentLineNumber(int y_coordinate) { ! throw new RuntimeException("Not Implemented"); ! }}); ! ret.update(); ! return ret; ! } ! ! ! /** ! * This method can be used to switch to a given perspective ! * @param perspectiveId the id of the perspective that should be activated. ! */ ! protected void switchToPerspective(final String perspectiveId) { ! final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench(); ! Display display = workBench.getDisplay(); ! // Make sure to run the UI thread. ! display.syncExec( new Runnable(){ ! public void run(){ ! IWorkbenchWindow window = workBench.getActiveWorkbenchWindow(); ! try { ! workBench.showPerspective(perspectiveId, window); ! } catch (WorkbenchException e) { ! failException = e; ! } ! } ! }); ! } ! ! /** ! * Waits until some thread is suspended. ! */ ! protected IThread waitForSuspendedThread(final PyDebugTarget target) throws Throwable { ! final IThread[] ret = new IThread[1]; ! ! waitForCondition(new ICallback(){ ! public Object call(Object args) throws Exception { ! IThread[] threads = target.getThreads(); ! for (IThread thread : threads) { ! if(thread.isSuspended()){ ! ret[0] = thread; ! return true; ! } ! } ! return false; ! }} ! ); ! return ret[0]; ! } ! /** ! * Waits until a launch becomes available ! * @return the launch that was found ! */ ! private ILaunch waitForLaunchAvailable() throws Throwable { ! final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ! waitForCondition(new ICallback(){ ! ! public Object call(Object args) throws Exception { ! ILaunch[] launches = launchManager.getLaunches(); ! return launches.length > 0; ! }}); ! return launchManager.getLaunches()[0]; ! } ! ! ! /** ! * Waits until a debug target is available in the passed launch ! * @return the debug target found ! */ ! private IDebugTarget waitForDebugTargetAvailable(final ILaunch launch) throws Throwable { ! waitForCondition(new ICallback(){ ! public Object call(Object args) throws Exception { ! return launch.getDebugTarget() != null; ! }}); ! ! return launch.getDebugTarget(); ! } ! ! ! /** ! * Keeps on a busy loop with a timeout until the given callback returns true (otherwise, an ! * exception is thrown when the total time is elapsed). ! */ ! private void waitForCondition(ICallback callback) throws Throwable { ! if(failException != null){ ! throw failException; ! } ! ! int loops = MAX_LOOPS; ! for(int i=0;i<loops;i++){ ! if((Boolean)callback.call(new Object[]{})){ ! return; ! } ! synchronized (lock) { ! try { ! Thread.yield(); ! lock.wait(STEP_TIMEOUT); ! } catch (InterruptedException e) { ! } ! } ! } ! fail("Unable to get to condition after "+(loops*STEP_TIMEOUT)/1000+" seconds."); ! } --- NEW FILE: SourceLocatorTestWorkbench.java --- package org.python.pydev.debug.ui; import java.io.File; import org.eclipse.core.runtime.IPath; import org.eclipse.ui.IEditorInput; import org.python.pydev.editor.codecompletion.revisited.javaintegration.AbstractWorkbenchTestCase; import org.python.pydev.editorinput.PySourceLocatorBase; import org.python.pydev.editorinput.PySourceLocatorPrefs; import org.python.pydev.editorinput.PydevFileEditorInput; public class SourceLocatorTestWorkbench extends AbstractWorkbenchTestCase { public void testSourceLocator() throws Exception { final Boolean[] called = new Boolean[]{false}; final IPath madeUpPath = mod1.getLocation().append("inexistent"); PySourceLocatorBase locator = new PySourceLocatorBase(){ @Override protected PydevFileEditorInput selectFilesystemFileForPath(IPath path) { called[0] = true; assertEquals(path, madeUpPath); return new PydevFileEditorInput(new File(path.removeLastSegments(1).toOSString())); } }; IEditorInput editorInput = locator.createEditorInput(madeUpPath); assertTrue(editorInput != null); assertTrue(called[0]); called[0] = false; editorInput = locator.createEditorInput(madeUpPath); assertTrue(!called[0]); assertTrue(editorInput != null); PySourceLocatorPrefs.setIgnorePathTranslation(madeUpPath); editorInput = locator.createEditorInput(madeUpPath); assertTrue(!called[0]); assertTrue(editorInput == null); } } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:14
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/visitors/scope In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/visitors/scope Modified Files: CodeFoldingVisitorTest.java EasyASTIteratorTest.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: EasyASTIteratorTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/visitors/scope/EasyASTIteratorTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EasyASTIteratorTest.java 31 Oct 2007 00:54:36 -0000 1.9 --- EasyASTIteratorTest.java 27 Sep 2008 19:58:43 -0000 1.10 *************** *** 55,72 **** EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C:\n" + ! " def met1(self):pass\n" + ! "\n" + ! "if True:\n" + ! " print 't'\n" + ! "\n" + ! "class D:\n" + ! " pass\n" + ! "class E:\n" + ! " '''t1\n" + ! " t2\n" + ! " '''\n" + ! "c = C()\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); --- 55,72 ---- EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C:\n" + ! " def met1(self):pass\n" + ! "\n" + ! "if True:\n" + ! " print 't'\n" + ! "\n" + ! "class D:\n" + ! " pass\n" + ! "class E:\n" + ! " '''t1\n" + ! " t2\n" + ! " '''\n" + ! "c = C()\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); *************** *** 88,99 **** EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C: \n"+ ! " def d(self):\n"+ ! " c = \\\n"+ ! "''' \n"+ ! "a \n"+ ! "b \n"+ ! "c \n"+ ! "''' \n"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); --- 88,99 ---- EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C: \n"+ ! " def d(self):\n"+ ! " c = \\\n"+ ! "''' \n"+ ! "a \n"+ ! "b \n"+ ! "c \n"+ ! "''' \n"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); *************** *** 113,127 **** EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C: \n"+ ! " def d(self): \n"+ ! " c = ''' \n"+ ! " \n"+ ! "c \n"+ ! "''' \n"+ ! " \n"+ ! "class E: \n"+ ! " '''t1 \n"+ ! " t2 \n"+ ! " ''' \n"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); --- 113,127 ---- EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C: \n"+ ! " def d(self): \n"+ ! " c = ''' \n"+ ! " \n"+ ! "c \n"+ ! "''' \n"+ ! " \n"+ ! "class E: \n"+ ! " '''t1 \n"+ ! " t2 \n"+ ! " ''' \n"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); *************** *** 142,150 **** EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "import test.lib\n" + ! "from test.lib import test\n" + ! "from test.lib import *\n" + ! "from test.lib import test as alias\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); --- 142,150 ---- EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "import test.lib\n" + ! "from test.lib import test\n" + ! "from test.lib import *\n" + ! "from test.lib import test as alias\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); *************** *** 188,198 **** EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C:\n" + ! " def met1(self):\n" + ! " self.attr1=1\n" + ! " self.attr2=2\n" + ! "\n" + ! " classAttr = 10\n" + ! "pass"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); --- 188,198 ---- EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor(); String str = "" + ! "class C:\n" + ! " def met1(self):\n" + ! " self.attr1=1\n" + ! " self.attr2=2\n" + ! "\n" + ! " classAttr = 10\n" + ! "pass"; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); Index: CodeFoldingVisitorTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/visitors/scope/CodeFoldingVisitorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CodeFoldingVisitorTest.java 31 Oct 2007 00:54:36 -0000 1.1 --- CodeFoldingVisitorTest.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 61,65 **** " else:\n" + " print 4\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); SimpleNode root = objects.o1; --- 61,65 ---- " else:\n" + " print 4\n" + ! ""; Tuple<SimpleNode, Throwable> objects = PyParser.reparseDocument(new PyParser.ParserInfo(new Document(str), false, IPythonNature.GRAMMAR_PYTHON_VERSION_2_4)); SimpleNode root = objects.o1; |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:11
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/jython In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/jython Modified Files: ReaderCharStreamTest.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: ReaderCharStreamTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/jython/ReaderCharStreamTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReaderCharStreamTest.java 7 Sep 2006 13:16:04 -0000 1.5 --- ReaderCharStreamTest.java 27 Sep 2008 19:58:44 -0000 1.6 *************** *** 24,68 **** public void testIt2() throws Exception { ! String s = new String(new char[]{'\n',34,34,34,'\n',97,'\n',34,34,34}); // //""" //a //""" ! ! StringReader inString = new StringReader(s); ! CharStream in = new ReaderCharStream(inString); ! checkCvsStream(in); ! ! in = new FastCharStream(s.toCharArray()); ! checkCvsStream(in); ! ! } ! private void checkCvsStream(CharStream in) throws IOException { ! assertEquals(10,in.BeginToken()); ! in.backup(0); ! assertEquals("\n",new String(in.GetSuffix(1))); ! in.backup(1); ! ! assertEquals(10,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(10,in.readChar()); ! ! assertEquals(97,in.readChar()); ! ! assertEquals(10,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! try { ! in.readChar(); ! fail("Expectend end"); ! } catch (IOException e) { ! // expected ! } ! } public void testIt() throws Exception { String initialDoc = --- 24,68 ---- public void testIt2() throws Exception { ! String s = new String(new char[]{'\n',34,34,34,'\n',97,'\n',34,34,34}); // //""" //a //""" ! ! StringReader inString = new StringReader(s); ! CharStream in = new ReaderCharStream(inString); ! checkCvsStream(in); ! ! in = new FastCharStream(s.toCharArray()); ! checkCvsStream(in); ! ! } ! private void checkCvsStream(CharStream in) throws IOException { ! assertEquals(10,in.BeginToken()); ! in.backup(0); ! assertEquals("\n",new String(in.GetSuffix(1))); ! in.backup(1); ! ! assertEquals(10,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(10,in.readChar()); ! ! assertEquals(97,in.readChar()); ! ! assertEquals(10,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! assertEquals(34,in.readChar()); ! try { ! in.readChar(); ! fail("Expectend end"); ! } catch (IOException e) { ! // expected ! } ! } public void testIt() throws Exception { String initialDoc = *************** *** 85,114 **** private void doTests2(CharStream in) throws IOException { ! assertEquals('a', in.readChar()); ! assertEquals("a", in.GetImage()); ! ! assertEquals('\n',in.BeginToken()); ! assertEquals('b', in.readChar()); ! assertEquals("\nb", in.GetImage()); ! ! in.backup(1); ! assertEquals("\n", in.GetImage()); ! ! assertEquals('b',in.BeginToken()); ! assertEquals("b", in.GetImage()); ! ! assertEquals('c',in.BeginToken()); ! assertEquals("c", in.GetImage()); ! ! assertEquals('\n',in.BeginToken()); ! assertEquals("\n", in.GetImage()); ! ! try { ! in.BeginToken(); ! fail("expected exception"); ! } catch (IOException e) { ! // expected ! } ! assertEquals("\n", in.GetImage()); } /** --- 85,114 ---- private void doTests2(CharStream in) throws IOException { ! assertEquals('a', in.readChar()); ! assertEquals("a", in.GetImage()); ! ! assertEquals('\n',in.BeginToken()); ! assertEquals('b', in.readChar()); ! assertEquals("\nb", in.GetImage()); ! ! in.backup(1); ! assertEquals("\n", in.GetImage()); ! ! assertEquals('b',in.BeginToken()); ! assertEquals("b", in.GetImage()); ! ! assertEquals('c',in.BeginToken()); ! assertEquals("c", in.GetImage()); ! ! assertEquals('\n',in.BeginToken()); ! assertEquals("\n", in.GetImage()); ! ! try { ! in.BeginToken(); ! fail("expected exception"); ! } catch (IOException e) { ! // expected ! } ! assertEquals("\n", in.GetImage()); } /** *************** *** 189,193 **** cs[5] = '\n'; final String suf = new String(in.GetSuffix(6)); ! assertEquals(new String(cs), suf); in.backup(4); --- 189,193 ---- cs[5] = '\n'; final String suf = new String(in.GetSuffix(6)); ! assertEquals(new String(cs), suf); in.backup(4); |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:08
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/visitors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/visitors Modified Files: NodeUtilsTest.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: NodeUtilsTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/visitors/NodeUtilsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NodeUtilsTest.java 8 Apr 2008 23:05:44 -0000 1.2 --- NodeUtilsTest.java 27 Sep 2008 19:58:43 -0000 1.3 *************** *** 12,17 **** public class NodeUtilsTest extends PyParserTestBase { ! public static void main(String[] args) { ! try { NodeUtilsTest test = new NodeUtilsTest(); test.setUp(); --- 12,17 ---- public class NodeUtilsTest extends PyParserTestBase { ! public static void main(String[] args) { ! try { NodeUtilsTest test = new NodeUtilsTest(); test.setUp(); *************** *** 23,99 **** e.printStackTrace(); } ! ! } ! public void testFullRep() throws Exception { SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "print a.b.c().d.__class__")); Iterator<ASTEntry> iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Print ! ASTEntry entry = iterator.next(); //Attribute ! assertEquals("a.b.c", NodeUtils.getFullRepresentationString(entry.node)); ! visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "'r.a.s.b'.join('a')")); ! iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Expr ! entry = iterator.next(); //Attribute ! assertEquals("str.join", NodeUtils.getFullRepresentationString(entry.node)); ! ! visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "print aa.bbb.cccc[comp.id].hasSimulate")); ! iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Expr ! entry = iterator.next(); //Attribute ! assertEquals("aa.bbb.cccc", NodeUtils.getFullRepresentationString(entry.node)); ! } ! ! public void testClassEndLine() { ! SimpleNode ast1 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "#comment\n"); ! ! checkEndLine(ast1, 4); ! ! ast1 = parseLegalDocStr("" + "class env:\n" + " pass\n" + "\n" + ! "if True:\n" + ! " pass\n" + ! "#comment\n"); ! ! checkEndLine(ast1, 2); ! } ! ! public void testGetContextName() { ! SimpleNode ast1 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "if __name__ == '__main__':\n" + ! " print 'step 1'\n" + ! "\n"); ! ! SimpleNode ast2 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "if __name__ == '__main__':\n" + ! " print 'step 1'\n" + ! "\n" + ! "#comment"); ! checkEndLine(ast1, 2); checkEndLine(ast2, 2); ! ! assertEquals(null, NodeUtils.getContextName(4, ast1)); assertEquals(null, NodeUtils.getContextName(4, ast2)); } --- 23,99 ---- e.printStackTrace(); } ! ! } ! public void testFullRep() throws Exception { SequencialASTIteratorVisitor visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "print a.b.c().d.__class__")); Iterator<ASTEntry> iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Print ! ASTEntry entry = iterator.next(); //Attribute ! assertEquals("a.b.c", NodeUtils.getFullRepresentationString(entry.node)); ! visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "'r.a.s.b'.join('a')")); ! iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Expr ! entry = iterator.next(); //Attribute ! assertEquals("str.join", NodeUtils.getFullRepresentationString(entry.node)); ! ! visitor = SequencialASTIteratorVisitor.create(parseLegalDocStr( ! "print aa.bbb.cccc[comp.id].hasSimulate")); ! iterator = visitor.getIterator(); ! iterator.next(); //Module ! iterator.next(); //Expr ! entry = iterator.next(); //Attribute ! assertEquals("aa.bbb.cccc", NodeUtils.getFullRepresentationString(entry.node)); ! } ! ! public void testClassEndLine() { ! SimpleNode ast1 = parseLegalDocStr("" + "class env:\n" + " pass\n" + "\n" + ! "#comment\n"); ! ! checkEndLine(ast1, 4); ! ! ast1 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "if True:\n" + ! " pass\n" + ! "#comment\n"); ! ! checkEndLine(ast1, 2); ! } ! ! public void testGetContextName() { ! SimpleNode ast1 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "if __name__ == '__main__':\n" + ! " print 'step 1'\n" + ! "\n"); ! ! SimpleNode ast2 = parseLegalDocStr("" + ! "class env:\n" + ! " pass\n" + ! "\n" + ! "if __name__ == '__main__':\n" + ! " print 'step 1'\n" + ! "\n" + ! "#comment"); ! checkEndLine(ast1, 2); checkEndLine(ast2, 2); ! ! assertEquals(null, NodeUtils.getContextName(4, ast1)); assertEquals(null, NodeUtils.getContextName(4, ast2)); } |
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:07
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/fastparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser/fastparser Modified Files: FastParserTest.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: FastParserTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/fastparser/FastParserTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FastParserTest.java 3 May 2008 13:37:39 -0000 1.2 --- FastParserTest.java 27 Sep 2008 19:58:44 -0000 1.3 *************** *** 54,68 **** Document doc = new Document(); doc.set("class Foo:\n" + ! "\n" + ! "class Bar(object):\n" + ! "\n" + ! " class My\n" + ! "'''class Dont\n" + ! "class Dont2\n" + ! "\n" + ! "'''\n" + ! "class My2:\n" + ! "" + ! ""); List<stmtType> all = FastParser.parseClassesAndFunctions(doc); --- 54,68 ---- Document doc = new Document(); doc.set("class Foo:\n" + ! "\n" + ! "class Bar(object):\n" + ! "\n" + ! " class My\n" + ! "'''class Dont\n" + ! "class Dont2\n" + ! "\n" + ! "'''\n" + ! "class My2:\n" + ! "" + ! ""); List<stmtType> all = FastParser.parseClassesAndFunctions(doc); |