pydev-cvs Mailing List for PyDev for Eclipse (Page 2)
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-28 12:48:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/ui/pythonpathconf Modified Files: InterpreterInfo.java AbstractInterpreterEditor.java AbstractInterpreterPreferencesPage.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: AbstractInterpreterPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf/AbstractInterpreterPreferencesPage.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractInterpreterPreferencesPage.java 8 Jul 2007 21:14:53 -0000 1.8 --- AbstractInterpreterPreferencesPage.java 28 Sep 2008 12:45:44 -0000 1.9 *************** *** 30,40 **** /** ! * Initializer sets the preference store ! */ ! public AbstractInterpreterPreferencesPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); changed = false; ! } protected abstract AbstractInterpreterEditor getInterpreterEditor(Composite p); --- 30,40 ---- /** ! * Initializer sets the preference store ! */ ! public AbstractInterpreterPreferencesPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); changed = false; ! } protected abstract AbstractInterpreterEditor getInterpreterEditor(Composite p); *************** *** 42,53 **** /** * @return whether this page has changed ! */ ! protected boolean hasChanged(){ ! return changed || isEditorChanged(); ! } ! public void init(IWorkbench workbench) { ! } ! /** * Applies changes (if any) --- 42,53 ---- /** * @return whether this page has changed ! */ ! protected boolean hasChanged(){ ! return changed || isEditorChanged(); ! } ! public void init(IWorkbench workbench) { ! } ! /** * Applies changes (if any) Index: AbstractInterpreterEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf/AbstractInterpreterEditor.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AbstractInterpreterEditor.java 22 Oct 2007 00:28:51 -0000 1.19 --- AbstractInterpreterEditor.java 28 Sep 2008 12:45:44 -0000 1.20 *************** *** 74,80 **** private IInterpreterManager interpreterManager; ! /** ! * Tree to add libs. ! */ private Tree tree; --- 74,80 ---- private IInterpreterManager interpreterManager; ! /** ! * Tree to add libs. ! */ private Tree tree; *************** *** 165,175 **** private Tree getTreeLibsControl(Composite parent) { if (tree == null){ ! tree = new Tree(parent, SWT.BORDER|SWT.MULTI); ! tree.setFont(parent.getFont()); ! tree.addDisposeListener(new DisposeListener() { ! public void widgetDisposed(DisposeEvent event) { ! tree = null; ! } ! }); } return tree; --- 165,175 ---- private Tree getTreeLibsControl(Composite parent) { if (tree == null){ ! tree = new Tree(parent, SWT.BORDER|SWT.MULTI); ! tree.setFont(parent.getFont()); ! tree.addDisposeListener(new DisposeListener() { ! public void widgetDisposed(DisposeEvent event) { ! tree = null; ! } ! }); } return tree; *************** *** 222,234 **** super.doFillIntoGrid(parent, numColumns); ! l1 = new Label(parent, SWT.None); ! l1.setText("System PYTHONPATH"); ! GridData gd = new GridData(); ! gd.horizontalSpan = numColumns; ! l1.setLayoutData(gd); ! //the tree tree = getTreeLibsControl(parent); ! gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.FILL; --- 222,234 ---- super.doFillIntoGrid(parent, numColumns); ! l1 = new Label(parent, SWT.None); ! l1.setText("System PYTHONPATH"); ! GridData gd = new GridData(); ! gd.horizontalSpan = numColumns; ! l1.setLayoutData(gd); ! //the tree tree = getTreeLibsControl(parent); ! gd = new GridData(); gd.horizontalAlignment = SWT.FILL; gd.verticalAlignment = SWT.FILL; *************** *** 238,253 **** //buttons at the side of the tree Composite control = getButtonBoxControlSystem(parent); ! gd = new GridData(); ! gd.verticalAlignment = GridData.BEGINNING; ! control.setLayoutData(gd); //label ! l2 = new Label(parent, SWT.None); ! l2.setText("Forced builtin libs (check http://pydev.sf.net/faq.html for more info)."); ! gd = new GridData(); ! l2.setLayoutData(gd); //the list with the builtins ! List list = getBuiltinsListControl(parent); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; --- 238,253 ---- //buttons at the side of the tree Composite control = getButtonBoxControlSystem(parent); ! gd = new GridData(); ! gd.verticalAlignment = GridData.BEGINNING; ! control.setLayoutData(gd); //label ! l2 = new Label(parent, SWT.None); ! l2.setText("Forced builtin libs (check http://pydev.sf.net/faq.html for more info)."); ! gd = new GridData(); ! l2.setLayoutData(gd); //the list with the builtins ! List list = getBuiltinsListControl(parent); gd = new GridData(); gd.horizontalAlignment = SWT.FILL; *************** *** 255,261 **** gd.heightHint = 100; list.setLayoutData(gd); ! //the builtins buttons ! control = getButtonBoxControlOthers(parent); gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; --- 255,261 ---- gd.heightHint = 100; list.setLayoutData(gd); ! //the builtins buttons ! control = getButtonBoxControlOthers(parent); gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; *************** *** 443,455 **** if (listControl.getSelectionCount() == 1) { String executable = listControl.getSelection()[0]; ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! ! InputDialog d = new InputDialog(this.getShell(), "Builtin to add", "Builtin to add", "", null); ! ! int retCode = d.open(); ! if (retCode == InputDialog.OK) { ! info.addForcedLib(d.getValue()); changed = true; ! } } --- 443,455 ---- if (listControl.getSelectionCount() == 1) { String executable = listControl.getSelection()[0]; ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! ! InputDialog d = new InputDialog(this.getShell(), "Builtin to add", "Builtin to add", "", null); ! ! int retCode = d.open(); ! if (retCode == InputDialog.OK) { ! info.addForcedLib(d.getValue()); changed = true; ! } } *************** *** 465,471 **** String builtin = listBuiltins.getSelection()[0]; ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! info.removeForcedLib(builtin); ! changed = true; } updateTree(); --- 465,471 ---- String builtin = listBuiltins.getSelection()[0]; ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! info.removeForcedLib(builtin); ! changed = true; } updateTree(); *************** *** 522,541 **** if(executable != null){ ! TreeItem item = new TreeItem(tree, SWT.NONE); ! item.setText("System libs"); ! item.setImage(imageSystemLibRoot); ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! ! for (Iterator<String> iter = info.libs.iterator(); iter.hasNext();) { ! TreeItem subItem = new TreeItem(item, SWT.NONE); ! subItem.setText(iter.next()); ! subItem.setImage(imageSystemLib); ! } ! item.setExpanded(true); ! ! //set the forced builtins ! for (Iterator<String> iter = info.forcedLibsIterator(); iter.hasNext();) { ! listBuiltins.add((String) iter.next()); } } --- 522,541 ---- if(executable != null){ ! TreeItem item = new TreeItem(tree, SWT.NONE); ! item.setText("System libs"); ! item.setImage(imageSystemLibRoot); ! InterpreterInfo info = (InterpreterInfo) interpreterManager.getInterpreterInfo(executable, new NullProgressMonitor()); ! ! for (Iterator<String> iter = info.libs.iterator(); iter.hasNext();) { ! TreeItem subItem = new TreeItem(item, SWT.NONE); ! subItem.setText(iter.next()); ! subItem.setImage(imageSystemLib); ! } ! item.setExpanded(true); ! ! //set the forced builtins ! for (Iterator<String> iter = info.forcedLibsIterator(); iter.hasNext();) { ! listBuiltins.add((String) iter.next()); } } *************** *** 551,599 **** */ protected String getNewInputObject() { ! CharArrayWriter charWriter = new CharArrayWriter(); ! PrintWriter logger = new PrintWriter(charWriter); ! logger.println("Information about process of adding new interpreter:"); try { ! ! FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); ! String[] filterExtensions = getInterpreterFilterExtensions(); ! if (filterExtensions != null) { ! dialog.setFilterExtensions(filterExtensions); ! } ! if (lastPath != null) { ! if (new File(lastPath).exists()) ! dialog.setFilterPath(lastPath); ! } ! logger.println("- Opening dialog to request executable (or jar)."); ! String file = dialog.open(); ! if (file != null) { ! logger.println("- Chosen interpreter file:'"+file); ! file = file.trim(); ! if (file.length() == 0){ ! logger.println("- When trimmed, the chosen file was empty (returning null)."); ! return null; ! } ! lastPath = file; ! }else{ ! logger.println("- The file chosen was null (returning null)."); ! return null; ! } ! ! if (file != null) { ! //ok, now that we got the file, let's see if it is valid and get the library info. ! logger.println("- Ok, file is non-null. Getting info on:"+file); ! ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(this.getShell()); ! monitorDialog.setBlockOnOpen(false); ! Operation operation = new Operation(file, logger); ! monitorDialog.run(true, false, operation); ! if (operation.e != null) { ! logger.println("- Some error happened while getting info on the interpreter:"); ! operation.e.printStackTrace(logger); ! if(operation.e instanceof SimpleJythonRunner.JavaNotConfiguredException){ SimpleJythonRunner.JavaNotConfiguredException javaNotConfiguredException = (SimpleJythonRunner.JavaNotConfiguredException) operation.e; --- 551,599 ---- */ protected String getNewInputObject() { ! CharArrayWriter charWriter = new CharArrayWriter(); ! PrintWriter logger = new PrintWriter(charWriter); ! logger.println("Information about process of adding new interpreter:"); try { ! ! FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); ! String[] filterExtensions = getInterpreterFilterExtensions(); ! if (filterExtensions != null) { ! dialog.setFilterExtensions(filterExtensions); ! } ! if (lastPath != null) { ! if (new File(lastPath).exists()) ! dialog.setFilterPath(lastPath); ! } ! logger.println("- Opening dialog to request executable (or jar)."); ! String file = dialog.open(); ! if (file != null) { ! logger.println("- Chosen interpreter file:'"+file); ! file = file.trim(); ! if (file.length() == 0){ ! logger.println("- When trimmed, the chosen file was empty (returning null)."); ! return null; ! } ! lastPath = file; ! }else{ ! logger.println("- The file chosen was null (returning null)."); ! return null; ! } ! ! if (file != null) { ! //ok, now that we got the file, let's see if it is valid and get the library info. ! logger.println("- Ok, file is non-null. Getting info on:"+file); ! ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(this.getShell()); ! monitorDialog.setBlockOnOpen(false); ! Operation operation = new Operation(file, logger); ! monitorDialog.run(true, false, operation); ! if (operation.e != null) { ! logger.println("- Some error happened while getting info on the interpreter:"); ! operation.e.printStackTrace(logger); ! if(operation.e instanceof SimpleJythonRunner.JavaNotConfiguredException){ SimpleJythonRunner.JavaNotConfiguredException javaNotConfiguredException = (SimpleJythonRunner.JavaNotConfiguredException) operation.e; *************** *** 602,612 **** PydevPlugin.makeStatus(IStatus.ERROR, "Java vm not configured.\n", javaNotConfiguredException)); ! }else if(operation.e instanceof JDTNotAvailableException){ ! JDTNotAvailableException noJdtException = (JDTNotAvailableException) operation.e; ErrorDialog.openError(this.getShell(), "Error getting info on interpreter", noJdtException.getMessage(), ! PydevPlugin.makeStatus(IStatus.ERROR, "JDT not available.\n", noJdtException)); ! ! }else{ String errorMsg = "Some error happened while getting info on the interpreter.\n\n" + "Common reasons include:\n\n" + --- 602,612 ---- PydevPlugin.makeStatus(IStatus.ERROR, "Java vm not configured.\n", javaNotConfiguredException)); ! }else if(operation.e instanceof JDTNotAvailableException){ ! JDTNotAvailableException noJdtException = (JDTNotAvailableException) operation.e; ErrorDialog.openError(this.getShell(), "Error getting info on interpreter", noJdtException.getMessage(), ! PydevPlugin.makeStatus(IStatus.ERROR, "JDT not available.\n", noJdtException)); ! ! }else{ String errorMsg = "Some error happened while getting info on the interpreter.\n\n" + "Common reasons include:\n\n" + *************** *** 620,637 **** "More info can also be found at the bug report: http://sourceforge.net/tracker/index.php?func=detail&aid=1523582&group_id=85796&atid=577329", operation.e)); ! } ! throw operation.e; ! } ! logger.println("- Success getting the info. Result:"+operation.result); ! return operation.result; ! } ! } catch (Exception e) { PydevPlugin.log(e); return null; } finally { ! PydevPlugin.logInfo(charWriter.toString()); } --- 620,637 ---- "More info can also be found at the bug report: http://sourceforge.net/tracker/index.php?func=detail&aid=1523582&group_id=85796&atid=577329", operation.e)); ! } ! throw operation.e; ! } ! logger.println("- Success getting the info. Result:"+operation.result); ! return operation.result; ! } ! } catch (Exception e) { PydevPlugin.log(e); return null; } finally { ! PydevPlugin.logInfo(charWriter.toString()); } *************** *** 643,647 **** String s = createList(list.getItems()); if (s != null){ ! interpreterManager.setPersistedString(s); } } --- 643,647 ---- String s = createList(list.getItems()); if (s != null){ ! interpreterManager.setPersistedString(s); } } *************** *** 650,654 **** protected void doLoad() { if (list != null) { ! String s = interpreterManager.getPersistedString(); String[] array = parseString(s); for (int i = 0; i < array.length; i++) { --- 650,654 ---- protected void doLoad() { if (list != null) { ! String s = interpreterManager.getPersistedString(); String[] array = parseString(s); for (int i = 0; i < array.length; i++) { *************** *** 660,664 **** public String getPreferenceName(){ ! throw new RuntimeException("The preferences should be stored/gotten from the IInterpreterManager, and not directly."); } --- 660,664 ---- public String getPreferenceName(){ ! throw new RuntimeException("The preferences should be stored/gotten from the IInterpreterManager, and not directly."); } *************** *** 679,711 **** private static class OperationMonitor extends ProgressMonitorWrapper{ ! private PrintWriter logger; ! protected OperationMonitor(IProgressMonitor monitor, PrintWriter logger) { ! super(monitor); ! this.logger = logger; ! } ! ! @Override ! public void beginTask(String name, int totalWork) { ! super.beginTask(name, totalWork); ! logger.print("- Beggining task:"); ! logger.print(name); ! logger.print(" totalWork:"); ! logger.println(totalWork); ! } ! ! @Override ! public void setTaskName(String name) { ! super.setTaskName(name); ! logger.print("- Setting task name:"); ! logger.println(name); ! } ! ! @Override ! public void subTask(String name) { ! super.subTask(name); ! logger.print("- Sub Task:"); ! logger.println(name); ! } } private class Operation implements IRunnableWithProgress{ --- 679,711 ---- private static class OperationMonitor extends ProgressMonitorWrapper{ ! private PrintWriter logger; ! protected OperationMonitor(IProgressMonitor monitor, PrintWriter logger) { ! super(monitor); ! this.logger = logger; ! } ! ! @Override ! public void beginTask(String name, int totalWork) { ! super.beginTask(name, totalWork); ! logger.print("- Beggining task:"); ! logger.print(name); ! logger.print(" totalWork:"); ! logger.println(totalWork); ! } ! ! @Override ! public void setTaskName(String name) { ! super.setTaskName(name); ! logger.print("- Setting task name:"); ! logger.println(name); ! } ! ! @Override ! public void subTask(String name) { ! super.subTask(name); ! logger.print("- Sub Task:"); ! logger.println(name); ! } } private class Operation implements IRunnableWithProgress{ *************** *** 714,718 **** public String file; public Exception e; ! private PrintWriter logger; /** --- 714,718 ---- public String file; public Exception e; ! private PrintWriter logger; /** *************** *** 729,738 **** */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { ! monitor = new OperationMonitor(monitor, logger); monitor.beginTask("Getting libs", 100); try { result = interpreterManager.addInterpreter(file, monitor); } catch (Exception e) { ! logger.println("Exception detected: "+e.getMessage()); this.e = e; } --- 729,738 ---- */ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { ! monitor = new OperationMonitor(monitor, logger); monitor.beginTask("Getting libs", 100); try { result = interpreterManager.addInterpreter(file, monitor); } catch (Exception e) { ! logger.println("Exception detected: "+e.getMessage()); this.e = e; } Index: InterpreterInfo.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/pythonpathconf/InterpreterInfo.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** InterpreterInfo.java 14 Jun 2008 22:14:56 -0000 1.53 --- InterpreterInfo.java 28 Sep 2008 12:45:44 -0000 1.54 *************** *** 130,134 **** this.version = version; //deprecated (keep it cleared) ! dllLibs.clear(); setModulesManager(new SystemModulesManager()); --- 130,134 ---- this.version = version; //deprecated (keep it cleared) ! dllLibs.clear(); setModulesManager(new SystemModulesManager()); *************** *** 190,194 **** throw new RuntimeException("Unable to recreate the Interpreter info (Its format changed. Please, re-create your Interpreter information).Contents found:"+received); } ! received = received.replaceAll("\n", "").replaceAll("\r", ""); String[] forcedSplit = received.split("\\$"); String[] libsSplit = forcedSplit[0].split("\\@"); --- 190,194 ---- throw new RuntimeException("Unable to recreate the Interpreter info (Its format changed. Please, re-create your Interpreter information).Contents found:"+received); } ! received = received.replaceAll("\n", "").replaceAll("\r", ""); String[] forcedSplit = received.split("\\$"); String[] libsSplit = forcedSplit[0].split("\\@"); *************** *** 238,317 **** final Boolean[] result = new Boolean[]{true}; //true == OK, false == CANCELLED if(ProjectModulesManager.IN_TESTS){ ! if(InterpreterInfo.configurePathsCallback != null){ ! InterpreterInfo.configurePathsCallback.call(new Tuple<List<String>, List<String>>(toAsk, l)); ! } }else{ ! if(toAsk.size() > 0){ ! Runnable runnable = new Runnable(){ ! ! public void run() { ! ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), toAsk, ! new IStructuredContentProvider(){ ! ! @SuppressWarnings("unchecked") ! public Object[] getElements(Object inputElement) { ! List<String> elements = (List<String>) inputElement; ! return elements.toArray(new String[0]); ! } ! ! public void dispose() { ! } ! ! public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { ! }}, ! ! ! new ILabelProvider(){ ! ! public Image getImage(Object element) { ! return PydevPlugin.getImageCache().get(UIConstants.LIB_SYSTEM); ! } ! ! public String getText(Object element) { ! return element.toString(); ! } ! ! public void addListener(ILabelProviderListener listener) { ! } ! ! public void dispose() { ! } ! ! public boolean isLabelProperty(Object element, String property) { ! return true; ! } ! ! public void removeListener(ILabelProviderListener listener) { ! }}, ! ! "Select the folders to be added to the SYSTEM pythonpath!\n" + ! "\n" + ! "IMPORTANT: The folders for your PROJECTS should NOT be added here, but in your project configuration.\n\n" + ! "Check:http://fabioz.com/pydev/manual_101_interpreter.html for more details."); ! dialog.setInitialSelections(l.toArray(new String[0])); ! int i = dialog.open(); if(i == Window.OK){ result[0] = true; ! Object[] result = dialog.getResult(); ! l.clear(); ! for (Object string : result) { ! l.add((String) string); ! } }else{ result[0] = false; } ! ! } ! ! }; ! try{ ! RunInUiThread.sync(runnable); ! }catch(NoClassDefFoundError e){ ! }catch(UnsatisfiedLinkError e){ ! //this means that we're running unit-tests, so, we don't have to do anything about it ! //as 'l' is already ok. ! } ! } } --- 238,317 ---- final Boolean[] result = new Boolean[]{true}; //true == OK, false == CANCELLED if(ProjectModulesManager.IN_TESTS){ ! if(InterpreterInfo.configurePathsCallback != null){ ! InterpreterInfo.configurePathsCallback.call(new Tuple<List<String>, List<String>>(toAsk, l)); ! } }else{ ! if(toAsk.size() > 0){ ! Runnable runnable = new Runnable(){ ! ! public void run() { ! ListSelectionDialog dialog = new ListSelectionDialog(Display.getDefault().getActiveShell(), toAsk, ! new IStructuredContentProvider(){ ! ! @SuppressWarnings("unchecked") ! public Object[] getElements(Object inputElement) { ! List<String> elements = (List<String>) inputElement; ! return elements.toArray(new String[0]); ! } ! ! public void dispose() { ! } ! ! public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { ! }}, ! ! ! new ILabelProvider(){ ! ! public Image getImage(Object element) { ! return PydevPlugin.getImageCache().get(UIConstants.LIB_SYSTEM); ! } ! ! public String getText(Object element) { ! return element.toString(); ! } ! ! public void addListener(ILabelProviderListener listener) { ! } ! ! public void dispose() { ! } ! ! public boolean isLabelProperty(Object element, String property) { ! return true; ! } ! ! public void removeListener(ILabelProviderListener listener) { ! }}, ! ! "Select the folders to be added to the SYSTEM pythonpath!\n" + ! "\n" + ! "IMPORTANT: The folders for your PROJECTS should NOT be added here, but in your project configuration.\n\n" + ! "Check:http://fabioz.com/pydev/manual_101_interpreter.html for more details."); ! dialog.setInitialSelections(l.toArray(new String[0])); ! int i = dialog.open(); if(i == Window.OK){ result[0] = true; ! Object[] result = dialog.getResult(); ! l.clear(); ! for (Object string : result) { ! l.add((String) string); ! } }else{ result[0] = false; } ! ! } ! ! }; ! try{ ! RunInUiThread.sync(runnable); ! }catch(NoClassDefFoundError e){ ! }catch(UnsatisfiedLinkError e){ ! //this means that we're running unit-tests, so, we don't have to do anything about it ! //as 'l' is already ok. ! } ! } } *************** *** 323,349 **** ArrayList<String> l1 = new ArrayList<String>(); if(libsSplit.length > 1){ ! String dllLibs = libsSplit[1]; ! String[] dllLibs1 = dllLibs.split("\\|"); ! for (int i = 0; i < dllLibs1.length; i++) { ! String trimmed = dllLibs1[i].trim(); ! if(trimmed.length() > 0){ ! l1.add(trimmed); ! } ! } } ! ArrayList<String> l2 = new ArrayList<String>(); if(forcedSplit.length > 1){ ! String forcedLibs = forcedSplit[1]; ! String[] forcedLibs1 = forcedLibs.split("\\|"); ! for (int i = 0; i < forcedLibs1.length; i++) { ! String trimmed = forcedLibs1[i].trim(); ! if(trimmed.length() > 0){ ! l2.add(trimmed); ! } ! } ! } return new InterpreterInfo(version, executable, l, l1, l2); ! } --- 323,349 ---- ArrayList<String> l1 = new ArrayList<String>(); if(libsSplit.length > 1){ ! String dllLibs = libsSplit[1]; ! String[] dllLibs1 = dllLibs.split("\\|"); ! for (int i = 0; i < dllLibs1.length; i++) { ! String trimmed = dllLibs1[i].trim(); ! if(trimmed.length() > 0){ ! l1.add(trimmed); ! } ! } } ! ArrayList<String> l2 = new ArrayList<String>(); if(forcedSplit.length > 1){ ! String forcedLibs = forcedSplit[1]; ! String[] forcedLibs1 = forcedLibs.split("\\|"); ! for (int i = 0; i < forcedLibs1.length; i++) { ! String trimmed = forcedLibs1[i].trim(); ! if(trimmed.length() > 0){ ! l2.add(trimmed); ! } ! } ! } return new InterpreterInfo(version, executable, l, l1, l2); ! } *************** *** 365,372 **** buffer.append("$"); if(forcedLibs.size() > 0){ ! for (Iterator<String> iter = forcedLibs.iterator(); iter.hasNext();) { ! buffer.append("|"); ! buffer.append(iter.next().toString()); ! } } --- 365,372 ---- buffer.append("$"); if(forcedLibs.size() > 0){ ! for (Iterator<String> iter = forcedLibs.iterator(); iter.hasNext();) { ! buffer.append("|"); ! buffer.append(iter.next().toString()); ! } } *************** *** 378,387 **** */ public void restoreCompiledLibs(IProgressMonitor monitor) { ! //the compiled with the interpreter should be already gotten. ! forcedLibs.add("os"); //we have it in source, but want to interpret it, source info (ast) does not give us much //as it is a set, there is no problem to add it twice ! forcedLibs.add("__builtin__"); //jython bug: __builtin__ is not added ! forcedLibs.add("sys"); //jython bug: sys is not added --- 378,388 ---- */ public void restoreCompiledLibs(IProgressMonitor monitor) { ! //the compiled with the interpreter should be already gotten. ! forcedLibs.add("os"); //we have it in source, but want to interpret it, source info (ast) does not give us much //as it is a set, there is no problem to add it twice ! forcedLibs.add("__builtin__"); //jython bug: __builtin__ is not added ! forcedLibs.add("sys"); //jython bug: sys is not added ! forcedLibs.add("email"); //email has some lazy imports that pydev cannot handle through the source |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:21
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/tests_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: ASTManagerTest.java PythonPathHelperTest.java CodeCompletionTestsBase.java SourceModuleProposalTest.java ProjectStub.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: SourceModuleProposalTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposalTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SourceModuleProposalTest.java 21 Aug 2008 20:56:28 -0000 1.4 --- SourceModuleProposalTest.java 28 Sep 2008 12:45:43 -0000 1.5 *************** *** 90,98 **** // s.doc = doc; // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } // s.addTo = addTo; // IRegion region = doc.getLineInformation(line); --- 90,98 ---- // s.doc = doc; // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } // s.addTo = addTo; // IRegion region = doc.getLineInformation(line); Index: ASTManagerTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/ASTManagerTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ASTManagerTest.java 5 Feb 2008 13:07:14 -0000 1.3 --- ASTManagerTest.java 28 Sep 2008 12:45:43 -0000 1.4 *************** *** 65,77 **** col = 11; sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 65,77 ---- col = 11; sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 81,99 **** ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 81,99 ---- ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 103,124 **** assertIsIn("Test", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! "def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 103,124 ---- assertIsIn("Test", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! "def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 129,150 **** assertIsIn("meth1", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! " def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 129,150 ---- assertIsIn("meth1", comps); ! sDoc = ""+ ! "import unittest \n" + ! " \n" + ! "class Classe1: \n" + ! " \n" + ! " def makeit(self): \n" + ! " self.makeit \n" + ! " \n" + ! " \n" + ! "class Test(unit \n" + ! " \n" + ! " def meth1(): \n" + ! " pass \n"; ! ! line = 8; ! col = 16; ! token = ""; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 154,170 **** assertIsIn("Test", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " ignoreThis=0 \n" + ! " self.a = 1 \n" + ! " self. \n" + ! " \n"; ! ! line = 6; ! col = 13; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 154,170 ---- assertIsIn("Test", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " ignoreThis=0 \n" + ! " self.a = 1 \n" + ! " self. \n" + ! " \n"; ! ! line = 6; ! col = 13; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 173,190 **** assertIsIn("foo", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " self.a = 2 \n" + ! " \n" + ! " test = foo \n" + ! " \n" + ! "Classe1. \n"; ! ! line = 8; ! col = 9; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 173,190 ---- assertIsIn("foo", comps); ! sDoc = ""+ ! "class Classe1: \n" + ! " \n" + ! " def foo(self): \n" + ! " self.a = 2 \n" + ! " \n" + ! " test = foo \n" + ! " \n" + ! "Classe1. \n"; ! ! line = 8; ! col = 9; ! token = "Classe1"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 196,215 **** ! sDoc = ""+ ! "class LinkedList: \n"+ ! " def __init__(self,content='Null'): \n" + ! " if not content: \n"+ ! " self.first=content \n"+ ! " self.last=content \n"+ ! " else: \n"+ ! " self.first='Null' \n"+ ! " self.last='Null' \n"+ ! " self.content=content \n"+ ! " self. \n"; ! ! line = 9; ! col = 9; ! token = "LinkedList"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); --- 196,215 ---- ! sDoc = ""+ ! "class LinkedList: \n"+ ! " def __init__(self,content='Null'): \n" + ! " if not content: \n"+ ! " self.first=content \n"+ ! " self.last=content \n"+ ! " else: \n"+ ! " self.first='Null' \n"+ ! " self.last='Null' \n"+ ! " self.content=content \n"+ ! " self. \n"; ! ! line = 9; ! col = 9; ! token = "LinkedList"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); comps = getComps(); *************** *** 220,230 **** } ! private IToken[] getComps() { ! try { ! return getManager().getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursion(){ --- 220,230 ---- } ! private IToken[] getComps() { ! try { ! return getManager().getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursion(){ *************** *** 233,238 **** col = 0; sDoc = ""+ ! "class A(B):pass \n" + ! "class B(A):pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 233,238 ---- col = 0; sDoc = ""+ ! "class A(B):pass \n" + ! "class B(A):pass \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 248,253 **** col = 0; sDoc = ""+ ! "from testlib.unittest.relative import Test1 \n" + ! "\n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 248,253 ---- col = 0; sDoc = ""+ ! "from testlib.unittest.relative import Test1 \n" + ! "\n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 277,282 **** col = 10; sDoc = ""+ ! "def met(par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 277,282 ---- col = 10; sDoc = ""+ ! "def met(par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 292,298 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 292,298 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 309,316 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 309,316 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 328,336 **** col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n" + ! " ignoreLineAfter = 5 \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); --- 328,336 ---- col = 13; sDoc = ""+ ! "class C: \n" + ! " def met(self, par1, par2): \n" + ! " loc1 = 10 \n" + ! " print \n" + ! " ignoreLineAfter = 5 \n"; doc = new Document(sDoc); state = new CompletionState(line,col, token, nature,""); *************** *** 350,362 **** */ public static void assertIsIn(String string, IToken[] comps) { ! StringBuffer buffer = new StringBuffer("Available: \n"); boolean found = false; for (int i = 0; i < comps.length; i++) { String rep = comps[i].getRepresentation(); ! if(string.equals(rep)){ found = true; } ! buffer.append(rep); ! buffer.append("\n"); } --- 350,362 ---- */ public static void assertIsIn(String string, IToken[] comps) { ! StringBuffer buffer = new StringBuffer("Available: \n"); boolean found = false; for (int i = 0; i < comps.length; i++) { String rep = comps[i].getRepresentation(); ! if(string.equals(rep)){ found = true; } ! buffer.append(rep); ! buffer.append("\n"); } Index: ProjectStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/ProjectStub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ProjectStub.java 31 Jul 2008 01:47:36 -0000 1.4 --- ProjectStub.java 28 Sep 2008 12:45:43 -0000 1.5 *************** *** 35,47 **** String name; ! public IProject[] referencedProjects; ! public IProject[] referencingProjects; ! private PythonNature nature; ! private String path; public ProjectStub(String name, String path2, IProject[] referencedProjects, IProject[] referencingProjects) { ! this.path = path2; ! this.name = name; ! this.referencedProjects = referencedProjects; this.referencingProjects = referencingProjects; } --- 35,47 ---- String name; ! public IProject[] referencedProjects; ! public IProject[] referencingProjects; ! private PythonNature nature; ! private String path; public ProjectStub(String name, String path2, IProject[] referencedProjects, IProject[] referencingProjects) { ! this.path = path2; ! this.name = name; ! this.referencedProjects = referencedProjects; this.referencingProjects = referencingProjects; } *************** *** 91,98 **** public IProjectNature getNature(String natureId) throws CoreException { ! if(nature == null){ ! throw new RuntimeException("not expected"); ! } ! return nature; } --- 91,98 ---- public IProjectNature getNature(String natureId) throws CoreException { ! if(nature == null){ ! throw new RuntimeException("not expected"); ! } ! return nature; } *************** *** 115,121 **** public boolean hasNature(String natureId) throws CoreException { ! if(PythonNature.PYTHON_NATURE_ID.equals(natureId)){ ! return true; ! } throw new RuntimeException("not expected"); } --- 115,121 ---- public boolean hasNature(String natureId) throws CoreException { ! if(PythonNature.PYTHON_NATURE_ID.equals(natureId)){ ! return true; ! } throw new RuntimeException("not expected"); } *************** *** 434,456 **** } ! public void setNature(PythonNature nature) { ! this.nature = nature; ! } ! public IResourceProxy createProxy() { ! return null; ! } ! public URI getLocationURI() { ! return null; ! } ! public URI getRawLocationURI() { ! return null; ! } ! public boolean isLinked(int options) { ! return false; ! } public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException { --- 434,456 ---- } ! public void setNature(PythonNature nature) { ! this.nature = nature; ! } ! public IResourceProxy createProxy() { ! return null; ! } ! public URI getLocationURI() { ! return null; ! } ! public URI getRawLocationURI() { ! return null; ! } ! public boolean isLinked(int options) { ! return false; ! } public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException { *************** *** 458,491 **** } ! public void create(IProjectDescription description, int updateFlags, ! IProgressMonitor monitor) throws CoreException { ! // TODO Auto-generated method stub ! ! } ! public Map getPersistentProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public Map getSessionProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public boolean isDerived(int options) { ! // TODO Auto-generated method stub ! return false; ! } ! public boolean isHidden() { ! // TODO Auto-generated method stub ! return false; ! } ! public void setHidden(boolean isHidden) throws CoreException { ! // TODO Auto-generated method stub ! ! } } --- 458,491 ---- } ! public void create(IProjectDescription description, int updateFlags, ! IProgressMonitor monitor) throws CoreException { ! // TODO Auto-generated method stub ! ! } ! public Map getPersistentProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public Map getSessionProperties() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! public boolean isDerived(int options) { ! // TODO Auto-generated method stub ! return false; ! } ! public boolean isHidden() { ! // TODO Auto-generated method stub ! return false; ! } ! public void setHidden(boolean isHidden) throws CoreException { ! // TODO Auto-generated method stub ! ! } } Index: PythonPathHelperTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/PythonPathHelperTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PythonPathHelperTest.java 2 May 2008 13:42:01 -0000 1.5 --- PythonPathHelperTest.java 28 Sep 2008 12:45:43 -0000 1.6 *************** *** 43,51 **** ! public String qual = ""; ! public String token = ""; ! public int line; ! public int col; ! public String sDoc = ""; --- 43,51 ---- ! public String qual = ""; ! public String token = ""; ! public int line; ! public int col; ! public String sDoc = ""; *************** *** 72,76 **** PythonPathHelper helper = new PythonPathHelper(); String path = TestDependent.GetCompletePythonLib(true)+"|"+TestDependent.TEST_PYSRC_LOC; ! helper.setPythonPath(path); assertEquals("unittest",helper.resolveModule(TestDependent.PYTHON_LIB+"unittest.py")); --- 72,76 ---- PythonPathHelper helper = new PythonPathHelper(); String path = TestDependent.GetCompletePythonLib(true)+"|"+TestDependent.TEST_PYSRC_LOC; ! helper.setPythonPath(path); assertEquals("unittest",helper.resolveModule(TestDependent.PYTHON_LIB+"unittest.py")); *************** *** 96,104 **** col = 9; ! sDoc = ""+ ! "from testlib import unittest \n"+ ! " \n"+ ! "unittest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 96,104 ---- col = 9; ! sDoc = ""+ ! "from testlib import unittest \n"+ ! " \n"+ ! "unittest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 119,129 **** } ! private IToken[] getComps(Document doc, ICompletionState state) { ! try { ! return ((ICodeCompletionASTManager)nature.getAstManager()).getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursionModuleCompletion() throws CompletionRecursionException{ --- 119,129 ---- } ! private IToken[] getComps(Document doc, ICompletionState state) { ! try { ! return ((ICodeCompletionASTManager)nature.getAstManager()).getCompletionsForToken(doc, state); ! } catch (CompletionRecursionException e) { ! throw new RuntimeException(e); ! } ! } public void testRecursionModuleCompletion() throws CompletionRecursionException{ *************** *** 132,139 **** col = 0; ! sDoc = ""+ ! "from testrec.imp1 import * \n"+ ! " \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 132,139 ---- col = 0; ! sDoc = ""+ ! "from testrec.imp1 import * \n"+ ! " \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 150,158 **** col = 2; ! sDoc = ""+ ! "from testrec.imp3 import MethodReturn1 \n"+ ! "i = MethodReturn1() \n" + ! "i."; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 150,158 ---- col = 2; ! sDoc = ""+ ! "from testrec.imp3 import MethodReturn1 \n"+ ! "i = MethodReturn1() \n" + ! "i."; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 167,184 **** public void testClassHierarchyCompletion(){ ! token = "TestCase"; ! line = 3; ! col = 9; ! sDoc = ""+ ! "from testlib.unittest.testcase import TestCase \n"+ ! " \n"+ ! "TestCase. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 167,184 ---- public void testClassHierarchyCompletion(){ ! token = "TestCase"; ! line = 3; ! col = 9; ! sDoc = ""+ ! "from testlib.unittest.testcase import TestCase \n"+ ! " \n"+ ! "TestCase. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 188,205 **** public void testClassHierarchyCompletion2(){ ! token = "GUITest"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest import GUITest \n"+ ! " \n"+ ! "GUITest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! ASTManagerTest.assertIsIn("SetWidget", comps); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 188,205 ---- public void testClassHierarchyCompletion2(){ ! token = "GUITest"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest import GUITest \n"+ ! " \n"+ ! "GUITest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! ASTManagerTest.assertIsIn("SetWidget", comps); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 210,227 **** public void testClassHierarchyCompletion3(){ ! token = "AnotherTest"; ! line = 3; ! col = 12; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest \n"+ ! " \n"+ ! "AnotherTest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 210,227 ---- public void testClassHierarchyCompletion3(){ ! token = "AnotherTest"; ! line = 3; ! col = 12; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest \n"+ ! " \n"+ ! "AnotherTest. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 235,243 **** col = 2; ! sDoc = ""+ ! "from testlib import unittest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); --- 235,243 ---- col = 2; ! sDoc = ""+ ! "from testlib import unittest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); *************** *** 259,276 **** public void testImportAs2(){ ! token = "t"; ! line = 3; ! col = 2; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); --- 259,276 ---- public void testImportAs2(){ ! token = "t"; ! line = 3; ! col = 2; ! sDoc = ""+ ! "from testlib.unittest import AnotherTest as t \n"+ ! " \n"+ ! "t. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ! assertTrue(comps.length > 5); ASTManagerTest.assertIsIn("assertEquals", comps); ASTManagerTest.assertIsIn("assertNotEquals", comps); *************** *** 281,300 **** public void testRelativeImport(){ ! token = "Derived"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest.relative.testrelative import Derived \n"+ ! " \n"+ ! "Derived. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ASTManagerTest.assertIsIn("test1", comps); ASTManagerTest.assertIsIn("test2", comps); ! assertEquals(2, comps.length); --- 281,300 ---- public void testRelativeImport(){ ! token = "Derived"; ! line = 3; ! col = 8; ! sDoc = ""+ ! "from testlib.unittest.relative.testrelative import Derived \n"+ ! " \n"+ ! "Derived. \n"; ! IToken[] comps = null; Document doc = new Document(sDoc); ICompletionState state = new CompletionState(line,col, token, nature,""); ! comps = getComps(doc, state); ASTManagerTest.assertIsIn("test1", comps); ASTManagerTest.assertIsIn("test2", comps); ! assertEquals(2, comps.length); Index: CodeCompletionTestsBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/CodeCompletionTestsBase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CodeCompletionTestsBase.java 31 Jul 2008 01:47:36 -0000 1.12 --- CodeCompletionTestsBase.java 28 Sep 2008 12:45:43 -0000 1.13 *************** *** 58,70 **** * Check the restorePythonPath function. */ ! public static PythonNature nature; ! ! /** ! * Nature for the second project. * * This nature has the other nature as a dependency. ! */ ! public static PythonNature nature2; ! /** * A map with the name of the project pointing to the last class that restored the --- 58,70 ---- * Check the restorePythonPath function. */ ! public static PythonNature nature; ! ! /** ! * Nature for the second project. * * This nature has the other nature as a dependency. ! */ ! public static PythonNature nature2; ! /** * A map with the name of the project pointing to the last class that restored the *************** *** 72,93 **** * all the time among tests from the same test case. */ ! public static Map<String, Class> restoredClass = new HashMap<String, Class>(); ! /** * Serves the same purpose that the restoredClass serves, but for the system * python nature. */ ! public static Class restoredSystem; ! private Preferences preferences; ! public Preferences getPreferences(){ ! if(this.preferences == null){ ! this.preferences = new Preferences(); ! } ! return this.preferences; ! } ! ! protected boolean ADD_MX_TO_FORCED_BUILTINS = true; ! protected boolean ADD_NUMPY_TO_FORCED_BUILTINS = true; /** --- 72,93 ---- * all the time among tests from the same test case. */ ! public static Map<String, Class> restoredClass = new HashMap<String, Class>(); ! /** * Serves the same purpose that the restoredClass serves, but for the system * python nature. */ ! public static Class restoredSystem; ! private Preferences preferences; ! public Preferences getPreferences(){ ! if(this.preferences == null){ ! this.preferences = new Preferences(); ! } ! return this.preferences; ! } ! ! protected boolean ADD_MX_TO_FORCED_BUILTINS = true; ! protected boolean ADD_NUMPY_TO_FORCED_BUILTINS = true; /** *************** *** 96,100 **** protected static boolean DEBUG_TESTS_BASE = false; ! /* * @see TestCase#setUp() */ --- 96,100 ---- protected static boolean DEBUG_TESTS_BASE = false; ! /* * @see TestCase#setUp() */ *************** *** 162,168 **** PythonNature n = checkNewNature(name, force); if(n != null){ ! nature2 = n; ! ProjectStub projectFromNature1 = (ProjectStub) nature.getProject(); //create a new project referencing the first one ProjectStub projectFromNature2 = new ProjectStub(name, path, new IProject[]{projectFromNature1}, new IProject[0]); --- 162,168 ---- PythonNature n = checkNewNature(name, force); if(n != null){ ! nature2 = n; ! ProjectStub projectFromNature1 = (ProjectStub) nature.getProject(); //create a new project referencing the first one ProjectStub projectFromNature2 = new ProjectStub(name, path, new IProject[]{projectFromNature1}, new IProject[0]); *************** *** 171,178 **** projectFromNature1.referencingProjects = new IProject[]{projectFromNature2}; ! setAstManager(path, projectFromNature2, nature2); ! return true; ! } ! return false; } --- 171,178 ---- projectFromNature1.referencingProjects = new IProject[]{projectFromNature2}; ! setAstManager(path, projectFromNature2, nature2); ! return true; ! } ! return false; } *************** *** 258,262 **** info.restoreCompiledLibs(getProgressMonitor()); if(ADD_MX_TO_FORCED_BUILTINS){ ! info.addForcedLib("mx"); } if(ADD_NUMPY_TO_FORCED_BUILTINS){ --- 258,262 ---- info.restoreCompiledLibs(getProgressMonitor()); if(ADD_MX_TO_FORCED_BUILTINS){ ! info.addForcedLib("mx"); } if(ADD_NUMPY_TO_FORCED_BUILTINS){ *************** *** 377,385 **** int size = ((ASTManager)nature.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); size = ((ASTManager)nature2.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); } --- 377,385 ---- int size = ((ASTManager)nature.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); size = ((ASTManager)nature2.getAstManager()).getSize(); assertTrue("Interpreter size:"+info.getModulesManager().getSize(true)+" should be smaller than project size:"+size+" " + ! "(because it contains system+project info)" , info.getModulesManager().getSize(true) < size ); } *************** *** 403,410 **** public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(strDoc, documentOffset, returned, retCompl, nature); } public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl, PythonNature nature) throws CoreException, BadLocationException{ ! return requestCompl(null, strDoc, documentOffset, returned, retCompl, nature); } --- 403,410 ---- public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(strDoc, documentOffset, returned, retCompl, nature); } public ICompletionProposal[] requestCompl(String strDoc, int documentOffset, int returned, String []retCompl, PythonNature nature) throws CoreException, BadLocationException{ ! return requestCompl(null, strDoc, documentOffset, returned, retCompl, nature); } *************** *** 415,419 **** public ICompletionProposal[] requestCompl(File file, String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(file, strDoc, documentOffset, returned, retCompl, nature); } --- 415,419 ---- public ICompletionProposal[] requestCompl(File file, String strDoc, int documentOffset, int returned, String []retCompl) throws CoreException, BadLocationException{ ! return requestCompl(file, strDoc, documentOffset, returned, retCompl, nature); } *************** *** 481,490 **** */ protected void assertNotContains(String string, ICompletionProposal[] codeCompletionProposals) { ! for (int i = 0; i < codeCompletionProposals.length; i++) { ! ICompletionProposal completionProposal = codeCompletionProposals[i]; ! if(checkIfEquals(string, completionProposal)){ ! fail("The string >>"+string+"<< was found in the returned completions (was not expected to be found)."); ! } ! } } --- 481,490 ---- */ protected void assertNotContains(String string, ICompletionProposal[] codeCompletionProposals) { ! for (int i = 0; i < codeCompletionProposals.length; i++) { ! ICompletionProposal completionProposal = codeCompletionProposals[i]; ! if(checkIfEquals(string, completionProposal)){ ! fail("The string >>"+string+"<< was found in the returned completions (was not expected to be found)."); ! } ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:19
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors Modified Files: GlobalModelVisitor.java HeuristicFindAttrs.java LocalScope.java FindDefinitionModelVisitor.java InnerModelVisitor.java FindScopeVisitor.java Definition.java KeywordParameterDefinition.java AbstractVisitor.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: Definition.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/Definition.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Definition.java 14 Jun 2008 22:14:56 -0000 1.4 --- Definition.java 28 Sep 2008 12:45:42 -0000 1.5 *************** *** 61,68 **** /** ! * The line and col are defined starting at 1 (and not 0) ! */ public Definition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module){ ! this(line, col, value, ast, scope, module, false); } /** --- 61,68 ---- /** ! * The line and col are defined starting at 1 (and not 0) ! */ public Definition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module){ ! this(line, col, value, ast, scope, module, false); } /** *************** *** 73,78 **** */ public Definition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module, boolean foundAsLocal){ ! Assert.isNotNull(value, "Invalid value."); ! Assert.isNotNull(module, "Invalid Module."); this.line = line; --- 73,78 ---- */ public Definition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module, boolean foundAsLocal){ ! Assert.isNotNull(value, "Invalid value."); ! Assert.isNotNull(module, "Invalid Module."); this.line = line; *************** *** 87,108 **** public Definition(org.python.pydev.core.IToken tok, ILocalScope scope, IModule module){ ! this(tok, scope, module, false); } public Definition(org.python.pydev.core.IToken tok, ILocalScope scope, IModule module, boolean foundAsLocal){ ! Assert.isNotNull(tok, "Invalid value."); ! Assert.isNotNull(module, "Invalid Module."); ! ! this.line = tok.getLineDefinition(); ! this.col = tok.getColDefinition(); ! this.value = tok.getRepresentation(); ! if(tok instanceof SourceToken){ ! this.ast = ((SourceToken)tok).getAst(); ! } ! this.scope = scope; ! this.module = module; } ! /** * @see java.lang.Object#toString() */ --- 87,108 ---- public Definition(org.python.pydev.core.IToken tok, ILocalScope scope, IModule module){ ! this(tok, scope, module, false); } public Definition(org.python.pydev.core.IToken tok, ILocalScope scope, IModule module, boolean foundAsLocal){ ! Assert.isNotNull(tok, "Invalid value."); ! Assert.isNotNull(module, "Invalid Module."); ! ! this.line = tok.getLineDefinition(); ! this.col = tok.getColDefinition(); ! this.value = tok.getRepresentation(); ! if(tok instanceof SourceToken){ ! this.ast = ((SourceToken)tok).getAst(); ! } ! this.scope = scope; ! this.module = module; } ! /** * @see java.lang.Object#toString() */ *************** *** 140,147 **** if(scope == d.scope){ ! return true; } if(scope == null || d.scope == null){ ! return false; } --- 140,147 ---- if(scope == d.scope){ ! return true; } if(scope == null || d.scope == null){ ! return false; } Index: FindDefinitionModelVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/FindDefinitionModelVisitor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FindDefinitionModelVisitor.java 14 Feb 2008 09:57:38 -0000 1.5 --- FindDefinitionModelVisitor.java 28 Sep 2008 12:45:42 -0000 1.6 *************** *** 71,77 **** public String moduleImported; ! private int line; ! private int col; private boolean foundAsDefinition = false; --- 71,77 ---- public String moduleImported; ! private int line; ! private int col; private boolean foundAsDefinition = false; *************** *** 82,86 **** * Call is stored for the context for a keyword parameter */ ! private Stack<Call> call = new Stack<Call>(); /** --- 82,86 ---- * Call is stored for the context for a keyword parameter */ ! private Stack<Call> call = new Stack<Call>(); /** *************** *** 101,133 **** @Override public Object visitImportFrom(ImportFrom node) throws Exception { ! String modRep = NodeUtils.getRepresentationString(node.module); ! if( NodeUtils.isWithin(line, col, node.module) ){ ! //it is a token in the definition of a module ! int startingCol = node.module.beginColumn; ! int endingCol = startingCol; ! while(endingCol < this.col){ ! endingCol++; ! } ! int lastChar = endingCol-startingCol; ! moduleImported = modRep.substring(0, lastChar); ! int i = lastChar; ! while(i < modRep.length()){ ! if(Character.isJavaIdentifierPart(modRep.charAt(i))){ ! i++; ! }else{ ! break; ! } ! } ! moduleImported += modRep.substring(lastChar, i); ! }else{ ! //it was not the module, so, we have to check for each name alias imported ! for (aliasType alias: node.names){ ! //we do not check the 'as' because if it is some 'as', it will be gotten as a global in the module ! if( NodeUtils.isWithin(line, col, alias.name) ){ ! moduleImported = modRep + "." + NodeUtils.getRepresentationString(alias.name); ! } ! } ! } ! return super.visitImportFrom(node); } --- 101,133 ---- @Override public Object visitImportFrom(ImportFrom node) throws Exception { ! String modRep = NodeUtils.getRepresentationString(node.module); ! if( NodeUtils.isWithin(line, col, node.module) ){ ! //it is a token in the definition of a module ! int startingCol = node.module.beginColumn; ! int endingCol = startingCol; ! while(endingCol < this.col){ ! endingCol++; ! } ! int lastChar = endingCol-startingCol; ! moduleImported = modRep.substring(0, lastChar); ! int i = lastChar; ! while(i < modRep.length()){ ! if(Character.isJavaIdentifierPart(modRep.charAt(i))){ ! i++; ! }else{ ! break; ! } ! } ! moduleImported += modRep.substring(lastChar, i); ! }else{ ! //it was not the module, so, we have to check for each name alias imported ! for (aliasType alias: node.names){ ! //we do not check the 'as' because if it is some 'as', it will be gotten as a global in the module ! if( NodeUtils.isWithin(line, col, alias.name) ){ ! moduleImported = modRep + "." + NodeUtils.getRepresentationString(alias.name); ! } ! } ! } ! return super.visitImportFrom(node); } *************** *** 170,178 **** if(node.args != null && node.args.args != null){ ! for(exprType arg:node.args.args){ ! if(arg instanceof Name){ ! checkParam((Name) arg); ! } ! } } node.traverse(this); --- 170,178 ---- if(node.args != null && node.args.args != null){ ! for(exprType arg:node.args.args){ ! if(arg instanceof Name){ ! checkParam((Name) arg); ! } ! } } node.traverse(this); *************** *** 190,217 **** */ private void checkParam(Name name) { ! String rep = NodeUtils.getRepresentationString(name); ! if(rep.equals(tokenToFind) && line == name.beginLine && col >= name.beginColumn && col <= name.beginColumn+rep.length()){ ! foundAsDefinition = true; ! // if it is found as a definition it is an 'exact' match, so, erase all the others. ! ILocalScope scope = new LocalScope(this.defsStack); ! for (Iterator<Definition> it = definitions.iterator(); it.hasNext();) { ! Definition d = it.next(); ! if(!d.scope.equals(scope)){ ! it.remove(); ! } ! } ! ! ! definitionFound = new Definition(line, name.beginColumn, rep, name, scope, module.get()); ! definitions.add(definitionFound); ! } } @Override public Object visitCall(Call node) throws Exception { ! this.call.push(node); ! Object r = super.visitCall(node); ! this.call.pop(); ! return r; } --- 190,217 ---- */ private void checkParam(Name name) { ! String rep = NodeUtils.getRepresentationString(name); ! if(rep.equals(tokenToFind) && line == name.beginLine && col >= name.beginColumn && col <= name.beginColumn+rep.length()){ ! foundAsDefinition = true; ! // if it is found as a definition it is an 'exact' match, so, erase all the others. ! ILocalScope scope = new LocalScope(this.defsStack); ! for (Iterator<Definition> it = definitions.iterator(); it.hasNext();) { ! Definition d = it.next(); ! if(!d.scope.equals(scope)){ ! it.remove(); ! } ! } ! ! ! definitionFound = new Definition(line, name.beginColumn, rep, name, scope, module.get()); ! definitions.add(definitionFound); ! } } @Override public Object visitCall(Call node) throws Exception { ! this.call.push(node); ! Object r = super.visitCall(node); ! this.call.pop(); ! return r; } *************** *** 219,246 **** @Override public Object visitNameTok(NameTok node) throws Exception { ! if(node.ctx == NameTok.KeywordName){ ! if(this.line == node.beginLine){ ! String rep = NodeUtils.getRepresentationString(node); ! if(PySelection.isInside(col, node.beginColumn, rep.length())){ ! foundAsDefinition = true; ! // if it is found as a definition it is an 'exact' match, so, erase all the others. ! ILocalScope scope = new LocalScope(this.defsStack); ! for (Iterator<Definition> it = definitions.iterator(); it.hasNext();) { ! Definition d = it.next(); ! if(!d.scope.equals(scope)){ ! it.remove(); ! } ! } ! ! definitions.clear(); ! ! definitionFound = new KeywordParameterDefinition(line, node.beginColumn, rep, node, scope, module.get(), this.call.peek()); ! definitions.add(definitionFound); ! throw new StopVisitingException(); ! } ! } ! } ! return null; } --- 219,246 ---- @Override public Object visitNameTok(NameTok node) throws Exception { ! if(node.ctx == NameTok.KeywordName){ ! if(this.line == node.beginLine){ ! String rep = NodeUtils.getRepresentationString(node); ! if(PySelection.isInside(col, node.beginColumn, rep.length())){ ! foundAsDefinition = true; ! // if it is found as a definition it is an 'exact' match, so, erase all the others. ! ILocalScope scope = new LocalScope(this.defsStack); ! for (Iterator<Definition> it = definitions.iterator(); it.hasNext();) { ! Definition d = it.next(); ! if(!d.scope.equals(scope)){ ! it.remove(); ! } ! } ! ! definitions.clear(); ! ! definitionFound = new KeywordParameterDefinition(line, node.beginColumn, rep, node, scope, module.get(), this.call.peek()); ! definitions.add(definitionFound); ! throw new StopVisitingException(); ! } ! } ! } ! return null; } *************** *** 296,314 **** } String rep = NodeUtils.getFullRepresentationString(target); ! if(tokenToFind.equals(rep)){ //note, order of equals is important (because one side may be null). ! exprType nodeValue = node.value; String value = NodeUtils.getFullRepresentationString(nodeValue); if(value == null){ value = ""; } ! //get the line and column correspondent to the target ! int line = NodeUtils.getLineDefinition(target); ! int col = NodeUtils.getColDefinition(target); ! AssignDefinition definition = new AssignDefinition(value, rep, i, node, line, col, scope, module.get()); ! //mark it as global (if it was found as global in some of the previous contexts). for(Set<String> globals: globalDeclarationsStack){ if(globals.contains(rep)){ --- 296,314 ---- } String rep = NodeUtils.getFullRepresentationString(target); ! if(tokenToFind.equals(rep)){ //note, order of equals is important (because one side may be null). ! exprType nodeValue = node.value; String value = NodeUtils.getFullRepresentationString(nodeValue); if(value == null){ value = ""; } ! //get the line and column correspondent to the target ! int line = NodeUtils.getLineDefinition(target); ! int col = NodeUtils.getColDefinition(target); ! AssignDefinition definition = new AssignDefinition(value, rep, i, node, line, col, scope, module.get()); ! //mark it as global (if it was found as global in some of the previous contexts). for(Set<String> globals: globalDeclarationsStack){ if(globals.contains(rep)){ *************** *** 317,322 **** } ! definitions.add(definition); ! } } --- 317,322 ---- } ! definitions.add(definition); ! } } Index: LocalScope.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/LocalScope.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** LocalScope.java 17 Aug 2008 00:26:46 -0000 1.9 --- LocalScope.java 28 Sep 2008 12:45:42 -0000 1.10 *************** *** 246,268 **** * @see org.python.pydev.core.ILocalScope#getClassDef() */ ! public ClassDef getClassDef() { ! for(Iterator<SimpleNode> it = this.scope.topDownIterator(); it.hasNext();){ SimpleNode node = it.next(); ! if(node instanceof ClassDef){ ! return (ClassDef) node; ! } ! } ! return null; ! } ! /** * @see org.python.pydev.core.ILocalScope#isLastClassDef() */ ! public boolean isLastClassDef() { ! if(this.scope.size() > 0 && this.scope.peek() instanceof ClassDef){ ! return true; ! } ! return false; ! } @SuppressWarnings("unchecked") --- 246,268 ---- * @see org.python.pydev.core.ILocalScope#getClassDef() */ ! public ClassDef getClassDef() { ! for(Iterator<SimpleNode> it = this.scope.topDownIterator(); it.hasNext();){ SimpleNode node = it.next(); ! if(node instanceof ClassDef){ ! return (ClassDef) node; ! } ! } ! return null; ! } ! /** * @see org.python.pydev.core.ILocalScope#isLastClassDef() */ ! public boolean isLastClassDef() { ! if(this.scope.size() > 0 && this.scope.peek() instanceof ClassDef){ ! return true; ! } ! return false; ! } @SuppressWarnings("unchecked") Index: InnerModelVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/InnerModelVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InnerModelVisitor.java 25 Mar 2007 16:09:05 -0000 1.1 --- InnerModelVisitor.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 30,36 **** public InnerModelVisitor(String moduleName, ICompletionState state){ ! this.moduleName = moduleName; attrsHeuristics.add(new HeuristicFindAttrs(HeuristicFindAttrs.WHITIN_METHOD_CALL, HeuristicFindAttrs.IN_KEYWORDS, "properties.create", moduleName, state)); ! attrsHeuristics.add(new HeuristicFindAttrs(HeuristicFindAttrs.WHITIN_ANY , HeuristicFindAttrs.IN_ASSIGN , "", moduleName, state)); } --- 30,36 ---- public InnerModelVisitor(String moduleName, ICompletionState state){ ! this.moduleName = moduleName; attrsHeuristics.add(new HeuristicFindAttrs(HeuristicFindAttrs.WHITIN_METHOD_CALL, HeuristicFindAttrs.IN_KEYWORDS, "properties.create", moduleName, state)); ! attrsHeuristics.add(new HeuristicFindAttrs(HeuristicFindAttrs.WHITIN_ANY , HeuristicFindAttrs.IN_ASSIGN , "", moduleName, state)); } *************** *** 68,73 **** if(visiting == VISITING_NOTHING){ visiting = VISITING_CLASS; ! node.traverse(this); ! }else if(visiting == VISITING_CLASS){ //that's a class within the class we're visiting --- 68,73 ---- if(visiting == VISITING_NOTHING){ visiting = VISITING_CLASS; ! node.traverse(this); ! }else if(visiting == VISITING_CLASS){ //that's a class within the class we're visiting *************** *** 100,108 **** //iterate heuristics to find attributes ! for (Iterator iter = attrsHeuristics.iterator(); iter.hasNext();) { ! HeuristicFindAttrs element = (HeuristicFindAttrs) iter.next(); ! element.visitAssign(node); ! addElementTokens(element); ! } } return null; --- 100,108 ---- //iterate heuristics to find attributes ! for (Iterator iter = attrsHeuristics.iterator(); iter.hasNext();) { ! HeuristicFindAttrs element = (HeuristicFindAttrs) iter.next(); ! element.visitAssign(node); ! addElementTokens(element); ! } } return null; *************** *** 116,124 **** //iterate heuristics to find attributes ! for (Iterator iter = attrsHeuristics.iterator(); iter.hasNext();) { ! HeuristicFindAttrs element = (HeuristicFindAttrs) iter.next(); ! element.visitCall(node); ! addElementTokens(element); ! } } return null; --- 116,124 ---- //iterate heuristics to find attributes ! for (Iterator iter = attrsHeuristics.iterator(); iter.hasNext();) { ! HeuristicFindAttrs element = (HeuristicFindAttrs) iter.next(); ! element.visitCall(node); ! addElementTokens(element); ! } } return null; Index: AbstractVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/AbstractVisitor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractVisitor.java 17 Aug 2008 00:26:46 -0000 1.5 --- AbstractVisitor.java 28 Sep 2008 12:45:42 -0000 1.6 *************** *** 101,117 **** public static List<IToken> makeImportToken(SimpleNode node, List<IToken> tokens, String moduleName, boolean allowForMultiple) { ! if(node instanceof Import){ ! return makeImportToken((Import)node, tokens, moduleName, allowForMultiple); ! } ! if(node instanceof ImportFrom){ ! ImportFrom i = (ImportFrom) node; ! if(isWildImport(i)){ ! makeWildImportToken(i, tokens, moduleName); ! return tokens; ! } ! return makeImportToken((ImportFrom)node, tokens, moduleName, allowForMultiple); ! } ! ! throw new RuntimeException("Unable to create token for the passed import ("+node+")"); } --- 101,117 ---- public static List<IToken> makeImportToken(SimpleNode node, List<IToken> tokens, String moduleName, boolean allowForMultiple) { ! if(node instanceof Import){ ! return makeImportToken((Import)node, tokens, moduleName, allowForMultiple); ! } ! if(node instanceof ImportFrom){ ! ImportFrom i = (ImportFrom) node; ! if(isWildImport(i)){ ! makeWildImportToken(i, tokens, moduleName); ! return tokens; ! } ! return makeImportToken((ImportFrom)node, tokens, moduleName, allowForMultiple); ! } ! ! throw new RuntimeException("Unable to create token for the passed import ("+node+")"); } *************** *** 151,155 **** if(initialImportName.length() > 0){ ! initialImportName = initialImportName+"."; } --- 151,155 ---- if(initialImportName.length() > 0){ ! initialImportName = initialImportName+"."; } *************** *** 237,241 **** */ public static List<IToken> getTokens(SimpleNode ast, int which, String moduleName, ICompletionState state, ! boolean onlyAllowTokensIn__all__) { AbstractVisitor modelVisitor; if(which == INNER_DEFS){ --- 237,241 ---- */ public static List<IToken> getTokens(SimpleNode ast, int which, String moduleName, ICompletionState state, ! boolean onlyAllowTokensIn__all__) { AbstractVisitor modelVisitor; if(which == INNER_DEFS){ *************** *** 257,260 **** --- 257,283 ---- } } + + /** + * This method traverses the ast and returns a model visitor that has the list of found tokens (and other related info, such as __all__, etc.) + */ + public static GlobalModelVisitor getGlobalModuleVisitorWithTokens(SimpleNode ast, int which, String moduleName, ICompletionState state, + boolean onlyAllowTokensIn__all__) { + if(which == INNER_DEFS){ + throw new RuntimeException("Only globals for getting the GlobalModelVisitor"); + } + GlobalModelVisitor modelVisitor = new GlobalModelVisitor(which, moduleName, onlyAllowTokensIn__all__); + + if (ast != null){ + try { + ast.accept(modelVisitor); + } catch (Exception e) { + throw new RuntimeException(e); + } + modelVisitor.finishVisit(); + return modelVisitor; + }else{ + return modelVisitor; + } + } *************** *** 263,269 **** * returned. */ ! protected void finishVisit() { ! /**Empty**/ ! } --- 286,292 ---- * returned. */ ! protected void finishVisit() { ! /**Empty**/ ! } Index: GlobalModelVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/GlobalModelVisitor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GlobalModelVisitor.java 17 Aug 2008 00:26:46 -0000 1.4 --- GlobalModelVisitor.java 28 Sep 2008 12:45:42 -0000 1.5 *************** *** 32,37 **** private SourceToken __all__; private Assign __all__Assign; private Assign lastAssign; ! private boolean onlyAllowTokensIn__all__; /** --- 32,38 ---- private SourceToken __all__; private Assign __all__Assign; + private exprType[] __all__AssignTargets; private Assign lastAssign; ! private boolean onlyAllowTokensIn__all__; /** *************** *** 78,82 **** */ public Object visitAssign(Assign node) throws Exception { ! lastAssign = node; node.traverse(this); return null; --- 79,83 ---- */ public Object visitAssign(Assign node) throws Exception { ! lastAssign = node; node.traverse(this); return null; *************** *** 93,99 **** if (node.ctx == Name.Store) { SourceToken added = addToken(node); ! if(onlyAllowTokensIn__all__ && added.getRepresentation().equals("__all__")){ ! __all__ = added; ! __all__Assign = lastAssign; } } --- 94,107 ---- if (node.ctx == Name.Store) { SourceToken added = addToken(node); ! if(added.getRepresentation().equals("__all__") && __all__Assign == null){ ! __all__ = added; ! __all__Assign = lastAssign; ! __all__AssignTargets = lastAssign.targets; ! } ! }else if(node.ctx == Name.Load){ ! if(node.id.equals("__all__")){ ! //if we find __all__ more than once, let's clear it (we can only have __all__ = list of strings... if later ! //an append, extend, etc is done in it, we have to skip this heuristic). ! __all__AssignTargets = null; } } *************** *** 147,178 **** @Override protected void finishVisit() { ! if(__all__ != null){ ! SimpleNode ast = __all__.getAst(); ! //just checking it ! if(__all__Assign.targets != null && __all__Assign.targets.length == 1 && __all__Assign.targets[0] == ast){ ! HashSet<String> validTokensInAll = new HashSet<String>(); ! exprType value = __all__Assign.value; ! if(value instanceof List){ ! List valueList = (List) value; ! if(valueList.elts != null){ ! for(exprType elt:valueList.elts){ ! if(elt instanceof Str){ ! Str str = (Str) elt; ! validTokensInAll.add(str.s); ! } ! } ! } ! } ! ! if(validTokensInAll.size() > 0){ ! for(Iterator<IToken> it = tokens.iterator();it.hasNext();){ ! IToken tok = it.next(); ! if(!validTokensInAll.contains(tok.getRepresentation())){ ! it.remove(); ! } ! } ! } ! } ! } } } \ No newline at end of file --- 155,198 ---- @Override protected void finishVisit() { ! if(onlyAllowTokensIn__all__){ ! filterAll(this.tokens); ! } ! } ! ! ! /** ! * This method will filter the passed tokens given the __all__ that was found when visiting. ! * ! * @param tokens the tokens to be filtered (IN and OUT parameter) ! */ ! public void filterAll(java.util.List<IToken> tokens) { ! if(__all__ != null){ ! SimpleNode ast = __all__.getAst(); ! //just checking it ! if(__all__AssignTargets != null && __all__AssignTargets.length == 1 && __all__AssignTargets[0] == ast){ ! HashSet<String> validTokensInAll = new HashSet<String>(); ! exprType value = __all__Assign.value; ! if(value instanceof List){ ! List valueList = (List) value; ! if(valueList.elts != null){ ! for(exprType elt:valueList.elts){ ! if(elt instanceof Str){ ! Str str = (Str) elt; ! validTokensInAll.add(str.s); ! } ! } ! } ! } ! ! if(validTokensInAll.size() > 0){ ! for(Iterator<IToken> it = tokens.iterator();it.hasNext();){ ! IToken tok = it.next(); ! if(!validTokensInAll.contains(tok.getRepresentation())){ ! it.remove(); ! } ! } ! } ! } ! } } } \ No newline at end of file Index: KeywordParameterDefinition.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/KeywordParameterDefinition.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** KeywordParameterDefinition.java 12 Apr 2007 17:10:52 -0000 1.1 --- KeywordParameterDefinition.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 16,25 **** public class KeywordParameterDefinition extends Definition{ ! public Call call; ! public KeywordParameterDefinition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module, Call call) { ! super(line, col, value, ast, scope, module, false); ! this.call = call; ! } } --- 16,25 ---- public class KeywordParameterDefinition extends Definition{ ! public Call call; ! public KeywordParameterDefinition(int line, int col, String value, SimpleNode ast, ILocalScope scope, IModule module, Call call) { ! super(line, col, value, ast, scope, module, false); ! this.call = call; ! } } Index: HeuristicFindAttrs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/HeuristicFindAttrs.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HeuristicFindAttrs.java 18 May 2008 20:02:16 -0000 1.3 --- HeuristicFindAttrs.java 28 Sep 2008 12:45:42 -0000 1.4 *************** *** 102,126 **** public Object visitCall(Call node) throws Exception { if(entryPointCorrect == false && methodCall.length() > 0){ ! entryPointCorrect = true; ! String[] c = StringUtils.dotSplit(methodCall); ! ! ! ! if (node.func instanceof Attribute){ ! Attribute func = (Attribute)node.func; ! if(((NameTok)func.attr).id.equals(c[1])){ ! ! if(func.value instanceof Name){ ! Name name = (Name) func.value; ! if(name.id.equals(c[0])){ ! for (int i=0; i<node.keywords.length; i++){ ! addToken(node.keywords[i]); ! } ! } ! } ! } ! } ! ! entryPointCorrect = false; } return null; --- 102,126 ---- public Object visitCall(Call node) throws Exception { if(entryPointCorrect == false && methodCall.length() > 0){ ! entryPointCorrect = true; ! String[] c = StringUtils.dotSplit(methodCall); ! ! ! ! if (node.func instanceof Attribute){ ! Attribute func = (Attribute)node.func; ! if(((NameTok)func.attr).id.equals(c[1])){ ! ! if(func.value instanceof Name){ ! Name name = (Name) func.value; ! if(name.id.equals(c[0])){ ! for (int i=0; i<node.keywords.length; i++){ ! addToken(node.keywords[i]); ! } ! } ! } ! } ! } ! ! entryPointCorrect = false; } return null; *************** *** 133,147 **** stack.push(node); if(entryPointCorrect == false){ ! entryPointCorrect = true; ! inFuncDef = true; ! ! if(where == WHITIN_ANY){ ! node.traverse(this); ! ! } else if(where == WHITIN_INIT && node.name.equals("__init__")){ ! node.traverse(this); ! } ! entryPointCorrect = false; ! inFuncDef = false; } stack.pop(); --- 133,147 ---- stack.push(node); if(entryPointCorrect == false){ ! entryPointCorrect = true; ! inFuncDef = true; ! ! if(where == WHITIN_ANY){ ! node.traverse(this); ! ! } else if(where == WHITIN_INIT && node.name.equals("__init__")){ ! node.traverse(this); ! } ! entryPointCorrect = false; ! inFuncDef = false; } stack.pop(); *************** *** 181,195 **** }else if(node.targets[i] instanceof Tuple && inFuncDef == false){ ! //that's for finding the definition: a,b,c = range(3) inside a class definition ! Tuple tuple = (Tuple) node.targets[i]; ! for(exprType t :tuple.elts){ ! if(t instanceof Name){ ! String id = ((Name)t).id; ! if(id != null){ ! addToken(t); ! } ! } ! } ! } } --- 181,195 ---- }else if(node.targets[i] instanceof Tuple && inFuncDef == false){ ! //that's for finding the definition: a,b,c = range(3) inside a class definition ! Tuple tuple = (Tuple) node.targets[i]; ! for(exprType t :tuple.elts){ ! if(t instanceof Name){ ! String id = ((Name)t).id; ! if(id != null){ ! addToken(t); ! } ! } ! } ! } } Index: FindScopeVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/visitors/FindScopeVisitor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FindScopeVisitor.java 4 Aug 2007 23:14:59 -0000 1.3 --- FindScopeVisitor.java 28 Sep 2008 12:45:42 -0000 1.4 *************** *** 50,54 **** */ protected FindScopeVisitor(){ ! } --- 50,54 ---- */ protected FindScopeVisitor(){ ! } *************** *** 68,81 **** */ @SuppressWarnings("unchecked") ! protected Object unhandled_node(SimpleNode node) throws Exception { //the line passed in starts at 1 and the lines for the visitor nodes start at 0 if(! found && !(node instanceof Module)){ ! if(line <= node.beginLine ){ ! //scope is locked at this time. ! found = true; ! int original = scope.getIfMainLine(); ! scope = new LocalScope((FastStack<SimpleNode>) this.stackScope.createCopy()); ! scope.setIfMainLine(original); ! } }else{ if(scope.getScopeEndLine() == -1 && line < node.beginLine && col >= node.beginColumn){ --- 68,81 ---- */ @SuppressWarnings("unchecked") ! protected Object unhandled_node(SimpleNode node) throws Exception { //the line passed in starts at 1 and the lines for the visitor nodes start at 0 if(! found && !(node instanceof Module)){ ! if(line <= node.beginLine ){ ! //scope is locked at this time. ! found = true; ! int original = scope.getIfMainLine(); ! scope = new LocalScope((FastStack<SimpleNode>) this.stackScope.createCopy()); ! scope.setIfMainLine(original); ! } }else{ if(scope.getScopeEndLine() == -1 && line < node.beginLine && col >= node.beginColumn){ *************** *** 97,101 **** */ public Object visitIf(If node) throws Exception { ! checkIfMainNode(node); return super.visitIf(node); } --- 97,101 ---- */ public Object visitIf(If node) throws Exception { ! checkIfMainNode(node); return super.visitIf(node); } *************** *** 104,113 **** * Checks if we found an 'if' main node */ ! protected void checkIfMainNode(If node) { ! boolean isIfMainNode = NodeUtils.isIfMAinNode(node); if(isIfMainNode){ scope.setIfMainLine(node.beginLine); } ! } --- 104,113 ---- * Checks if we found an 'if' main node */ ! protected void checkIfMainNode(If node) { ! boolean isIfMainNode = NodeUtils.isIfMAinNode(node); if(isIfMainNode){ scope.setIfMainLine(node.beginLine); } ! } *************** *** 117,123 **** public Object visitClassDef(ClassDef node) throws Exception { if(!found){ ! stackScope.push(node); ! node.traverse(this); ! stackScope.pop(); } return super.visitClassDef(node); --- 117,123 ---- public Object visitClassDef(ClassDef node) throws Exception { if(!found){ ! stackScope.push(node); ! node.traverse(this); ! stackScope.pop(); } return super.visitClassDef(node); *************** *** 129,135 **** public Object visitFunctionDef(FunctionDef node) throws Exception { if(!found){ ! stackScope.push(node); ! node.traverse(this); ! stackScope.pop(); } return super.visitFunctionDef(node); --- 129,135 ---- public Object visitFunctionDef(FunctionDef node) throws Exception { if(!found){ ! stackScope.push(node); ! node.traverse(this); ! stackScope.pop(); } return super.visitFunctionDef(node); |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/actions Modified Files: PyMethodNavigation.java PyFormatStd.java FirstCharAction.java PyOpenAction.java PyShowBrowser.java PyShowOutline.java PyAction.java PySelectWord.java PyGoToDefinition.java OfflineActionTarget.java PyOrganizeImports.java PyConvertTabToSpace.java PyBackspace.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: PySelectWord.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PySelectWord.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PySelectWord.java 1 Jun 2006 17:45:01 -0000 1.1 --- PySelectWord.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 9,27 **** public class PySelectWord extends PyAction{ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! try { ! Tuple<String,Integer> currToken = ps.getCurrToken(); ! if(currToken.o1 != null){ ! int len = currToken.o1.length(); ! if(len > 0){ ! pyEdit.selectAndReveal(currToken.o2, len); ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } } --- 9,27 ---- public class PySelectWord extends PyAction{ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! try { ! Tuple<String,Integer> currToken = ps.getCurrToken(); ! if(currToken.o1 != null){ ! int len = currToken.o1.length(); ! if(len > 0){ ! pyEdit.selectAndReveal(currToken.o2, len); ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } } Index: PyConvertTabToSpace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyConvertTabToSpace.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyConvertTabToSpace.java 14 Jun 2008 22:14:55 -0000 1.6 --- PyConvertTabToSpace.java 28 Sep 2008 12:45:41 -0000 1.7 *************** *** 77,81 **** } ! // If all goes well, replace the text with the modified information doc.replace(ps.getStartLine().getOffset(), ps.getSelLength(), strbuf.toString()); return true; --- 77,81 ---- } ! // If all goes well, replace the text with the modified information doc.replace(ps.getStartLine().getOffset(), ps.getSelLength(), strbuf.toString()); return true; Index: PyShowBrowser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyShowBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyShowBrowser.java 21 Feb 2006 19:27:37 -0000 1.1 --- PyShowBrowser.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 8,14 **** public class PyShowBrowser extends PyShowOutline{ ! @Override ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_GLOBALS_BROWSER; ! } } --- 8,14 ---- public class PyShowBrowser extends PyShowOutline{ ! @Override ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_GLOBALS_BROWSER; ! } } Index: PyMethodNavigation.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyMethodNavigation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyMethodNavigation.java 23 Feb 2008 18:58:09 -0000 1.6 --- PyMethodNavigation.java 28 Sep 2008 12:45:41 -0000 1.7 *************** *** 24,38 **** public abstract class PyMethodNavigation extends PyAction { ! /** ! * This method will search for the next/previous function (depending on the abstract methods) ! * and will go to the position in the document that corresponds to the name of the class/function definiton. ! */ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ! ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); ! boolean searchForward = getSearchForward(); ! int startLine = selection.getStartLine(); --- 24,38 ---- public abstract class PyMethodNavigation extends PyAction { ! /** ! * This method will search for the next/previous function (depending on the abstract methods) ! * and will go to the position in the document that corresponds to the name of the class/function definiton. ! */ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ! ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); ! boolean searchForward = getSearchForward(); ! int startLine = selection.getStartLine(); *************** *** 44,48 **** } stmtType goHere = FastParser.firstClassOrFunction(doc, startLine, searchForward); ! NameTok node = getNameNode(goHere); if(node != null){ --- 44,48 ---- } stmtType goHere = FastParser.firstClassOrFunction(doc, startLine, searchForward); ! NameTok node = getNameNode(goHere); if(node != null){ *************** *** 59,75 **** } } ! } ! /** ! * @return true if the search should be forward (next method) and false if it should be backward (previous method) ! */ ! protected abstract boolean getSearchForward(); ! /** ! * @param defNode the ClassDef or FunctionDef from where we want to get the name ! * @return the name of the given statement ! */ protected NameTok getNameNode(stmtType defNode) { ! NameTok node = null; if(defNode != null){ if(defNode instanceof ClassDef){ --- 59,75 ---- } } ! } ! /** ! * @return true if the search should be forward (next method) and false if it should be backward (previous method) ! */ ! protected abstract boolean getSearchForward(); ! /** ! * @param defNode the ClassDef or FunctionDef from where we want to get the name ! * @return the name of the given statement ! */ protected NameTok getNameNode(stmtType defNode) { ! NameTok node = null; if(defNode != null){ if(defNode instanceof ClassDef){ *************** *** 82,87 **** } } ! return node; ! } --- 82,87 ---- } } ! return node; ! } Index: PyOpenAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOpenAction.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PyOpenAction.java 6 Aug 2008 16:23:19 -0000 1.20 --- PyOpenAction.java 28 Sep 2008 12:45:41 -0000 1.21 *************** *** 45,55 **** textEdit.getSelectionProvider().setSelection(sel); } catch (BadLocationException e1) { ! if(textEdit instanceof PyEdit){ ! PyEdit p = (PyEdit) textEdit; ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end+" - "+p.getEditorFile(), e1); ! ! }else{ ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end, e1); ! } } } --- 45,55 ---- textEdit.getSelectionProvider().setSelection(sel); } catch (BadLocationException e1) { ! if(textEdit instanceof PyEdit){ ! PyEdit p = (PyEdit) textEdit; ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end+" - "+p.getEditorFile(), e1); ! ! }else{ ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end, e1); ! } } } *************** *** 65,69 **** } else if (file instanceof IFile) { ! IFile f = (IFile) file; editor = PyOpenEditor.doOpenEditor(f); --- 65,69 ---- } else if (file instanceof IFile) { ! IFile f = (IFile) file; editor = PyOpenEditor.doOpenEditor(f); *************** *** 74,78 **** } else if (file instanceof File) { String absPath = REF.getFileAbsolutePath((File) file); ! IPath path = Path.fromOSString(absPath); editor = PyOpenEditor.doOpenEditor(path); } --- 74,78 ---- } else if (file instanceof File) { String absPath = REF.getFileAbsolutePath((File) file); ! IPath path = Path.fromOSString(absPath); editor = PyOpenEditor.doOpenEditor(path); } Index: PyShowOutline.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyShowOutline.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyShowOutline.java 21 Feb 2006 19:27:37 -0000 1.4 --- PyShowOutline.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 17,60 **** public class PyShowOutline extends PyAction{ ! protected IEditorActionDelegate registered; ! /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.run(action); ! } } public void setActiveEditor(IAction action, IEditorPart targetEditor){ ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.setActiveEditor(action, targetEditor); ! } } @Override public void selectionChanged(IAction action, ISelection selection) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.selectionChanged(action, selection); ! } } ! protected IEditorActionDelegate getParticipant() { ! if(registered != null){ ! return registered; ! } ! ! registered = (IEditorActionDelegate) ExtensionHelper.getParticipant(getExtensionName()); ! return registered; ! } ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_QUICK_OUTLINE; ! } } --- 17,60 ---- public class PyShowOutline extends PyAction{ ! protected IEditorActionDelegate registered; ! /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.run(action); ! } } public void setActiveEditor(IAction action, IEditorPart targetEditor){ ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.setActiveEditor(action, targetEditor); ! } } @Override public void selectionChanged(IAction action, ISelection selection) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.selectionChanged(action, selection); ! } } ! protected IEditorActionDelegate getParticipant() { ! if(registered != null){ ! return registered; ! } ! ! registered = (IEditorActionDelegate) ExtensionHelper.getParticipant(getExtensionName()); ! return registered; ! } ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_QUICK_OUTLINE; ! } } Index: PyOrganizeImports.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOrganizeImports.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyOrganizeImports.java 16 Jun 2008 00:55:34 -0000 1.19 --- PyOrganizeImports.java 28 Sep 2008 12:45:41 -0000 1.20 *************** *** 44,90 **** */ @SuppressWarnings("unchecked") ! public void run(IAction action) { ! try ! { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! String endLineDelim = ps.getEndLineDelim(); ! final IDocument doc = ps.getDoc(); ! DocumentRewriteSession session = null; ! ! try { ! if (ps.getStartLineIndex() == ps.getEndLineIndex()) { ! //let's see if someone wants to make a better implementation in another plugin... ! List<IOrganizeImports> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_ORGANIZE_IMPORTS); ! ! for (IOrganizeImports organizeImports : participants) { if(!organizeImports.beforePerformArrangeImports(ps, pyEdit)){ return; } } ! ! session = startWrite(doc); ! ! performArrangeImports(doc, endLineDelim, pyEdit.getIndentPrefs().getIndentationString()); ! ! for (IOrganizeImports organizeImports : participants) { ! organizeImports.afterPerformArrangeImports(ps, pyEdit); ! } ! } else { ! session = startWrite(doc); ! performSimpleSort(doc, endLineDelim, ps.getStartLineIndex(), ps.getEndLineIndex()); ! } ! } finally { ! if(session != null){ ! endWrite(doc, session); ! } ! } ! } ! catch ( Exception e ) ! { PydevPlugin.log(e); ! beep ( e ); ! } } --- 44,90 ---- */ @SuppressWarnings("unchecked") ! public void run(IAction action) { ! try ! { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! String endLineDelim = ps.getEndLineDelim(); ! final IDocument doc = ps.getDoc(); ! DocumentRewriteSession session = null; ! ! try { ! if (ps.getStartLineIndex() == ps.getEndLineIndex()) { ! //let's see if someone wants to make a better implementation in another plugin... ! List<IOrganizeImports> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_ORGANIZE_IMPORTS); ! ! for (IOrganizeImports organizeImports : participants) { if(!organizeImports.beforePerformArrangeImports(ps, pyEdit)){ return; } } ! ! session = startWrite(doc); ! ! performArrangeImports(doc, endLineDelim, pyEdit.getIndentPrefs().getIndentationString()); ! ! for (IOrganizeImports organizeImports : participants) { ! organizeImports.afterPerformArrangeImports(ps, pyEdit); ! } ! } else { ! session = startWrite(doc); ! performSimpleSort(doc, endLineDelim, ps.getStartLineIndex(), ps.getEndLineIndex()); ! } ! } finally { ! if(session != null){ ! endWrite(doc, session); ! } ! } ! } ! catch ( Exception e ) ! { PydevPlugin.log(e); ! beep ( e ); ! } } *************** *** 92,112 **** * Stop a rewrite session */ ! private void endWrite(IDocument doc, DocumentRewriteSession session) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! d.stopRewriteSession(session); ! } ! } ! /** ! * Starts a rewrite session (keep things in a single undo/redo) ! */ ! private DocumentRewriteSession startWrite(IDocument doc) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED); ! } ! return null; ! } /** --- 92,112 ---- * Stop a rewrite session */ ! private void endWrite(IDocument doc, DocumentRewriteSession session) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! d.stopRewriteSession(session); ! } ! } ! /** ! * Starts a rewrite session (keep things in a single undo/redo) ! */ ! private DocumentRewriteSession startWrite(IDocument doc) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED); ! } ! return null; ! } /** *************** *** 117,126 **** */ @SuppressWarnings("unchecked") ! public static void performArrangeImports(IDocument doc, String endLineDelim, String indentStr){ ! List<Tuple3<Integer, String, ImportHandle>> list = new ArrayList<Tuple3<Integer, String, ImportHandle>>(); ! //Gather imports in a structure we can work on. ! PyImportsHandling pyImportsHandling = new PyImportsHandling(doc); ! int firstImport = -1; ! for(ImportHandle imp:pyImportsHandling){ list.add( new Tuple3<Integer, String, ImportHandle>(imp.startFoundLine, imp.importFound, imp) ); --- 117,126 ---- */ @SuppressWarnings("unchecked") ! public static void performArrangeImports(IDocument doc, String endLineDelim, String indentStr){ ! List<Tuple3<Integer, String, ImportHandle>> list = new ArrayList<Tuple3<Integer, String, ImportHandle>>(); ! //Gather imports in a structure we can work on. ! PyImportsHandling pyImportsHandling = new PyImportsHandling(doc); ! int firstImport = -1; ! for(ImportHandle imp:pyImportsHandling){ list.add( new Tuple3<Integer, String, ImportHandle>(imp.startFoundLine, imp.importFound, imp) ); *************** *** 128,139 **** firstImport = imp.startFoundLine; } ! } ! ! //check if we had any import ! if(firstImport == -1){ ! return; ! } ! //sort in inverse order (for removal of the string of the document). Collections.sort(list, new Comparator<Tuple3<Integer, String, ImportHandle>>() { --- 128,139 ---- firstImport = imp.startFoundLine; } ! } ! ! //check if we had any import ! if(firstImport == -1){ ! return; ! } ! //sort in inverse order (for removal of the string of the document). Collections.sort(list, new Comparator<Tuple3<Integer, String, ImportHandle>>() { *************** *** 405,419 **** */ @SuppressWarnings("unchecked") ! public static void performSimpleSort(IDocument doc, String endLineDelim, int startLine, int endLine) { try { ! ArrayList<String> list = new ArrayList<String>(); ! ! StringBuffer lastLine = null; ! for (int i = startLine; i <= endLine; i++) { ! ! String line = PySelection.getLine(doc, i); ! if(lastLine != null){ ! int len = lastLine.length(); if(len > 0 && lastLine.charAt(len-1) == '\\'){ lastLine.append(endLineDelim); --- 405,419 ---- */ @SuppressWarnings("unchecked") ! public static void performSimpleSort(IDocument doc, String endLineDelim, int startLine, int endLine) { try { ! ArrayList<String> list = new ArrayList<String>(); ! ! StringBuffer lastLine = null; ! for (int i = startLine; i <= endLine; i++) { ! String line = PySelection.getLine(doc, i); ! ! if(lastLine != null){ ! int len = lastLine.length(); if(len > 0 && lastLine.charAt(len-1) == '\\'){ lastLine.append(endLineDelim); *************** *** 423,444 **** lastLine = new StringBuffer(line); } ! }else{ ! lastLine = new StringBuffer(line); ! } ! } ! ! if(lastLine != null){ ! list.add(lastLine.toString()); ! } ! ! Collections.sort(list); ! StringBuffer all = new StringBuffer(); ! for (Iterator iter = list.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! all.append(element); ! if(iter.hasNext()) ! all.append(endLineDelim); ! } ! int length = doc.getLineInformation(endLine).getLength(); int endOffset = doc.getLineInformation(endLine).getOffset()+length; --- 423,444 ---- lastLine = new StringBuffer(line); } ! }else{ ! lastLine = new StringBuffer(line); ! } ! } ! ! if(lastLine != null){ ! list.add(lastLine.toString()); ! } ! ! Collections.sort(list); ! StringBuffer all = new StringBuffer(); ! for (Iterator iter = list.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! all.append(element); ! if(iter.hasNext()) ! all.append(endLineDelim); ! } ! int length = doc.getLineInformation(endLine).getLength(); int endOffset = doc.getLineInformation(endLine).getOffset()+length; Index: PyFormatStd.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyFormatStd.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PyFormatStd.java 17 Aug 2008 00:26:46 -0000 1.21 --- PyFormatStd.java 28 Sep 2008 12:45:41 -0000 1.22 *************** *** 231,266 **** case '+': case '-': ! ! if(c == '-' || c == '+'){ // could also be * ! ! //handle exponentials correctly: e.g.: 1e-6 cannot have a space ! FastStringBuffer localBufToCheckNumber = new FastStringBuffer(); ! for(int j=buf.length()-1;j>=0;j--){ ! char localC = buf.charAt(j); ! if(Character.isJavaIdentifierPart(localC)){ ! localBufToCheckNumber.append(localC); ! }else{ ! break; ! } ! } ! boolean isExponential = true;; ! String partialNumber = localBufToCheckNumber.reverse().toString(); ! int partialLen = partialNumber.length(); ! if(partialLen < 2 || !Character.isDigit(partialNumber.charAt(0))){ ! //at least 2 chars: the number and the 'e' ! isExponential = false; ! }else{ ! //first char checked... now, if the last is an 'e', we must leave it together no matter what ! if(partialNumber.charAt(partialLen-1) != 'e'){ ! isExponential = false; ! break; ! } ! } ! if(isExponential){ ! buf.append(c); ! break; ! } ! //Otherwise, FALLTHROUGH ! } case '/': --- 231,266 ---- case '+': case '-': ! ! if(c == '-' || c == '+'){ // could also be * ! ! //handle exponentials correctly: e.g.: 1e-6 cannot have a space ! FastStringBuffer localBufToCheckNumber = new FastStringBuffer(); ! for(int j=buf.length()-1;j>=0;j--){ ! char localC = buf.charAt(j); ! if(Character.isJavaIdentifierPart(localC)){ ! localBufToCheckNumber.append(localC); ! }else{ ! break; ! } ! } ! boolean isExponential = true;; ! String partialNumber = localBufToCheckNumber.reverse().toString(); ! int partialLen = partialNumber.length(); ! if(partialLen < 2 || !Character.isDigit(partialNumber.charAt(0))){ ! //at least 2 chars: the number and the 'e' ! isExponential = false; ! }else{ ! //first char checked... now, if the last is an 'e', we must leave it together no matter what ! if(partialNumber.charAt(partialLen-1) != 'e'){ ! isExponential = false; ! break; ! } ! } ! if(isExponential){ ! buf.append(c); ! break; ! } ! //Otherwise, FALLTHROUGH ! } case '/': Index: OfflineActionTarget.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/OfflineActionTarget.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OfflineActionTarget.java 14 Jun 2008 22:14:55 -0000 1.7 --- OfflineActionTarget.java 28 Sep 2008 12:45:41 -0000 1.8 *************** *** 60,64 **** */ private boolean fIsStatusFieldExtension; ! private PyEdit fEdit; --- 60,64 ---- */ private boolean fIsStatusFieldExtension; ! private PyEdit fEdit; *************** *** 192,209 **** } else { ! switch (event.character) { // ESC = quit case 0x1B: ! leave(); ! event.doit= false; ! break; ! //CR = exec and quit case 0x0D: ! boolean executed = doExec(); event.doit= false; if(!executed){ ! return; //we don't want to update the status } break; --- 192,209 ---- } else { ! switch (event.character) { // ESC = quit case 0x1B: ! leave(); ! event.doit= false; ! break; ! //CR = exec and quit case 0x0D: ! boolean executed = doExec(); event.doit= false; if(!executed){ ! return; //we don't want to update the status } break; *************** *** 212,216 **** case 0x08: case 0x7F: ! removeLastCharSearch(); event.doit= false; break; --- 212,216 ---- case 0x08: case 0x7F: ! removeLastCharSearch(); event.doit= false; break; *************** *** 240,244 **** final boolean executed = fEdit.onOfflineAction(fFindString.toString(), this); if(executed){ ! leave(); } return executed; --- 240,244 ---- final boolean executed = fEdit.onOfflineAction(fFindString.toString(), this); if(executed){ ! leave(); } return executed; *************** *** 251,266 **** */ public void removeLastCharSearchAndUpdateStatus() { ! removeLastCharSearch(); ! updateStatus(); } private void removeLastCharSearch() { ! final int len = fFindString.length(); ! if(len > 0){ ! fFindString.deleteCharAt(len-1); ! } ! } ! /** * Adds the given character to the search string and repeats the search with the last parameters. * --- 251,266 ---- */ public void removeLastCharSearchAndUpdateStatus() { ! removeLastCharSearch(); ! updateStatus(); } private void removeLastCharSearch() { ! final int len = fFindString.length(); ! if(len > 0){ ! fFindString.deleteCharAt(len-1); ! } ! } ! /** * Adds the given character to the search string and repeats the search with the last parameters. * *************** *** 426,431 **** ! public boolean isInstalled() { ! return fInstalled; ! } } --- 426,431 ---- ! public boolean isInstalled() { ! return fInstalled; ! } } Index: PyBackspace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyBackspace.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyBackspace.java 19 Mar 2008 02:22:30 -0000 1.19 --- PyBackspace.java 28 Sep 2008 12:45:41 -0000 1.20 *************** *** 122,132 **** */ public void run(IAction action) { ! OfflineActionTarget adapter = (OfflineActionTarget) getPyEdit().getAdapter(OfflineActionTarget.class); ! if(adapter != null){ ! if(adapter.isInstalled()){ ! adapter.removeLastCharSearchAndUpdateStatus(); ! return; ! } ! } PySelection ps = new PySelection(getTextEditor()); perform(ps); --- 122,132 ---- */ public void run(IAction action) { ! OfflineActionTarget adapter = (OfflineActionTarget) getPyEdit().getAdapter(OfflineActionTarget.class); ! if(adapter != null){ ! if(adapter.isInstalled()){ ! adapter.removeLastCharSearchAndUpdateStatus(); ! return; ! } ! } PySelection ps = new PySelection(getTextEditor()); perform(ps); *************** *** 150,157 **** // |a (delete to previous indentation - considers cursor position) // ! //or ! // // as | as (delete single char) ! // //so, we have to treat it carefully //TODO: use the conditions above and not just erase a single --- 150,157 ---- // |a (delete to previous indentation - considers cursor position) // ! //or ! // // as | as (delete single char) ! // //so, we have to treat it carefully //TODO: use the conditions above and not just erase a single *************** *** 159,167 **** if(PySelection.containsOnlyWhitespaces(lineContentsToCursor)){ ! eraseToIndentation(ps, lineContentsToCursor); ! ! }else{ ! eraseSingleChar(ps); ! } } } --- 159,167 ---- if(PySelection.containsOnlyWhitespaces(lineContentsToCursor)){ ! eraseToIndentation(ps, lineContentsToCursor); ! ! }else{ ! eraseSingleChar(ps); ! } } } Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PyAction.java 15 Jun 2008 16:45:26 -0000 1.37 --- PyAction.java 28 Sep 2008 12:45:41 -0000 1.38 *************** *** 47,215 **** ! // Always points to the current editor ! protected volatile IEditorPart targetEditor; ! public void setEditor(IEditorPart targetEditor) { ! this.targetEditor = targetEditor; ! } ! ! /** ! * This is an IEditorActionDelegate override ! */ ! public void setActiveEditor(IAction action, IEditorPart targetEditor) { ! setEditor(targetEditor); ! } ! /** ! * Activate action (if we are getting text) ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! action.setEnabled(true); ! } ! public static String getDelimiter(IDocument doc){ ! return PySelection.getDelimiter(doc); ! } ! ! /** ! * This function returns the text editor. ! */ ! protected ITextEditor getTextEditor() { ! if (targetEditor instanceof ITextEditor) { ! return (ITextEditor) targetEditor; ! } else { ! throw new RuntimeException("Expecting text editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! /** ! * @return python editor. ! */ ! protected PyEdit getPyEdit() { ! if (targetEditor instanceof PyEdit) { ! return (PyEdit) targetEditor; ! } else { ! throw new RuntimeException("Expecting PyEdit editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! ! /** ! * Helper for setting caret ! * @param pos ! * @throws BadLocationException ! */ ! protected void setCaretPosition(int pos) throws BadLocationException { ! getTextEditor().selectAndReveal(pos, 0); ! } ! /** ! * Are we in the first char of the line with the offset passed? ! * @param doc ! * @param cursorOffset ! */ ! protected void isInFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! if ("".equals(src)) ! return; ! int i = 0; ! while (i < src.length()) { ! if (!Character.isWhitespace(src.charAt(i))) { ! break; ! } ! i++; ! } ! setCaretPosition(offset + i - 1); ! } catch (BadLocationException e) { ! beep(e); ! return; ! } ! } ! /** ! * Returns the position of the last non whitespace char in the current line. ! * @param doc ! * @param cursorOffset ! * @return position of the last character of the line (returned as an absolute ! * offset) ! * ! * @throws BadLocationException ! */ ! protected int getLastCharPosition(IDocument doc, int cursorOffset) ! throws BadLocationException { ! IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! int i = src.length(); ! boolean breaked = false; ! while (i > 0 ) { ! i--; ! //we have to break if we find a character that is not a whitespace or a tab. ! if ( Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t' ) { ! breaked = true; ! break; ! } ! } ! if (!breaked){ ! i--; ! } ! return (offset + i); ! } ! /** ! * Goes to first char of the line. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! setCaretPosition(offset); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! setCaretPosition(PySelection.getFirstCharPosition(doc, cursorOffset)); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected boolean isAtFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! return PySelection.getFirstCharPosition(doc, cursorOffset) == cursorOffset; ! } catch (BadLocationException e) { ! return false; ! } ! } ! //================================================================ ! // HELPER FOR DEBBUGING... ! //================================================================ ! /* ! * Beep...humm... yeah....beep....ehehheheh ! */ ! protected static void beep(Exception e) { try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); --- 47,215 ---- ! // Always points to the current editor ! protected volatile IEditorPart targetEditor; ! public void setEditor(IEditorPart targetEditor) { ! this.targetEditor = targetEditor; ! } ! ! /** ! * This is an IEditorActionDelegate override ! */ ! public void setActiveEditor(IAction action, IEditorPart targetEditor) { ! setEditor(targetEditor); ! } ! /** ! * Activate action (if we are getting text) ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! action.setEnabled(true); ! } ! public static String getDelimiter(IDocument doc){ ! return PySelection.getDelimiter(doc); ! } ! ! /** ! * This function returns the text editor. ! */ ! protected ITextEditor getTextEditor() { ! if (targetEditor instanceof ITextEditor) { ! return (ITextEditor) targetEditor; ! } else { ! throw new RuntimeException("Expecting text editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! /** ! * @return python editor. ! */ ! protected PyEdit getPyEdit() { ! if (targetEditor instanceof PyEdit) { ! return (PyEdit) targetEditor; ! } else { ! throw new RuntimeException("Expecting PyEdit editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! ! /** ! * Helper for setting caret ! * @param pos ! * @throws BadLocationException ! */ ! protected void setCaretPosition(int pos) throws BadLocationException { ! getTextEditor().selectAndReveal(pos, 0); ! } ! /** ! * Are we in the first char of the line with the offset passed? ! * @param doc ! * @param cursorOffset ! */ ! protected void isInFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! if ("".equals(src)) ! return; ! int i = 0; ! while (i < src.length()) { ! if (!Character.isWhitespace(src.charAt(i))) { ! break; ! } ! i++; ! } ! setCaretPosition(offset + i - 1); ! } catch (BadLocationException e) { ! beep(e); ! return; ! } ! } ! /** ! * Returns the position of the last non whitespace char in the current line. ! * @param doc ! * @param cursorOffset ! * @return position of the last character of the line (returned as an absolute ! * offset) ! * ! * @throws BadLocationException ! */ ! protected int getLastCharPosition(IDocument doc, int cursorOffset) ! throws BadLocationException { ! IRegion region; ! region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! int i = src.length(); ! boolean breaked = false; ! while (i > 0 ) { ! i--; ! //we have to break if we find a character that is not a whitespace or a tab. ! if ( Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t' ) { ! breaked = true; ! break; ! } ! } ! if (!breaked){ ! i--; ! } ! return (offset + i); ! } ! /** ! * Goes to first char of the line. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! setCaretPosition(offset); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! setCaretPosition(PySelection.getFirstCharPosition(doc, cursorOffset)); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected boolean isAtFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! return PySelection.getFirstCharPosition(doc, cursorOffset) == cursorOffset; ! } catch (BadLocationException e) { ! return false; ! } ! } ! //================================================================ ! // HELPER FOR DEBBUGING... ! //================================================================ ! /* ! * Beep...humm... yeah....beep....ehehheheh ! */ ! protected static void beep(Exception e) { try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); *************** *** 217,222 **** //ignore, workbench has still not been created } ! e.printStackTrace(); ! } --- 217,222 ---- //ignore, workbench has still not been created } ! e.printStackTrace(); ! } *************** *** 244,255 **** */ public static int countChars(char c, String line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } --- 244,255 ---- */ public static int countChars(char c, String line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } *************** *** 262,273 **** */ public static int countChars(char c, StringBuffer line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } --- 262,273 ---- */ public static int countChars(char c, StringBuffer line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } Index: FirstCharAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/FirstCharAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FirstCharAction.java 28 Feb 2004 05:13:16 -0000 1.1 --- FirstCharAction.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 15,33 **** */ public void run(IAction action) { ! ! try{ ! ITextEditor textEditor = getTextEditor(); ! IDocument doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); ! ITextSelection selection = (ITextSelection)textEditor.getSelectionProvider().getSelection(); ! ! boolean isAtFirstChar = isAtFirstVisibleChar(doc, selection.getOffset()); ! if (! isAtFirstChar){ ! gotoFirstVisibleChar(doc, selection.getOffset()); ! }else{ ! gotoFirstChar(doc, selection.getOffset()); ! } ! }catch(Exception e){ ! beep(e); ! } } } \ No newline at end of file --- 15,33 ---- */ public void run(IAction action) { ! ! try{ ! ITextEditor textEditor = getTextEditor(); ! IDocument doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); ! ITextSelection selection = (ITextSelection)textEditor.getSelectionProvider().getSelection(); ! ! boolean isAtFirstChar = isAtFirstVisibleChar(doc, selection.getOffset()); ! if (! isAtFirstChar){ ! gotoFirstVisibleChar(doc, selection.getOffset()); ! }else{ ! gotoFirstChar(doc, selection.getOffset()); ! } ! }catch(Exception e){ ! beep(e); ! } } } \ No newline at end of file Index: PyGoToDefinition.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyGoToDefinition.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PyGoToDefinition.java 11 Jan 2008 01:01:18 -0000 1.28 --- PyGoToDefinition.java 28 Sep 2008 12:45:41 -0000 1.29 *************** *** 66,70 **** pyRefactoring.checkAvailableForRefactoring(request); } catch (Exception e) { ! e.printStackTrace(); ErrorDialog.openError(null, "Error", "Unable to do requested action", new Status(Status.ERROR, PydevPlugin.getPluginID(), 0, e.getMessage(), null)); --- 66,70 ---- pyRefactoring.checkAvailableForRefactoring(request); } catch (Exception e) { ! e.printStackTrace(); ErrorDialog.openError(null, "Error", "Unable to do requested action", new Status(Status.ERROR, PydevPlugin.getPluginID(), 0, e.getMessage(), null)); *************** *** 73,77 **** if (request.pyEdit.isDirty()) ! request.pyEdit.doSave(null); return true; --- 73,77 ---- if (request.pyEdit.isDirty()) ! request.pyEdit.doSave(null); return true; *************** *** 88,92 **** public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) { ! request = null; final Shell shell = getShell(); try { --- 88,92 ---- public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) { ! request = null; final Shell shell = getShell(); try { *************** *** 103,107 **** } catch (Exception e) { e.printStackTrace(); ! PydevPlugin.log(e); String msg = e.getMessage(); if(msg == null){ --- 103,107 ---- } catch (Exception e) { e.printStackTrace(); ! PydevPlugin.log(e); String msg = e.getMessage(); if(msg == null){ |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:17
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor Modified Files: PyCodeScanner.java PyEditConfiguration.java IPyEditListener.java PyColoredScanner.java PyEdit.java PyEditNotifier.java PyDoubleClickStrategy.java Added Files: IPyEditListener3.java Removed Files: ErrorDescription.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: PyEditNotifier.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditNotifier.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyEditNotifier.java 17 Jan 2007 16:26:13 -0000 1.4 --- PyEditNotifier.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 8,106 **** import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.text.IDocument; import org.python.pydev.editor.PyEdit.MyResources; import org.python.pydev.plugin.PydevPlugin; public class PyEditNotifier { ! ! private WeakReference<PyEdit> pyEdit; ! public static interface INotifierRunnable{ ! public void run(IProgressMonitor monitor); ! } ! ! public PyEditNotifier(PyEdit edit){ ! this.pyEdit = new WeakReference<PyEdit>(edit); ! } ! public void notifyOnCreateActions(final MyResources resources) { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(final IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onCreateActions(resources, edit, monitor); ! } ! } catch (Exception e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); } public void notifyOnSave() { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onSave(edit, monitor); ! } ! } catch (Throwable e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); } ! private void runIt(final INotifierRunnable runnable) { ! Job job = new Job("PyEditNotifier"){ ! @Override ! protected IStatus run(IProgressMonitor monitor) { ! runnable.run(monitor); ! return Status.OK_STATUS; ! } ! ! }; ! job.setPriority(Job.BUILD); ! job.setSystem(true); ! job.schedule(); ! } public void notifyOnDispose() { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onDispose(edit, monitor); ! } ! } catch (Throwable e) { ! //no need to worry... as we're disposing, in shutdown, we may not have access to some classes anymore ! } ! } ! } ! }; ! runIt(runnable); } --- 8,126 ---- import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.text.IDocument; + import org.eclipse.ui.IEditorInput; import org.python.pydev.editor.PyEdit.MyResources; import org.python.pydev.plugin.PydevPlugin; + /** + * Helper to give notifications for the listeners of the editor. + * + * @author Fabio + */ public class PyEditNotifier { ! ! private WeakReference<PyEdit> pyEdit; ! public static interface INotifierRunnable{ ! public void run(IProgressMonitor monitor); ! } ! ! public PyEditNotifier(PyEdit edit){ ! this.pyEdit = new WeakReference<PyEdit>(edit); ! } ! ! /** ! * Notifies listeners that the actions have just been created in the editor. ! */ public void notifyOnCreateActions(final MyResources resources) { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(final IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onCreateActions(resources, edit, monitor); ! } ! } catch (Exception e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); } + /** + * Notifies listeners that the editor has just been saved + */ public void notifyOnSave() { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onSave(edit, monitor); ! } ! } catch (Throwable e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); } ! /** ! * Helper function to run the notifications of the editor in a job. ! * ! * @param runnable the runnable to be run. ! */ ! private void runIt(final INotifierRunnable runnable) { ! Job job = new Job("PyEditNotifier"){ ! @Override ! protected IStatus run(IProgressMonitor monitor) { ! runnable.run(monitor); ! return Status.OK_STATUS; ! } ! ! }; ! job.setPriority(Job.SHORT); ! job.setSystem(true); ! job.schedule(); ! } + /** + * Notifies listeners that the editor has just been disposed + */ public void notifyOnDispose() { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onDispose(edit, monitor); ! } ! } catch (Throwable e) { ! //no need to worry... as we're disposing, in shutdown, we may not have access to some classes anymore ! } ! } ! } ! }; ! runIt(runnable); } *************** *** 109,131 **** */ public void notifyOnSetDocument(final IDocument document) { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onSetDocument(document, edit, monitor); ! } ! } catch (Exception e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); } --- 129,182 ---- */ public void notifyOnSetDocument(final IDocument document) { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! try { ! if(!monitor.isCanceled()){ ! listener.onSetDocument(document, edit, monitor); ! } ! } catch (Exception e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! }; ! runIt(runnable); ! } ! ! /** ! * Notifies the available listeners that the input has changed for the editor. ! * ! * @param oldInput the old input of the editor ! * @param input the new input of the editor ! */ ! public void notifyInputChanged(final IEditorInput oldInput, final IEditorInput input) { ! final PyEdit edit = pyEdit.get(); ! if(edit == null){ ! return; ! } ! INotifierRunnable runnable = new INotifierRunnable(){ ! public void run(IProgressMonitor monitor){ ! for(IPyEditListener listener : edit.getAllListeners()){ ! if(listener instanceof IPyEditListener3){ ! IPyEditListener3 pyEditListener3 = (IPyEditListener3) listener; ! try { ! if(!monitor.isCanceled()){ ! pyEditListener3.onInputChanged(edit, oldInput, input, monitor); ! } ! } catch (Exception e) { ! //must not fail ! PydevPlugin.log(e); ! } ! } ! } ! } ! }; ! runIt(runnable); } Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** PyEditConfiguration.java 14 Jun 2008 22:14:55 -0000 1.58 --- PyEditConfiguration.java 28 Sep 2008 12:45:40 -0000 1.59 *************** *** 115,120 **** public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IPythonPartitions.PY_COMMENT, ! IPythonPartitions.PY_SINGLELINE_STRING1, IPythonPartitions.PY_SINGLELINE_STRING2, ! IPythonPartitions.PY_MULTILINE_STRING1, IPythonPartitions.PY_MULTILINE_STRING2 }; } --- 115,120 ---- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IPythonPartitions.PY_COMMENT, ! IPythonPartitions.PY_SINGLELINE_STRING1, IPythonPartitions.PY_SINGLELINE_STRING2, ! IPythonPartitions.PY_MULTILINE_STRING1, IPythonPartitions.PY_MULTILINE_STRING2 }; } *************** *** 281,287 **** */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ! // next create a content assistant processor to populate the completions window IContentAssistProcessor processor = new SimpleAssistProcessor(edit, ! new PythonCompletionProcessor(edit, pyContentAssistant), pyContentAssistant); PythonStringCompletionProcessor stringProcessor = new PythonStringCompletionProcessor(edit, pyContentAssistant); --- 281,287 ---- */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ! // next create a content assistant processor to populate the completions window IContentAssistProcessor processor = new SimpleAssistProcessor(edit, ! new PythonCompletionProcessor(edit, pyContentAssistant), pyContentAssistant); PythonStringCompletionProcessor stringProcessor = new PythonStringCompletionProcessor(edit, pyContentAssistant); Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** PyEdit.java 21 Aug 2008 20:56:28 -0000 1.134 --- PyEdit.java 28 Sep 2008 12:45:40 -0000 1.135 *************** *** 10,14 **** import org.eclipse.core.resources.IFile; - import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; --- 10,13 ---- *************** *** 59,63 **** import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; [...1015 lines suppressed...] */ ! public Font getFont(FontData descriptor) { ! Font font = getResourceManager().createFont(FontDescriptor.createFrom(descriptor)); ! ! // Old implementation (for Eclipse 3.3) // Font font = (Font) SWTResourceUtil.getFontTable().get(descriptor); // if (font == null) { *************** *** 1220,1224 **** return font; } ! //--------------------------------------------------------------------- END: actions that are activated after Ctrl+2 --- 1155,1159 ---- return font; } ! //--------------------------------------------------------------------- END: actions that are activated after Ctrl+2 --- NEW FILE: IPyEditListener3.java --- /* * Created on Apr 30, 2006 */ package org.python.pydev.editor; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ui.IEditorInput; /** * Used if the interface also wants to be notified of input changes. * * This is an extension to the IPyEditListener */ public interface IPyEditListener3 { /** * Called when the input of the editor is changed. * * @param edit the editor that had the input changed * @param oldInput the old input of the editor * @param input the new input of the editor * @param monitor the monitor for the job that's making the notifications */ void onInputChanged(PyEdit edit, IEditorInput oldInput, IEditorInput input, IProgressMonitor monitor); } Index: PyColoredScanner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyColoredScanner.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyColoredScanner.java 30 Aug 2005 14:19:38 -0000 1.2 --- PyColoredScanner.java 28 Sep 2008 12:45:40 -0000 1.3 *************** *** 18,40 **** */ public class PyColoredScanner extends RuleBasedScanner { ! private ColorCache colorCache; ! private String colorName; ! private int style; ! ! public PyColoredScanner(ColorCache colorCache, String colorName, int style) { ! super(); ! this.colorCache = colorCache; ! this.colorName = colorName; ! this.style = style; ! updateColorAndStyle(); ! } public void setStyle(int style){ this.style = style; } ! ! public void updateColorAndStyle() { ! setDefaultReturnToken(new Token(new TextAttribute(colorCache.getNamedColor(colorName), null, style))); ! } --- 18,40 ---- */ public class PyColoredScanner extends RuleBasedScanner { ! private ColorCache colorCache; ! private String colorName; ! private int style; ! ! public PyColoredScanner(ColorCache colorCache, String colorName, int style) { ! super(); ! this.colorCache = colorCache; ! this.colorName = colorName; ! this.style = style; ! updateColorAndStyle(); ! } public void setStyle(int style){ this.style = style; } ! ! public void updateColorAndStyle() { ! setDefaultReturnToken(new Token(new TextAttribute(colorCache.getNamedColor(colorName), null, style))); ! } Index: PyDoubleClickStrategy.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyDoubleClickStrategy.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyDoubleClickStrategy.java 26 May 2006 13:41:32 -0000 1.7 --- PyDoubleClickStrategy.java 28 Sep 2008 12:45:41 -0000 1.8 *************** *** 19,83 **** public class PyDoubleClickStrategy implements ITextDoubleClickStrategy { ! protected PythonPairMatcher fPairMatcher = new PythonPairMatcher(DocUtils.BRACKETS); ! /** ! * @see ITextDoubleClickStrategy#doubleClicked ! */ ! public void doubleClicked(ITextViewer textViewer) { ! int offset = textViewer.getSelectedRange().x; ! if (offset < 0) ! return; ! IDocument document = textViewer.getDocument(); ! IRegion region = fPairMatcher.match(document, offset); ! if (region != null && region.getLength() >= 2){ ! textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2); ! }else{ ! selectWord(textViewer, document, offset); ! } ! } ! protected void selectWord(ITextViewer textViewer, IDocument document, int anchor) { ! try { ! int offset = anchor; ! char c; ! while (offset >= 0) { ! c = document.getChar(offset); ! if (!Character.isJavaIdentifierPart(c)){ ! break; ! } ! ! --offset; ! } ! int start = offset; ! offset = anchor; ! int length = document.getLength(); ! while (offset < length) { ! c = document.getChar(offset); ! if (!Character.isJavaIdentifierPart(c)){ ! break; ! } ! ++offset; ! } ! int end = offset; ! if (start == end){ ! textViewer.setSelectedRange(start, 0); ! }else{ ! textViewer.setSelectedRange(start + 1, end - start - 1); ! } ! } catch (BadLocationException x) { ! } ! } } --- 19,83 ---- public class PyDoubleClickStrategy implements ITextDoubleClickStrategy { ! protected PythonPairMatcher fPairMatcher = new PythonPairMatcher(DocUtils.BRACKETS); ! /** ! * @see ITextDoubleClickStrategy#doubleClicked ! */ ! public void doubleClicked(ITextViewer textViewer) { ! int offset = textViewer.getSelectedRange().x; ! if (offset < 0) ! return; ! IDocument document = textViewer.getDocument(); ! IRegion region = fPairMatcher.match(document, offset); ! if (region != null && region.getLength() >= 2){ ! textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2); ! }else{ ! selectWord(textViewer, document, offset); ! } ! } ! protected void selectWord(ITextViewer textViewer, IDocument document, int anchor) { ! try { ! int offset = anchor; ! char c; ! while (offset >= 0) { ! c = document.getChar(offset); ! if (!Character.isJavaIdentifierPart(c)){ ! break; ! } ! ! --offset; ! } ! int start = offset; ! offset = anchor; ! int length = document.getLength(); ! while (offset < length) { ! c = document.getChar(offset); ! if (!Character.isJavaIdentifierPart(c)){ ! break; ! } ! ++offset; ! } ! int end = offset; ! if (start == end){ ! textViewer.setSelectedRange(start, 0); ! }else{ ! textViewer.setSelectedRange(start + 1, end - start - 1); ! } ! } catch (BadLocationException x) { ! } ! } } Index: PyCodeScanner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyCodeScanner.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyCodeScanner.java 14 Jun 2008 22:14:55 -0000 1.10 --- PyCodeScanner.java 28 Sep 2008 12:45:40 -0000 1.11 *************** *** 33,37 **** */ public class PyCodeScanner extends RuleBasedScanner { ! // keywords list has to be alphabetized for the keyword detector to work properly static final public String[] KEYWORDS = { --- 33,37 ---- */ public class PyCodeScanner extends RuleBasedScanner { ! // keywords list has to be alphabetized for the keyword detector to work properly static final public String[] KEYWORDS = { *************** *** 56,88 **** ! /** ! * Whitespace detector. ! * ! * I know, naming the class after a band that burned ! * is not funny, but I've got to get my brain off my ! * annoyance with the abstractions of JFace. ! * So many classes and interfaces for a single method? ! * f$%@#$!! ! */ ! static private class GreatWhite implements IWhitespaceDetector { ! public boolean isWhitespace(char c) {return Character.isWhitespace(c);} ! } ! ! /** ! * Python keyword detector ! */ ! static private class GreatKeywordDetector implements IWordDetector { ! public GreatKeywordDetector() { ! } ! public boolean isWordStart(char c) { ! return Character.isJavaIdentifierStart(c); ! } ! public boolean isWordPart(char c) { ! return Character.isJavaIdentifierPart(c); ! } ! } ! ! static private class DecoratorDetector implements IWordDetector{ /** --- 56,88 ---- ! /** ! * Whitespace detector. ! * ! * I know, naming the class after a band that burned ! * is not funny, but I've got to get my brain off my ! * annoyance with the abstractions of JFace. ! * So many classes and interfaces for a single method? ! * f$%@#$!! ! */ ! static private class GreatWhite implements IWhitespaceDetector { ! public boolean isWhitespace(char c) {return Character.isWhitespace(c);} ! } ! ! /** ! * Python keyword detector ! */ ! static private class GreatKeywordDetector implements IWordDetector { ! public GreatKeywordDetector() { ! } ! public boolean isWordStart(char c) { ! return Character.isJavaIdentifierStart(c); ! } ! public boolean isWordPart(char c) { ! return Character.isJavaIdentifierPart(c); ! } ! } ! ! static private class DecoratorDetector implements IWordDetector{ /** *************** *** 97,106 **** */ public boolean isWordPart(char c) { ! return c != '\n' && c != '\r' && c != '('; } ! ! } ! ! static public class NumberDetector implements IWordDetector{ /** --- 97,106 ---- */ public boolean isWordPart(char c) { ! return c != '\n' && c != '\r' && c != '('; } ! ! } ! ! static public class NumberDetector implements IWordDetector{ /** *************** *** 151,188 **** } } ! ! } ! ! public PyCodeScanner(ColorCache colorCache) { ! super(); ! this.colorCache = colorCache; ! ! setupRules(); ! } ! ! public void updateColors() { ! setupRules(); ! } ! private void setupRules() { ! IPreferenceStore preferences = PydevPlugin.getChainedPrefStore(); ! keywordToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.KEYWORD_COLOR), null, preferences.getInt(PydevPrefs.KEYWORD_STYLE))); ! selfToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.SELF_COLOR), null, preferences.getInt(PydevPrefs.SELF_STYLE))); ! defaultToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.CODE_COLOR), null, preferences.getInt(PydevPrefs.CODE_STYLE))); ! decoratorToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.DECORATOR_COLOR), null, preferences.getInt(PydevPrefs.DECORATOR_STYLE))); ! numberToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.NUMBER_COLOR), null, preferences.getInt(PydevPrefs.NUMBER_STYLE))); ! classNameToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.CLASS_NAME_COLOR), null, preferences.getInt(PydevPrefs.CLASS_NAME_STYLE))); ! funcNameToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.FUNC_NAME_COLOR), null, preferences.getInt(PydevPrefs.FUNC_NAME_STYLE))); ! ! setDefaultReturnToken(defaultToken); ! List<IRule> rules = new ArrayList<IRule>(); ! ! // Scanning strategy: ! // 1) whitespace ! // 2) code ! // 3) regular words? ! ! rules.add(new WhitespaceRule(new GreatWhite())); ! Map<String,IToken> defaults = new HashMap<String, IToken>(); defaults.put("self", selfToken); --- 151,188 ---- } } ! ! } ! ! public PyCodeScanner(ColorCache colorCache) { ! super(); ! this.colorCache = colorCache; ! ! setupRules(); ! } ! ! public void updateColors() { ! setupRules(); ! } ! private void setupRules() { ! IPreferenceStore preferences = PydevPlugin.getChainedPrefStore(); ! keywordToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.KEYWORD_COLOR), null, preferences.getInt(PydevPrefs.KEYWORD_STYLE))); ! selfToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.SELF_COLOR), null, preferences.getInt(PydevPrefs.SELF_STYLE))); ! defaultToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.CODE_COLOR), null, preferences.getInt(PydevPrefs.CODE_STYLE))); ! decoratorToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.DECORATOR_COLOR), null, preferences.getInt(PydevPrefs.DECORATOR_STYLE))); ! numberToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.NUMBER_COLOR), null, preferences.getInt(PydevPrefs.NUMBER_STYLE))); ! classNameToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.CLASS_NAME_COLOR), null, preferences.getInt(PydevPrefs.CLASS_NAME_STYLE))); ! funcNameToken = new Token( new TextAttribute(colorCache.getNamedColor(PydevPrefs.FUNC_NAME_COLOR), null, preferences.getInt(PydevPrefs.FUNC_NAME_STYLE))); ! ! setDefaultReturnToken(defaultToken); ! List<IRule> rules = new ArrayList<IRule>(); ! ! // Scanning strategy: ! // 1) whitespace ! // 2) code ! // 3) regular words? ! ! rules.add(new WhitespaceRule(new GreatWhite())); ! Map<String,IToken> defaults = new HashMap<String, IToken>(); defaults.put("self", selfToken); *************** *** 194,206 **** token = keywordToken; } ! wordRule.addWord( keyword, token); ! } ! rules.add(wordRule); ! rules.add(new WordRule(new DecoratorDetector(), decoratorToken)); ! rules.add(new WordRule(new NumberDetector(), numberToken)); ! ! setRules(rules.toArray(new IRule[0])); ! } } --- 194,206 ---- token = keywordToken; } ! wordRule.addWord( keyword, token); ! } ! rules.add(wordRule); ! rules.add(new WordRule(new DecoratorDetector(), decoratorToken)); ! rules.add(new WordRule(new NumberDetector(), numberToken)); ! ! setRules(rules.toArray(new IRule[0])); ! } } --- ErrorDescription.java DELETED --- Index: IPyEditListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/IPyEditListener.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IPyEditListener.java 17 Jan 2007 16:26:13 -0000 1.4 --- IPyEditListener.java 28 Sep 2008 12:45:40 -0000 1.5 *************** *** 9,17 **** public interface IPyEditListener { ! /** ! * Anytime a PyEdit is saved, it will notify that to its listeners. ! * @param edit the PyEdit that has just been saved. ! */ ! void onSave(PyEdit edit, IProgressMonitor monitor); /** --- 9,17 ---- public interface IPyEditListener { ! /** ! * Anytime a PyEdit is saved, it will notify that to its listeners. ! * @param edit the PyEdit that has just been saved. ! */ ! void onSave(PyEdit edit, IProgressMonitor monitor); /** *************** *** 28,31 **** --- 28,38 ---- void onDispose(PyEdit edit, IProgressMonitor monitor); + /** + * Use to notify listeners that the document that the editor was editing has just changed. + * + * @param document the document being edited + * @param edit the editor that had the document changed + * @param monitor the monitor for the change + */ void onSetDocument(IDocument document, PyEdit edit, IProgressMonitor monitor); } |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/plugin/nature Modified Files: PythonNatureStore.java PythonNature.java SystemPythonNature.java PythonPathNature.java AbstractPythonNature.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: SystemPythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/SystemPythonNature.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SystemPythonNature.java 2 May 2008 23:24:14 -0000 1.12 --- SystemPythonNature.java 28 Sep 2008 12:45:40 -0000 1.13 *************** *** 19,110 **** public class SystemPythonNature extends AbstractPythonNature implements IPythonNature{ ! private IInterpreterManager manager; ! private SystemASTManager systemASTManager; ! public SystemPythonNature(IInterpreterManager manager){ ! this.manager = manager; ! } ! public String getVersion() throws CoreException { ! if(this.manager.isPython()){ ! return IPythonNature.PYTHON_VERSION_LATEST; ! }else if(this.manager.isJython()){ ! return IPythonNature.JYTHON_VERSION_LATEST; ! }else{ ! throw new RuntimeException("Not python nor jython?"); ! } ! } ! public String getDefaultVersion() { ! try { return getVersion(); } catch (CoreException e) { throw new RuntimeException(e); } ! } ! public void setVersion(String version) throws CoreException { ! throw new RuntimeException("Not Implemented: the system nature is read-only."); ! } ! public boolean isJython() throws CoreException { ! return manager.isJython(); ! } ! public boolean isPython() throws CoreException { ! return manager.isPython(); ! } ! public int getRelatedId() throws CoreException { ! return PythonNature.getRelatedId(this); ! } ! public File getCompletionsCacheDir() { ! throw new RuntimeException("Not Implemented"); ! } ! public void saveAstManager() { ! throw new RuntimeException("Not Implemented: system nature is only transient."); ! } ! public IPythonPathNature getPythonPathNature() { ! throw new RuntimeException("Not Implemented"); ! } ! public String resolveModule(String file) { ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); if(info == null){ return null; } ! return info.getModulesManager().resolveModule(file); ! } ! public ICodeCompletionASTManager getAstManager() { ! if(systemASTManager == null){ ! systemASTManager = new SystemASTManager(this.manager, this); ! } ! return systemASTManager; ! } ! public void configure() throws CoreException { ! } ! public void deconfigure() throws CoreException { ! } ! public IProject getProject() { ! return null; ! } ! public void setProject(IProject project) { ! } ! public void rebuildPath() { ! throw new RuntimeException("Not Implemented"); ! } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! throw new RuntimeException("Not Implemented"); ! } public IInterpreterManager getRelatedInterpreterManager() { --- 19,110 ---- public class SystemPythonNature extends AbstractPythonNature implements IPythonNature{ ! private IInterpreterManager manager; ! private SystemASTManager systemASTManager; ! public SystemPythonNature(IInterpreterManager manager){ ! this.manager = manager; ! } ! public String getVersion() throws CoreException { ! if(this.manager.isPython()){ ! return IPythonNature.PYTHON_VERSION_LATEST; ! }else if(this.manager.isJython()){ ! return IPythonNature.JYTHON_VERSION_LATEST; ! }else{ ! throw new RuntimeException("Not python nor jython?"); ! } ! } ! public String getDefaultVersion() { ! try { return getVersion(); } catch (CoreException e) { throw new RuntimeException(e); } ! } ! public void setVersion(String version) throws CoreException { ! throw new RuntimeException("Not Implemented: the system nature is read-only."); ! } ! public boolean isJython() throws CoreException { ! return manager.isJython(); ! } ! public boolean isPython() throws CoreException { ! return manager.isPython(); ! } ! public int getRelatedId() throws CoreException { ! return PythonNature.getRelatedId(this); ! } ! public File getCompletionsCacheDir() { ! throw new RuntimeException("Not Implemented"); ! } ! public void saveAstManager() { ! throw new RuntimeException("Not Implemented: system nature is only transient."); ! } ! public IPythonPathNature getPythonPathNature() { ! throw new RuntimeException("Not Implemented"); ! } ! public String resolveModule(String file) { ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); if(info == null){ return null; } ! return info.getModulesManager().resolveModule(file); ! } ! public ICodeCompletionASTManager getAstManager() { ! if(systemASTManager == null){ ! systemASTManager = new SystemASTManager(this.manager, this); ! } ! return systemASTManager; ! } ! public void configure() throws CoreException { ! } ! public void deconfigure() throws CoreException { ! } ! public IProject getProject() { ! return null; ! } ! public void setProject(IProject project) { ! } ! public void rebuildPath() { ! throw new RuntimeException("Not Implemented"); ! } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! throw new RuntimeException("Not Implemented"); ! } public IInterpreterManager getRelatedInterpreterManager() { *************** *** 116,140 **** private IToken[] builtinCompletions; ! public IToken[] getBuiltinCompletions() { ! return builtinCompletions; ! } ! public void setBuiltinCompletions(IToken[] toks) { ! this.builtinCompletions = toks; ! } ! ! ! //builtin mod ! private IModule builtinMod; ! public IModule getBuiltinMod() { ! return builtinMod; ! } ! public void setBuiltinMod(IModule mod) { ! this.builtinMod = mod; ! } ! public int getGrammarVersion() { IInterpreterInfo info = manager.getDefaultInterpreterInfo(new NullProgressMonitor()); --- 116,140 ---- private IToken[] builtinCompletions; ! public IToken[] getBuiltinCompletions() { ! return builtinCompletions; ! } ! public void setBuiltinCompletions(IToken[] toks) { ! this.builtinCompletions = toks; ! } ! ! ! //builtin mod ! private IModule builtinMod; ! public IModule getBuiltinMod() { ! return builtinMod; ! } ! public void setBuiltinMod(IModule mod) { ! this.builtinMod = mod; ! } ! public int getGrammarVersion() { IInterpreterInfo info = manager.getDefaultInterpreterInfo(new NullProgressMonitor()); Index: PythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNature.java,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** PythonNature.java 31 Jul 2008 01:47:36 -0000 1.67 --- PythonNature.java 28 Sep 2008 12:45:39 -0000 1.68 *************** *** 88,101 **** JobProgressComunicator jobProgressComunicator = new JobProgressComunicator(monitorArg, "Rebuilding modules", IProgressMonitor.UNKNOWN, this); try { ! ICodeCompletionASTManager tempAstManager = astManager; if (tempAstManager == null) { ! tempAstManager = new ASTManager(); } synchronized(tempAstManager){ ! astManager = tempAstManager; ! tempAstManager.setProject(getProject(), PythonNature.this, false); //it is a new manager, so, remove all deltas //begins task automatically ! tempAstManager.changePythonPath(paths, project, jobProgressComunicator, defaultSelectedInterpreter); saveAstManager(); --- 88,101 ---- JobProgressComunicator jobProgressComunicator = new JobProgressComunicator(monitorArg, "Rebuilding modules", IProgressMonitor.UNKNOWN, this); try { ! ICodeCompletionASTManager tempAstManager = astManager; if (tempAstManager == null) { ! tempAstManager = new ASTManager(); } synchronized(tempAstManager){ ! astManager = tempAstManager; ! tempAstManager.setProject(getProject(), PythonNature.this, false); //it is a new manager, so, remove all deltas //begins task automatically ! tempAstManager.changePythonPath(paths, project, jobProgressComunicator, defaultSelectedInterpreter); saveAstManager(); *************** *** 105,109 **** observer.notifyProjectPythonpathRestored(PythonNature.this, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { ! //let's keep it safe PydevPlugin.log(e); } --- 105,109 ---- observer.notifyProjectPythonpathRestored(PythonNature.this, jobProgressComunicator, defaultSelectedInterpreter); } catch (Exception e) { ! //let's keep it safe PydevPlugin.log(e); } *************** *** 214,250 **** */ public void setProject(final IProject project) { ! getStore().setProject(project); ! this.project = project; this.pythonPathNature.setProject(project, this); if(project != null && !initializationStarted && !initializationFinished){ ! synchronized (jobs) { ! Job job = jobs.get(project); ! if(job != null){ ! job.cancel(); ! } ! job = new Job("PyDev: Restoring projects python nature") { ! ! protected IStatus run(IProgressMonitor monitor) { ! try { ! if(monitor.isCanceled()){ ! return Status.OK_STATUS; ! } ! init(null, null, monitor); ! synchronized (jobs) { ! if(jobs.get(project) == this){ ! jobs.remove(project); ! } ! } ! } catch (Throwable t) { ! PydevPlugin.log(t); ! } ! return Status.OK_STATUS; ! } ! ! }; ! jobs.put(project, job); ! job.schedule(250L); //wait to see if we've more than 1 request. ! } } --- 214,250 ---- */ public void setProject(final IProject project) { ! getStore().setProject(project); ! this.project = project; this.pythonPathNature.setProject(project, this); if(project != null && !initializationStarted && !initializationFinished){ ! synchronized (jobs) { ! Job job = jobs.get(project); ! if(job != null){ ! job.cancel(); ! } ! job = new Job("PyDev: Restoring projects python nature") { ! ! protected IStatus run(IProgressMonitor monitor) { ! try { ! if(monitor.isCanceled()){ ! return Status.OK_STATUS; ! } ! init(null, null, monitor); ! synchronized (jobs) { ! if(jobs.get(project) == this){ ! jobs.remove(project); ! } ! } ! } catch (Throwable t) { ! PydevPlugin.log(t); ! } ! return Status.OK_STATUS; ! } ! ! }; ! jobs.put(project, job); ! job.schedule(250L); //wait to see if we've more than 1 request. ! } } *************** *** 253,265 **** public static synchronized IPythonNature addNature(IEditorInput element) { if(element instanceof FileEditorInput){ ! IFile file = (IFile)((FileEditorInput)element).getAdapter(IFile.class); ! if (file != null){ ! try { ! return PythonNature.addNature(file.getProject(), null, null, null); ! } catch (CoreException e) { ! PydevPlugin.log(e); ! } ! } ! } return null; } --- 253,265 ---- public static synchronized IPythonNature addNature(IEditorInput element) { if(element instanceof FileEditorInput){ ! IFile file = (IFile)((FileEditorInput)element).getAdapter(IFile.class); ! if (file != null){ ! try { ! return PythonNature.addNature(file.getProject(), null, null, null); ! } catch (CoreException e) { ! PydevPlugin.log(e); ! } ! } ! } return null; } *************** *** 392,451 **** @SuppressWarnings("unchecked") private void init(String version, String projectPythonpath, IProgressMonitor monitor) { ! if(version != null || projectPythonpath != null){ ! this.getStore().startInit(); ! try { ! if(projectPythonpath != null){ ! this.getPythonPathNature().setProjectSourcePath(projectPythonpath); ! } ! if(version != null){ ! this.setVersion(version); ! } ! } catch (CoreException e) { ! PydevPlugin.log(e); ! }finally{ ! this.getStore().endInit(); ! } ! }else{ ! //Change: 1.3.10: it could be reloaded more than once... (when it shouldn't) ! if(astManager != null){ ! return; //already initialized... ! } ! } ! ! if(initializationStarted || monitor.isCanceled()){ ! return; ! } ! ! initializationStarted = true; //Change: 1.3.10: no longer in a Job... should already be called in a job if that's needed. try { ! astManager = (ICodeCompletionASTManager) ASTManager.loadFromFile(getAstOutputFile()); ! if (astManager != null) { ! synchronized (astManager) { ! astManager.setProject(getProject(), this, true); // this is the project related to it, restore the deltas (we may have some crash) ! //just a little validation so that we restore the needed info if we did not get the modules ! if (astManager.getModulesManager().getOnlyDirectModules().length < 5) { ! astManager = null; ! } ! if (astManager != null) { ! List<IInterpreterObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_INTERPRETER_OBSERVER); ! for (IInterpreterObserver observer : participants) { ! try { ! observer.notifyNatureRecreated(this, monitor); ! } catch (Exception e) { ! //let's not fail because of other plugins ! PydevPlugin.log(e); ! } ! } ! } ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! astManager = null; ! } //errors can happen when restoring it --- 392,451 ---- @SuppressWarnings("unchecked") private void init(String version, String projectPythonpath, IProgressMonitor monitor) { ! if(version != null || projectPythonpath != null){ ! this.getStore().startInit(); ! try { ! if(projectPythonpath != null){ ! this.getPythonPathNature().setProjectSourcePath(projectPythonpath); ! } ! if(version != null){ ! this.setVersion(version); ! } ! } catch (CoreException e) { ! PydevPlugin.log(e); ! }finally{ ! this.getStore().endInit(); ! } ! }else{ ! //Change: 1.3.10: it could be reloaded more than once... (when it shouldn't) ! if(astManager != null){ ! return; //already initialized... ! } ! } ! ! if(initializationStarted || monitor.isCanceled()){ ! return; ! } ! ! initializationStarted = true; //Change: 1.3.10: no longer in a Job... should already be called in a job if that's needed. try { ! astManager = (ICodeCompletionASTManager) ASTManager.loadFromFile(getAstOutputFile()); ! if (astManager != null) { ! synchronized (astManager) { ! astManager.setProject(getProject(), this, true); // this is the project related to it, restore the deltas (we may have some crash) ! //just a little validation so that we restore the needed info if we did not get the modules ! if (astManager.getModulesManager().getOnlyDirectModules().length < 5) { ! astManager = null; ! } ! if (astManager != null) { ! List<IInterpreterObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_INTERPRETER_OBSERVER); ! for (IInterpreterObserver observer : participants) { ! try { ! observer.notifyNatureRecreated(this, monitor); ! } catch (Exception e) { ! //let's not fail because of other plugins ! PydevPlugin.log(e); ! } ! } ! } ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! astManager = null; ! } //errors can happen when restoring it *************** *** 461,465 **** ! /** * Returns the directory that should store completions. * --- 461,465 ---- ! /** * Returns the directory that should store completions. * *************** *** 492,508 **** */ public void rebuildPath() { ! this.rebuildPath(null, new NullProgressMonitor()); } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! try { ! clearCaches(); ! String paths = this.pythonPathNature.getOnlyProjectPythonPathStr(); ! this.rebuildPath(defaultSelectedInterpreter, paths); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } --- 492,508 ---- */ public void rebuildPath() { ! this.rebuildPath(null, new NullProgressMonitor()); } ! public void rebuildPath(String defaultSelectedInterpreter, IProgressMonitor monitor) { ! try { ! clearCaches(); ! String paths = this.pythonPathNature.getOnlyProjectPythonPathStr(); ! this.rebuildPath(defaultSelectedInterpreter, paths); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! } *************** *** 524,541 **** public ICodeCompletionASTManager getAstManager() { if(astManager == null){ ! //this is needed because it may not be restarted already... ! //also, this will only happen when initializing eclipse with some editors already open ! ! for(int i=0; i<10 && astManager == null && !initializationFinished; i++){ //we will wait 10 seconds for it ! try { ! Thread.sleep(1000); ! } catch (InterruptedException e) { //ignore ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! //next time we won't wait as long. ! initializationFinished = true; } --- 524,541 ---- public ICodeCompletionASTManager getAstManager() { if(astManager == null){ ! //this is needed because it may not be restarted already... ! //also, this will only happen when initializing eclipse with some editors already open ! ! for(int i=0; i<10 && astManager == null && !initializationFinished; i++){ //we will wait 10 seconds for it ! try { ! Thread.sleep(1000); ! } catch (InterruptedException e) { //ignore ! } catch (Exception e) { ! e.printStackTrace(); ! } ! } ! //next time we won't wait as long. ! initializationFinished = true; } *************** *** 563,583 **** */ public static List<IPythonNature> getAllPythonNatures() { ! List<IPythonNature> natures = new ArrayList<IPythonNature>(); ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! IProject[] projects = root.getProjects(); ! for (IProject project : projects) { ! PythonNature nature = getPythonNature(project); ! if(nature != null){ ! natures.add(nature); ! } ! } ! return natures; } public static PythonNature getPythonNature(IResource resource) { ! if(resource == null){ ! return null; ! } ! return getPythonNature(resource.getProject()); } --- 563,583 ---- */ public static List<IPythonNature> getAllPythonNatures() { ! List<IPythonNature> natures = new ArrayList<IPythonNature>(); ! IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); ! IProject[] projects = root.getProjects(); ! for (IProject project : projects) { ! PythonNature nature = getPythonNature(project); ! if(nature != null){ ! natures.add(nature); ! } ! } ! return natures; } public static PythonNature getPythonNature(IResource resource) { ! if(resource == null){ ! return null; ! } ! return getPythonNature(resource.getProject()); } *************** *** 615,626 **** public String getVersion() throws CoreException { if(project != null){ ! if (versionPropertyCache == null) { ! String storeVersion = getStore().getPropertyFromXml(getPythonProjectVersionQualifiedName()); ! if(storeVersion == null){ //there is no such property set (let's set it to the default) ! setVersion(getDefaultVersion()); //will set the versionPropertyCache too ! }else{ ! versionPropertyCache = storeVersion; } ! } } return versionPropertyCache; --- 615,626 ---- public String getVersion() throws CoreException { if(project != null){ ! if (versionPropertyCache == null) { ! String storeVersion = getStore().getPropertyFromXml(getPythonProjectVersionQualifiedName()); ! if(storeVersion == null){ //there is no such property set (let's set it to the default) ! setVersion(getDefaultVersion()); //will set the versionPropertyCache too ! }else{ ! versionPropertyCache = storeVersion; } ! } } return versionPropertyCache; *************** *** 632,638 **** */ public void setVersion(String version) throws CoreException{ ! clearCaches(); if(project != null){ ! this.versionPropertyCache = version; getStore().setPropertyToXml(getPythonProjectVersionQualifiedName(), version, true); } --- 632,638 ---- */ public void setVersion(String version) throws CoreException{ ! clearCaches(); if(project != null){ ! this.versionPropertyCache = version; getStore().setPropertyToXml(getPythonProjectVersionQualifiedName(), version, true); } *************** *** 656,671 **** public void saveAstManager() { ! if(astManager == null){ ! REF.writeToFile(null, getAstOutputFile()); ! ! }else{ ! synchronized(astManager){ ! REF.writeToFile(astManager, getAstOutputFile()); ! } ! } } public int getRelatedId() throws CoreException { ! return getRelatedId(this); } --- 656,671 ---- public void saveAstManager() { ! if(astManager == null){ ! REF.writeToFile(null, getAstOutputFile()); ! ! }else{ ! synchronized(astManager){ ! REF.writeToFile(astManager, getAstOutputFile()); ! } ! } } public int getRelatedId() throws CoreException { ! return getRelatedId(this); } *************** *** 723,741 **** Boolean isJython = null; //cache ! public void setBuiltinCompletions(IToken[] comps) { ! this.getRelatedInterpreterManager().setBuiltinCompletions(comps); ! } ! public IToken[] getBuiltinCompletions() { ! return this.getRelatedInterpreterManager().getBuiltinCompletions(); ! } ! public IModule getBuiltinMod() { ! return this.getRelatedInterpreterManager().getBuiltinMod(); ! } ! public void setBuiltinMod(IModule mod) { ! this.getRelatedInterpreterManager().setBuiltinMod(mod); ! } public static List<IPythonNature> getPythonNaturesRelatedTo(int relatedTo) { --- 723,741 ---- Boolean isJython = null; //cache ! public void setBuiltinCompletions(IToken[] comps) { ! this.getRelatedInterpreterManager().setBuiltinCompletions(comps); ! } ! public IToken[] getBuiltinCompletions() { ! return this.getRelatedInterpreterManager().getBuiltinCompletions(); ! } ! public IModule getBuiltinMod() { ! return this.getRelatedInterpreterManager().getBuiltinMod(); ! } ! public void setBuiltinMod(IModule mod) { ! this.getRelatedInterpreterManager().setBuiltinMod(mod); ! } public static List<IPythonNature> getPythonNaturesRelatedTo(int relatedTo) { *************** *** 775,779 **** protected IPythonNatureStore getStore(){ ! return pythonNatureStore; } --- 775,779 ---- protected IPythonNatureStore getStore(){ ! return pythonNatureStore; } Index: AbstractPythonNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/AbstractPythonNature.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractPythonNature.java 7 Jul 2007 18:03:07 -0000 1.2 --- AbstractPythonNature.java 28 Sep 2008 12:45:40 -0000 1.3 *************** *** 19,39 **** */ public boolean isResourceInPythonpath(IResource resource) { ! return resolveModule(resource) != null; } public boolean isResourceInPythonpath(String absPath) { ! return resolveModule(absPath) != null; } ! /** * @param resource the resource we want to get the name from * @return the name of the module in the environment */ public String resolveModule(IResource resource) { ! return resolveModule(PydevPlugin.getIResourceOSString(resource)); } public String resolveModule(File file) { ! return resolveModule(REF.getFileAbsolutePath(file)); } --- 19,39 ---- */ public boolean isResourceInPythonpath(IResource resource) { ! return resolveModule(resource) != null; } public boolean isResourceInPythonpath(String absPath) { ! return resolveModule(absPath) != null; } ! /** * @param resource the resource we want to get the name from * @return the name of the module in the environment */ public String resolveModule(IResource resource) { ! return resolveModule(PydevPlugin.getIResourceOSString(resource)); } public String resolveModule(File file) { ! return resolveModule(REF.getFileAbsolutePath(file)); } *************** *** 48,71 **** */ public synchronized boolean startRequests() { ! ICodeCompletionASTManager astManager = this.getAstManager(); ! if(astManager == null){ ! return false; ! } ! IModulesManager modulesManager = astManager.getModulesManager(); ! if(modulesManager == null){ ! return false; ! } ! synchronized (modulesManagerStack) { ! modulesManagerStack.push(modulesManager); ! return modulesManager.startCompletionCache(); } ! } ! /** * End a request for an ast manager (end caching things) */ ! public synchronized void endRequests() { ! synchronized (modulesManagerStack) { ! try { IModulesManager modulesManager = modulesManagerStack.pop(); modulesManager.endCompletionCache(); --- 48,71 ---- */ public synchronized boolean startRequests() { ! ICodeCompletionASTManager astManager = this.getAstManager(); ! if(astManager == null){ ! return false; } ! IModulesManager modulesManager = astManager.getModulesManager(); ! if(modulesManager == null){ ! return false; ! } ! synchronized (modulesManagerStack) { ! modulesManagerStack.push(modulesManager); ! return modulesManager.startCompletionCache(); ! } ! } ! /** * End a request for an ast manager (end caching things) */ ! public synchronized void endRequests() { ! synchronized (modulesManagerStack) { ! try { IModulesManager modulesManager = modulesManagerStack.pop(); modulesManager.endCompletionCache(); *************** *** 73,79 **** PydevPlugin.log(e); } ! } ! } ! } --- 73,79 ---- PydevPlugin.log(e); } ! } ! } ! } Index: PythonPathNature.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonPathNature.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PythonPathNature.java 31 Jul 2008 01:47:36 -0000 1.30 --- PythonPathNature.java 28 Sep 2008 12:45:40 -0000 1.31 *************** *** 128,135 **** if(ResourcesPlugin.getPlugin() == null){ ! //in tests ! buf.append(strings[i]); ! buf.append("|"); ! continue; } --- 128,135 ---- if(ResourcesPlugin.getPlugin() == null){ ! //in tests ! buf.append(strings[i]); ! buf.append("|"); ! continue; } *************** *** 150,175 **** }else if(r instanceof IFile){ //zip/jar/egg file ! String extension = r.getFileExtension(); ! if(extension == null || FileTypesPreferencesPage.isValidZipFile("."+extension) == false){ ! PydevPlugin.log("Error: the path "+strings[i]+" is a file but is not a recognized zip file."); ! ! }else{ ! buf.append(REF.getFileAbsolutePath(r.getLocation().toFile())); ! buf.append("|"); ! } }else{ ! if(root.isSynchronized(IResource.DEPTH_INFINITE)){ ! //if it's synchronized, it really doesn't exist (let's warn about it) ! //not in workspace?... maybe it was removed, so, do nothing, but let the user know about it ! Log.log(IStatus.WARNING, "Unable to find the path "+strings[i]+" in the project were it's \n" + ! "added as a source folder for pydev (project: "+project.getName()+") member:"+r, null); ! } ! ! IPath rootLocation = root.getRawLocation(); ! //still, let's add it there (this'll be cached for later use) ! buf.append(REF.getFileAbsolutePath(rootLocation.append(strings[i].trim()).toFile())); ! buf.append("|"); ! } } --- 150,175 ---- }else if(r instanceof IFile){ //zip/jar/egg file ! String extension = r.getFileExtension(); ! if(extension == null || FileTypesPreferencesPage.isValidZipFile("."+extension) == false){ ! PydevPlugin.log("Error: the path "+strings[i]+" is a file but is not a recognized zip file."); ! ! }else{ ! buf.append(REF.getFileAbsolutePath(r.getLocation().toFile())); ! buf.append("|"); ! } }else{ ! if(root.isSynchronized(IResource.DEPTH_INFINITE)){ ! //if it's synchronized, it really doesn't exist (let's warn about it) ! //not in workspace?... maybe it was removed, so, do nothing, but let the user know about it ! Log.log(IStatus.WARNING, "Unable to find the path "+strings[i]+" in the project were it's \n" + ! "added as a source folder for pydev (project: "+project.getName()+") member:"+r, null); ! } ! ! IPath rootLocation = root.getRawLocation(); ! //still, let's add it there (this'll be cached for later use) ! buf.append(REF.getFileAbsolutePath(rootLocation.append(strings[i].trim()).toFile())); ! buf.append("|"); ! } } *************** *** 247,252 **** String projectSourcePath = nature.getStore().getPathProperty(PythonPathNature.getProjectSourcePathQualifiedName()); if(projectSourcePath == null){ ! //has not been set ! return ""; } //we have to validate it, because as we store the values relative to the workspace, and not to the --- 247,252 ---- String projectSourcePath = nature.getStore().getPathProperty(PythonPathNature.getProjectSourcePathQualifiedName()); if(projectSourcePath == null){ ! //has not been set ! return ""; } //we have to validate it, because as we store the values relative to the workspace, and not to the *************** *** 292,300 **** synchronized(project){ //no need to validate because those are always 'file-system' related ! String extPath = nature.getStore().getPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName()); if(extPath == null){ ! extPath = ""; } ! return extPath; } } --- 292,300 ---- synchronized(project){ //no need to validate because those are always 'file-system' related ! String extPath = nature.getStore().getPathProperty(PythonPathNature.getProjectExternalSourcePathQualifiedName()); if(extPath == null){ ! extPath = ""; } ! return extPath; } } Index: PythonNatureStore.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/nature/PythonNatureStore.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PythonNatureStore.java 13 Aug 2008 21:12:15 -0000 1.22 --- PythonNatureStore.java 28 Sep 2008 12:45:39 -0000 1.23 *************** *** 98,102 **** public String getLastLoadedContents(){ ! return lastLoadedContents; } --- 98,102 ---- public String getLastLoadedContents(){ ! return lastLoadedContents; } *************** *** 138,154 **** }else{ traceFunc("setProject - ", project.getName()); ! try{ ! this.project = project; ! this.xmlFile = project.getFile(STORE_FILE_NAME); ! try { ! loadFromFile(); ! } catch (CoreException e) { ! throw new RuntimeException("Error loading project: "+project, e); ! } ! if (!ProjectModulesManager.IN_TESTS) { ! project.getWorkspace().addResourceChangeListener(this); ! } }finally{ ! loaded = true; } traceFunc("END setProject - ", project.getName()); --- 138,154 ---- }else{ traceFunc("setProject - ", project.getName()); ! try{ ! this.project = project; ! this.xmlFile = project.getFile(STORE_FILE_NAME); ! try { ! loadFromFile(); ! } catch (CoreException e) { ! throw new RuntimeException("Error loading project: "+project, e); ! } ! if (!ProjectModulesManager.IN_TESTS) { ! project.getWorkspace().addResourceChangeListener(this); ! } }finally{ ! loaded = true; } traceFunc("END setProject - ", project.getName()); *************** *** 161,165 **** */ private synchronized void checkLoad(String function) { ! if(!loaded){ PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); } --- 161,165 ---- */ private synchronized void checkLoad(String function) { ! if(!loaded){ PydevPlugin.log(new RuntimeException(StringUtils.format("%s still not loaded and '%s' already called.", xmlFile, function))); } *************** *** 173,177 **** return ""; } ! checkLoad("getPathProperty"); String ret = getPathStringFromArray(getPathPropertyFromXml(key)); traceFunc("END getPathProperty - ", key, ret); --- 173,177 ---- return ""; } ! checkLoad("getPathProperty"); String ret = getPathStringFromArray(getPathPropertyFromXml(key)); traceFunc("END getPathProperty - ", key, ret); *************** *** 179,187 **** } ! /* (non-Javadoc) * @see org.python.pydev.plugin.nature.IPythonNatureStore#setPathProperty(org.eclipse.core.runtime.QualifiedName, java.lang.String) */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! checkLoad("setPathProperty"); setPathPropertyToXml(key, getArrayFromPathString(value), true); } --- 179,187 ---- } ! /* (non-Javadoc) * @see org.python.pydev.plugin.nature.IPythonNatureStore#setPathProperty(org.eclipse.core.runtime.QualifiedName, java.lang.String) */ public synchronized void setPathProperty(QualifiedName key, String value) throws CoreException { ! checkLoad("setPathProperty"); setPathPropertyToXml(key, getArrayFromPathString(value), true); } *************** *** 226,239 **** } } else { ! String fileContents = REF.getFileContents(file); ! if(lastLoadedContents != null && fileContents.equals(lastLoadedContents)){ ! return false; ! } ! lastLoadedContents = fileContents; document = parser.parse(new ByteArrayInputStream(fileContents.getBytes())); return true; } } catch (Exception e) { ! PydevPlugin.log("Error loading contents from .pydevproject", e); } --- 226,239 ---- } } else { ! String fileContents = REF.getFileContents(file); ! if(lastLoadedContents != null && fileContents.equals(lastLoadedContents)){ ! return false; ! } ! lastLoadedContents = fileContents; document = parser.parse(new ByteArrayInputStream(fileContents.getBytes())); return true; } } catch (Exception e) { ! PydevPlugin.log("Error loading contents from .pydevproject", e); } *************** *** 246,257 **** * @return the actual file from the IFile we have */ ! private File getRawXmlFileLocation() { ! IPath rawLocation = xmlFile.getRawLocation(); ! File file = null; ! if(rawLocation != null){ ! file = rawLocation.toFile(); ! } ! return file; ! } private synchronized void migrateProperty(QualifiedName key) throws CoreException { --- 246,257 ---- * @return the actual file from the IFile we have */ ! private File getRawXmlFileLocation() { ! IPath rawLocation = xmlFile.getRawLocation(); ! File file = null; ! if(rawLocation != null){ ! file = rawLocation.toFile(); ! } ! return file; ! } private synchronized void migrateProperty(QualifiedName key) throws CoreException { *************** *** 289,293 **** private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); Node ret = null; --- 289,293 ---- private synchronized Node getRootNodeInXml() { traceFunc("getRootNodeInXml"); ! Assert.isNotNull(document); NodeList nodeList = document.getElementsByTagName(PYDEV_PROJECT_DESCRIPTION); Node ret = null; *************** *** 446,450 **** traceFunc("getPropertyFromXml - ", key); synchronized (this) { ! checkLoad("getPropertyFromXml"); try { Node propertyNode = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); --- 446,450 ---- traceFunc("getPropertyFromXml - ", key); synchronized (this) { ! checkLoad("getPropertyFromXml"); try { Node propertyNode = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); *************** *** 471,477 **** traceFunc(StringUtils.format("setPropertyToXml key:%s value:%s store:%s", key, value, store)); synchronized (this) { ! if(store){ ! checkLoad("setPropertyToXml"); ! } try { Node child = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); --- 471,477 ---- traceFunc(StringUtils.format("setPropertyToXml key:%s value:%s store:%s", key, value, store)); synchronized (this) { ! if(store){ ! checkLoad("setPropertyToXml"); ! } try { Node child = findPropertyNodeInXml(PYDEV_NATURE_PROPERTY, key); *************** *** 493,501 **** }else{ ! store = false; } if (store) { ! doStore(); } --- 493,501 ---- }else{ ! store = false; } if (store) { ! doStore(); } *************** *** 575,579 **** boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; traceFunc("END hasTextContent ", ret); --- 575,579 ---- boolean ret = child.getNodeType() != Node.COMMENT_NODE && ! child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE; traceFunc("END hasTextContent ", ret); *************** *** 638,646 **** } }else{ ! store = false; } if (store) { ! doStore(); } --- 638,646 ---- } }else{ ! store = false; } if (store) { ! doStore(); } *************** *** 745,772 **** } ! File file = getRawXmlFileLocation(); ! ! try { ! //Ok, we may receive multiple requests at once (e.g.: when updating the version and the pythonpath together), but ! //as the file is pretty small, there should be no problems in writing it directly (if that proves a problem later on, we ! //could have a *very* simple mechanism for saving it after some millis) ! String str = new String(serializeDocument(document)); ! lastLoadedContents = str; ! ! if(file == null){ ! if (!ProjectModulesManager.IN_TESTS) { ! //if we're not in tests, let's log this, as it'd be an error. ! PydevPlugin.log("Error: xml file should only be null in tests (when no workspace is available)"); ! } ! return Status.OK_STATUS; ! } ! ! if(TRACE_PYTHON_NATURE_STORE){ ! System.out.println("Writing to file: "+file+" "+str); ! } ! REF.writeStrToFile(str, file); ! } catch (Exception e) { ! PydevPlugin.log("Unable to write contents of file: "+file, e); ! } traceFunc("END doStore"); --- 745,772 ---- } ! File file = getRawXmlFileLocation(); ! ! try { ! //Ok, we may receive multiple requests at once (e.g.: when updating the version and the pythonpath together), but ! //as the file is pretty small, there should be no problems in writing it directly (if that proves a problem later on, we ! //could have a *very* simple mechanism for saving it after some millis) ! String str = new String(serializeDocument(document)); ! lastLoadedContents = str; ! ! if(file == null){ ! if (!ProjectModulesManager.IN_TESTS) { ! //if we're not in tests, let's log this, as it'd be an error. ! PydevPlugin.log("Error: xml file should only be null in tests (when no workspace is available)"); ! } ! return Status.OK_STATUS; ! } ! ! if(TRACE_PYTHON_NATURE_STORE){ ! System.out.println("Writing to file: "+file+" "+str); ! } ! REF.writeStrToFile(str, file); ! } catch (Exception e) { ! PydevPlugin.log("Unable to write contents of file: "+file, e); ! } traceFunc("END doStore"); |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:39
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_navigator/org/python/pydev/navigator/ui Modified Files: PydevPackageExplorer.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: PydevPackageExplorer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/ui/PydevPackageExplorer.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PydevPackageExplorer.java 12 Jul 2007 01:31:14 -0000 1.9 --- PydevPackageExplorer.java 28 Sep 2008 12:45:52 -0000 1.10 *************** *** 44,58 **** * This viewer is the one used instead of the common viewer -- should only be used to fix failures in the base class. */ ! public static class PydevCommonViewer extends CommonViewer { ! ! /** ! * This is used so that we only restore the memento in the 'right' place ! */ ! public boolean availableToRestoreMemento = false; ! ! public PydevCommonViewer(String id, Composite parent, int style) { ! super(id, parent, style); ! } ! /** * Returns the tree path for the given item. --- 44,58 ---- * This viewer is the one used instead of the common viewer -- should only be used to fix failures in the base class. */ ! public static class PydevCommonViewer extends CommonViewer { ! ! /** ! * This is used so that we only restore the memento in the 'right' place ! */ ! public boolean availableToRestoreMemento = false; ! ! public PydevCommonViewer(String id, Composite parent, int style) { ! super(id, parent, style); ! } ! /** * Returns the tree path for the given item. *************** *** 75,92 **** return new TreePath(segments.toArray()); } ! } /** * This is the memento to be used. */ ! private IMemento memento; /** * Overridden to keep the memento to be used later (it's private in the superclass). */ ! public void init(IViewSite aSite, IMemento aMemento) throws PartInitException { ! super.init(aSite, aMemento); ! memento = aMemento; ! } /** --- 75,92 ---- return new TreePath(segments.toArray()); } ! } /** * This is the memento to be used. */ ! private IMemento memento; /** * Overridden to keep the memento to be used later (it's private in the superclass). */ ! public void init(IViewSite aSite, IMemento aMemento) throws PartInitException { ! super.init(aSite, aMemento); ! memento = aMemento; ! } /** *************** *** 96,163 **** * too -- that's why we have to keep the memento object in the init method). */ ! @Override ! protected CommonViewer createCommonViewer(Composite aParent) { //super.createCommonViewer(aParent); -- don't even call the super class ! CommonViewer aViewer = new PydevCommonViewer(getViewSite().getId(), aParent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); ! initListeners(aViewer); ! ! //commented: we do that only after the part is completely created (because otherwise the state is reverted later) ! //aViewer.getNavigatorContentService().restoreState(memento); ! ! return aViewer; ! } ! /** ! * Overridden because if the state is not restored as the last thing, it is reverted back to the previous state. ! */ ! @Override ! public void createPartControl(Composite aParent) { ! super.createPartControl(aParent); ! PydevCommonViewer viewer = (PydevCommonViewer) getCommonViewer(); ! viewer.availableToRestoreMemento = true; ! for(int i=0;i<3;i++){ ! try { ! //I don't know why the 1st time we restore it it doesn't work... so, we have to do it twice ! //(and the other 1 is because we may have an exception in the 1st step). ! viewer.getNavigatorContentService().restoreState(memento); ! } catch (Exception e1) { ! if(i>1){ ! PydevPlugin.log("Unable to restore the state of the Pydev Package Explorer.", e1); ! } ! } ! } ! } ! ! /** ! * Returns the element contained in the EditorInput ! */ ! Object getElementOfInput(IEditorInput input) { ! if (input instanceof IFileEditorInput) { ! return ((IFileEditorInput) input).getFile(); ! } ! return null; ! } ! /** ! * Implements the 'show in...' action ! */ ! public boolean show(ShowInContext context) { ! Object elementOfInput = null; ! ISelection selection = context.getSelection(); ! if (selection instanceof IStructuredSelection) { ! IStructuredSelection structuredSelection = ((IStructuredSelection) selection); ! if (structuredSelection.size() == 1) { ! elementOfInput = structuredSelection.getFirstElement(); ! } ! } ! Object input = context.getInput(); ! if (input instanceof IEditorInput) { ! elementOfInput = getElementOfInput((IEditorInput) context.getInput()); ! } ! return elementOfInput != null && tryToReveal(elementOfInput); ! } ! /** * This is the method that actually tries to reveal some item in the tree. --- 96,163 ---- * too -- that's why we have to keep the memento object in the init method). */ ! @Override ! protected CommonViewer createCommonViewer(Composite aParent) { //super.createCommonViewer(aParent); -- don't even call the super class ! CommonViewer aViewer = new PydevCommonViewer(getViewSite().getId(), aParent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); ! initListeners(aViewer); ! ! //commented: we do that only after the part is completely created (because otherwise the state is reverted later) ! //aViewer.getNavigatorContentService().restoreState(memento); ! ! return aViewer; ! } ! /** ! * Overridden because if the state is not restored as the last thing, it is reverted back to the previous state. ! */ ! @Override ! public void createPartControl(Composite aParent) { ! super.createPartControl(aParent); ! PydevCommonViewer viewer = (PydevCommonViewer) getCommonViewer(); ! viewer.availableToRestoreMemento = true; ! for(int i=0;i<3;i++){ ! try { ! //I don't know why the 1st time we restore it it doesn't work... so, we have to do it twice ! //(and the other 1 is because we may have an exception in the 1st step). ! viewer.getNavigatorContentService().restoreState(memento); ! } catch (Exception e1) { ! if(i>1){ ! PydevPlugin.log("Unable to restore the state of the Pydev Package Explorer.", e1); ! } ! } ! } ! } ! ! /** ! * Returns the element contained in the EditorInput ! */ ! Object getElementOfInput(IEditorInput input) { ! if (input instanceof IFileEditorInput) { ! return ((IFileEditorInput) input).getFile(); ! } ! return null; ! } ! /** ! * Implements the 'show in...' action ! */ ! public boolean show(ShowInContext context) { ! Object elementOfInput = null; ! ISelection selection = context.getSelection(); ! if (selection instanceof IStructuredSelection) { ! IStructuredSelection structuredSelection = ((IStructuredSelection) selection); ! if (structuredSelection.size() == 1) { ! elementOfInput = structuredSelection.getFirstElement(); ! } ! } ! Object input = context.getInput(); ! if (input instanceof IEditorInput) { ! elementOfInput = getElementOfInput((IEditorInput) context.getInput()); ! } ! return elementOfInput != null && tryToReveal(elementOfInput); ! } ! /** * This is the method that actually tries to reveal some item in the tree. *************** *** 165,194 **** * It will go through the pipeline to see if the actual object to reveal has been replaced in the replace pipeline. */ ! public boolean tryToReveal(Object element) { ! element = getPythonModelElement(element); ! //null is checked in the revealAndVerify function ! if (revealAndVerify(element)) { ! return true; ! } //if it is a wrapped resource that we couldn't show, try to reveal as a resource... ! if (element instanceof IAdaptable && !(element instanceof IResource)) { ! IAdaptable adaptable = (IAdaptable) element; ! IResource resource = (IResource) adaptable.getAdapter(IResource.class); ! if (resource != null) { ! if (revealAndVerify(resource)){ ! return true; ! } ! } ! } ! return false; ! } ! /** ! * @param element the element that should be gotten as an element from the pydev model ! * @return a pydev element or the same element passed as a parameter. ! */ private Object getPythonModelElement(Object element) { if(element instanceof IWrappedResource){ --- 165,194 ---- * It will go through the pipeline to see if the actual object to reveal has been replaced in the replace pipeline. */ ! public boolean tryToReveal(Object element) { ! element = getPythonModelElement(element); ! //null is checked in the revealAndVerify function ! if (revealAndVerify(element)) { ! return true; ! } //if it is a wrapped resource that we couldn't show, try to reveal as a resource... ! if (element instanceof IAdaptable && !(element instanceof IResource)) { ! IAdaptable adaptable = (IAdaptable) element; ! IResource resource = (IResource) adaptable.getAdapter(IResource.class); ! if (resource != null) { ! if (revealAndVerify(resource)){ ! return true; ! } ! } ! } ! return false; ! } ! /** ! * @param element the element that should be gotten as an element from the pydev model ! * @return a pydev element or the same element passed as a parameter. ! */ private Object getPythonModelElement(Object element) { if(element instanceof IWrappedResource){ *************** *** 196,211 **** } INavigatorPipelineService pipelineService = this.getNavigatorContentService().getPipelineService(); ! if(element instanceof IAdaptable){ ! IAdaptable adaptable = (IAdaptable) element; ! IFile file = (IFile) adaptable.getAdapter(IFile.class); ! if(file != null){ ! HashSet<Object> files = new ContributorTrackingSet((NavigatorContentService) this.getNavigatorContentService()); ! files.add(file); ! pipelineService.interceptAdd(new PipelinedShapeModification(file.getParent(), files)); ! if(files.size() > 0){ ! element = files.iterator().next(); ! } ! } ! } return element; } --- 196,211 ---- } INavigatorPipelineService pipelineService = this.getNavigatorContentService().getPipelineService(); ! if(element instanceof IAdaptable){ ! IAdaptable adaptable = (IAdaptable) element; ! IFile file = (IFile) adaptable.getAdapter(IFile.class); ! if(file != null){ ! HashSet<Object> files = new ContributorTrackingSet((NavigatorContentService) this.getNavigatorContentService()); ! files.add(file); ! pipelineService.interceptAdd(new PipelinedShapeModification(file.getParent(), files)); ! if(files.size() > 0){ ! element = files.iterator().next(); ! } ! } ! } return element; } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:38
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/utils Modified Files: PyFileListing.java MultiStringFieldEditor.java CounterThread.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: MultiStringFieldEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils/MultiStringFieldEditor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MultiStringFieldEditor.java 20 Oct 2007 19:30:36 -0000 1.3 --- MultiStringFieldEditor.java 28 Sep 2008 12:45:49 -0000 1.4 *************** *** 4,9 **** package org.python.pydev.utils; - import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.core.runtime.Assert; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; --- 4,9 ---- package org.python.pydev.utils; import org.eclipse.core.runtime.Assert; + import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; *************** *** 13,18 **** import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; - import org.eclipse.swt.graphics.GC; - import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; --- 13,16 ---- Index: CounterThread.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils/CounterThread.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CounterThread.java 7 Jun 2006 21:54:33 -0000 1.2 --- CounterThread.java 28 Sep 2008 12:45:49 -0000 1.3 *************** *** 10,47 **** */ public class CounterThread extends Thread{ ! private ICallback callback; ! private int elapseTime; ! private int stopWhenReaches; ! /** ! * @param callback the callback that should be called whenever the time elapses (it passes an int, that ! * says which call is this one). ! * @param elapseTime this is the millis that should elapse between the calls ! * @param stopWhenReaches this is the number of times that it should be called ! */ ! public CounterThread(ICallback callback, int elapseTime, int stopWhenReaches){ ! this.callback = callback; ! this.elapseTime = elapseTime; ! this.stopWhenReaches = stopWhenReaches; setName("Callback (CounterThread)"); ! } ! ! @Override ! public void run() { ! try { ! for (int i = 0; i < stopWhenReaches; i++) { ! try { ! sleep(elapseTime); ! callback.call(i); ! } catch (Exception e) { ! Log.log(e); ! return; ! } ! } ! ! } catch (Exception e) { ! Log.log(e); ! return; ! } ! } } --- 10,47 ---- */ public class CounterThread extends Thread{ ! private ICallback callback; ! private int elapseTime; ! private int stopWhenReaches; ! /** ! * @param callback the callback that should be called whenever the time elapses (it passes an int, that ! * says which call is this one). ! * @param elapseTime this is the millis that should elapse between the calls ! * @param stopWhenReaches this is the number of times that it should be called ! */ ! public CounterThread(ICallback callback, int elapseTime, int stopWhenReaches){ ! this.callback = callback; ! this.elapseTime = elapseTime; ! this.stopWhenReaches = stopWhenReaches; setName("Callback (CounterThread)"); ! } ! ! @Override ! public void run() { ! try { ! for (int i = 0; i < stopWhenReaches; i++) { ! try { ! sleep(elapseTime); ! callback.call(i); ! } catch (Exception e) { ! Log.log(e); ! return; ! } ! } ! ! } catch (Exception e) { ! Log.log(e); ! return; ! } ! } } Index: PyFileListing.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/utils/PyFileListing.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyFileListing.java 13 Aug 2008 21:12:15 -0000 1.4 --- PyFileListing.java 28 Sep 2008 12:45:49 -0000 1.5 *************** *** 26,62 **** public class PyFileListing { ! /** ! * Information about a python file found (the actual file and the way it was resolved as a python module) ! */ public static final class PyFileInfo { ! private final String relPath; ! private final File file; ! public PyFileInfo(File file, String relPath) { ! this.file = file; ! this.relPath = relPath; ! } ! /** File object. */ ! public File getFile() { ! return file; ! } ! /** Returns fully qualified name of module. */ ! public String getModuleName() { ! return relPath; ! } ! } /** ! * Returns the directories and python files in a list. ! * ! * @param file ! * @param addSubFolders ! * indicates if sub-folders should be added ! * @return tuple with files in pos 0 and folders in pos 1 ! */ @SuppressWarnings("unchecked") private static PyFileListing getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, --- 26,62 ---- public class PyFileListing { ! /** ! * Information about a python file found (the actual file and the way it was resolved as a python module) ! */ public static final class PyFileInfo { ! private final String relPath; ! private final File file; ! public PyFileInfo(File file, String relPath) { ! this.file = file; ! this.relPath = relPath; ! } ! /** File object. */ ! public File getFile() { ! return file; ! } ! /** Returns fully qualified name of module. */ ! public String getModuleName() { ! return relPath; ! } ! } /** ! * Returns the directories and python files in a list. ! * ! * @param file ! * @param addSubFolders ! * indicates if sub-folders should be added ! * @return tuple with files in pos 0 and folders in pos 1 ! */ @SuppressWarnings("unchecked") private static PyFileListing getPyFilesBelow(File file, FileFilter filter, IProgressMonitor monitor, boolean addSubFolders, *************** *** 106,112 **** if (checkHasInit && hasInit == false){ //only check if it has __init__ if really needed ! if(PythonPathHelper.isValidInitFile(file2.getName())){ ! hasInit = true; ! } } --- 106,112 ---- if (checkHasInit && hasInit == false){ //only check if it has __init__ if really needed ! if(PythonPathHelper.isValidInitFile(file2.getName())){ ! hasInit = true; ! } } *************** *** 123,130 **** if(file2.isDirectory() && addSubFolders){ ! ret.extendWith(getPyFilesBelow(file2, filter, monitor, addSubFolders, level+1, ! checkHasInit, currModuleRep)); ! ! monitor.worked(1); } } --- 123,130 ---- if(file2.isDirectory() && addSubFolders){ ! ret.extendWith(getPyFilesBelow(file2, filter, monitor, addSubFolders, level+1, ! checkHasInit, currModuleRep)); ! ! monitor.worked(1); } } *************** *** 156,178 **** */ public static FileFilter getPyFilesFileFilter(final boolean includeDirs) { ! return new FileFilter() { public boolean accept(File pathname) { if (includeDirs){ ! if(pathname.isDirectory()){ ! return true; ! } ! if(PythonPathHelper.isValidSourceFile(pathname.toString())){ ! return true; ! } ! return false; }else{ ! if(pathname.isDirectory()){ ! return false; ! } ! if(PythonPathHelper.isValidSourceFile(pathname.toString())){ ! return true; ! } ! return false; } } --- 156,178 ---- */ public static FileFilter getPyFilesFileFilter(final boolean includeDirs) { ! return new FileFilter() { public boolean accept(File pathname) { if (includeDirs){ ! if(pathname.isDirectory()){ ! return true; ! } ! if(PythonPathHelper.isValidSourceFile(pathname.toString())){ ! return true; ! } ! return false; }else{ ! if(pathname.isDirectory()){ ! return false; ! } ! if(PythonPathHelper.isValidSourceFile(pathname.toString())){ ! return true; ! } ! return false; } } *************** *** 196,216 **** */ public static List<IFile> getAllIFilesBelow(IFolder member) { ! final ArrayList<IFile> ret = new ArrayList<IFile>(); ! try { ! member.accept(new IResourceVisitor(){ ! public boolean visit(IResource resource) { ! if(resource instanceof IFile){ ! ret.add((IFile) resource); ! return false; //has no members ! } ! return true; ! } ! ! }); ! } catch (CoreException e) { ! throw new RuntimeException(e); ! } ! return ret; } --- 196,216 ---- */ public static List<IFile> getAllIFilesBelow(IFolder member) { ! final ArrayList<IFile> ret = new ArrayList<IFile>(); ! try { ! member.accept(new IResourceVisitor(){ ! public boolean visit(IResource resource) { ! if(resource instanceof IFile){ ! ret.add((IFile) resource); ! return false; //has no members ! } ! return true; ! } ! ! }); ! } catch (CoreException e) { ! throw new RuntimeException(e); ! } ! return ret; } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:37
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/correctionassist/docstrings Modified Files: AssistDocString.java DocstringsPrefPage.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: DocstringsPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings/DocstringsPrefPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DocstringsPrefPage.java 24 Jan 2007 20:29:30 -0000 1.2 --- DocstringsPrefPage.java 28 Sep 2008 12:45:47 -0000 1.3 *************** *** 23,59 **** public class DocstringsPrefPage extends FieldEditorPreferencePage implements ! IWorkbenchPreferencePage, IPropertyChangeListener { ! /* Preference identifiers */ ! public static final String P_DOCSTRINGCHARACTER = "DOCSTRING CHARACTER"; ! public static final String DEFAULT_P_DOCSTRINGCHARACTER = "'"; ! public static final String TYPETAG_GENERATION_NEVER = "Never"; ! public static final String TYPETAG_GENERATION_ALWAYS = "Always"; ! public static final String TYPETAG_GENERATION_CUSTOM = "Custom"; ! public static final String P_TYPETAGGENERATION = "TYPETAGGENERATION"; ! public static final String DEFAULT_P_TYPETAGGENERATION = TYPETAG_GENERATION_NEVER; ! public static final String P_DONT_GENERATE_TYPETAGS = "DONT_GENERATE_TYPETAGS_PREFIXES"; ! public static final String DEFAULT_P_DONT_GENERATE_TYPETAGS = "sz\0n\0f"; ! public DocstringsPrefPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Docstring preferences"); ! } ! /** ! * Getter for the preferred docstring character. Only a shortcut. ! * ! * @return ! */ ! public static String getPreferredDocstringCharacter() { PydevPlugin plugin = PydevPlugin.getDefault(); if(plugin == null){ --- 23,59 ---- public class DocstringsPrefPage extends FieldEditorPreferencePage implements ! IWorkbenchPreferencePage, IPropertyChangeListener { ! /* Preference identifiers */ ! public static final String P_DOCSTRINGCHARACTER = "DOCSTRING CHARACTER"; ! public static final String DEFAULT_P_DOCSTRINGCHARACTER = "'"; ! public static final String TYPETAG_GENERATION_NEVER = "Never"; ! public static final String TYPETAG_GENERATION_ALWAYS = "Always"; ! public static final String TYPETAG_GENERATION_CUSTOM = "Custom"; ! public static final String P_TYPETAGGENERATION = "TYPETAGGENERATION"; ! public static final String DEFAULT_P_TYPETAGGENERATION = TYPETAG_GENERATION_NEVER; ! public static final String P_DONT_GENERATE_TYPETAGS = "DONT_GENERATE_TYPETAGS_PREFIXES"; ! public static final String DEFAULT_P_DONT_GENERATE_TYPETAGS = "sz\0n\0f"; ! public DocstringsPrefPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Docstring preferences"); ! } ! /** ! * Getter for the preferred docstring character. Only a shortcut. ! * ! * @return ! */ ! public static String getPreferredDocstringCharacter() { PydevPlugin plugin = PydevPlugin.getDefault(); if(plugin == null){ *************** *** 61,163 **** } ! Preferences preferences = PydevPrefs.getPreferences(); return preferences.getString(P_DOCSTRINGCHARACTER); ! } ! /** ! * ! * @return The string that should be used to mark the beginning or end of a ! * docstring. (""") or (''') ! */ ! public static String getDocstringMarker() { ! String docstringChar = getPreferredDocstringCharacter(); ! return docstringChar + docstringChar + docstringChar; ! } ! /** ! * Determines, from the preferences, whether a type tag should be generated ! * for a function / method parameter. ! * ! * @param parameterName The name of the parameter. ! * @return true if it should be generated and false otherwise ! */ ! public static boolean getTypeTagShouldBeGenerated(String parameterName) { if(PydevPlugin.getDefault() == null){ //on tests return true; } ! String preference = PydevPrefs.getPreferences().getString(P_TYPETAGGENERATION); ! if (preference.equals(TYPETAG_GENERATION_NEVER)) { ! return false; ! } else if (preference.equals(TYPETAG_GENERATION_ALWAYS)) { ! return true; ! } else {// TYPETAG_GENERATION_CUSTOM - check prefix. ! String prefixesString = PydevPrefs.getPreferences().getString(P_DONT_GENERATE_TYPETAGS); ! StringTokenizer st = new StringTokenizer(prefixesString, "\0"); // "\0" is the separator ! ! while (st.hasMoreTokens()) ! { ! if (parameterName.startsWith(st.nextToken())) ! { ! return false; ! } ! } ! ! return true; // No match ! } ! } ! /** ! * Creates the field editors. Field editors are abstractions of the common ! * GUI blocks needed to manipulate various types of preferences. Each field ! * editor knows how to save and restore itself. ! */ ! public void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! ! Composite p2 = new Composite(p, 0); ! p2.setLayout(new RowLayout()); ! ! RadioGroupFieldEditor docstringCharEditor = ! new RadioGroupFieldEditor(P_DOCSTRINGCHARACTER, ! "Docstring character", 1, new String[][] { ! { "Quotation mark (\")", "\"" }, ! { "Apostrophe (')", "'" } }, p2, true); ! addField(docstringCharEditor); ! ! Group typeDoctagGroup = new Group(p2, 0); ! typeDoctagGroup.setText("Type doctag generation (@type x:...)"); ! typeDoctagEditor = new RadioGroupFieldEditor(P_TYPETAGGENERATION, ! "", 1, new String[][] { ! { "&Always", TYPETAG_GENERATION_ALWAYS }, ! { "&Never", TYPETAG_GENERATION_NEVER}, ! { "&Custom", TYPETAG_GENERATION_CUSTOM } }, typeDoctagGroup); ! addField(typeDoctagEditor); ! typeDoctagEditor.setPropertyChangeListener(this); ! addField(new ParameterNamePrefixListEditor(P_DONT_GENERATE_TYPETAGS, ! "Don't create for parameters with prefix", typeDoctagGroup)); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! ! public void propertyChange(PropertyChangeEvent event) { ! InputDialog d = new InputDialog(getShell(), ! "Type doctag generation", ! "Enter a parameter prefix", ! null, ! null); ! d.open(); ! } ! private RadioGroupFieldEditor typeDoctagEditor; } --- 61,163 ---- } ! Preferences preferences = PydevPrefs.getPreferences(); return preferences.getString(P_DOCSTRINGCHARACTER); ! } ! /** ! * ! * @return The string that should be used to mark the beginning or end of a ! * docstring. (""") or (''') ! */ ! public static String getDocstringMarker() { ! String docstringChar = getPreferredDocstringCharacter(); ! return docstringChar + docstringChar + docstringChar; ! } ! /** ! * Determines, from the preferences, whether a type tag should be generated ! * for a function / method parameter. ! * ! * @param parameterName The name of the parameter. ! * @return true if it should be generated and false otherwise ! */ ! public static boolean getTypeTagShouldBeGenerated(String parameterName) { if(PydevPlugin.getDefault() == null){ //on tests return true; } ! String preference = PydevPrefs.getPreferences().getString(P_TYPETAGGENERATION); ! if (preference.equals(TYPETAG_GENERATION_NEVER)) { ! return false; ! } else if (preference.equals(TYPETAG_GENERATION_ALWAYS)) { ! return true; ! } else {// TYPETAG_GENERATION_CUSTOM - check prefix. ! String prefixesString = PydevPrefs.getPreferences().getString(P_DONT_GENERATE_TYPETAGS); ! StringTokenizer st = new StringTokenizer(prefixesString, "\0"); // "\0" is the separator ! ! while (st.hasMoreTokens()) ! { ! if (parameterName.startsWith(st.nextToken())) ! { ! return false; ! } ! } ! ! return true; // No match ! } ! } ! /** ! * Creates the field editors. Field editors are abstractions of the common ! * GUI blocks needed to manipulate various types of preferences. Each field ! * editor knows how to save and restore itself. ! */ ! public void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! ! Composite p2 = new Composite(p, 0); ! p2.setLayout(new RowLayout()); ! ! RadioGroupFieldEditor docstringCharEditor = ! new RadioGroupFieldEditor(P_DOCSTRINGCHARACTER, ! "Docstring character", 1, new String[][] { ! { "Quotation mark (\")", "\"" }, ! { "Apostrophe (')", "'" } }, p2, true); ! addField(docstringCharEditor); ! ! Group typeDoctagGroup = new Group(p2, 0); ! typeDoctagGroup.setText("Type doctag generation (@type x:...)"); ! typeDoctagEditor = new RadioGroupFieldEditor(P_TYPETAGGENERATION, ! "", 1, new String[][] { ! { "&Always", TYPETAG_GENERATION_ALWAYS }, ! { "&Never", TYPETAG_GENERATION_NEVER}, ! { "&Custom", TYPETAG_GENERATION_CUSTOM } }, typeDoctagGroup); ! addField(typeDoctagEditor); ! typeDoctagEditor.setPropertyChangeListener(this); ! addField(new ParameterNamePrefixListEditor(P_DONT_GENERATE_TYPETAGS, ! "Don't create for parameters with prefix", typeDoctagGroup)); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! ! public void propertyChange(PropertyChangeEvent event) { ! InputDialog d = new InputDialog(getShell(), ! "Type doctag generation", ! "Enter a parameter prefix", ! null, ! null); ! d.open(); ! } ! private RadioGroupFieldEditor typeDoctagEditor; } Index: AssistDocString.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings/AssistDocString.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AssistDocString.java 14 Jun 2008 22:14:56 -0000 1.6 --- AssistDocString.java 28 Sep 2008 12:45:47 -0000 1.7 *************** *** 85,89 **** */ public boolean isValid(PySelection ps, String sel, PyEdit edit, int offset) { ! return ps.isInFunctionLine() || ps.isInClassLine(); } --- 85,89 ---- */ public boolean isValid(PySelection ps, String sel, PyEdit edit, int offset) { ! return ps.isInFunctionLine() || ps.isInClassLine(); } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:36
|
Update of /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_dltk_console/org/python/pydev/dltk/console/ui/internal Modified Files: ScriptConsoleDocumentListener.java ScriptConsoleViewer.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: ScriptConsoleDocumentListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal/ScriptConsoleDocumentListener.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ScriptConsoleDocumentListener.java 9 Jul 2008 19:11:34 -0000 1.12 --- ScriptConsoleDocumentListener.java 28 Sep 2008 12:45:37 -0000 1.13 *************** *** 426,442 **** } }else if (addedCloseParen){ ! String cmdLine = getCommandLine(); String existingDoc = cmdLine+text.substring(1); int cmdLineOffset = cmdLine.length(); if(existingDoc.length() > cmdLineOffset){ ! Document parenDoc = new Document(existingDoc); ! DocCmd docCmd = new DocCmd(cmdLineOffset, 0, ")"); ! docCmd.shiftsCaret = true; ! boolean canSkipOpenParenthesis = strategy.canSkipOpenParenthesis(parenDoc, docCmd); ! if(canSkipOpenParenthesis){ ! shiftsCaret = false; ! setCaretOffset(offset + 1); ! newText = newText.substring(1); ! } } } --- 426,442 ---- } }else if (addedCloseParen){ ! String cmdLine = getCommandLine(); String existingDoc = cmdLine+text.substring(1); int cmdLineOffset = cmdLine.length(); if(existingDoc.length() > cmdLineOffset){ ! Document parenDoc = new Document(existingDoc); ! DocCmd docCmd = new DocCmd(cmdLineOffset, 0, ")"); ! docCmd.shiftsCaret = true; ! boolean canSkipOpenParenthesis = strategy.canSkipOpenParenthesis(parenDoc, docCmd); ! if(canSkipOpenParenthesis){ ! shiftsCaret = false; ! setCaretOffset(offset + 1); ! newText = newText.substring(1); ! } } } *************** *** 552,556 **** private void setCaretOffset(int offset) { ! setCaretOffset(offset, false); } --- 552,556 ---- private void setCaretOffset(int offset) { ! setCaretOffset(offset, false); } Index: ScriptConsoleViewer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal/ScriptConsoleViewer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ScriptConsoleViewer.java 28 Jun 2008 12:35:38 -0000 1.21 --- ScriptConsoleViewer.java 28 Sep 2008 12:45:37 -0000 1.22 *************** *** 117,121 **** //if we had an enter with the shift pressed and we're in a completion, we must stop it if(inCompletion && (event.stateMask & SWT.SHIFT) != 0){ ! ((PyContentAssistant)ScriptConsoleViewer.this.fContentAssistant).hide(); } --- 117,121 ---- //if we had an enter with the shift pressed and we're in a completion, we must stop it if(inCompletion && (event.stateMask & SWT.SHIFT) != 0){ ! ((PyContentAssistant)ScriptConsoleViewer.this.fContentAssistant).hide(); } *************** *** 130,155 **** if (event.character == SWT.ESC) { ! if(!inCompletion){ ! //while in a completion, esc won't clear the line (just stop the completion) ! listener.setCommandLine(""); ! } ! return; } }else{ //not printable char if (isCaretInEditableRange()) { ! if(!inCompletion && event.keyCode == SWT.PAGE_UP){ ! event.doit = false; ! List<String> commands = history.getAsList(); ! List<String> commandsToExecute = ScriptConsoleHistorySelector.select(commands); ! if(commandsToExecute != null){ ! //remove the current command (substituted by the one gotten from page up) ! listener.setCommandLine(""); ! for(String s:commandsToExecute){ ! IDocument d = getDocument(); ! d.replace(d.getLength(), 0, s+"\n"); ! } ! } ! return; ! } } } --- 130,155 ---- if (event.character == SWT.ESC) { ! if(!inCompletion){ ! //while in a completion, esc won't clear the line (just stop the completion) ! listener.setCommandLine(""); ! } ! return; } }else{ //not printable char if (isCaretInEditableRange()) { ! if(!inCompletion && event.keyCode == SWT.PAGE_UP){ ! event.doit = false; ! List<String> commands = history.getAsList(); ! List<String> commandsToExecute = ScriptConsoleHistorySelector.select(commands); ! if(commandsToExecute != null){ ! //remove the current command (substituted by the one gotten from page up) ! listener.setCommandLine(""); ! for(String s:commandsToExecute){ ! IDocument d = getDocument(); ! d.replace(d.getLength(), 0, s+"\n"); ! } ! } ! return; ! } } } *************** *** 203,207 **** * @param style style to be used */ ! public ScriptConsoleStyledText(Composite parent, int style) { super(parent, style); --- 203,207 ---- * @param style style to be used */ ! public ScriptConsoleStyledText(Composite parent, int style) { super(parent, style); *************** *** 215,221 **** addVerifyListener(new VerifyListener(){ ! public void verifyText(VerifyEvent e) { ! internalCaretSet = -1; ! }} ); --- 215,221 ---- addVerifyListener(new VerifyListener(){ ! public void verifyText(VerifyEvent e) { ! internalCaretSet = -1; ! }} ); *************** *** 225,237 **** addExtendedModifyListener(new ExtendedModifyListener(){ ! public void modifyText(ExtendedModifyEvent event) { ! if(internalCaretSet != -1){ ! if(internalCaretSet != getCaretOffset()){ ! setCaretOffset(internalCaretSet); ! } ! internalCaretSet = -1; ! } ! }} ); --- 225,237 ---- addExtendedModifyListener(new ExtendedModifyListener(){ ! public void modifyText(ExtendedModifyEvent event) { ! if(internalCaretSet != -1){ ! if(internalCaretSet != getCaretOffset()){ ! setCaretOffset(internalCaretSet); ! } ! internalCaretSet = -1; ! } ! }} ); *************** *** 241,258 **** } ! /** ! * Overridden to keep track of changes in the caret. ! */ ! @Override ! public void setCaretOffset(int offset) { ! internalCaretSet = offset; ! super.setCaretOffset(offset); ! } ! ! /** ! * Execute some action. ! */ ! public void invokeAction(int action) { ! //some actions have a different scope (not in selected range / out of selected range) switch (action) { case ST.LINE_START: --- 241,258 ---- } ! /** ! * Overridden to keep track of changes in the caret. ! */ ! @Override ! public void setCaretOffset(int offset) { ! internalCaretSet = offset; ! super.setCaretOffset(offset); ! } ! ! /** ! * Execute some action. ! */ ! public void invokeAction(int action) { ! //some actions have a different scope (not in selected range / out of selected range) switch (action) { case ST.LINE_START: *************** *** 270,274 **** try { int historyChange = 0; ! switch (action) { case ST.LINE_UP: historyChange = 1; --- 270,274 ---- try { int historyChange = 0; ! switch (action) { case ST.LINE_UP: historyChange = 1; *************** *** 284,305 **** case ST.DELETE_WORD_PREVIOUS: ! handleDeletePreviousWord.execute(getDocument(), getCaretOffset(), getCommandLineOffset()); return; } ! ! if(historyChange != 0){ ! if(changedAfterLastHistoryRequest){ ! //only set a new match if it didn't change since the last time we did an UP/DOWN ! history.setMatchStart(getCommandLine()); ! } ! boolean didChange; ! if(historyChange == 1){ ! didChange = history.prev(); ! }else{ ! didChange = history.next(); ! } ! ! if(didChange){ ! inHistoryRequests += 1; try { listener.setCommandLine(history.get()); --- 284,305 ---- case ST.DELETE_WORD_PREVIOUS: ! handleDeletePreviousWord.execute(getDocument(), getCaretOffset(), getCommandLineOffset()); return; } ! ! if(historyChange != 0){ ! if(changedAfterLastHistoryRequest){ ! //only set a new match if it didn't change since the last time we did an UP/DOWN ! history.setMatchStart(getCommandLine()); ! } ! boolean didChange; ! if(historyChange == 1){ ! didChange = history.prev(); ! }else{ ! didChange = history.next(); ! } ! ! if(didChange){ ! inHistoryRequests += 1; try { listener.setCommandLine(history.get()); *************** *** 308,315 **** inHistoryRequests -= 1; } ! } changedAfterLastHistoryRequest = false; return; ! } --- 308,315 ---- inHistoryRequests -= 1; } ! } changedAfterLastHistoryRequest = false; return; ! } *************** *** 420,435 **** final StyledText textWidget = getTextWidget(); if(textWidget != null){ ! if(async){ ! Display display = textWidget.getDisplay(); ! if(display != null){ ! display.asyncExec(new Runnable() { ! public void run() { ! textWidget.setCaretOffset(offset); ! } ! }); ! } ! }else{ ! textWidget.setCaretOffset(offset); ! } } } --- 420,435 ---- final StyledText textWidget = getTextWidget(); if(textWidget != null){ ! if(async){ ! Display display = textWidget.getDisplay(); ! if(display != null){ ! display.asyncExec(new Runnable() { ! public void run() { ! textWidget.setCaretOffset(offset); ! } ! }); ! } ! }else{ ! textWidget.setCaretOffset(offset); ! } } } *************** *** 542,548 **** styledText.addFocusListener(new FocusListener() { ! /** ! * When the initial focus is gained, set the caret position to the last position (just after the prompt) ! */ public void focusGained(FocusEvent e) { setCaretOffset(getDocument().getLength(), true); --- 542,548 ---- styledText.addFocusListener(new FocusListener() { ! /** ! * When the initial focus is gained, set the caret position to the last position (just after the prompt) ! */ public void focusGained(FocusEvent e) { setCaretOffset(getDocument().getLength(), true); *************** *** 576,587 **** styledText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { ! if (getCaretOffset() >= getCommandLineOffset()){ ! if (KeyBindingHelper.matchesContentAssistKeybinding(e)) { ! contentHandler.contentAssistRequired(); ! ! }else if (KeyBindingHelper.matchesQuickAssistKeybinding(e)) { ! contentHandler.quickAssistRequired(); } ! } } --- 576,587 ---- styledText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { ! if (getCaretOffset() >= getCommandLineOffset()){ ! if (KeyBindingHelper.matchesContentAssistKeybinding(e)) { ! contentHandler.contentAssistRequired(); ! ! }else if (KeyBindingHelper.matchesQuickAssistKeybinding(e)) { ! contentHandler.quickAssistRequired(); } ! } } *************** *** 598,627 **** @Override public void configure(SourceViewerConfiguration configuration) { ! super.configure(configuration); ! ICompletionListener completionListener = new ICompletionListener(){ ! ! public void assistSessionStarted(ContentAssistEvent event) { ! inCompletion = true; ! } ! ! public void assistSessionEnded(ContentAssistEvent event) { ! inCompletion = false; ! } ! ! public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) { ! } ! }; ! ! if(fContentAssistant != null){ ((IContentAssistantExtension2)fContentAssistant).addCompletionListener(completionListener); ! } ! ! if(fQuickAssistAssistant != null){ ! fQuickAssistAssistant.addCompletionListener(completionListener); ! } ! ! if(isMainViewer){ ! clear(true); ! } } --- 598,627 ---- @Override public void configure(SourceViewerConfiguration configuration) { ! super.configure(configuration); ! ICompletionListener completionListener = new ICompletionListener(){ ! ! public void assistSessionStarted(ContentAssistEvent event) { ! inCompletion = true; ! } ! ! public void assistSessionEnded(ContentAssistEvent event) { ! inCompletion = false; ! } ! ! public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) { ! } ! }; ! ! if(fContentAssistant != null){ ((IContentAssistantExtension2)fContentAssistant).addCompletionListener(completionListener); ! } ! ! if(fQuickAssistAssistant != null){ ! fQuickAssistAssistant.addCompletionListener(completionListener); ! } ! ! if(isMainViewer){ ! clear(true); ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:35
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion/templates Modified Files: PyDocumentTemplateContext.java PyTemplateCompletionProcessor.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: PyTemplateCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/templates/PyTemplateCompletionProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyTemplateCompletionProcessor.java 3 Apr 2008 17:48:19 -0000 1.2 --- PyTemplateCompletionProcessor.java 28 Sep 2008 12:45:52 -0000 1.3 *************** *** 54,58 **** */ protected Image getImage(Template template) { ! return PydevPlugin.getImageCache().get(UIConstants.COMPLETION_TEMPLATE); } --- 54,58 ---- */ protected Image getImage(Template template) { ! return PydevPlugin.getImageCache().get(UIConstants.COMPLETION_TEMPLATE); } Index: PyDocumentTemplateContext.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/templates/PyDocumentTemplateContext.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyDocumentTemplateContext.java 28 Jul 2008 15:53:31 -0000 1.3 --- PyDocumentTemplateContext.java 28 Sep 2008 12:45:52 -0000 1.4 *************** *** 123,135 **** int size = splitted.size(); if(size > 0){ ! FastStringBuffer buffer = new FastStringBuffer("", (pattern.length()+(size*2))+((size+1)*indentToStr.length())); for (int i=0; i<size;i++) { //we don't want to get the first line ! ! if(i != 0){ ! //the 1st line is not indented (that's where the user requested the completion -- others should be indented to it) ! buffer.append(indentToStr); ! } ! String str = splitted.get(i); --- 123,135 ---- int size = splitted.size(); if(size > 0){ ! FastStringBuffer buffer = new FastStringBuffer("", (pattern.length()+(size*2))+((size+1)*indentToStr.length())); for (int i=0; i<size;i++) { //we don't want to get the first line ! ! if(i != 0){ ! //the 1st line is not indented (that's where the user requested the completion -- others should be indented to it) ! buffer.append(indentToStr); ! } ! String str = splitted.get(i); *************** *** 138,152 **** boolean hasNewLine = false; if(str.endsWith("\r") || str.endsWith("\n")){ ! hasNewLine = true; ! if(str.endsWith("\r\n")){ ! str = str.substring(0, str.length()-2); ! }else{ ! str = str.substring(0, str.length()-1); ! } } - buffer.append(str); - if(hasNewLine){ - buffer.append(endLineDelim); - } } //just to change the pattern... --- 138,152 ---- boolean hasNewLine = false; if(str.endsWith("\r") || str.endsWith("\n")){ ! hasNewLine = true; ! if(str.endsWith("\r\n")){ ! str = str.substring(0, str.length()-2); ! }else{ ! str = str.substring(0, str.length()-1); ! } ! } ! buffer.append(str); ! if(hasNewLine){ ! buffer.append(endLineDelim); } } //just to change the pattern... |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:34
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/tests/org/python/pydev/editor/correctionassist/heuristics Modified Files: AssistCreateInModuleTest.java AssistAssignTest.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: AssistCreateInModuleTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistCreateInModuleTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AssistCreateInModuleTest.java 25 Sep 2005 13:07:04 -0000 1.8 --- AssistCreateInModuleTest.java 28 Sep 2008 12:45:42 -0000 1.9 *************** *** 43,72 **** // public void testAssistMethod() throws BadLocationException { // assist = new AssistCreateMethodInModule(); ! // String d = ""+ ! // "from testAssist import assist\n" + ! // "assist.NewMethod(a,b)"; // ! // String res = "\n" + ! // "def NewMethod(a,b):\n" + ! // " '''\n"+ ! // " @param a:\n"+ ! // " @param b:\n"+ ! // " '''\n"+ ! // " "; // ! // checkCreateMethod(d, res, "testAssist.assist", true, -1, "NewMethod"); // ! // d = ""+ ! // "from testAssist import assist\n" + ! // "NewMethod(a,b)"; ! // checkCreateMethod(d, res, "", true, -1, "NewMethod"); // ! // d = ""+ ! // "class NewClass(object): \n" + ! // " \n" + ! // " def NewMethod(a,b): \n" + ! // " pass \n"; ! // checkCreateMethod(d, res, "", false, 0, ""); ! // checkCreateMethod(d, res, "", false, 2, ""); // } // --- 43,72 ---- // public void testAssistMethod() throws BadLocationException { // assist = new AssistCreateMethodInModule(); ! // String d = ""+ ! // "from testAssist import assist\n" + ! // "assist.NewMethod(a,b)"; // ! // String res = "\n" + ! // "def NewMethod(a,b):\n" + ! // " '''\n"+ ! // " @param a:\n"+ ! // " @param b:\n"+ ! // " '''\n"+ ! // " "; // ! // checkCreateMethod(d, res, "testAssist.assist", true, -1, "NewMethod"); // ! // d = ""+ ! // "from testAssist import assist\n" + ! // "NewMethod(a,b)"; ! // checkCreateMethod(d, res, "", true, -1, "NewMethod"); // ! // d = ""+ ! // "class NewClass(object): \n" + ! // " \n" + ! // " def NewMethod(a,b): \n" + ! // " pass \n"; ! // checkCreateMethod(d, res, "", false, 0, ""); ! // checkCreateMethod(d, res, "", false, 2, ""); // } // *************** *** 83,94 **** // Document doc = new Document(docStr); // ! // int offset = 0; ! // if (line == -1){ ! // offset = docStr.length(); ! // }else{ ! // IRegion lineInformation = doc.getLineInformation(line); ! // offset = lineInformation.getOffset() + lineInformation.getLength(); ! // } ! // // PySelection ps = new PySelection(doc, new TextSelection(doc, offset, 0)); // String sel = PyAction.getLineWithoutComments(ps); --- 83,94 ---- // Document doc = new Document(docStr); // ! // int offset = 0; ! // if (line == -1){ ! // offset = docStr.length(); ! // }else{ ! // IRegion lineInformation = doc.getLineInformation(line); ! // offset = lineInformation.getOffset() + lineInformation.getLength(); ! // } ! // // PySelection ps = new PySelection(doc, new TextSelection(doc, offset, 0)); // String sel = PyAction.getLineWithoutComments(ps); *************** *** 96,107 **** // assertEquals(isValid, assist.isValid(ps, sel, null, offset)); // if(isValid){ ! // List props = assist.getProps(ps, null, null, nature, null, offset); ! // assertEquals(1, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // ! // assertEquals(res, p.getReplacementStr()); ! // assertEquals(moduleName, p.module.getName()); ! // assertTrue(p.getDisplayString().indexOf(tok) != -1); // } // } --- 96,107 ---- // assertEquals(isValid, assist.isValid(ps, sel, null, offset)); // if(isValid){ ! // List props = assist.getProps(ps, null, null, nature, null, offset); ! // assertEquals(1, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // ! // assertEquals(res, p.getReplacementStr()); ! // assertEquals(moduleName, p.module.getName()); ! // assertTrue(p.getDisplayString().indexOf(tok) != -1); // } // } *************** *** 113,142 **** // */ // public void testAssistClass() throws BadLocationException { ! // String docStr = ""+ ! // "from testAssist import assist\n" + ! // "assist.NewClass(a,b)"; ! // String moduleName = "testAssist.assist"; ! // int nProps = 1; ! // assist = new AssistCreateClassInModule(); ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", true); ! // // ! // nProps = 1; ! // moduleName = ""; ! // docStr = ""+ ! // "from testAssist import assist\n" + ! // "newClass = NewClass(a,b)"; ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", true); // ! // docStr = ""+ ! // "from testAssist import assist\n" + ! // "newClass = NewClass()"; ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", false); // ! // //same as before... different sel ! // docStr = ""+ ! // "from testAssist import assist\n" + //30 chars ! // "assist.Ignore(NewClass(a,b)) "; //from 14 to +13 ! // checkAssistClass(docStr, moduleName, nProps,30+14,13, "NewClass", true); // } // --- 113,142 ---- // */ // public void testAssistClass() throws BadLocationException { ! // String docStr = ""+ ! // "from testAssist import assist\n" + ! // "assist.NewClass(a,b)"; ! // String moduleName = "testAssist.assist"; ! // int nProps = 1; ! // assist = new AssistCreateClassInModule(); ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", true); ! // // ! // nProps = 1; ! // moduleName = ""; ! // docStr = ""+ ! // "from testAssist import assist\n" + ! // "newClass = NewClass(a,b)"; ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", true); // ! // docStr = ""+ ! // "from testAssist import assist\n" + ! // "newClass = NewClass()"; ! // checkAssistClass(docStr, moduleName, nProps,-1,0, "NewClass", false); // ! // //same as before... different sel ! // docStr = ""+ ! // "from testAssist import assist\n" + //30 chars ! // "assist.Ignore(NewClass(a,b)) "; //from 14 to +13 ! // checkAssistClass(docStr, moduleName, nProps,30+14,13, "NewClass", true); // } // *************** *** 152,180 **** // selStart = docStr.length(); // Document doc = new Document(docStr); ! // PySelection ps = new PySelection(doc, new TextSelection(doc, selStart, selLength)); // String sel = PyAction.getLineWithoutComments(ps); // ! // assertEquals(true, assist.isValid(ps, sel, null, selStart)); ! // List props = assist.getProps(ps, null, null, nature, null, selStart); // assertEquals(nProps, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // String res = "\n" + ! // "class NewClass(object):\n" + ! // " '''\n"+ ! // " '''\n"+ ! // " \n"; ! // ! // if (hasParams){ ! // res += ""+ ! // " def __init__(self, a, b):\n"+ ! // " '''\n"+ ! // " @param a:\n"+ ! // " @param b:\n"+ ! // " '''\n"+ ! // " "; ! // } ! // ! // assertEquals(res, p.getReplacementStr()); // assertEquals(moduleName, p.module.getName()); // assertTrue(p.getDisplayString().indexOf(tok) != -1); --- 152,180 ---- // selStart = docStr.length(); // Document doc = new Document(docStr); ! // PySelection ps = new PySelection(doc, new TextSelection(doc, selStart, selLength)); // String sel = PyAction.getLineWithoutComments(ps); // ! // assertEquals(true, assist.isValid(ps, sel, null, selStart)); ! // List props = assist.getProps(ps, null, null, nature, null, selStart); // assertEquals(nProps, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // String res = "\n" + ! // "class NewClass(object):\n" + ! // " '''\n"+ ! // " '''\n"+ ! // " \n"; ! // ! // if (hasParams){ ! // res += ""+ ! // " def __init__(self, a, b):\n"+ ! // " '''\n"+ ! // " @param a:\n"+ ! // " @param b:\n"+ ! // " '''\n"+ ! // " "; ! // } ! // ! // assertEquals(res, p.getReplacementStr()); // assertEquals(moduleName, p.module.getName()); // assertTrue(p.getDisplayString().indexOf(tok) != -1); *************** *** 187,215 **** // public void testAssistMethodInClass() throws BadLocationException { // assist = new AssistCreateMethodInClass(); ! // String d = ""+ ! // "from testAssist import assist\n" + ! // "ex = assist.ExistingClass()\n" + ! // "ex.newMethod(c,d)"; // ! // Document doc = new Document(d); ! // PySelection ps = new PySelection(doc, new TextSelection(doc, d.length(), 0)); // String sel = PyAction.getLineWithoutComments(ps); // ! // assertEquals(true, assist.isValid(ps, sel, null, d.length())); ! // List props = assist.getProps(ps, null, null, nature, null, d.length()); ! // assertEquals(1, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // String res = "\n" + ! // " def newMethod(self, c, d):\n"+ ! // " '''\n"+ ! // " @param c:\n"+ ! // " @param d:\n"+ ! // " '''\n"+ ! // " "; ! // assertEquals(res, p.getReplacementStr()); ! // assertEquals("testAssist.assist", p.module.getName()); ! // assertEquals("ExistingClass", p.definition.value); ! // assertEquals(SourceModuleProposal.ADD_TO_LAST_CLASS_LINE, p.addTo); // assertTrue(p.getDisplayString().indexOf("newMethod") != -1); // } --- 187,215 ---- // public void testAssistMethodInClass() throws BadLocationException { // assist = new AssistCreateMethodInClass(); ! // String d = ""+ ! // "from testAssist import assist\n" + ! // "ex = assist.ExistingClass()\n" + ! // "ex.newMethod(c,d)"; // ! // Document doc = new Document(d); ! // PySelection ps = new PySelection(doc, new TextSelection(doc, d.length(), 0)); // String sel = PyAction.getLineWithoutComments(ps); // ! // assertEquals(true, assist.isValid(ps, sel, null, d.length())); ! // List props = assist.getProps(ps, null, null, nature, null, d.length()); ! // assertEquals(1, props.size()); ! // SourceModuleProposal p = (SourceModuleProposal) props.get(0); ! // ! // String res = "\n" + ! // " def newMethod(self, c, d):\n"+ ! // " '''\n"+ ! // " @param c:\n"+ ! // " @param d:\n"+ ! // " '''\n"+ ! // " "; ! // assertEquals(res, p.getReplacementStr()); ! // assertEquals("testAssist.assist", p.module.getName()); ! // assertEquals("ExistingClass", p.definition.value); ! // assertEquals(SourceModuleProposal.ADD_TO_LAST_CLASS_LINE, p.addTo); // assertTrue(p.getDisplayString().indexOf("newMethod") != -1); // } Index: AssistAssignTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistAssignTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AssistAssignTest.java 30 Aug 2007 01:26:49 -0000 1.7 --- AssistAssignTest.java 28 Sep 2008 12:45:42 -0000 1.8 *************** *** 44,48 **** private static final boolean DEBUG = false; ! private AssistAssign assist; public static void main(String[] args) { --- 44,48 ---- private static final boolean DEBUG = false; ! private AssistAssign assist; public static void main(String[] args) { *************** *** 74,89 **** public void testSimple() throws BadLocationException { ! String d = ""+ ! "from testAssist import assist\n" + ! "assist.NewMethod(a,b)"; ! Document doc = new Document(d); ! PySelection ps = new PySelection(doc, new TextSelection(doc, d.length(), 0)); String sel = PyAction.getLineWithoutComments(ps); ! assertEquals(true, assist.isValid(ps, sel, null, d.length())); ! List<ICompletionProposal> props = assist.getProps(ps, null, null, null, null, d.length()); ! assertEquals(2, props.size()); } --- 74,89 ---- public void testSimple() throws BadLocationException { ! String d = ""+ ! "from testAssist import assist\n" + ! "assist.NewMethod(a,b)"; ! Document doc = new Document(d); ! PySelection ps = new PySelection(doc, new TextSelection(doc, d.length(), 0)); String sel = PyAction.getLineWithoutComments(ps); ! assertEquals(true, assist.isValid(ps, sel, null, d.length())); ! List<ICompletionProposal> props = assist.getProps(ps, null, null, null, null, d.length()); ! assertEquals(2, props.size()); } *************** *** 270,276 **** for (ICompletionProposal proposal : props) { ! if(DEBUG){ ! System.out.println(proposal.getDisplayString()); ! } if(proposal.getDisplayString().equals(string)){ return; --- 270,276 ---- for (ICompletionProposal proposal : props) { ! if(DEBUG){ ! System.out.println(proposal.getDisplayString()); ! } if(proposal.getDisplayString().equals(string)){ return; |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/actions/codefolding Modified Files: PyUnCollapseAll.java PyCollapseAll.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: PyUnCollapseAll.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/codefolding/PyUnCollapseAll.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyUnCollapseAll.java 9 Jul 2005 01:05:56 -0000 1.5 --- PyUnCollapseAll.java 28 Sep 2008 12:45:49 -0000 1.6 *************** *** 23,27 **** */ public void run(IAction action) { ! final ProjectionAnnotationModel model = getModel(); if (model != null) { --- 23,27 ---- */ public void run(IAction action) { ! final ProjectionAnnotationModel model = getModel(); if (model != null) { *************** *** 31,56 **** if(iter != null){ ! //we just want to expand the roots, and we are working only with the collapsed sorted by offset. ! ! List elements = new ArrayList(); //used to know the context ! while (iter.hasNext()) { ! PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); ! ! //special case, we have none in our context ! if(elements.size() == 0){ ! model.expand(element); ! elements.add(element); ! ! } else{ ! if(isInsideLast(element, elements, model)){ ! //ignore ! ! }else{ ! //ok, the one in the top has to be collapsed ( and this one added ) ! model.expand(element); ! elements.add(element); ! } ! } ! } } } --- 31,56 ---- if(iter != null){ ! //we just want to expand the roots, and we are working only with the collapsed sorted by offset. ! ! List elements = new ArrayList(); //used to know the context ! while (iter.hasNext()) { ! PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); ! ! //special case, we have none in our context ! if(elements.size() == 0){ ! model.expand(element); ! elements.add(element); ! ! } else{ ! if(isInsideLast(element, elements, model)){ ! //ignore ! ! }else{ ! //ok, the one in the top has to be collapsed ( and this one added ) ! model.expand(element); ! elements.add(element); ! } ! } ! } } } Index: PyCollapseAll.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/codefolding/PyCollapseAll.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyCollapseAll.java 9 Jul 2005 01:05:56 -0000 1.5 --- PyCollapseAll.java 28 Sep 2008 12:45:49 -0000 1.6 *************** *** 25,29 **** */ public void run(IAction action) { ! final ProjectionAnnotationModel model = getModel(); if (model != null) { --- 25,29 ---- */ public void run(IAction action) { ! final ProjectionAnnotationModel model = getModel(); if (model != null) { *************** *** 33,62 **** if(iter != null){ ! //we just want to collapse the leafs, and we are working only with the not collapsed sorted by offset. ! ! List elements = new ArrayList(); //used to know the context ! while (iter.hasNext()) { ! PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); ! ! //special case, we have none in our context ! if(elements.size() == 0){ ! elements.add(element); ! ! } else{ ! if(isInsideLast(element, elements, model)){ ! elements.add(element); ! ! }else{ ! //ok, the one in the top has to be collapsed ( and this one added ) ! PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size()-1); ! model.collapse(top); ! elements.add(element); ! } ! } ! } ! if(elements.size() > 0){ ! PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size()-1); ! model.collapse(top); ! } } } --- 33,62 ---- if(iter != null){ ! //we just want to collapse the leafs, and we are working only with the not collapsed sorted by offset. ! ! List elements = new ArrayList(); //used to know the context ! while (iter.hasNext()) { ! PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); ! ! //special case, we have none in our context ! if(elements.size() == 0){ ! elements.add(element); ! ! } else{ ! if(isInsideLast(element, elements, model)){ ! elements.add(element); ! ! }else{ ! //ok, the one in the top has to be collapsed ( and this one added ) ! PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size()-1); ! model.collapse(top); ! elements.add(element); ! } ! } ! } ! if(elements.size() > 0){ ! PyProjectionAnnotation top = (PyProjectionAnnotation) elements.remove(elements.size()-1); ! model.collapse(top); ! } } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:32
|
Update of /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_navigator/org/python/pydev/navigator/actions Modified Files: PyCopyResourceAction.java PythonLinkHelper.java PyRenameResourceAction.java PyMoveResourceAction.java PyPasteAction.java PyDeleteResourceAction.java PythonRefactorActionProvider.java PythonActionProvider.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: PyDeleteResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyDeleteResourceAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyDeleteResourceAction.java 31 Jul 2008 01:47:36 -0000 1.4 --- PyDeleteResourceAction.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 72,76 **** ! @Override protected List getSelectedResources() { --- 72,76 ---- ! @Override protected List getSelectedResources() { *************** *** 80,84 **** @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } --- 80,84 ---- @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } Index: PythonLinkHelper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PythonLinkHelper.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonLinkHelper.java 6 Aug 2008 16:23:19 -0000 1.4 --- PythonLinkHelper.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 62,74 **** //ok, let's check if the active editor is already the selection, because although the findEditor(editorInput) method //may return an editor for the correct file, we may have multiple editors for the same file, and if the current ! //editor is already correct, we don't want to change it ! //@see bug: https://sourceforge.net/tracker/?func=detail&atid=577329&aid=2037682&group_id=85796 IEditorPart activeEditor = aPage.getActiveEditor(); if(activeEditor != null){ ! IEditorInput editorInput = activeEditor.getEditorInput(); ! IFile currFile = (IFile) editorInput.getAdapter(IFile.class); ! if(currFile != null && currFile.equals(firstElement)){ ! return; //the current editor is already the active editor. ! } } --- 62,74 ---- //ok, let's check if the active editor is already the selection, because although the findEditor(editorInput) method //may return an editor for the correct file, we may have multiple editors for the same file, and if the current ! //editor is already correct, we don't want to change it ! //@see bug: https://sourceforge.net/tracker/?func=detail&atid=577329&aid=2037682&group_id=85796 IEditorPart activeEditor = aPage.getActiveEditor(); if(activeEditor != null){ ! IEditorInput editorInput = activeEditor.getEditorInput(); ! IFile currFile = (IFile) editorInput.getAdapter(IFile.class); ! if(currFile != null && currFile.equals(firstElement)){ ! return; //the current editor is already the active editor. ! } } Index: PyMoveResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyMoveResourceAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyMoveResourceAction.java 31 Jul 2008 01:47:36 -0000 1.3 --- PyMoveResourceAction.java 28 Sep 2008 12:45:41 -0000 1.4 *************** *** 68,72 **** @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } --- 68,72 ---- @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } Index: PyPasteAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyPasteAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyPasteAction.java 31 Jul 2008 01:47:36 -0000 1.3 --- PyPasteAction.java 28 Sep 2008 12:45:41 -0000 1.4 *************** *** 70,74 **** @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } --- 70,74 ---- @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } Index: PyRenameResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyRenameResourceAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyRenameResourceAction.java 31 Jul 2008 01:47:36 -0000 1.2 --- PyRenameResourceAction.java 28 Sep 2008 12:45:41 -0000 1.3 *************** *** 115,119 **** @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } --- 115,119 ---- @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } Index: PythonRefactorActionProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PythonRefactorActionProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRefactorActionProvider.java 10 Mar 2007 14:32:43 -0000 1.1 --- PythonRefactorActionProvider.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 12,16 **** public class PythonRefactorActionProvider extends CommonActionProvider{ ! private PyRenameResourceAction renameResourceAction; --- 12,16 ---- public class PythonRefactorActionProvider extends CommonActionProvider{ ! private PyRenameResourceAction renameResourceAction; Index: PythonActionProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PythonActionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonActionProvider.java 7 Jul 2007 11:53:08 -0000 1.4 --- PythonActionProvider.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 29,33 **** private PyPasteAction pasteAction; private PyMoveResourceAction moveResourceAction; ! private ISelectionProvider selectionProvider; @Override --- 29,33 ---- private PyPasteAction pasteAction; private PyMoveResourceAction moveResourceAction; ! private ISelectionProvider selectionProvider; @Override Index: PyCopyResourceAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_navigator/org/python/pydev/navigator/actions/PyCopyResourceAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyCopyResourceAction.java 31 Jul 2008 01:47:36 -0000 1.3 --- PyCopyResourceAction.java 28 Sep 2008 12:45:41 -0000 1.4 *************** *** 69,73 **** @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } --- 69,73 ---- @Override public IStructuredSelection getStructuredSelection() { ! return new StructuredSelection(selected); } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:31
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/perspective In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/ui/perspective Modified Files: PythonPerspectiveFactory.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: PythonPerspectiveFactory.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/perspective/PythonPerspectiveFactory.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PythonPerspectiveFactory.java 6 May 2007 14:29:16 -0000 1.7 --- PythonPerspectiveFactory.java 28 Sep 2008 12:45:40 -0000 1.8 *************** *** 19,34 **** */ public class PythonPerspectiveFactory implements IPerspectiveFactory { ! ! public static final String PERSPECTIVE_ID = "org.python.pydev.ui.PythonPerspective"; ! /** ! * Creates Python perspective layout ! * ! * Copied from org.eclipse.jdt.internal.ui.JavaPerspectiveFactory ! */ ! public void createInitialLayout(IPageLayout layout) { ! defineLayout(layout); ! defineActions(layout); ! } --- 19,34 ---- */ public class PythonPerspectiveFactory implements IPerspectiveFactory { ! ! public static final String PERSPECTIVE_ID = "org.python.pydev.ui.PythonPerspective"; ! /** ! * Creates Python perspective layout ! * ! * Copied from org.eclipse.jdt.internal.ui.JavaPerspectiveFactory ! */ ! public void createInitialLayout(IPageLayout layout) { ! defineLayout(layout); ! defineActions(layout); ! } *************** *** 42,56 **** IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.26, editorArea); //$NON-NLS-1$ topLeft.addView("org.python.pydev.navigator.view"); ! IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$ ! outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW); ! outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID); ! outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW); ! outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS); ! outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); ! ! layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea); } --- 42,56 ---- IFolderLayout topLeft = layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.26, editorArea); //$NON-NLS-1$ topLeft.addView("org.python.pydev.navigator.view"); ! IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$ ! outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW); ! outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID); ! outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW); ! outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS); ! outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); ! ! layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea); } *************** *** 59,76 **** */ public void defineActions(IPageLayout layout) { ! layout.addNewWizardShortcut(PythonProjectWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonSourceFolderWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonPackageWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonModuleWizard.WIZARD_ID); //$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$ ! layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); ! layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); ! layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); ! layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); ! layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); ! layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView"); layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); layout.addShowViewShortcut("org.python.pydev.views.PyRefactorView"); --- 59,76 ---- */ public void defineActions(IPageLayout layout) { ! layout.addNewWizardShortcut(PythonProjectWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonSourceFolderWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonPackageWizard.WIZARD_ID); //$NON-NLS-1$ ! layout.addNewWizardShortcut(PythonModuleWizard.WIZARD_ID); //$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$ ! layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); ! layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); ! layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); ! layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); ! layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); ! layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView"); layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST); layout.addShowViewShortcut("org.python.pydev.views.PyRefactorView"); *************** *** 80,84 **** layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); ! } --- 80,84 ---- layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); ! } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/templates Modified Files: PyTemplatePreferencesPage.java PyContextType.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: PyTemplatePreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates/PyTemplatePreferencesPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyTemplatePreferencesPage.java 6 Aug 2004 17:20:03 -0000 1.1 --- PyTemplatePreferencesPage.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 14,35 **** */ public class PyTemplatePreferencesPage extends TemplatePreferencePage implements IWorkbenchPreferencePage { ! public PyTemplatePreferencesPage() { ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setTemplateStore(PydevPlugin.getDefault().getTemplateStore()); ! setContextTypeRegistry(PydevPlugin.getDefault().getContextTypeRegistry()); ! } ! protected boolean isShowFormatterSetting() { ! return true; ! } ! ! ! public boolean performOk() { ! boolean ok= super.performOk(); ! ! PydevPlugin.getDefault().savePluginPreferences(); ! ! return ok; ! } --- 14,35 ---- */ public class PyTemplatePreferencesPage extends TemplatePreferencePage implements IWorkbenchPreferencePage { ! public PyTemplatePreferencesPage() { ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setTemplateStore(PydevPlugin.getDefault().getTemplateStore()); ! setContextTypeRegistry(PydevPlugin.getDefault().getContextTypeRegistry()); ! } ! protected boolean isShowFormatterSetting() { ! return true; ! } ! ! ! public boolean performOk() { ! boolean ok= super.performOk(); ! ! PydevPlugin.getDefault().savePluginPreferences(); ! ! return ok; ! } Index: PyContextType.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates/PyContextType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyContextType.java 6 Aug 2004 17:20:03 -0000 1.1 --- PyContextType.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 16,36 **** public static final String PY_CONTEXT_TYPE = "org.python.pydev.editor.templates.python"; ! /** ! * Creates a new XML context type. ! */ ! public PyContextType() { ! addGlobalResolvers(); ! } ! private void addGlobalResolvers() { ! addResolver(new GlobalTemplateVariables.Cursor()); ! addResolver(new GlobalTemplateVariables.WordSelection()); ! addResolver(new GlobalTemplateVariables.LineSelection()); ! addResolver(new GlobalTemplateVariables.Dollar()); ! addResolver(new GlobalTemplateVariables.Date()); ! addResolver(new GlobalTemplateVariables.Year()); ! addResolver(new GlobalTemplateVariables.Time()); ! addResolver(new GlobalTemplateVariables.User()); ! } } --- 16,36 ---- public static final String PY_CONTEXT_TYPE = "org.python.pydev.editor.templates.python"; ! /** ! * Creates a new XML context type. ! */ ! public PyContextType() { ! addGlobalResolvers(); ! } ! private void addGlobalResolvers() { ! addResolver(new GlobalTemplateVariables.Cursor()); ! addResolver(new GlobalTemplateVariables.WordSelection()); ! addResolver(new GlobalTemplateVariables.LineSelection()); ! addResolver(new GlobalTemplateVariables.Dollar()); ! addResolver(new GlobalTemplateVariables.Date()); ! addResolver(new GlobalTemplateVariables.Year()); ! addResolver(new GlobalTemplateVariables.Time()); ! addResolver(new GlobalTemplateVariables.User()); ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:29
|
Update of /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_dltk_console/org/python/pydev/dltk/console Modified Files: IScriptConsoleCommunication.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: IScriptConsoleCommunication.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/IScriptConsoleCommunication.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IScriptConsoleCommunication.java 20 Mar 2008 16:56:07 -0000 1.3 --- IScriptConsoleCommunication.java 28 Sep 2008 12:45:46 -0000 1.4 *************** *** 19,29 **** public interface IScriptConsoleCommunication { ! /** ! * Executes a given command in the interpreter (push a line) ! * ! * @param command the command to be executed ! * @return the response from the interpreter (contains the stdout, stderr, etc). ! * @throws Exception ! */ InterpreterResponse execInterpreter(String command) throws Exception; --- 19,29 ---- public interface IScriptConsoleCommunication { ! /** ! * Executes a given command in the interpreter (push a line) ! * ! * @param command the command to be executed ! * @return the response from the interpreter (contains the stdout, stderr, etc). ! * @throws Exception ! */ InterpreterResponse execInterpreter(String command) throws Exception; |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:25
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/builder Modified Files: PydevInternalResourceDeltaVisitor.java PyDevBuilder.java PyDevBuilderPrefPage.java PyDevDeltaCounter.java PyDevBuilderVisitor.java PydevGrouperVisitor.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: PydevGrouperVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PydevGrouperVisitor.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PydevGrouperVisitor.java 14 Jun 2008 22:14:55 -0000 1.13 --- PydevGrouperVisitor.java 28 Sep 2008 12:45:46 -0000 1.14 *************** *** 40,89 **** */ private void visitWith(String name, boolean isAddOrChange, IResource resource, IDocument document, IProgressMonitor monitor){ ! if(monitor.isCanceled()){ ! return; //it's already cancelled ! } ! IPythonNature nature = PythonNature.getPythonNature(resource); ! if(nature == null){ ! return; ! } ! if(!nature.startRequests()){ ! return; ! } ! ! FastStringBuffer bufferToCreateString = new FastStringBuffer(); ! ! try{ ! if(!nature.isResourceInPythonpath(resource)){ ! return; // we only analyze resources that are in the pythonpath ! } ! HashMap<String, Object> memo = new HashMap<String, Object>(); ! memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, false); //mark it as a delta build ! ! for (PyDevBuilderVisitor visitor : visitors) { ! // some visitors cannot visit too many elements because they do a lot of processing ! if (visitor.maxResourcesToVisit() == PyDevBuilderVisitor.MAX_TO_VISIT_INFINITE || visitor.maxResourcesToVisit() >= totalResources) { ! visitor.memo = memo; //setting the memo must be the first thing. ! try { //communicate progress for each visitor ! PyDevBuilder.communicateProgress(monitor, totalResources, currentResourcesVisited, resource, visitor, bufferToCreateString); ! REF.invoke(visitor, name, resource, document, monitor); ! ! //ok, standard visiting ended... now, we have to check if we should visit the other ! //resources if it was an __init__.py file that changed ! if(isAddOrChange && visitor.shouldVisitInitDependency() && isInitFile(resource)){ ! IResource[] initDependents = getInitDependents(resource); ! ! for (int i = 0; i < initDependents.length; i++) { ! IDocument doc = REF.getDocFromResource(initDependents[i]); ! REF.invoke(visitor, name, initDependents[i], doc, monitor); ! } ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } } }finally{ ! nature.endRequests(); } --- 40,89 ---- */ private void visitWith(String name, boolean isAddOrChange, IResource resource, IDocument document, IProgressMonitor monitor){ ! if(monitor.isCanceled()){ ! return; //it's already cancelled ! } ! IPythonNature nature = PythonNature.getPythonNature(resource); ! if(nature == null){ ! return; ! } ! if(!nature.startRequests()){ ! return; ! } ! ! FastStringBuffer bufferToCreateString = new FastStringBuffer(); ! ! try{ ! if(!nature.isResourceInPythonpath(resource)){ ! return; // we only analyze resources that are in the pythonpath ! } ! HashMap<String, Object> memo = new HashMap<String, Object>(); ! memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, false); //mark it as a delta build ! ! for (PyDevBuilderVisitor visitor : visitors) { ! // some visitors cannot visit too many elements because they do a lot of processing ! if (visitor.maxResourcesToVisit() == PyDevBuilderVisitor.MAX_TO_VISIT_INFINITE || visitor.maxResourcesToVisit() >= totalResources) { ! visitor.memo = memo; //setting the memo must be the first thing. ! try { //communicate progress for each visitor ! PyDevBuilder.communicateProgress(monitor, totalResources, currentResourcesVisited, resource, visitor, bufferToCreateString); ! REF.invoke(visitor, name, resource, document, monitor); ! ! //ok, standard visiting ended... now, we have to check if we should visit the other ! //resources if it was an __init__.py file that changed ! if(isAddOrChange && visitor.shouldVisitInitDependency() && isInitFile(resource)){ ! IResource[] initDependents = getInitDependents(resource); ! ! for (int i = 0; i < initDependents.length; i++) { ! IDocument doc = REF.getDocFromResource(initDependents[i]); ! REF.invoke(visitor, name, initDependents[i], doc, monitor); ! } ! } ! } catch (Exception e) { ! Log.log(e); ! } ! } } }finally{ ! nature.endRequests(); } Index: PyDevBuilderVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PyDevBuilderVisitor.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PyDevBuilderVisitor.java 8 Mar 2007 10:47:16 -0000 1.37 --- PyDevBuilderVisitor.java 28 Sep 2008 12:45:46 -0000 1.38 *************** *** 24,27 **** --- 24,28 ---- import org.python.pydev.core.IPythonNature; import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; + import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; import org.python.pydev.plugin.nature.PythonNature; *************** *** 52,81 **** * Higher priorities are minor numbers (and vice-versa). */ ! public static final int PRIORITY_DEFAULT = 5; ! /** ! * Maximum priority is 0 ! */ ! public static final int PRIORITY_MAX = 0; ! ! /** ! * Minimum priority is 10 ! */ ! public static final int PRIORITY_MIN = 10; ! ! /** ! * Compares them by priority (they are ordered before visiting by priority, so, this can ! * be useful if some visitor needs to run only after some other visitor was executed). ! */ public int compareTo(PyDevBuilderVisitor o) { ! int priority = getPriority(); ! int otherPriority = o.getPriority(); ! if(priority < otherPriority){ ! return -1; ! } ! if(otherPriority < priority){ ! return 1; ! } ! return 0; //equal } --- 53,82 ---- * Higher priorities are minor numbers (and vice-versa). */ ! public static final int PRIORITY_DEFAULT = 5; ! /** ! * Maximum priority is 0 ! */ ! public static final int PRIORITY_MAX = 0; ! ! /** ! * Minimum priority is 10 ! */ ! public static final int PRIORITY_MIN = 10; ! ! /** ! * Compares them by priority (they are ordered before visiting by priority, so, this can ! * be useful if some visitor needs to run only after some other visitor was executed). ! */ public int compareTo(PyDevBuilderVisitor o) { ! int priority = getPriority(); ! int otherPriority = o.getPriority(); ! if(priority < otherPriority){ ! return -1; ! } ! if(otherPriority < priority){ ! return 1; ! } ! return 0; //equal } *************** *** 85,92 **** */ protected int getPriority() { ! return PRIORITY_DEFAULT; ! } ! /** * This field acts like a memory. * --- 86,93 ---- */ protected int getPriority() { ! return PRIORITY_DEFAULT; ! } ! /** * This field acts like a memory. * *************** *** 124,129 **** * @return the module that is created by the given resource */ ! protected IModule getSourceModule(IResource resource, IDocument document, IPythonNature nature) { ! IModule module = (IModule) memo.get(MODULE_CACHE); if(module == null){ module = createSoureModule(resource, document, getModuleName(resource, nature)); --- 125,130 ---- * @return the module that is created by the given resource */ ! protected SourceModule getSourceModule(IResource resource, IDocument document, IPythonNature nature) { ! SourceModule module = (SourceModule) memo.get(MODULE_CACHE); if(module == null){ module = createSoureModule(resource, document, getModuleName(resource, nature)); *************** *** 138,147 **** * @return */ ! public static IModule createSoureModule(IResource resource, IDocument document, String moduleName) { ! IModule module; PythonNature nature = PythonNature.getPythonNature(resource.getProject()); IFile f = (IFile) resource; String file = f.getRawLocation().toOSString(); ! module = AbstractModule.createModuleFromDoc(moduleName, new File(file), document, nature, 0); return module; } --- 139,148 ---- * @return */ ! private static SourceModule createSoureModule(IResource resource, IDocument document, String moduleName) { ! SourceModule module; PythonNature nature = PythonNature.getPythonNature(resource.getProject()); IFile f = (IFile) resource; String file = f.getRawLocation().toOSString(); ! module = (SourceModule)AbstractModule.createModuleFromDoc(moduleName, new File(file), document, nature, 0); return module; } *************** *** 174,178 **** setModuleNameInCache(moduleName); }else{ ! throw new RuntimeException("Unable to resolve module for:"+resource); } } --- 175,179 ---- setModuleNameInCache(moduleName); }else{ ! throw new RuntimeException("Unable to resolve module for:"+resource); } } *************** *** 204,210 **** */ public static boolean isInPythonPath(IResource resource){ ! if(resource == null){ ! return false; ! } IProject project = resource.getProject(); PythonNature nature = PythonNature.getPythonNature(project); --- 205,211 ---- */ public static boolean isInPythonPath(IResource resource){ ! if(resource == null){ ! return false; ! } IProject project = resource.getProject(); PythonNature nature = PythonNature.getPythonNature(project); *************** *** 238,242 **** } ! /** * @param toRet * @param parent --- 239,243 ---- } ! /** * @param toRet * @param parent *************** *** 257,269 **** ! /** ! * ! * @return the maximun number of resources that it is allowed to visit (if this ! * number is higher than the number of resources changed, this visitor is not called). */ public int maxResourcesToVisit() { return MAX_TO_VISIT_INFINITE; } ! /** * if all the files below a folder that has an __init__.py just added or removed should --- 258,270 ---- ! /** ! * ! * @return the maximun number of resources that it is allowed to visit (if this ! * number is higher than the number of resources changed, this visitor is not called). */ public int maxResourcesToVisit() { return MAX_TO_VISIT_INFINITE; } ! /** * if all the files below a folder that has an __init__.py just added or removed should Index: PyDevDeltaCounter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PyDevDeltaCounter.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyDevDeltaCounter.java 16 Mar 2006 19:43:08 -0000 1.7 --- PyDevDeltaCounter.java 28 Sep 2008 12:45:46 -0000 1.8 *************** *** 25,44 **** * Overriden so that we don't load the document on this visitor (there is no need for that). */ ! protected boolean chooseVisit(IResourceDelta delta, IResource resource, boolean isAddOrChange) { ! switch (delta.getKind()) { ! case IResourceDelta.ADDED : ! visitAddedResource(resource, null, monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.CHANGED: ! visitChangedResource(resource, null, monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.REMOVED: ! visitRemovedResource(resource, null, monitor); ! break; ! } ! return isAddOrChange; ! } /** --- 25,44 ---- * Overriden so that we don't load the document on this visitor (there is no need for that). */ ! protected boolean chooseVisit(IResourceDelta delta, IResource resource, boolean isAddOrChange) { ! switch (delta.getKind()) { ! case IResourceDelta.ADDED : ! visitAddedResource(resource, null, monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.CHANGED: ! visitChangedResource(resource, null, monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.REMOVED: ! visitRemovedResource(resource, null, monitor); ! break; ! } ! return isAddOrChange; ! } /** Index: PydevInternalResourceDeltaVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PydevInternalResourceDeltaVisitor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PydevInternalResourceDeltaVisitor.java 14 Jun 2008 22:14:55 -0000 1.6 --- PydevInternalResourceDeltaVisitor.java 28 Sep 2008 12:45:46 -0000 1.7 *************** *** 123,142 **** } ! protected boolean chooseVisit(IResourceDelta delta, IResource resource, boolean isAddOrChange) { ! switch (delta.getKind()) { ! case IResourceDelta.ADDED : ! visitAddedResource(resource, REF.getDocFromResource(resource), monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.CHANGED: ! visitChangedResource(resource, REF.getDocFromResource(resource), monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.REMOVED: ! visitRemovedResource(resource, null, monitor); ! break; ! } ! return isAddOrChange; ! } } --- 123,142 ---- } ! protected boolean chooseVisit(IResourceDelta delta, IResource resource, boolean isAddOrChange) { ! switch (delta.getKind()) { ! case IResourceDelta.ADDED : ! visitAddedResource(resource, REF.getDocFromResource(resource), monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.CHANGED: ! visitChangedResource(resource, REF.getDocFromResource(resource), monitor); ! isAddOrChange = true; ! break; ! case IResourceDelta.REMOVED: ! visitRemovedResource(resource, null, monitor); ! break; ! } ! return isAddOrChange; ! } } Index: PyDevBuilderPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PyDevBuilderPrefPage.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyDevBuilderPrefPage.java 2 Apr 2007 00:19:56 -0000 1.5 --- PyDevBuilderPrefPage.java 28 Sep 2008 12:45:46 -0000 1.6 *************** *** 31,34 **** --- 31,37 ---- public static final String PYDEV_ELAPSE_BEFORE_ANALYSIS = PyParserManager.PYDEV_ELAPSE_BEFORE_ANALYSIS; + public static final String ANALYZE_ONLY_ACTIVE_EDITOR = "ANALYZE_ONLY_ACTIVE_EDITOR"; + public static final boolean DEFAULT_ANALYZE_ONLY_ACTIVE_EDITOR = true; + /** * @param style *************** *** 37,41 **** super(GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("PyDev builders"); } --- 40,44 ---- super(GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Pydev builders"); } *************** *** 47,65 **** String s = "WARNING: \n\n" + ! "PyDev builders are required for many features \n" + ! "provided by Pydev such as:\n" + ! "\n" + ! "- Code completion\n" + ! "- PyLint\n" + ! "- TODO tasks\n" + ! "\n" + ! "So, if you choose to disable it, note that the features \n" + ! "mentioned above may not work as expected or may even not \n" + ! "work at all (use at your own risk).\n"; addField(new LabelFieldEditor("LabelFieldEditor", s, p)); addField(new BooleanFieldEditor(USE_PYDEV_BUILDERS, "Use builders?", p)); ! addField(new BooleanFieldEditor(PyParserManager.USE_PYDEV_ANALYSIS_ONLY_ON_DOC_SAVE, "Build only on save?", p)); ! addField(new IntegerFieldEditor(PyParserManager.PYDEV_ELAPSE_BEFORE_ANALYSIS, "Time to elapse before analyzing changed file (millis)", p)); } --- 50,78 ---- String s = "WARNING: \n\n" + ! "Pydev builders are required for many features \n" + ! "provided by Pydev such as:\n" + ! "\n" + ! "- Code completion\n" + ! "- PyLint\n" + ! "- TODO tasks\n" + ! "\n" + ! "So, if you choose to disable it, note that the features \n" + ! "mentioned above may not work as expected or may even not \n" + ! "work at all (use at your own risk).\n"; addField(new LabelFieldEditor("LabelFieldEditor", s, p)); addField(new BooleanFieldEditor(USE_PYDEV_BUILDERS, "Use builders?", p)); ! ! ! //Analysis only on save means that we'll not have parse notifications (so, things will be analyzed only on save) ! addField(new BooleanFieldEditor(PyParserManager.USE_PYDEV_ANALYSIS_ONLY_ON_DOC_SAVE, "Disable parser notifications?", p)); ! addField(new IntegerFieldEditor(PyParserManager.PYDEV_ELAPSE_BEFORE_ANALYSIS, "Time to elapse before reparsing changed file (millis)", p)); ! ! s = "If only open editors are analyzed, markers will only be added\n" + ! "to the opened Pydev editors and will be removed upon close.\n" + ! "(note that a full rebuild may be needed to remove existing markers)"; ! addField(new LabelFieldEditor("ActiveBufferLabelFieldEditor", s, p)); ! ! addField(new BooleanFieldEditor(ANALYZE_ONLY_ACTIVE_EDITOR, "Only analyze open editors?", p)); } *************** *** 78,81 **** --- 91,102 ---- } + public static boolean getAnalyzeOnlyActiveEditor() { + return PydevPrefs.getPreferences().getBoolean(ANALYZE_ONLY_ACTIVE_EDITOR); + } + + public static void setAnalyzeOnlyActiveEditor(boolean b) { + PydevPrefs.getPreferences().setValue(ANALYZE_ONLY_ACTIVE_EDITOR, b); + } + public static int getElapseMillisBeforeAnalysis() { return PyParserManager.getPyParserManager(PydevPrefs.getPreferences()).getElapseMillisBeforeAnalysis(); Index: PyDevBuilder.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PyDevBuilder.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** PyDevBuilder.java 14 Jun 2008 22:14:55 -0000 1.53 --- PyDevBuilder.java 28 Sep 2008 12:45:46 -0000 1.54 *************** *** 24,27 **** --- 24,28 ---- import org.python.pydev.builder.pycremover.PycRemoverBuilderVisitor; import org.python.pydev.builder.pylint.PyLintVisitor; + import org.python.pydev.builder.syntaxchecker.PySyntaxChecker; import org.python.pydev.builder.todo.PyTodoVisitor; import org.python.pydev.core.ExtensionHelper; *************** *** 44,48 **** private static final boolean DEBUG = false; ! /** * * @return a list of visitors for building the application. --- 45,49 ---- private static final boolean DEBUG = false; ! /** * * @return a list of visitors for building the application. *************** *** 55,58 **** --- 56,60 ---- list.add(new PyCodeCompletionVisitor()); list.add(new PycRemoverBuilderVisitor()); + list.add(new PySyntaxChecker()); list.addAll(ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_BUILDER)); *************** *** 68,71 **** --- 70,74 ---- * @see org.eclipse.core.internal.events InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ + @SuppressWarnings("unchecked") protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { *************** *** 121,177 **** if (nature != null && nature.startRequests()){ ! try{ ! IPythonPathNature pythonPathNature = nature.getPythonPathNature(); ! pythonPathNature.getProjectSourcePath(); //this is just to update the paths (in case the project name has just changed) ! ! List<IFile> resourcesToParse = new ArrayList<IFile>(); ! ! List<PyDevBuilderVisitor> visitors = getVisitors(); ! notifyVisitingWillStart(visitors, monitor, true, nature); ! ! monitor.beginTask("Building...", (visitors.size() * 100) + 30); ! ! IResource[] members = project.members(); ! ! if (members != null) { ! // get all the python files to get information. ! for (int i = 0; i < members.length; i++) { ! try { ! IResource member = members[i]; ! if (member == null) { ! continue; ! } ! ! if (member.getType() == IResource.FILE) { ! addToResourcesToParse(resourcesToParse, (IFile)member, nature); ! ! } else if (member.getType() == IResource.FOLDER) { ! //if it is a folder, let's get all python files that are beneath it ! //the heuristics to know if we have to analyze them are the same we have ! //for a single file ! List<IFile> l = PyFileListing.getAllIFilesBelow((IFolder) member); ! ! for (Iterator<IFile> iter = l.iterator(); iter.hasNext();) { ! IFile element = iter.next(); ! if (element != null) { ! addToResourcesToParse(resourcesToParse, element, nature); ! } ! } ! } else { ! if (DEBUG){ ! System.out.println("Unknown type: "+member.getType()); ! } ! } ! } catch (Exception e) { ! // that's ok... ! } ! } ! monitor.worked(30); ! buildResources(resourcesToParse, monitor, visitors); ! } ! notifyVisitingEnded(visitors, monitor); ! }finally{ ! nature.endRequests(); ! } } } --- 124,180 ---- if (nature != null && nature.startRequests()){ ! try{ ! IPythonPathNature pythonPathNature = nature.getPythonPathNature(); ! pythonPathNature.getProjectSourcePath(); //this is just to update the paths (in case the project name has just changed) ! ! List<IFile> resourcesToParse = new ArrayList<IFile>(); ! ! List<PyDevBuilderVisitor> visitors = getVisitors(); ! notifyVisitingWillStart(visitors, monitor, true, nature); ! ! monitor.beginTask("Building...", (visitors.size() * 100) + 30); ! ! IResource[] members = project.members(); ! ! if (members != null) { ! // get all the python files to get information. ! for (int i = 0; i < members.length; i++) { ! try { ! IResource member = members[i]; ! if (member == null) { ! continue; ! } ! ! if (member.getType() == IResource.FILE) { ! addToResourcesToParse(resourcesToParse, (IFile)member, nature); ! ! } else if (member.getType() == IResource.FOLDER) { ! //if it is a folder, let's get all python files that are beneath it ! //the heuristics to know if we have to analyze them are the same we have ! //for a single file ! List<IFile> l = PyFileListing.getAllIFilesBelow((IFolder) member); ! ! for (Iterator<IFile> iter = l.iterator(); iter.hasNext();) { ! IFile element = iter.next(); ! if (element != null) { ! addToResourcesToParse(resourcesToParse, element, nature); ! } ! } ! } else { ! if (DEBUG){ ! System.out.println("Unknown type: "+member.getType()); ! } ! } ! } catch (Exception e) { ! // that's ok... ! } ! } ! monitor.worked(30); ! buildResources(resourcesToParse, monitor, visitors); ! } ! notifyVisitingEnded(visitors, monitor); ! }finally{ ! nature.endRequests(); ! } } } *************** *** 204,215 **** String fileExtension = member.getFileExtension(); if(DEBUG){ ! System.out.println("Checking name:'"+member.getName()+"' projPath:'"+member.getProjectRelativePath()+ "' ext:'"+fileExtension+"'"); ! System.out.println("loc:'"+member.getLocation()+"' rawLoc:'"+member.getRawLocation()+"'"); ! } if (fileExtension != null && PythonPathHelper.isValidSourceFile("."+fileExtension)) { ! if(DEBUG){ ! System.out.println("Adding resource to parse:"+member.getProjectRelativePath()); ! } resourcesToParse.add(member); } --- 207,218 ---- String fileExtension = member.getFileExtension(); if(DEBUG){ ! System.out.println("Checking name:'"+member.getName()+"' projPath:'"+member.getProjectRelativePath()+ "' ext:'"+fileExtension+"'"); ! System.out.println("loc:'"+member.getLocation()+"' rawLoc:'"+member.getRawLocation()+"'"); ! } if (fileExtension != null && PythonPathHelper.isValidSourceFile("."+fileExtension)) { ! if(DEBUG){ ! System.out.println("Adding resource to parse:"+member.getProjectRelativePath()); ! } resourcesToParse.add(member); } *************** *** 224,228 **** * @param visitors */ ! public void buildResources(List<IFile> resourcesToParse, IProgressMonitor monitor, List visitors) { // we have 100 units here --- 227,231 ---- * @param visitors */ ! public void buildResources(List<IFile> resourcesToParse, IProgressMonitor monitor, List<PyDevBuilderVisitor> visitors) { // we have 100 units here *************** *** 241,277 **** IPythonNature nature = PythonNature.getPythonNature(r); if (nature == null){ ! continue; } if(!nature.startRequests()){ ! continue; } try{ ! if(!nature.isResourceInPythonpath(r)){ ! continue; // we only analyze resources that are in the pythonpath ! } ! IDocument doc = REF.getDocFromResource(r); ! ! HashMap<String, Object> memo = new HashMap<String, Object>(); ! memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, true); //mark it as full build ! ! if(doc != null){ //might be out of synch ! for (Iterator it = visitors.iterator(); it.hasNext() && monitor.isCanceled() == false;) { ! ! PyDevBuilderVisitor visitor = (PyDevBuilderVisitor) it.next(); ! visitor.memo = memo; //setting the memo must be the first thing. ! ! communicateProgress(monitor, totalResources, i, r, visitor, bufferToCreateString); ! ! //on a full build, all visits are as some add... ! visitor.visitAddedResource(r, doc, monitor); ! } ! ! if (total > 1) { ! monitor.worked((int) total); ! total -= (int) total; ! } ! } }finally{ ! nature.endRequests(); } } --- 244,280 ---- IPythonNature nature = PythonNature.getPythonNature(r); if (nature == null){ ! continue; } if(!nature.startRequests()){ ! continue; } try{ ! if(!nature.isResourceInPythonpath(r)){ ! continue; // we only analyze resources that are in the pythonpath ! } ! IDocument doc = REF.getDocFromResource(r); ! ! HashMap<String, Object> memo = new HashMap<String, Object>(); ! memo.put(PyDevBuilderVisitor.IS_FULL_BUILD, true); //mark it as full build ! ! if(doc != null){ //might be out of synch ! for (Iterator<PyDevBuilderVisitor> it = visitors.iterator(); it.hasNext() && monitor.isCanceled() == false;) { ! ! PyDevBuilderVisitor visitor = it.next(); ! visitor.memo = memo; //setting the memo must be the first thing. ! ! communicateProgress(monitor, totalResources, i, r, visitor, bufferToCreateString); ! ! //on a full build, all visits are as some add... ! visitor.visitAddedResource(r, doc, monitor); ! } ! ! if (total > 1) { ! monitor.worked((int) total); ! total -= (int) total; ! } ! } }finally{ ! nature.endRequests(); } } |
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion/revisited/modules Modified Files: AbstractModule.java EmptyModule.java SourceModule.java SourceToken.java CompiledModule.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: SourceModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules/SourceModule.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SourceModule.java 17 Aug 2008 00:26:47 -0000 1.20 --- SourceModule.java 28 Sep 2008 12:45:40 -0000 1.21 *************** *** 102,105 **** --- 102,112 ---- public String zipFilePath; + + /** + * This is a parse error that was found when parsing the code that generated this module + */ + public final Throwable parseError; + + public String getZipFilePath(){ return zipFilePath; *************** *** 115,118 **** --- 122,140 ---- */ private HashMap<Integer, TreeMap<String, Object>> tokensCache = new HashMap<Integer, TreeMap<String,Object>>(); + + /** + * Set when the visiting is done (can hold some metadata, such as __all__ token assign) + */ + private GlobalModelVisitor globalModelVisitorCache = null; + + /** + * + * @return the visitor that was used to generate the internal tokens for this module (if any). + * + * May be null + */ + public GlobalModelVisitor getGlobalModelVisitorCache() { + return globalModelVisitorCache; + } /** *************** *** 123,127 **** */ public IToken[] getWildImportedModules() { ! return getTokens(GlobalModelVisitor.WILD_MODULES, null); } --- 145,149 ---- */ public IToken[] getWildImportedModules() { ! return getTokens(GlobalModelVisitor.WILD_MODULES, null, null); } *************** *** 136,140 **** */ public IToken[] getTokenImportedModules() { ! return getTokens(GlobalModelVisitor.ALIAS_MODULES, null); } --- 158,162 ---- */ public IToken[] getTokenImportedModules() { ! return getTokens(GlobalModelVisitor.ALIAS_MODULES, null, null); } *************** *** 153,157 **** */ public IToken[] getGlobalTokens() { ! return getTokens(GlobalModelVisitor.GLOBAL_TOKENS, null); } --- 175,179 ---- */ public IToken[] getGlobalTokens() { ! return getTokens(GlobalModelVisitor.GLOBAL_TOKENS, null, null); } *************** *** 160,164 **** */ public String getDocString() { ! IToken[] l = getTokens(GlobalModelVisitor.MODULE_DOCSTRING, null); if (l.length > 0) { SimpleNode a = ((SourceToken) l[0]).getAst(); --- 182,186 ---- */ public String getDocString() { ! IToken[] l = getTokens(GlobalModelVisitor.MODULE_DOCSTRING, null, null); if (l.length > 0) { SimpleNode a = ((SourceToken) l[0]).getAst(); *************** *** 178,218 **** public boolean isInDirectGlobalTokens(String tok, ICompletionCache completionCache){ TreeMap<String, Object> tokens = tokensCache.get(GlobalModelVisitor.GLOBAL_TOKENS); ! if(tokens == null){ ! getGlobalTokens(); ! } ! ! boolean ret = false; ! if(tokens != null){ ! synchronized (tokens) { ! ret = tokens.containsKey(tok); ! } ! } ! ! if(ret == false){ ! ret = isInDirectImportTokens(tok); ! } ! return ret; } ! public boolean isInDirectImportTokens(String tok) { TreeMap<String, Object> tokens = tokensCache.get(GlobalModelVisitor.ALIAS_MODULES); if(tokens != null){ ! getTokenImportedModules(); ! } ! ! boolean ret = false; ! if(tokens != null){ ! synchronized (tokens) { ! ret = tokens.containsKey(tok); ! } ! } ! return ret; ! } ! ! ! private IToken[] getTokens(int which, ICompletionState state) { ! return getTokens(which, state, null); } ! /** * @param lookOnlyForNameStartingWith: if not null, well only get from the cache tokens starting with the given representation --- 200,236 ---- public boolean isInDirectGlobalTokens(String tok, ICompletionCache completionCache){ TreeMap<String, Object> tokens = tokensCache.get(GlobalModelVisitor.GLOBAL_TOKENS); ! if(tokens == null){ ! getGlobalTokens(); ! } ! ! boolean ret = false; ! if(tokens != null){ ! synchronized (tokens) { ! ret = tokens.containsKey(tok); ! } ! } ! ! if(ret == false){ ! ret = isInDirectImportTokens(tok); ! } ! return ret; } ! public boolean isInDirectImportTokens(String tok) { TreeMap<String, Object> tokens = tokensCache.get(GlobalModelVisitor.ALIAS_MODULES); if(tokens != null){ ! getTokenImportedModules(); ! } ! ! boolean ret = false; ! if(tokens != null){ ! synchronized (tokens) { ! ret = tokens.containsKey(tok); ! } ! } ! return ret; } ! ! /** * @param lookOnlyForNameStartingWith: if not null, well only get from the cache tokens starting with the given representation *************** *** 224,228 **** throw new RuntimeException("Cannot do this one with caches"); } ! //cache TreeMap<String, Object> tokens = tokensCache.get(which); --- 242,246 ---- throw new RuntimeException("Cannot do this one with caches"); } ! //cache TreeMap<String, Object> tokens = tokensCache.get(which); *************** *** 230,236 **** return createArrayFromCacheValues(tokens, lookOnlyForNameStartingWith); } ! //end cache ! ! try { tokensCache.put(GlobalModelVisitor.ALIAS_MODULES, new TreeMap<String, Object>()); --- 248,254 ---- return createArrayFromCacheValues(tokens, lookOnlyForNameStartingWith); } ! //end cache ! ! try { tokensCache.put(GlobalModelVisitor.ALIAS_MODULES, new TreeMap<String, Object>()); *************** *** 243,247 **** //we request all and put it into the cache (partitioned), because that's faster than making multiple runs through it ! List<IToken> ret = GlobalModelVisitor.getTokens(ast, all, name, state, true); --- 261,269 ---- //we request all and put it into the cache (partitioned), because that's faster than making multiple runs through it ! GlobalModelVisitor globalModelVisitor = GlobalModelVisitor.getGlobalModuleVisitorWithTokens(ast, all, name, state, false); ! ! this.globalModelVisitorCache = globalModelVisitor; ! ! List<IToken> ret = globalModelVisitor.getTokens(); *************** *** 250,257 **** } //cache ! for (IToken token : ret) { int choice; ! if(token.isWildImport()){ ! choice = GlobalModelVisitor.WILD_MODULES; }else if(token.isImportFrom() || token.isImport()){ choice = GlobalModelVisitor.ALIAS_MODULES; --- 272,279 ---- } //cache ! for (IToken token : ret) { int choice; ! if(token.isWildImport()){ ! choice = GlobalModelVisitor.WILD_MODULES; }else if(token.isImportFrom() || token.isImport()){ choice = GlobalModelVisitor.ALIAS_MODULES; *************** *** 263,267 **** String rep = token.getRepresentation(); if(DEBUG_INTERNAL_GLOBALS_CACHE){ ! System.out.println("Adding choice:"+choice+" name:"+rep); if(choice != which){ System.out.println("Looking for:"+which+"found:"+choice); --- 285,289 ---- String rep = token.getRepresentation(); if(DEBUG_INTERNAL_GLOBALS_CACHE){ ! System.out.println("Adding choice:"+choice+" name:"+rep); if(choice != which){ System.out.println("Looking for:"+which+"found:"+choice); *************** *** 290,294 **** } } ! } //end cache --- 312,316 ---- } } ! } //end cache *************** *** 332,341 **** * @param n */ ! public SourceModule(String name, File f, SimpleNode n) { super(name); this.ast = n; this.file = f; ! if(f != null) this.lastModified = f.lastModified(); } --- 354,365 ---- * @param n */ ! public SourceModule(String name, File f, SimpleNode n, Throwable parseError) { super(name); this.ast = n; this.file = f; ! this.parseError = parseError; ! if(f != null){ this.lastModified = f.lastModified(); + } } *************** *** 397,408 **** ClassDef classDef = (ClassDef) d.scope.getClassDef(); if(classDef != null){ ! FindDefinitionModelVisitor visitor = new FindDefinitionModelVisitor(actToks[actToks.length-1], d.line, d.col, d.module); try { ! classDef.accept(visitor); ! } catch (StopVisitingException e) { ! //expected exception ! } if(visitor.definitions.size() == 0){ ! return EMPTY_ITOKEN_ARRAY; } d = visitor.definitions.get(0); --- 421,432 ---- ClassDef classDef = (ClassDef) d.scope.getClassDef(); if(classDef != null){ ! FindDefinitionModelVisitor visitor = new FindDefinitionModelVisitor(actToks[actToks.length-1], d.line, d.col, d.module); try { ! classDef.accept(visitor); ! } catch (StopVisitingException e) { ! //expected exception ! } if(visitor.definitions.size() == 0){ ! return EMPTY_ITOKEN_ARRAY; } d = visitor.definitions.get(0); *************** *** 412,428 **** } }else{ ! if(d.module instanceof SourceModule){ ! SourceModule m = (SourceModule) d.module; ! String joined = FullRepIterable.joinFirstParts(actToks); Definition[] definitions2 = m.findDefinition(initialState.getCopyWithActTok(joined), d.line, d.col, manager.getNature()); ! if(definitions2.length == 0){ ! return EMPTY_ITOKEN_ARRAY; ! } ! d = definitions2[0]; ! value = d.value+"."+actToks[actToks.length-1]; ! if(d instanceof AssignDefinition){ ! return ((SourceModule)d.module).getValueCompletions(initialState, manager, value, d.module); ! } ! } } --- 436,452 ---- } }else{ ! if(d.module instanceof SourceModule){ ! SourceModule m = (SourceModule) d.module; ! String joined = FullRepIterable.joinFirstParts(actToks); Definition[] definitions2 = m.findDefinition(initialState.getCopyWithActTok(joined), d.line, d.col, manager.getNature()); ! if(definitions2.length == 0){ ! return EMPTY_ITOKEN_ARRAY; ! } ! d = definitions2[0]; ! value = d.value+"."+actToks[actToks.length-1]; ! if(d instanceof AssignDefinition){ ! return ((SourceModule)d.module).getValueCompletions(initialState, manager, value, d.module); ! } ! } } *************** *** 584,588 **** */ @SuppressWarnings("unchecked") ! public Definition[] findDefinition(ICompletionState state, int line, int col, final IPythonNature nature) throws Exception{ String rep = state.getActivationToken(); //the line passed in starts at 1 and the lines for the visitor start at 0 --- 608,612 ---- */ @SuppressWarnings("unchecked") ! public Definition[] findDefinition(ICompletionState state, int line, int col, final IPythonNature nature) throws Exception{ String rep = state.getActivationToken(); //the line passed in starts at 1 and the lines for the visitor start at 0 *************** *** 596,616 **** if(visitor.definitions.size() > 0){ ! //ok, it is an assign, so, let's get it for (Iterator iter = visitor.definitions.iterator(); iter.hasNext();) { ! Object next = iter.next(); if(next instanceof AssignDefinition){ AssignDefinition element = (AssignDefinition) next; ! if(element.target.startsWith("self") == false){ ! if(element.scope.isOuterOrSameScope(scopeVisitor.scope) || element.foundAsGlobal){ ! toRet.add(element); ! } ! }else{ ! toRet.add(element); ! } }else{ toRet.add((Definition) next); } ! } if(toRet.size() > 0){ return (Definition[]) toRet.toArray(new Definition[0]); --- 620,640 ---- if(visitor.definitions.size() > 0){ ! //ok, it is an assign, so, let's get it for (Iterator iter = visitor.definitions.iterator(); iter.hasNext();) { ! Object next = iter.next(); if(next instanceof AssignDefinition){ AssignDefinition element = (AssignDefinition) next; ! if(element.target.startsWith("self") == false){ ! if(element.scope.isOuterOrSameScope(scopeVisitor.scope) || element.foundAsGlobal){ ! toRet.add(element); ! } ! }else{ ! toRet.add(element); ! } }else{ toRet.add((Definition) next); } ! } if(toRet.size() > 0){ return (Definition[]) toRet.toArray(new Definition[0]); *************** *** 623,629 **** IToken[] localTokens = scopeVisitor.scope.getAllLocalTokens(); for (IToken tok : localTokens) { ! if(tok.getRepresentation().equals(rep)){ ! return new Definition[]{new Definition(tok, scopeVisitor.scope, this, true)}; ! } } --- 647,653 ---- IToken[] localTokens = scopeVisitor.scope.getAllLocalTokens(); for (IToken tok : localTokens) { ! if(tok.getRepresentation().equals(rep)){ ! return new Definition[]{new Definition(tok, scopeVisitor.scope, this, true)}; ! } } *************** *** 632,636 **** ICodeCompletionASTManager astManager = nature.getAstManager(); for (IToken tok : localImportedModules) { ! if(tok.getRepresentation().equals(rep)){ Tuple3<IModule, String, IToken> o = astManager.findOnImportedMods(new IToken[]{tok}, state.getCopyWithActTok(rep), this.getName()); if(o != null && o.o1 instanceof SourceModule){ --- 656,660 ---- ICodeCompletionASTManager astManager = nature.getAstManager(); for (IToken tok : localImportedModules) { ! if(tok.getRepresentation().equals(rep)){ Tuple3<IModule, String, IToken> o = astManager.findOnImportedMods(new IToken[]{tok}, state.getCopyWithActTok(rep), this.getName()); if(o != null && o.o1 instanceof SourceModule){ *************** *** 641,693 **** } if(toRet.size() > 0){ ! return (Definition[]) toRet.toArray(new Definition[0]); } ! } } ! //ok, not assign nor import, let's check if it is some self (we do not check for only 'self' because that would map to a //local (which has already been covered). if (rep.startsWith("self.")){ ! //ok, it is some self, now, that is only valid if we are in some class definition ! ClassDef classDef = (ClassDef) scopeVisitor.scope.getClassDef(); ! if(classDef != null){ ! //ok, we are in a class, so, let's get the self completions ! String classRep = NodeUtils.getRepresentationString(classDef); ! IToken[] globalTokens = getGlobalTokens( ! new CompletionState(line-1, col-1, classRep, nature,"", state), //use the old state as the cache ! astManager); ! ! String withoutSelf = rep.substring(5); ! for (IToken token : globalTokens) { ! if(token.getRepresentation().equals(withoutSelf)){ ! String parentPackage = token.getParentPackage(); ! IModule module = astManager.getModule(parentPackage, nature, true); ! if(token instanceof SourceToken && (module != null || this.name.equals(parentPackage))){ if(module == null){ module = this; } ! SimpleNode ast2 = ((SourceToken)token).getAst(); ! Tuple<Integer, Integer> def = getLineColForDefinition(ast2); ! FastStack<SimpleNode> stack = new FastStack<SimpleNode>(); if(module instanceof SourceModule){ stack.push(((SourceModule)module).getAst()); } ! stack.push(classDef); ! ILocalScope scope = new LocalScope(stack); ! return new Definition[]{new Definition(def.o1, def.o2, token.getRepresentation(), ast2, scope, module)}; ! }else{ ! return new Definition[0]; ! } ! } ! } ! } } ! ! //ok, it is not an assign, so, let's search the global tokens (and imports) String tok = rep; SourceModule mod = this; --- 665,717 ---- } if(toRet.size() > 0){ ! return (Definition[]) toRet.toArray(new Definition[0]); } ! } } ! //ok, not assign nor import, let's check if it is some self (we do not check for only 'self' because that would map to a //local (which has already been covered). if (rep.startsWith("self.")){ ! //ok, it is some self, now, that is only valid if we are in some class definition ! ClassDef classDef = (ClassDef) scopeVisitor.scope.getClassDef(); ! if(classDef != null){ ! //ok, we are in a class, so, let's get the self completions ! String classRep = NodeUtils.getRepresentationString(classDef); ! IToken[] globalTokens = getGlobalTokens( ! new CompletionState(line-1, col-1, classRep, nature,"", state), //use the old state as the cache ! astManager); ! ! String withoutSelf = rep.substring(5); ! for (IToken token : globalTokens) { ! if(token.getRepresentation().equals(withoutSelf)){ ! String parentPackage = token.getParentPackage(); ! IModule module = astManager.getModule(parentPackage, nature, true); ! if(token instanceof SourceToken && (module != null || this.name.equals(parentPackage))){ if(module == null){ module = this; } ! SimpleNode ast2 = ((SourceToken)token).getAst(); ! Tuple<Integer, Integer> def = getLineColForDefinition(ast2); ! FastStack<SimpleNode> stack = new FastStack<SimpleNode>(); if(module instanceof SourceModule){ stack.push(((SourceModule)module).getAst()); } ! stack.push(classDef); ! ILocalScope scope = new LocalScope(stack); ! return new Definition[]{new Definition(def.o1, def.o2, token.getRepresentation(), ast2, scope, module)}; ! }else{ ! return new Definition[0]; ! } ! } ! } ! } } ! ! //ok, it is not an assign, so, let's search the global tokens (and imports) String tok = rep; SourceModule mod = this; *************** *** 706,710 **** return new Definition[]{new Definition(1,1,"",null,null,o.o1)}; }else{ ! state.checkFindDefinitionMemory(o.o1, tok); return (Definition[]) o.o1.findDefinition(state.getCopyWithActTok(tok), -1, -1, nature); } --- 730,734 ---- return new Definition[]{new Definition(1,1,"",null,null,o.o1)}; }else{ ! state.checkFindDefinitionMemory(o.o1, tok); return (Definition[]) o.o1.findDefinition(state.getCopyWithActTok(tok), -1, -1, nature); } *************** *** 724,731 **** copy.setActivationToken(tok); try{ ! state.checkFindDefinitionMemory(mod, tok); ! findDefinitionsFromModAndTok(nature, toRet, visitor.moduleImported, mod, copy); }catch(CompletionRecursionException e){ ! //ignore (will return what we've got so far) // e.printStackTrace(); } --- 748,755 ---- copy.setActivationToken(tok); try{ ! state.checkFindDefinitionMemory(mod, tok); ! findDefinitionsFromModAndTok(nature, toRet, visitor.moduleImported, mod, copy); }catch(CompletionRecursionException e){ ! //ignore (will return what we've got so far) // e.printStackTrace(); } *************** *** 738,780 **** * @throws Exception */ ! private void findDefinitionsFromModAndTok(IPythonNature nature, ArrayList<Definition> toRet, String moduleImported, SourceModule mod, ICompletionState state) throws Exception { String tok = state.getActivationToken(); ! if(tok != null){ ! if(tok.length() > 0){ ! Definition d = mod.findGlobalTokDef(state.getCopyWithActTok(tok), nature); ! if(d != null){ ! toRet.add(d); ! ! }else if(moduleImported != null){ ! //if it was found as some import (and is already stored as a dotted name), we must check for ! //multiple representations in the absolute form: ! //as a relative import ! //as absolute import ! getModuleDefinition(nature, toRet, mod, moduleImported); ! } ! }else{ ! //we found it, but it is an empty tok (which means that what we found is the actual module). ! toRet.add(new Definition(1,1,"",null,null,mod)); ! } } ! } ! private IDefinition getModuleDefinition(IPythonNature nature, ArrayList<Definition> toRet, SourceModule mod, String moduleImported) { ! String rel = AbstractToken.makeRelative(mod.getName(), moduleImported); ! IModule modFound = nature.getAstManager().getModule(rel, nature, false); ! if(modFound == null){ ! modFound = nature.getAstManager().getModule(moduleImported, nature, false); ! } ! if(modFound != null){ ! //ok, found it ! Definition definition = new Definition(1,1,"", null, null, modFound); ! if(toRet != null){ ! toRet.add(definition); ! } ! return definition; ! } ! return null; ! } --- 762,804 ---- * @throws Exception */ ! private void findDefinitionsFromModAndTok(IPythonNature nature, ArrayList<Definition> toRet, String moduleImported, SourceModule mod, ICompletionState state) throws Exception { String tok = state.getActivationToken(); ! if(tok != null){ ! if(tok.length() > 0){ ! Definition d = mod.findGlobalTokDef(state.getCopyWithActTok(tok), nature); ! if(d != null){ ! toRet.add(d); ! ! }else if(moduleImported != null){ ! //if it was found as some import (and is already stored as a dotted name), we must check for ! //multiple representations in the absolute form: ! //as a relative import ! //as absolute import ! getModuleDefinition(nature, toRet, mod, moduleImported); ! } ! }else{ ! //we found it, but it is an empty tok (which means that what we found is the actual module). ! toRet.add(new Definition(1,1,"",null,null,mod)); ! } } ! } ! private IDefinition getModuleDefinition(IPythonNature nature, ArrayList<Definition> toRet, SourceModule mod, String moduleImported) { ! String rel = AbstractToken.makeRelative(mod.getName(), moduleImported); ! IModule modFound = nature.getAstManager().getModule(rel, nature, false); ! if(modFound == null){ ! modFound = nature.getAstManager().getModule(moduleImported, nature, false); ! } ! if(modFound != null){ ! //ok, found it ! Definition definition = new Definition(1,1,"", null, null, modFound); ! if(toRet != null){ ! toRet.add(definition); ! } ! return definition; ! } ! return null; ! } *************** *** 787,800 **** public Definition findGlobalTokDef(ICompletionState state, IPythonNature nature) throws Exception { String tok = state.getActivationToken(); ! String[] headAndTail = FullRepIterable.headAndTail(tok); ! String firstPart = headAndTail[0]; ! String rep = headAndTail[1]; ! ! IToken[] tokens = null; ! if(nature != null){ ! tokens = nature.getAstManager().getCompletionsForModule(this, state.getCopyWithActTok(firstPart), true); ! }else{ ! tokens = getGlobalTokens(); ! } for (IToken token : tokens) { boolean sameRep = token.getRepresentation().equals(rep); --- 811,824 ---- public Definition findGlobalTokDef(ICompletionState state, IPythonNature nature) throws Exception { String tok = state.getActivationToken(); ! String[] headAndTail = FullRepIterable.headAndTail(tok); ! String firstPart = headAndTail[0]; ! String rep = headAndTail[1]; ! ! IToken[] tokens = null; ! if(nature != null){ ! tokens = nature.getAstManager().getCompletionsForModule(this, state.getCopyWithActTok(firstPart), true); ! }else{ ! tokens = getGlobalTokens(); ! } for (IToken token : tokens) { boolean sameRep = token.getRepresentation().equals(rep); *************** *** 806,810 **** continue; } ! //ok, we found it SimpleNode a = ((SourceToken)token).getAst(); Tuple<Integer, Integer> def = getLineColForDefinition(a); --- 830,834 ---- continue; } ! //ok, we found it SimpleNode a = ((SourceToken)token).getAst(); Tuple<Integer, Integer> def = getLineColForDefinition(a); *************** *** 813,820 **** IModule module = this; if(nature != null){ ! IModule mod = nature.getAstManager().getModule(parentPackage, nature, true); ! if(mod != null){ ! module = mod; ! } } --- 837,844 ---- IModule module = this; if(nature != null){ ! IModule mod = nature.getAstManager().getModule(parentPackage, nature, true); ! if(mod != null){ ! module = mod; ! } } *************** *** 830,846 **** } }else if(token instanceof ConcreteToken){ ! //a contrete token represents a module ! String modName = token.getParentPackage(); ! if(modName.length() > 0){ ! modName+= "."; ! } ! modName += token.getRepresentation(); ! IModule module = nature.getAstManager().getModule(modName, nature, true); ! if(module == null){ ! return null; ! }else{ ! return new Definition(0+1, 0+1, "", null, null, module); // it is the module itself ! } ! }else if(token instanceof CompiledToken){ String parentPackage = token.getParentPackage(); --- 854,870 ---- } }else if(token instanceof ConcreteToken){ ! //a contrete token represents a module ! String modName = token.getParentPackage(); ! if(modName.length() > 0){ ! modName+= "."; ! } ! modName += token.getRepresentation(); ! IModule module = nature.getAstManager().getModule(modName, nature, true); ! if(module == null){ ! return null; ! }else{ ! return new Definition(0+1, 0+1, "", null, null, module); // it is the module itself ! } ! }else if(token instanceof CompiledToken){ String parentPackage = token.getParentPackage(); *************** *** 874,878 **** } }else{ ! throw new RuntimeException("Unexpected token:"+token.getClass()); } } --- 898,902 ---- } }else{ ! throw new RuntimeException("Unexpected token:"+token.getClass()); } } *************** *** 883,901 **** public Tuple<Integer, Integer> getLineColForDefinition(SimpleNode a){ ! int line = a.beginLine; ! int col = a.beginColumn; ! ! if(a instanceof ClassDef){ ! ClassDef c = (ClassDef)a; ! line = c.name.beginLine; ! col = c.name.beginColumn; ! ! } else if(a instanceof FunctionDef){ ! FunctionDef c = (FunctionDef)a; ! line = c.name.beginLine; ! col = c.name.beginColumn; ! } ! ! return new Tuple<Integer, Integer>(line,col); } --- 907,925 ---- public Tuple<Integer, Integer> getLineColForDefinition(SimpleNode a){ ! int line = a.beginLine; ! int col = a.beginColumn; ! ! if(a instanceof ClassDef){ ! ClassDef c = (ClassDef)a; ! line = c.name.beginLine; ! col = c.name.beginColumn; ! ! } else if(a instanceof FunctionDef){ ! FunctionDef c = (FunctionDef)a; ! line = c.name.beginLine; ! col = c.name.beginColumn; ! } ! ! return new Tuple<Integer, Integer>(line,col); } *************** *** 907,915 **** try { if(scope == null){ ! FindScopeVisitor scopeVisitor = getScopeVisitor(line, col); scope = scopeVisitor.scope; } ! ! return scope.getLocalTokens(line, col, false); } catch (Exception e) { e.printStackTrace(); --- 931,939 ---- try { if(scope == null){ ! FindScopeVisitor scopeVisitor = getScopeVisitor(line, col); scope = scopeVisitor.scope; } ! ! return scope.getLocalTokens(line, col, false); } catch (Exception e) { e.printStackTrace(); *************** *** 954,959 **** try { FindScopeVisitor scopeVisitor = getScopeVisitor(node.beginLine, node.beginColumn); ! ! return scopeVisitor.scope.getScopeEndLine(); } catch (Exception e) { e.printStackTrace(); --- 978,983 ---- try { FindScopeVisitor scopeVisitor = getScopeVisitor(node.beginLine, node.beginColumn); ! ! return scopeVisitor.scope.getScopeEndLine(); } catch (Exception e) { e.printStackTrace(); *************** *** 968,973 **** try { FindScopeVisitor scopeVisitor = getScopeVisitor(-1, -1); ! ! return scopeVisitor.scope.getIfMainLine(); } catch (Exception e) { e.printStackTrace(); --- 992,997 ---- try { FindScopeVisitor scopeVisitor = getScopeVisitor(-1, -1); ! ! return scopeVisitor.scope.getIfMainLine(); } catch (Exception e) { e.printStackTrace(); *************** *** 995,1006 **** } ! public void setName(String n) { ! this.name = n; ! } ! /** ! * @return true if this is a bootstrap module (i.e.: a module that's only used to load a compiled module with the ! * same name -- that used in eggs) ! * * A bootstrapped module is the way that egg handles pyd files: * it'll create a file with the same name of the dll (e.g.: --- 1019,1030 ---- } ! public void setName(String n) { ! this.name = n; ! } ! /** ! * @return true if this is a bootstrap module (i.e.: a module that's only used to load a compiled module with the ! * same name -- that used in eggs) ! * * A bootstrapped module is the way that egg handles pyd files: * it'll create a file with the same name of the dll (e.g.: *************** *** 1017,1021 **** * __bootstrap__() * ! */ public boolean isBootstrapModule() { if(bootstrap == null){ --- 1041,1045 ---- * __bootstrap__() * ! */ public boolean isBootstrapModule() { if(bootstrap == null){ Index: AbstractModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules/AbstractModule.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractModule.java 2 May 2008 13:42:01 -0000 1.15 --- AbstractModule.java 28 Sep 2008 12:45:40 -0000 1.16 *************** *** 38,49 **** public abstract class AbstractModule implements IModule { ! private static final IToken[] EMPTY_TOKEN_ARRAY = new IToken[0]; /** ! * May be changed for tests ! */ public static String MODULE_NAME_WHEN_FILE_IS_UNDEFINED = ""; ! /** * @see org.python.pydev.core.IModule#getWildImportedModules() */ --- 38,49 ---- public abstract class AbstractModule implements IModule { ! private static final IToken[] EMPTY_TOKEN_ARRAY = new IToken[0]; /** ! * May be changed for tests ! */ public static String MODULE_NAME_WHEN_FILE_IS_UNDEFINED = ""; ! /** * @see org.python.pydev.core.IModule#getWildImportedModules() */ *************** *** 91,95 **** */ public boolean isInGlobalTokens(String tok, IPythonNature nature, ICompletionCache completionCache) throws CompletionRecursionException{ ! return isInGlobalTokens(tok, nature, true, completionCache); } --- 91,95 ---- */ public boolean isInGlobalTokens(String tok, IPythonNature nature, ICompletionCache completionCache) throws CompletionRecursionException{ ! return isInGlobalTokens(tok, nature, true, completionCache); } *************** *** 109,115 **** //it's worth checking it if it is not dotted... (much faster as it's in a map already) if(tok.indexOf(".") == -1){ ! if(isInDirectGlobalTokens(tok, completionCache)){ ! return IModule.FOUND_TOKEN; ! } } --- 109,115 ---- //it's worth checking it if it is not dotted... (much faster as it's in a map already) if(tok.indexOf(".") == -1){ ! if(isInDirectGlobalTokens(tok, completionCache)){ ! return IModule.FOUND_TOKEN; ! } } *************** *** 231,240 **** String path = REF.getFileAbsolutePath(f); if(PythonPathHelper.isValidFileMod(path)){ ! if(PythonPathHelper.isValidSourceFile(path)){ return createModuleFromDoc(name, f, REF.getDocFromFile(f), nature, currLine); ! ! }else{ //this should be a compiled extension... we have to get completions from the python shell. ! return new CompiledModule(name, nature.getAstManager()); ! } } --- 231,240 ---- String path = REF.getFileAbsolutePath(f); if(PythonPathHelper.isValidFileMod(path)){ ! if(PythonPathHelper.isValidSourceFile(path)){ return createModuleFromDoc(name, f, REF.getDocFromFile(f), nature, currLine); ! ! }else{ //this should be a compiled extension... we have to get completions from the python shell. ! return new CompiledModule(name, nature.getAstManager()); ! } } *************** *** 255,265 **** if(f != null){ ! if(!checkForPath || PythonPathHelper.isValidSourceFile(REF.getFileAbsolutePath(f))){ ! Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(doc, true, nature, currLine)); ! return new SourceModule(name, f, obj.o1); ! } } else { ! Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(doc, true, nature, currLine)); ! return new SourceModule(name, f, obj.o1); } return null; --- 255,265 ---- if(f != null){ ! if(!checkForPath || PythonPathHelper.isValidSourceFile(REF.getFileAbsolutePath(f))){ ! Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(doc, true, nature, currLine, name, f)); ! return new SourceModule(name, f, obj.o1, obj.o2); ! } } else { ! Tuple<SimpleNode, Throwable> obj = PyParser.reparseDocument(new PyParser.ParserInfo(doc, true, nature, currLine, name, f)); ! return new SourceModule(name, f, obj.o1, obj.o2); } return null; *************** *** 269,283 **** * This function creates a module and resolves the module name (use this function if only the file is available). */ ! public static IModule createModuleFromDoc(File file, IDocument doc, IPythonNature pythonNature, int line, IModulesManager projModulesManager) { ! String moduleName = null; ! if(file != null){ ! moduleName = projModulesManager.resolveModule(REF.getFileAbsolutePath(file)); ! } ! if(moduleName == null){ ! moduleName = MODULE_NAME_WHEN_FILE_IS_UNDEFINED; ! } ! IModule module = createModuleFromDoc(moduleName, file, doc, pythonNature, line, false); ! return module; ! } --- 269,283 ---- * This function creates a module and resolves the module name (use this function if only the file is available). */ ! public static IModule createModuleFromDoc(File file, IDocument doc, IPythonNature pythonNature, int line, IModulesManager projModulesManager) { ! String moduleName = null; ! if(file != null){ ! moduleName = projModulesManager.resolveModule(REF.getFileAbsolutePath(file)); ! } ! if(moduleName == null){ ! moduleName = MODULE_NAME_WHEN_FILE_IS_UNDEFINED; ! } ! IModule module = createModuleFromDoc(moduleName, file, doc, pythonNature, line, false); ! return module; ! } *************** *** 288,292 **** */ public static IModule createModule(SimpleNode n) { ! return new SourceModule(null, null, n); } --- 288,292 ---- */ public static IModule createModule(SimpleNode n) { ! return new SourceModule(null, null, n, null); } *************** *** 301,305 **** */ public static IModule createModule(SimpleNode n, File file, String moduleName) { ! return new SourceModule(moduleName, file, n); } --- 301,305 ---- */ public static IModule createModule(SimpleNode n, File file, String moduleName) { ! return new SourceModule(moduleName, file, n, null); } *************** *** 314,325 **** */ public static IModule createModule(SimpleNode n, File file, IModulesManager projModulesManager) { ! String moduleName = null; ! if(file != null){ ! moduleName = projModulesManager.resolveModule(REF.getFileAbsolutePath(file)); ! } ! if(moduleName == null){ ! moduleName = MODULE_NAME_WHEN_FILE_IS_UNDEFINED; ! } ! return createModule(n, file, moduleName); } --- 314,325 ---- */ public static IModule createModule(SimpleNode n, File file, IModulesManager projModulesManager) { ! String moduleName = null; ! if(file != null){ ! moduleName = projModulesManager.resolveModule(REF.getFileAbsolutePath(file)); ! } ! if(moduleName == null){ ! moduleName = MODULE_NAME_WHEN_FILE_IS_UNDEFINED; ! } ! return createModule(n, file, moduleName); } *************** *** 346,352 **** @Override public String toString() { ! String n2 = this.getClass().getName(); ! String n = n2.substring(n2.lastIndexOf('.')+1); ! return this.getName()+" ("+n+")"; } --- 346,352 ---- @Override public String toString() { ! String n2 = this.getClass().getName(); ! String n = n2.substring(n2.lastIndexOf('.')+1); ! return this.getName()+" ("+n+")"; } Index: SourceToken.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules/SourceToken.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SourceToken.java 1 Oct 2007 00:26:54 -0000 1.3 --- SourceToken.java 28 Sep 2008 12:45:40 -0000 1.4 *************** *** 127,157 **** int[] colLineEndComplete; public int getLineEnd(boolean getOnlyToFirstDot){ ! if(getOnlyToFirstDot){ ! if(colLineEndToFirstDot == null){ ! colLineEndToFirstDot = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndToFirstDot[0]; ! ! }else{ ! if(colLineEndComplete == null){ ! colLineEndComplete = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndComplete[0]; ! } } public int getColEnd(boolean getOnlyToFirstDot){ ! if(getOnlyToFirstDot){ ! if(colLineEndToFirstDot == null){ ! colLineEndToFirstDot = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndToFirstDot[1]; ! ! }else{ ! if(colLineEndComplete == null){ ! colLineEndComplete = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndComplete[1]; ! } } --- 127,157 ---- int[] colLineEndComplete; public int getLineEnd(boolean getOnlyToFirstDot){ ! if(getOnlyToFirstDot){ ! if(colLineEndToFirstDot == null){ ! colLineEndToFirstDot = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndToFirstDot[0]; ! ! }else{ ! if(colLineEndComplete == null){ ! colLineEndComplete = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndComplete[0]; ! } } public int getColEnd(boolean getOnlyToFirstDot){ ! if(getOnlyToFirstDot){ ! if(colLineEndToFirstDot == null){ ! colLineEndToFirstDot = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndToFirstDot[1]; ! ! }else{ ! if(colLineEndComplete == null){ ! colLineEndComplete = NodeUtils.getColLineEnd(getRepresentationNode(), getOnlyToFirstDot); ! } ! return colLineEndComplete[1]; ! } } *************** *** 187,195 **** public boolean isImportFrom() { ! return ast instanceof ImportFrom; } public boolean isWildImport() { ! return AbstractVisitor.isWildImport(ast); } --- 187,195 ---- public boolean isImportFrom() { ! return ast instanceof ImportFrom; } public boolean isWildImport() { ! return AbstractVisitor.isWildImport(ast); } *************** *** 202,210 **** */ public int[] getLineColEnd() { ! if(ast instanceof NameTok || ast instanceof Name){ ! //those are the ones that we can be certain of... ! return new int[]{getLineDefinition(), getColDefinition()+getRepresentation().length()}; ! } ! throw new RuntimeException("Unable to get the lenght of the token:"+ast.getClass().getName()); } --- 202,210 ---- */ public int[] getLineColEnd() { ! if(ast instanceof NameTok || ast instanceof Name){ ! //those are the ones that we can be certain of... ! return new int[]{getLineDefinition(), getColDefinition()+getRepresentation().length()}; ! } ! throw new RuntimeException("Unable to get the lenght of the token:"+ast.getClass().getName()); } Index: CompiledModule.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules/CompiledModule.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CompiledModule.java 4 May 2008 16:48:46 -0000 1.8 --- CompiledModule.java 28 Sep 2008 12:45:40 -0000 1.9 *************** *** 61,65 **** @Override public File getFile() { ! return file; } --- 61,65 ---- @Override public File getFile() { ! return file; } *************** *** 80,107 **** super(name); if(COMPILED_MODULES_ENABLED){ ! try { ! setTokens(name, manager); ! } catch (Exception e) { ! //ok, something went wrong... let's give it another shot... ! synchronized (this) { ! try { ! wait(10); ! } catch (InterruptedException e1) { ! //empty block ! } //just wait a little before a retry... ! } ! ! try { ! AbstractShell shell = AbstractShell.getServerShell(manager.getNature(), AbstractShell.COMPLETION_SHELL); ! synchronized(shell){ ! shell.clearSocket(); ! } ! setTokens(name, manager); ! } catch (Exception e2) { ! tokens = new HashMap<String, CompiledToken>(); ! e2.printStackTrace(); ! PydevPlugin.log(e2); ! } ! } if(tokens != null && tokens.size() > 0){ List<IModulesObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_MODULES_OBSERVER); --- 80,107 ---- super(name); if(COMPILED_MODULES_ENABLED){ ! try { ! setTokens(name, manager); ! } catch (Exception e) { ! //ok, something went wrong... let's give it another shot... ! synchronized (this) { ! try { ! wait(10); ! } catch (InterruptedException e1) { ! //empty block ! } //just wait a little before a retry... ! } ! ! try { ! AbstractShell shell = AbstractShell.getServerShell(manager.getNature(), AbstractShell.COMPLETION_SHELL); ! synchronized(shell){ ! shell.clearSocket(); ! } ! setTokens(name, manager); ! } catch (Exception e2) { ! tokens = new HashMap<String, CompiledToken>(); ! e2.printStackTrace(); ! PydevPlugin.log(e2); ! } ! } if(tokens != null && tokens.size() > 0){ List<IModulesObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_MODULES_OBSERVER); *************** *** 117,126 **** } ! private void setTokens(String name, ICodeCompletionASTManager manager) throws IOException, Exception, CoreException { ! if(TRACE_COMPILED_MODULES){ ! PydevPlugin.log(IStatus.INFO, "Compiled modules: getting info for:"+name, null); ! } ! AbstractShell shell = AbstractShell.getServerShell(manager.getNature(), AbstractShell.COMPLETION_SHELL); ! synchronized(shell){ Tuple<String, List<String[]>> completions = shell.getImportCompletions(name, manager.getModulesManager().getCompletePythonPath(null)); //default String fPath = completions.o1; --- 117,126 ---- } ! private void setTokens(String name, ICodeCompletionASTManager manager) throws IOException, Exception, CoreException { ! if(TRACE_COMPILED_MODULES){ ! PydevPlugin.log(IStatus.INFO, "Compiled modules: getting info for:"+name, null); ! } ! AbstractShell shell = AbstractShell.getServerShell(manager.getNature(), AbstractShell.COMPLETION_SHELL); ! synchronized(shell){ Tuple<String, List<String[]>> completions = shell.getImportCompletions(name, manager.getModulesManager().getCompletePythonPath(null)); //default String fPath = completions.o1; *************** *** 137,188 **** } } ! ArrayList<IToken> array = new ArrayList<IToken>(); ! ! for (Iterator iter = completions.o2.iterator(); iter.hasNext();) { ! String[] element = (String[]) iter.next(); ! //let's make this less error-prone. ! try { ! String o1 = element[0]; //this one is really, really needed ! String o2 = ""; ! String o3 = ""; ! String o4; ! ! if(element.length > 0) ! o2 = element[1]; ! ! if(element.length > 0) ! o3 = element[2]; ! ! if(element.length > 0) ! o4 = element[3]; ! else ! o4 = ""+IToken.TYPE_BUILTIN; ! ! IToken t = new CompiledToken(o1, o2, o3, name, Integer.parseInt(o4)); ! array.add(t); ! } catch (Exception e) { ! String received = ""; ! for (int i = 0; i < element.length; i++) { ! received += element[i]; ! received += " "; ! } ! ! PydevPlugin.log(IStatus.ERROR, "Error getting completions for compiled module "+name+" received = '"+received+"'", e); ! } ! } ! ! //as we will use it for code completion on sources that map to modules, the __file__ should also ! //be added... ! if(array.size() > 0 && name.equals("__builtin__")){ ! array.add(new CompiledToken("__file__","","",name,IToken.TYPE_BUILTIN)); ! array.add(new CompiledToken("__builtins__","","",name,IToken.TYPE_BUILTIN)); ! } ! ! this.tokens = new HashMap<String, CompiledToken>(); ! for (IToken token : array) { ! this.tokens.put(token.getRepresentation(), (CompiledToken) token); ! } ! } ! } /** --- 137,188 ---- } } ! ArrayList<IToken> array = new ArrayList<IToken>(); ! ! for (Iterator iter = completions.o2.iterator(); iter.hasNext();) { ! String[] element = (String[]) iter.next(); ! //let's make this less error-prone. ! try { ! String o1 = element[0]; //this one is really, really needed ! String o2 = ""; ! String o3 = ""; ! String o4; ! ! if(element.length > 0) ! o2 = element[1]; ! ! if(element.length > 0) ! o3 = element[2]; ! ! if(element.length > 0) ! o4 = element[3]; ! else ! o4 = ""+IToken.TYPE_BUILTIN; ! ! IToken t = new CompiledToken(o1, o2, o3, name, Integer.parseInt(o4)); ! array.add(t); ! } catch (Exception e) { ! String received = ""; ! for (int i = 0; i < element.length; i++) { ! received += element[i]; ! received += " "; ! } ! ! PydevPlugin.log(IStatus.ERROR, "Error getting completions for compiled module "+name+" received = '"+received+"'", e); ! } ! } ! ! //as we will use it for code completion on sources that map to modules, the __file__ should also ! //be added... ! if(array.size() > 0 && name.equals("__builtin__")){ ! array.add(new CompiledToken("__file__","","",name,IToken.TYPE_BUILTIN)); ! array.add(new CompiledToken("__builtins__","","",name,IToken.TYPE_BUILTIN)); ! } ! ! this.tokens = new HashMap<String, CompiledToken>(); ! for (IToken token : array) { ! this.tokens.put(token.getRepresentation(), (CompiledToken) token); ! } ! } ! } /** *************** *** 206,215 **** */ public IToken[] getGlobalTokens() { ! if(tokens == null){ ! return new IToken[0]; ! } ! Collection<CompiledToken> values = tokens.values(); ! return values.toArray(new IToken[values.size()]); } --- 206,215 ---- */ public IToken[] getGlobalTokens() { ! if(tokens == null){ ! return new IToken[0]; ! } ! Collection<CompiledToken> values = tokens.values(); ! return values.toArray(new IToken[values.size()]); } *************** *** 225,231 **** */ public IToken[] getGlobalTokens(ICompletionState state, ICodeCompletionASTManager manager) { ! Map<String, IToken> v = cache.get(state.getActivationToken()); if(v != null){ ! Collection<IToken> values = v.values(); return values.toArray(new IToken[values.size()]); } --- 225,231 ---- */ public IToken[] getGlobalTokens(ICompletionState state, ICodeCompletionASTManager manager) { ! Map<String, IToken> v = cache.get(state.getActivationToken()); if(v != null){ ! Collection<IToken> values = v.values(); return values.toArray(new IToken[values.size()]); } *************** *** 234,265 **** if(COMPILED_MODULES_ENABLED){ ! try { ! AbstractShell shell = AbstractShell.getServerShell(manager.getNature(), AbstractShell.COMPLETION_SHELL); ! synchronized(shell){ ! String act = name+"."+state.getActivationToken(); List<String[]> completions = shell.getImportCompletions(act, manager.getModulesManager().getCompletePythonPath(null)).o2;//default ! ! ArrayList<IToken> array = new ArrayList<IToken>(); ! ! for (Iterator iter = completions.iterator(); iter.hasNext();) { ! ... [truncated message content] |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:02
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/shell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion/shell Modified Files: AbstractShell.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: AbstractShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/shell/AbstractShell.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractShell.java 4 Mar 2008 01:54:11 -0000 1.3 --- AbstractShell.java 28 Sep 2008 12:45:53 -0000 1.4 *************** *** 130,153 **** */ public synchronized static void shutdownAllShells(){ ! synchronized(shells){ ! for (Iterator<Map<Integer, AbstractShell>> iter = shells.values().iterator(); iter.hasNext();) { ! finishedForGood = true; //we may no longer restart shells ! ! Map<Integer,AbstractShell> rel = (Map<Integer, AbstractShell>) iter.next(); ! if(rel != null){ ! for (Iterator iter2 = rel.values().iterator(); iter2.hasNext();) { ! AbstractShell element = (AbstractShell) iter2.next(); ! if(element != null){ ! try { ! element.shutdown(); //shutdown ! } catch (Exception e) { ! PydevPlugin.log(e); //let's log it... this should not happen ! } ! } ! } ! } ! } ! shells.clear(); ! } } --- 130,153 ---- */ public synchronized static void shutdownAllShells(){ ! synchronized(shells){ ! for (Iterator<Map<Integer, AbstractShell>> iter = shells.values().iterator(); iter.hasNext();) { ! finishedForGood = true; //we may no longer restart shells ! ! Map<Integer,AbstractShell> rel = (Map<Integer, AbstractShell>) iter.next(); ! if(rel != null){ ! for (Iterator iter2 = rel.values().iterator(); iter2.hasNext();) { ! AbstractShell element = (AbstractShell) iter2.next(); ! if(element != null){ ! try { ! element.shutdown(); //shutdown ! } catch (Exception e) { ! PydevPlugin.log(e); //let's log it... this should not happen ! } ! } ! } ! } ! } ! shells.clear(); ! } } *************** *** 157,169 **** */ private synchronized static Map<Integer, AbstractShell> getTypeToShellFromId(int relatedId) { ! synchronized(shells){ ! Map<Integer, AbstractShell> typeToShell = shells.get(relatedId); ! ! if (typeToShell == null) { ! typeToShell = new HashMap<Integer, AbstractShell>(); ! shells.put(relatedId, typeToShell); ! } ! return typeToShell; ! } } --- 157,169 ---- */ private synchronized static Map<Integer, AbstractShell> getTypeToShellFromId(int relatedId) { ! synchronized(shells){ ! Map<Integer, AbstractShell> typeToShell = shells.get(relatedId); ! ! if (typeToShell == null) { ! typeToShell = new HashMap<Integer, AbstractShell>(); ! shells.put(relatedId, typeToShell); ! } ! return typeToShell; ! } } *************** *** 206,247 **** */ public synchronized static AbstractShell getServerShell(int relatedId, int id) throws IOException, JDTNotAvailableException, CoreException { ! AbstractShell pythonShell = null; ! synchronized(shells){ ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! Log.toLogFile("Synchronizing on shells...", AbstractShell.class); ! } if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile( "Getting shell relatedId:"+relatedId+" id:"+id, AbstractShell.class); } ! Map<Integer, AbstractShell> typeToShell = getTypeToShellFromId(relatedId); ! pythonShell = (AbstractShell) typeToShell.get(new Integer(id)); ! ! if(pythonShell == null){ if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile("pythonShell == null", AbstractShell.class); } ! if(relatedId == IPythonNature.PYTHON_RELATED){ ! pythonShell = new PythonShell(); ! }else if(relatedId == IPythonNature.JYTHON_RELATED){ ! pythonShell = new JythonShell(); ! }else{ ! throw new RuntimeException("unknown related id"); ! } if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile("pythonShell.startIt()", AbstractShell.class); Log.addLogLevel(); } ! pythonShell.startIt(); //first start it ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! Log.remLogLevel(); ! Log.toLogFile("Finished pythonShell.startIt()", AbstractShell.class); ! } ! ! //then make it accessible ! typeToShell.put(new Integer(id), pythonShell); ! } ! } ! return pythonShell; } --- 206,247 ---- */ public synchronized static AbstractShell getServerShell(int relatedId, int id) throws IOException, JDTNotAvailableException, CoreException { ! AbstractShell pythonShell = null; ! synchronized(shells){ ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! Log.toLogFile("Synchronizing on shells...", AbstractShell.class); ! } if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile( "Getting shell relatedId:"+relatedId+" id:"+id, AbstractShell.class); } ! Map<Integer, AbstractShell> typeToShell = getTypeToShellFromId(relatedId); ! pythonShell = (AbstractShell) typeToShell.get(new Integer(id)); ! ! if(pythonShell == null){ if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile("pythonShell == null", AbstractShell.class); } ! if(relatedId == IPythonNature.PYTHON_RELATED){ ! pythonShell = new PythonShell(); ! }else if(relatedId == IPythonNature.JYTHON_RELATED){ ! pythonShell = new JythonShell(); ! }else{ ! throw new RuntimeException("unknown related id"); ! } if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ Log.toLogFile("pythonShell.startIt()", AbstractShell.class); Log.addLogLevel(); } ! pythonShell.startIt(); //first start it ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! Log.remLogLevel(); ! Log.toLogFile("Finished pythonShell.startIt()", AbstractShell.class); ! } ! ! //then make it accessible ! typeToShell.put(new Integer(id), pythonShell); ! } ! } ! return pythonShell; } *************** *** 309,315 **** */ public synchronized void startIt() throws IOException, JDTNotAvailableException, CoreException { ! synchronized(this){ ! this.startIt(AbstractShell.DEFAULT_SLEEP_BETWEEN_ATTEMPTS); ! } } --- 309,315 ---- */ public synchronized void startIt() throws IOException, JDTNotAvailableException, CoreException { ! synchronized(this){ ! this.startIt(AbstractShell.DEFAULT_SLEEP_BETWEEN_ATTEMPTS); ! } } *************** *** 326,439 **** */ protected synchronized void startIt(int milisSleep) throws IOException, JDTNotAvailableException, CoreException { ! if(inStart || isConnected){ ! //it is already in the process of starting, so, if we are in another thread, just forget about it. ! return; ! } ! inStart = true; try { ! if (finishedForGood) { ! throw new RuntimeException( ! "Shells are already finished for good, so, it is an invalid state to try to restart it."); ! } ! try { ! int pWrite = SocketUtil.findUnusedLocalPort(); ! int pRead = SocketUtil.findUnusedLocalPort(); ! if (process != null) { ! endIt(); //end the current process ! } ! String execMsg = createServerProcess(pWrite, pRead); ! dbg("executing " + execMsg,1); ! sleepALittle(200); ! String osName = System.getProperty("os.name"); ! if (process == null) { ! String msg = "Error creating python process - got null process(" + execMsg + ") - os:" + osName; dbg(msg, 1); PydevPlugin.log(msg); ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, msg, new Exception(msg))); ! } ! try { ! int exitVal = process.exitValue(); //should throw exception saying that it still is not terminated... ! String msg = "Error creating python process - exited before creating sockets - exitValue = ("+ exitVal + ")(" + execMsg + ") - os:" + osName; ! dbg(msg, 1); ! PydevPlugin.log(msg); ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, msg, new Exception(msg))); ! } catch (IllegalThreadStateException e2) { //this is ok ! } ! dbg("afterCreateProcess ",1); ! //ok, process validated, so, let's get its output and store it for further use. ! afterCreateProcess(); ! boolean connected = false; ! int attempts = 0; ! dbg("connecting... ",1); ! sleepALittle(milisSleep); ! socketToWrite = null; ! serverSocket = new ServerSocket(pRead); //read in this port ! int maxAttempts = PyCodeCompletionPreferencesPage.getNumberOfConnectionAttempts(); ! while (!connected && attempts < maxAttempts && !finishedForGood) { ! attempts += 1; ! dbg("connecting attept..."+attempts,1); ! try { ! if (socketToWrite == null || socketToWrite.isConnected() == false) { ! socketToWrite = new Socket("127.0.0.1", pWrite); //we should write in this port ! } ! if (socketToWrite != null || socketToWrite.isConnected()) { ! serverSocket.setSoTimeout(milisSleep * 2); //let's give it a higher timeout, as we're already half - connected ! try { ! socketToRead = serverSocket.accept(); socketToRead.setSoTimeout(5000); ! connected = true; ! dbg("connected! ",1); ! } catch (SocketTimeoutException e) { ! //that's ok, timeout for waiting connection expired, let's check it again in the next loop ! } ! } ! } catch (IOException e1) { ! if (socketToWrite != null && socketToWrite.isConnected() == true) { ! String msg = "Attempt: " + attempts + " of " + maxAttempts + " failed, trying again...(socketToWrite already binded)"; ! dbg(msg,1); PydevPlugin.log(IStatus.ERROR, msg, e1); ! } ! if (socketToWrite != null && !socketToWrite.isConnected() == true) { ! String msg = "Attempt: " + attempts + " of " + maxAttempts + " failed, trying again...(socketToWrite still not binded)"; ! dbg(msg,1); PydevPlugin.log(IStatus.ERROR, msg, e1); ! } ! } ! //if not connected, let's sleep a little for another attempt ! if (!connected) { ! sleepALittle(milisSleep); ! } ! } ! if (!connected && !finishedForGood) { ! dbg("NOT connected ",1); ! //what, after all this trouble we are still not connected????!?!?!?! ! //let's communicate this to the user... ! String isAlive; ! try { ! int exitVal = process.exitValue(); //should throw exception saying that it still is not terminated... ! isAlive = " - the process in NOT ALIVE anymore (output=" + exitVal + ") - "; ! } catch (IllegalThreadStateException e2) { //this is ok ! isAlive = " - the process in still alive (killing it now)- "; ! process.destroy(); ! } ! String output = getProcessOutput(); ! String msg = "Error connecting to python process (" + execMsg + ") " + isAlive + " the output of the process is: " + output; --- 326,439 ---- */ protected synchronized void startIt(int milisSleep) throws IOException, JDTNotAvailableException, CoreException { ! if(inStart || isConnected){ ! //it is already in the process of starting, so, if we are in another thread, just forget about it. ! return; ! } ! inStart = true; try { ! if (finishedForGood) { ! throw new RuntimeException( ! "Shells are already finished for good, so, it is an invalid state to try to restart it."); ! } ! try { ! int pWrite = SocketUtil.findUnusedLocalPort(); ! int pRead = SocketUtil.findUnusedLocalPort(); ! if (process != null) { ! endIt(); //end the current process ! } ! String execMsg = createServerProcess(pWrite, pRead); ! dbg("executing " + execMsg,1); ! sleepALittle(200); ! String osName = System.getProperty("os.name"); ! if (process == null) { ! String msg = "Error creating python process - got null process(" + execMsg + ") - os:" + osName; dbg(msg, 1); PydevPlugin.log(msg); ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, msg, new Exception(msg))); ! } ! try { ! int exitVal = process.exitValue(); //should throw exception saying that it still is not terminated... ! String msg = "Error creating python process - exited before creating sockets - exitValue = ("+ exitVal + ")(" + execMsg + ") - os:" + osName; ! dbg(msg, 1); ! PydevPlugin.log(msg); ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, msg, new Exception(msg))); ! } catch (IllegalThreadStateException e2) { //this is ok ! } ! dbg("afterCreateProcess ",1); ! //ok, process validated, so, let's get its output and store it for further use. ! afterCreateProcess(); ! boolean connected = false; ! int attempts = 0; ! dbg("connecting... ",1); ! sleepALittle(milisSleep); ! socketToWrite = null; ! serverSocket = new ServerSocket(pRead); //read in this port ! int maxAttempts = PyCodeCompletionPreferencesPage.getNumberOfConnectionAttempts(); ! while (!connected && attempts < maxAttempts && !finishedForGood) { ! attempts += 1; ! dbg("connecting attept..."+attempts,1); ! try { ! if (socketToWrite == null || socketToWrite.isConnected() == false) { ! socketToWrite = new Socket("127.0.0.1", pWrite); //we should write in this port ! } ! if (socketToWrite != null || socketToWrite.isConnected()) { ! serverSocket.setSoTimeout(milisSleep * 2); //let's give it a higher timeout, as we're already half - connected ! try { ! socketToRead = serverSocket.accept(); socketToRead.setSoTimeout(5000); ! connected = true; ! dbg("connected! ",1); ! } catch (SocketTimeoutException e) { ! //that's ok, timeout for waiting connection expired, let's check it again in the next loop ! } ! } ! } catch (IOException e1) { ! if (socketToWrite != null && socketToWrite.isConnected() == true) { ! String msg = "Attempt: " + attempts + " of " + maxAttempts + " failed, trying again...(socketToWrite already binded)"; ! dbg(msg,1); PydevPlugin.log(IStatus.ERROR, msg, e1); ! } ! if (socketToWrite != null && !socketToWrite.isConnected() == true) { ! String msg = "Attempt: " + attempts + " of " + maxAttempts + " failed, trying again...(socketToWrite still not binded)"; ! dbg(msg,1); PydevPlugin.log(IStatus.ERROR, msg, e1); ! } ! } ! //if not connected, let's sleep a little for another attempt ! if (!connected) { ! sleepALittle(milisSleep); ! } ! } ! if (!connected && !finishedForGood) { ! dbg("NOT connected ",1); ! //what, after all this trouble we are still not connected????!?!?!?! ! //let's communicate this to the user... ! String isAlive; ! try { ! int exitVal = process.exitValue(); //should throw exception saying that it still is not terminated... ! isAlive = " - the process in NOT ALIVE anymore (output=" + exitVal + ") - "; ! } catch (IllegalThreadStateException e2) { //this is ok ! isAlive = " - the process in still alive (killing it now)- "; ! process.destroy(); ! } ! String output = getProcessOutput(); ! String msg = "Error connecting to python process (" + execMsg + ") " + isAlive + " the output of the process is: " + output; *************** *** 441,462 **** dbg(msg, 1); PydevPlugin.log(exception); ! throw exception; ! } ! } catch (IOException e) { ! if (process != null) { ! process.destroy(); ! process = null; ! } ! throw e; ! } ! } finally { ! this.inStart = false; ! } ! ! ! //if it got here, everything went ok (otherwise we would have gotten an exception). ! isConnected = true; } --- 441,462 ---- dbg(msg, 1); PydevPlugin.log(exception); ! throw exception; ! } ! } catch (IOException e) { ! if (process != null) { ! process.destroy(); ! process = null; ! } ! throw e; ! } ! } finally { ! this.inStart = false; ! } ! ! ! //if it got here, everything went ok (otherwise we would have gotten an exception). ! isConnected = true; } *************** *** 514,529 **** public synchronized void clearSocket() throws IOException { ! while(true){ //clear until we get no message... ! byte[] b = new byte[AbstractShell.BUFFER_SIZE]; if(this.socketToRead != null){ ! this.socketToRead.getInputStream().read(b); ! ! String s = new String(b); ! s = s.replaceAll((char)0+"",""); //python sends this char as payload. ! if(s.length() == 0){ ! return; ! } } ! } } --- 514,529 ---- public synchronized void clearSocket() throws IOException { ! while(true){ //clear until we get no message... ! byte[] b = new byte[AbstractShell.BUFFER_SIZE]; if(this.socketToRead != null){ ! this.socketToRead.getInputStream().read(b); ! ! String s = new String(b); ! s = s.replaceAll((char)0+"",""); //python sends this char as payload. ! if(s.length() == 0){ ! return; ! } } ! } } *************** *** 806,812 **** } catch (Exception e) { ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! PydevPlugin.log(IStatus.ERROR, "ERROR getting completions.", e); ! } restartShell(); --- 806,812 ---- } catch (Exception e) { ! if(PyCodeCompletion.DEBUG_CODE_COMPLETION){ ! PydevPlugin.log(IStatus.ERROR, "ERROR getting completions.", e); ! } restartShell(); |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:01
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/ui/editors Modified Files: TreeWithAddRemove.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: TreeWithAddRemove.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/editors/TreeWithAddRemove.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TreeWithAddRemove.java 14 Jun 2008 22:14:56 -0000 1.9 --- TreeWithAddRemove.java 28 Sep 2008 12:45:52 -0000 1.10 *************** *** 47,73 **** } ! GridLayout layout = new GridLayout(); ! layout.numColumns = 2; ! this.setLayout(layout); ! GridData data= new GridData(GridData.FILL_BOTH); ! this.project = project; ! ! tree = new Tree(this, SWT.BORDER ); ! data.grabExcessHorizontalSpace = true; ! data.grabExcessVerticalSpace = true; ! tree.setLayoutData(data); ! Composite buttonsSourceFolders= new Composite(this, SWT.NONE); ! buttonsSourceFolders.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); ! ! layout = new GridLayout(); ! layout.marginHeight= 0; ! layout.marginWidth= 0; ! buttonsSourceFolders.setLayout(layout); ! ! Button buttonAddSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeAddSourceFolderButton(buttonAddSourceFolder, true); buttonAddSourceFolder.setText(getButtonAddText()); data = new GridData (); --- 47,73 ---- } ! GridLayout layout = new GridLayout(); ! layout.numColumns = 2; ! this.setLayout(layout); ! GridData data= new GridData(GridData.FILL_BOTH); ! this.project = project; ! ! tree = new Tree(this, SWT.BORDER ); ! data.grabExcessHorizontalSpace = true; ! data.grabExcessVerticalSpace = true; ! tree.setLayoutData(data); ! Composite buttonsSourceFolders= new Composite(this, SWT.NONE); ! buttonsSourceFolders.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); ! ! layout = new GridLayout(); ! layout.marginHeight= 0; ! layout.marginWidth= 0; ! buttonsSourceFolders.setLayout(layout); ! ! Button buttonAddSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeAddSourceFolderButton(buttonAddSourceFolder, true); buttonAddSourceFolder.setText(getButtonAddText()); data = new GridData (); *************** *** 84,89 **** buttonAddZip.setLayoutData(data); ! Button buttonRemSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeRemSourceFolderButton(buttonRemSourceFolder); data = new GridData (); data.horizontalAlignment = GridData.FILL; --- 84,89 ---- buttonAddZip.setLayoutData(data); ! Button buttonRemSourceFolder = new Button(buttonsSourceFolders, SWT.PUSH); ! customizeRemSourceFolderButton(buttonRemSourceFolder); data = new GridData (); data.horizontalAlignment = GridData.FILL; *************** *** 100,106 **** ! /** ! * Remove is almost always default ! * * @param buttonRemSourceFolder */ --- 100,106 ---- ! /** ! * Remove is almost always default ! * * @param buttonRemSourceFolder */ *************** *** 162,168 **** }else if(d instanceof SelectionDialog){ SelectionDialog dialog = (SelectionDialog) d; ! dialog.open(); ! Object[] objects = dialog.getResult(); ! if (objects != null) { for (int i = 0; i < objects.length; i++) { Object object = objects[i]; --- 162,168 ---- }else if(d instanceof SelectionDialog){ SelectionDialog dialog = (SelectionDialog) d; ! dialog.open(); ! Object[] objects = dialog.getResult(); ! if (objects != null) { for (int i = 0; i < objects.length; i++) { Object object = objects[i]; *************** *** 174,179 **** addTreeItem(pathAsString); }else if(object instanceof IFile){ ! //IMPORTANT: get it relative to the workspace root, and not to the project!! ! //(historical reasons) IFile p = (IFile) object; String pathAsString = getPathAsString(p.getProjectRelativePath()); --- 174,179 ---- addTreeItem(pathAsString); }else if(object instanceof IFile){ ! //IMPORTANT: get it relative to the workspace root, and not to the project!! ! //(historical reasons) IFile p = (IFile) object; String pathAsString = getPathAsString(p.getProjectRelativePath()); *************** *** 184,188 **** } } ! } }else{ throw new RuntimeException("Dont know how to treat dialog: "+d.getClass()); --- 184,188 ---- } } ! } }else{ throw new RuntimeException("Dont know how to treat dialog: "+d.getClass()); *************** *** 259,265 **** private void addTreeItem(String pathAsString) { if(pathAsString != null && pathAsString.trim().length() > 0){ ! TreeItem item = new TreeItem(tree, 0); ! item.setText(pathAsString); ! item.setImage(PydevPlugin.getImageCache().get(getImageConstant())); } } --- 259,265 ---- private void addTreeItem(String pathAsString) { if(pathAsString != null && pathAsString.trim().length() > 0){ ! TreeItem item = new TreeItem(tree, 0); ! item.setText(pathAsString); ! item.setImage(PydevPlugin.getImageCache().get(getImageConstant())); } } *************** *** 271,276 **** String text = items[i].getText(); if(text != null && text.trim().length() > 0){ ! ret.append(text); ! ret.append("|"); } } --- 271,276 ---- String text = items[i].getText(); if(text != null && text.trim().length() > 0){ ! ret.append(text); ! ret.append("|"); } } |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/actions/refactoring Modified Files: PyRefactorAction.java PyExtractLocalVariable.java PyInlineLocalVariable.java PyExtractMethod.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: PyExtractLocalVariable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyExtractLocalVariable.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyExtractLocalVariable.java 19 Jan 2007 23:15:14 -0000 1.6 --- PyExtractLocalVariable.java 28 Sep 2008 12:45:51 -0000 1.7 *************** *** 20,27 **** * we need: * ! * def extract(self, filename_path, ! * begin_line, begin_col, ! * end_line, end_col, ! * name): * @throws BadLocationException * @throws CoreException --- 20,27 ---- * we need: * ! * def extract(self, filename_path, ! * begin_line, begin_col, ! * end_line, end_col, ! * name): * @throws BadLocationException * @throws CoreException Index: PyExtractMethod.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyExtractMethod.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyExtractMethod.java 19 Jan 2007 23:15:14 -0000 1.8 --- PyExtractMethod.java 28 Sep 2008 12:45:51 -0000 1.9 *************** *** 21,28 **** * we need: * ! * def extract(self, filename_path, ! * begin_line, begin_col, ! * end_line, end_col, ! * name): * @throws BadLocationException * @throws CoreException --- 21,28 ---- * we need: * ! * def extract(self, filename_path, ! * begin_line, begin_col, ! * end_line, end_col, ! * name): * @throws BadLocationException * @throws CoreException *************** *** 33,37 **** String res = ""; if(name.equals("") == false){ ! res = getPyRefactoring().extract(getRefactoringRequest(name, monitor)); } return res; --- 33,37 ---- String res = ""; if(name.equals("") == false){ ! res = getPyRefactoring().extract(getRefactoringRequest(name, monitor)); } return res; Index: PyRefactorAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyRefactorAction.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PyRefactorAction.java 12 Mar 2007 15:34:05 -0000 1.24 --- PyRefactorAction.java 28 Sep 2008 12:45:51 -0000 1.25 *************** *** 133,140 **** public RefactoringRequest getRefactoringRequest(){ ! return getRefactoringRequest(null, null); } public RefactoringRequest getRefactoringRequest(IProgressMonitor monitor){ ! return getRefactoringRequest(null, monitor); } --- 133,140 ---- public RefactoringRequest getRefactoringRequest(){ ! return getRefactoringRequest(null, null); } public RefactoringRequest getRefactoringRequest(IProgressMonitor monitor){ ! return getRefactoringRequest(null, monitor); } *************** *** 151,159 **** //testing first with whole lines. PyEdit pyEdit = getPyEdit(); //may not be available in tests, that's why it is important to be able to operate without it ! request = createRefactoringRequest(monitor, pyEdit, ps); } request.pushMonitor(monitor); request.inputName = name; ! return request; } --- 151,159 ---- //testing first with whole lines. PyEdit pyEdit = getPyEdit(); //may not be available in tests, that's why it is important to be able to operate without it ! request = createRefactoringRequest(monitor, pyEdit, ps); } request.pushMonitor(monitor); request.inputName = name; ! return request; } Index: PyInlineLocalVariable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyInlineLocalVariable.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyInlineLocalVariable.java 19 Jan 2007 23:15:14 -0000 1.7 --- PyInlineLocalVariable.java 28 Sep 2008 12:45:51 -0000 1.8 *************** *** 21,26 **** * we need: * ! * def inlineLocalVariable(self,filename_path, line, col) ! * * @throws BadLocationException * @throws CoreException --- 21,26 ---- * we need: * ! * def inlineLocalVariable(self,filename_path, line, col) ! * * @throws BadLocationException * @throws CoreException |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:45:58
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/hyperlink In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/hyperlink Modified Files: PythonHyperlink.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: PythonHyperlink.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/hyperlink/PythonHyperlink.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonHyperlink.java 31 Jul 2008 01:47:36 -0000 1.2 --- PythonHyperlink.java 28 Sep 2008 12:45:52 -0000 1.3 *************** *** 54,61 **** IWorkbench workbench = PlatformUI.getWorkbench(); if(workbench != null){ ! IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); ! if(workbenchWindow != null){ ! workbenchWindow.getActivePage().saveAllEditors(false); ! } } --- 54,61 ---- IWorkbench workbench = PlatformUI.getWorkbench(); if(workbench != null){ ! IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); ! if(workbenchWindow != null){ ! workbenchWindow.getActivePage().saveAllEditors(false); ! } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:45:55
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/builder/syntaxchecker Added Files: PySyntaxChecker.java ClearSyntaxMarkersPyeditListener.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 --- NEW FILE: PySyntaxChecker.java --- package org.python.pydev.builder.syntaxchecker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.IDocument; import org.python.pydev.builder.PyDevBuilderPrefPage; import org.python.pydev.builder.PyDevBuilderVisitor; import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; import org.python.pydev.parser.PyParser; import org.python.pydev.plugin.DebugSettings; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.nature.PythonNature; /** * Whenever a given resource is changed, a syntax check is done, updating errors related to the syntax. * * @author Fabio */ public class PySyntaxChecker extends PyDevBuilderVisitor{ @Override public void visitChangedResource(IResource resource, IDocument document, IProgressMonitor monitor) { PythonNature nature = getPythonNature(resource); if(nature == null){ return; } if(PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()){ if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ System.out.println("PySyntaxChecker: PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()"); } return; //not analyzed with this builder... always from parser changes. } try { PyParser.deleteErrorMarkers(resource); } catch (CoreException e) { PydevPlugin.log(e); } if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ System.out.println("PySyntaxChecker: Checking!"); } SourceModule mod = getSourceModule(resource, document, nature); Throwable parseError = mod.parseError; if(parseError != null){ try { PyParser.createParserErrorMarkers(parseError, resource, document); } catch (Exception e) { PydevPlugin.log(e); } } } @Override public void visitRemovedResource(IResource resource, IDocument document, IProgressMonitor monitor) { // Nothing needs to be done in this case } } --- NEW FILE: ClearSyntaxMarkersPyeditListener.java --- package org.python.pydev.builder.syntaxchecker; import java.util.ListResourceBundle; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IEditorInput; import org.python.pydev.builder.PyDevBuilderPrefPage; import org.python.pydev.editor.IPyEditListener; import org.python.pydev.editor.IPyEditListener3; import org.python.pydev.editor.PyEdit; import org.python.pydev.parser.PyParser; import org.python.pydev.plugin.DebugSettings; import org.python.pydev.plugin.PydevPlugin; /** * When the editor is disposed, if needed this class will remove the markers from the related * file (if no other editor is still editing the same file). * * @author Fabio */ public class ClearSyntaxMarkersPyeditListener implements IPyEditListener, IPyEditListener3{ public void onCreateActions(ListResourceBundle resources, PyEdit edit, IProgressMonitor monitor) { } public void onDispose(PyEdit edit, IProgressMonitor monitor) { //remove the markers if we want problems only in the active editor. IEditorInput input = edit.getEditorInput(); removeMarkersFromInput(input); } public void onSave(PyEdit edit, IProgressMonitor monitor) { } public void onSetDocument(IDocument document, PyEdit edit, IProgressMonitor monitor) { } public void onInputChanged(PyEdit edit, IEditorInput oldInput, IEditorInput input, IProgressMonitor monitor) { removeMarkersFromInput(oldInput); } /** * This function will remove the markers from the passed input. * @param input the input */ private void removeMarkersFromInput(IEditorInput input) { if(input!= null && PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()){ if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ System.out.println("ClearSyntaxMarkersPyeditListener: removing syntax error markers from editor."); } IFile relatedFile = (IFile) input.getAdapter(IFile.class); if(relatedFile != null && relatedFile.exists()){ //when disposing, remove all markers try { PyParser.deleteErrorMarkers(relatedFile); } catch (CoreException e) { PydevPlugin.log(e); } } } } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:45:50
|
Update of /cvsroot/pydev/org.python.pydev/tests/pysrc/extendable/all_check2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/tests/pysrc/extendable/all_check2 Added Files: __init__.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 --- NEW FILE: __init__.py --- class ThisGoes: pass class ThisGoesToo: pass class ThisDoesnt: pass __all__ = ['ThisGoes'] __all__.append('ThisGoesToo') #When it's defined in runtime, any addition will make it accept anything (at least for now). |