pydev-cvs Mailing List for PyDev for Eclipse
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-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/todo In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/builder/todo Modified Files: PyTodoVisitor.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: PyTodoVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/todo/PyTodoVisitor.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyTodoVisitor.java 28 Sep 2008 12:45:46 -0000 1.14 --- PyTodoVisitor.java 3 Oct 2008 00:43:54 -0000 1.15 *************** *** 18,21 **** --- 18,22 ---- import org.python.pydev.builder.PydevMarkerUtils; import org.python.pydev.builder.PydevMarkerUtils.MarkerInfo; + import org.python.pydev.core.log.Log; import org.python.pydev.plugin.DebugSettings; import org.python.pydev.plugin.PydevPlugin; *************** *** 70,74 **** } if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ ! System.out.println("Adding todo markers"); } PydevMarkerUtils.replaceMarkers(lst, resource, IMarker.TASK); --- 71,75 ---- } if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ ! Log.toLogFile(this, "Adding todo markers"); } PydevMarkerUtils.replaceMarkers(lst, resource, IMarker.TASK); |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/builder Modified Files: PyDevBuilderPrefPage.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: PyDevBuilderPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/PyDevBuilderPrefPage.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyDevBuilderPrefPage.java 28 Sep 2008 12:45:46 -0000 1.6 --- PyDevBuilderPrefPage.java 3 Oct 2008 00:43:54 -0000 1.7 *************** *** 32,36 **** public static final String ANALYZE_ONLY_ACTIVE_EDITOR = "ANALYZE_ONLY_ACTIVE_EDITOR"; ! public static final boolean DEFAULT_ANALYZE_ONLY_ACTIVE_EDITOR = true; /** --- 32,36 ---- public static final String ANALYZE_ONLY_ACTIVE_EDITOR = "ANALYZE_ONLY_ACTIVE_EDITOR"; ! public static final boolean DEFAULT_ANALYZE_ONLY_ACTIVE_EDITOR = false; /** *************** *** 70,75 **** 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)); --- 70,74 ---- 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"; addField(new LabelFieldEditor("ActiveBufferLabelFieldEditor", s, p)); |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/plugin Modified Files: DebugSettings.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: DebugSettings.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/DebugSettings.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DebugSettings.java 28 Sep 2008 12:45:44 -0000 1.1 --- DebugSettings.java 3 Oct 2008 00:43:54 -0000 1.2 *************** *** 1,4 **** --- 1,6 ---- package org.python.pydev.plugin; + import org.python.pydev.logging.PyLoggingPreferencesPage; + /** * This class is used to give debug settings for this plugin. *************** *** 8,11 **** public class DebugSettings { ! public final static boolean DEBUG_ANALYSIS_REQUESTS = false; } --- 10,14 ---- public class DebugSettings { ! public static boolean DEBUG_ANALYSIS_REQUESTS = PyLoggingPreferencesPage.isToDebugAnalysisRequests(); ! } |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/builder/syntaxchecker Modified Files: ClearSyntaxMarkersPyeditListener.java PySyntaxChecker.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: PySyntaxChecker.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker/PySyntaxChecker.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PySyntaxChecker.java 28 Sep 2008 12:45:46 -0000 1.1 --- PySyntaxChecker.java 3 Oct 2008 00:43:54 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- import org.python.pydev.builder.PyDevBuilderPrefPage; import org.python.pydev.builder.PyDevBuilderVisitor; + import org.python.pydev.core.log.Log; import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; import org.python.pydev.parser.PyParser; *************** *** 30,46 **** 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!"); } --- 31,42 ---- if(PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()){ if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ ! Log.toLogFile(this, "PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()"); } return; //not analyzed with this builder... always from parser changes. } if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ ! Log.toLogFile(this, "Checking!"); } *************** *** 48,51 **** --- 44,53 ---- Throwable parseError = mod.parseError; + try { + PyParser.deleteErrorMarkers(resource); + } catch (CoreException e) { + PydevPlugin.log(e); + } + if(parseError != null){ try { Index: ClearSyntaxMarkersPyeditListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/syntaxchecker/ClearSyntaxMarkersPyeditListener.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClearSyntaxMarkersPyeditListener.java 28 Sep 2008 12:45:46 -0000 1.1 --- ClearSyntaxMarkersPyeditListener.java 3 Oct 2008 00:43:54 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- import org.eclipse.ui.IEditorInput; import org.python.pydev.builder.PyDevBuilderPrefPage; + import org.python.pydev.core.log.Log; import org.python.pydev.editor.IPyEditListener; import org.python.pydev.editor.IPyEditListener3; *************** *** 51,55 **** 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); --- 52,56 ---- if(input!= null && PyDevBuilderPrefPage.getAnalyzeOnlyActiveEditor()){ if(DebugSettings.DEBUG_ANALYSIS_REQUESTS){ ! Log.toLogFile(this, "removing syntax error markers from editor."); } IFile relatedFile = (IFile) input.getAdapter(IFile.class); |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/actions/container In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/ui/actions/container Modified Files: PyDeletePycAndClassFiles.java Added Files: PyDeleteErrors.java PyContainerAction.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: PyDeletePycAndClassFiles.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/actions/container/PyDeletePycAndClassFiles.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyDeletePycAndClassFiles.java 14 Jan 2008 00:21:45 -0000 1.2 --- PyDeletePycAndClassFiles.java 3 Oct 2008 00:43:54 -0000 1.3 *************** *** 1,8 **** package org.python.pydev.ui.actions.container; - import java.util.ArrayList; - import java.util.Iterator; - import java.util.List; - import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; --- 1,4 ---- *************** *** 11,20 **** import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; - import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; - import org.eclipse.jface.viewers.ISelection; - import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IObjectActionDelegate; - import org.eclipse.ui.IWorkbenchPart; import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.plugin.PydevPlugin; --- 7,12 ---- *************** *** 25,39 **** * @author Fabio */ ! public class PyDeletePycAndClassFiles implements IObjectActionDelegate { ! ! /** ! * List with the containers the user selected ! */ ! protected List<IContainer> selectedContainers; ! - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - //empty - } /** --- 17,22 ---- * @author Fabio */ ! public class PyDeletePycAndClassFiles extends PyContainerAction implements IObjectActionDelegate { /** *************** *** 44,48 **** * @return the number of files deleted */ ! protected int deletePycFiles(IContainer container) { IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); --- 27,31 ---- * @return the number of files deleted */ ! protected int doActionOnContainer(IContainer container) { IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); *************** *** 53,57 **** for (IResource c:members) { if(c instanceof IContainer){ ! deleted += this.deletePycFiles((IContainer) c); }else if(c instanceof IFile){ --- 36,40 ---- for (IResource c:members) { if(c instanceof IContainer){ ! deleted += this.doActionOnContainer((IContainer) c); }else if(c instanceof IFile){ *************** *** 72,127 **** } ! /** ! * Act on the selection to delete the pyc/$py.class files. ! */ ! public void run(IAction action) { ! //should not happen ! if(selectedContainers == null){ ! return; ! } ! ! if (!MessageDialog.openConfirm(null, "Confirm deletion", "Are you sure that you want to delete the *.pyc and *$py.class files from the selected folder(s)?")){ ! return; ! } ! ! int nDeleted = 0; ! IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); ! ! for (Iterator<IContainer> iter = this.selectedContainers.iterator(); iter.hasNext();) { ! IContainer next = iter.next(); ! //as files are generated externally, if we don't refresh, it's very likely that we won't delete a bunch of files. ! try { ! next.refreshLocal(IResource.DEPTH_INFINITE, nullProgressMonitor); ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! nDeleted += this.deletePycFiles(next); ! } ! ! MessageDialog.openInformation(null, "Files deleted", StringUtils.format("Deleted %s files.", nDeleted)); } ! /** ! * When the selection changes, we've to keep the selected containers... ! */ ! @SuppressWarnings("unchecked") ! public void selectionChanged(IAction action, ISelection selection) { ! if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) { ! selectedContainers = null; ! return; ! } ! ! IStructuredSelection selections = (IStructuredSelection) selection; ! ArrayList<IContainer> containers = new ArrayList<IContainer>(); ! ! for(Iterator<Object> it = selections.iterator(); it.hasNext();){ ! Object o = it.next(); ! if(o instanceof IContainer){ ! containers.add((IContainer) o); ! } ! } ! ! this.selectedContainers = containers; } } --- 55,71 ---- } ! @Override ! protected void afterRun(int deleted) { ! MessageDialog.openInformation(null, "Files deleted", StringUtils.format("Deleted %s files.", deleted)); } ! @Override ! protected boolean confirmRun() { ! return MessageDialog.openConfirm(null, "Confirm deletion", "Are you sure that you want to delete the *.pyc and *$py.class files from the selected folder(s)?"); } + + + + } --- NEW FILE: PyDeleteErrors.java --- package org.python.pydev.ui.actions.container; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IObjectActionDelegate; import org.python.pydev.plugin.PydevPlugin; /** * Action used to delete the error markers * * @author Fabio */ public class PyDeleteErrors extends PyContainerAction implements IObjectActionDelegate { /** * Deletes the error markers... recursively pass the folders and delete the files (and sum them so that we know how many * files were affected). * * @param container the folder from where we want to remove the markers * @return the number of markers deleted */ protected int doActionOnContainer(IContainer container) { try { container.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (CoreException e) { PydevPlugin.log(e); } try{ container.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); } catch (CoreException e) { PydevPlugin.log(e); } return -1; } @Override protected void afterRun(int deleted) { } @Override protected boolean confirmRun() { return MessageDialog.openConfirm(null, "Confirm deletion", "Are you sure that you want to recursively remove all the markers from the selected folder(s)?"); } } --- NEW FILE: PyContainerAction.java --- package org.python.pydev.ui.actions.container; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IWorkbenchPart; import org.python.pydev.plugin.PydevPlugin; /** * Abstract class for actions that'll act upon the selected containers. * * @author Fabio */ public abstract class PyContainerAction { /** * List with the containers the user selected */ protected List<IContainer> selectedContainers; public void setActivePart(IAction action, IWorkbenchPart targetPart) { //empty } /** * When the selection changes, we've to keep the selected containers... */ @SuppressWarnings("unchecked") public void selectionChanged(IAction action, ISelection selection) { if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) { selectedContainers = null; return; } IStructuredSelection selections = (IStructuredSelection) selection; ArrayList<IContainer> containers = new ArrayList<IContainer>(); for(Iterator<Object> it = selections.iterator(); it.hasNext();){ Object o = it.next(); if(o instanceof IContainer){ containers.add((IContainer) o); } } this.selectedContainers = containers; } /** * Act on the selection to do the needed action (will confirm and make a refresh before executing) */ public void run(IAction action) { //should not happen if(selectedContainers == null){ return; } if (!confirmRun()){ return; } int nDeleted = 0; IProgressMonitor nullProgressMonitor = new NullProgressMonitor(); for (Iterator<IContainer> iter = this.selectedContainers.iterator(); iter.hasNext();) { IContainer next = iter.next(); //as files are generated externally, if we don't refresh, it's very likely that we won't delete a bunch of files. try { next.refreshLocal(IResource.DEPTH_INFINITE, nullProgressMonitor); } catch (Exception e) { PydevPlugin.log(e); } nDeleted += this.doActionOnContainer(next); } afterRun(nDeleted); } /** * @return true if the action should be run and false otherwise */ protected abstract boolean confirmRun() ; /** * Hook for clients to implement after the run is done (useful to show message) * * @param resourcesAffected the number of resources that've been affected. */ protected abstract void afterRun(int resourcesAffected); /** * Executes the action on the container passed * * @param next the container where the action should be executed * @return the number of resources affected in the action */ protected abstract int doActionOnContainer(IContainer next); } |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036 Modified Files: Changes.txt plugin.xml Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.417 retrieving revision 1.418 diff -C2 -d -r1.417 -r1.418 *** Changes.txt 28 Sep 2008 12:45:46 -0000 1.417 --- Changes.txt 3 Oct 2008 00:43:54 -0000 1.418 *************** *** 3,8 **** Pydev Extensions <ul> ! <li><strong>Code-analysis</strong>: only done when the file has really changed</li> ! <li><strong>Code-analysis</strong>: only on active editor</li> </ul> --- 3,8 ---- Pydev Extensions <ul> ! <li><strong>Code-analysis</strong>: Option to analyze only active editor</li> ! <li><strong>Code-analysis</strong>: works on case where imported module has same name of builtin.</li> </ul> *************** *** 10,20 **** 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> --- 10,23 ---- Pydev <ul> ! <li><strong>Debugger</strong>: Pythonpath is the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> ! <li><strong>Debugger</strong>: Choices for paths not found are persisted</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>Code-completion</strong>: Works on case where imported module has same name of builtin</li> ! <li><strong>Editor</strong>: Cursor settings no longer overridden</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 analyze only active editor</li> ! <li><strong>getpass.getpass</strong>: No longer halts when run from pydev (but will show the password being written)</li> ! <li><strong>Remove error markers</strong>: Context menu in folders to remove error markers created</li> </ul> Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.210 retrieving revision 1.211 diff -C2 -d -r1.210 -r1.211 *** plugin.xml 28 Sep 2008 12:45:46 -0000 1.210 --- plugin.xml 3 Oct 2008 00:43:54 -0000 1.211 *************** *** 115,118 **** --- 115,134 ---- </objectContribution> + <!-- remove errors --> + <objectContribution + adaptable="true" + id="org.python.pydev.ui.actions.container.pyDeleteErrors" + objectClass="org.eclipse.core.resources.IContainer"> + <menu id="org.python.pydev.ui.actions.menu" label="Pydev"/> + <action + class="org.python.pydev.ui.actions.container.PyDeleteErrors" + enablesFor="+" + id="org.python.pydev.ui.actions.container.pyDeleteErrors" + label="Remove error markers" + menubarPath="org.python.pydev.ui.actions.menu/pydev" + tooltip="Remove error markers"> + </action> + </objectContribution> + <!-- remove nature --> *************** *** 173,176 **** --- 189,198 ---- </page> <page + name="Logging" + category="org.python.pydev.prefs" + class="org.python.pydev.logging.PyLoggingPreferencesPage" + id="org.python.pydev.logging.pyLoggingPreferencesPage"> + </page> + <page name="Typing" category="org.python.pydev.prefs" |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:10
|
Update of /cvsroot/pydev/org.python.pydev/tests/pysrc/extendable/help In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/tests/pysrc/extendable/help Added Files: __init__.py Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) --- NEW FILE: __init__.py --- #note: module name MUST be help about = 'test' |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:05
|
Update of /cvsroot/pydev/org.python.pydev/PySrc/pydev_sitecustomize In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/PySrc/pydev_sitecustomize Modified Files: sitecustomize.py Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: sitecustomize.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/pydev_sitecustomize/sitecustomize.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sitecustomize.py 29 Jun 2008 23:11:22 -0000 1.3 --- sitecustomize.py 3 Oct 2008 00:43:55 -0000 1.4 *************** *** 6,10 **** - change raw_input() and input() to also remove any trailing \r ''' - DEBUG = 0 #0 or 1 because of jython import os --- 6,9 ---- *************** *** 129,133 **** return ret raw_input.__doc__ = original_raw_input.__doc__ ! def input(prompt=''): #input must also be rebinded for using the new raw_input defined --- 128,132 ---- return ret raw_input.__doc__ = original_raw_input.__doc__ ! def input(prompt=''): #input must also be rebinded for using the new raw_input defined *************** *** 143,144 **** --- 142,158 ---- import traceback;traceback.print_exc() #@Reimport + + try: + #The original getpass doesn't work from the eclipse console, so, let's put a replacement + #here (note that it'll not go into echo mode in the console, so, what' the user writes + #will actually be seen) + import getpass + def pydev_getpass(msg='Password: '): + return raw_input(msg) + + getpass.getpass = pydev_getpass + except: + #Don't report errors at this stage + if DEBUG: + import traceback;traceback.print_exc() #@Reimport + |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:05
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src/org/python/pydev/logging Added Files: PyLoggingPreferencesPage.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) --- NEW FILE: PyLoggingPreferencesPage.java --- package org.python.pydev.logging; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.editor.codecompletion.PyCodeCompletion; import org.python.pydev.plugin.DebugSettings; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; /** * Preferences page for logging -- gives the option to enable logging on some specific feature * and show it in the console. * * @author Fabio */ public class PyLoggingPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{ public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; public static final String DEBUG_ANALYSIS_REQUESTS = "DEBUG_ANALYSIS_REQUESTS"; public static final boolean DEFAULT_DEBUG_ANALYSIS_REQUESTS = false; public PyLoggingPreferencesPage() { super(GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); } protected void createFieldEditors() { Composite p = getFieldEditorParent(); addField(new BooleanFieldEditor( DEBUG_CODE_COMPLETION, "Enable logging for code completion?", p)); addField(new BooleanFieldEditor( DEBUG_ANALYSIS_REQUESTS, "Enable logging for analysis requests?", p)); } public void init(IWorkbench workbench) { } public static boolean isToDebugCodeCompletion() { if(PydevPlugin.getDefault() == null){//testing return false; } return PydevPrefs.getPreferences().getBoolean(DEBUG_CODE_COMPLETION); } public static boolean isToDebugAnalysisRequests() { if(PydevPlugin.getDefault() == null){//testing return false; } return PydevPrefs.getPreferences().getBoolean(DEBUG_ANALYSIS_REQUESTS); } @Override public boolean performOk() { boolean ret = super.performOk(); PyCodeCompletion.DEBUG_CODE_COMPLETION = isToDebugCodeCompletion(); DebugSettings.DEBUG_ANALYSIS_REQUESTS = isToDebugAnalysisRequests(); return ret; } } |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:44:04
|
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/modules In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src_completions/org/python/pydev/editor/codecompletion/revisited/modules Modified Files: AbstractModule.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) 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.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractModule.java 28 Sep 2008 12:45:40 -0000 1.16 --- AbstractModule.java 3 Oct 2008 00:43:54 -0000 1.17 *************** *** 100,104 **** public boolean isInGlobalTokens(String tok, IPythonNature nature, boolean searchSameLevelMods, ICompletionCache completionCache) throws CompletionRecursionException{ ! return isInGlobalTokens(tok, nature, true, false, completionCache) != IModule.NOT_FOUND; } --- 100,104 ---- public boolean isInGlobalTokens(String tok, IPythonNature nature, boolean searchSameLevelMods, ICompletionCache completionCache) throws CompletionRecursionException{ ! return isInGlobalTokens(tok, nature, searchSameLevelMods, false, completionCache) != IModule.NOT_FOUND; } *************** *** 165,169 **** state.setActivationToken (activationToken); ! IToken[] globalTokens = astManager.getCompletionsForModule(this, state, searchSameLevelMods); for (IToken token : globalTokens) { --- 165,170 ---- state.setActivationToken (activationToken); ! //we don't want to gather builtins in this case. ! state.setBuiltinsGotten(true); IToken[] globalTokens = astManager.getCompletionsForModule(this, state, searchSameLevelMods); for (IToken token : globalTokens) { |
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10036/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java PyCodeCompletionInitializer.java PyCodeCompletionPreferencesPage.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: PyCodeCompletionInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionInitializer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCompletionInitializer.java 28 Sep 2008 12:45:42 -0000 1.2 --- PyCodeCompletionInitializer.java 3 Oct 2008 00:43:54 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- import org.eclipse.core.runtime.preferences.DefaultScope; import org.osgi.service.prefs.Preferences; + import org.python.pydev.logging.PyLoggingPreferencesPage; import org.python.pydev.plugin.PydevPlugin; *************** *** 22,27 **** node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); - node.putBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); } --- 23,30 ---- node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); + + node.putBoolean(PyLoggingPreferencesPage.DEBUG_CODE_COMPLETION, PyLoggingPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); + node.putBoolean(PyLoggingPreferencesPage.DEBUG_ANALYSIS_REQUESTS, PyLoggingPreferencesPage.DEFAULT_DEBUG_ANALYSIS_REQUESTS); } Index: PyCodeCompletionPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionPreferencesPage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyCodeCompletionPreferencesPage.java 28 Sep 2008 12:45:42 -0000 1.3 --- PyCodeCompletionPreferencesPage.java 3 Oct 2008 00:43:54 -0000 1.4 *************** *** 45,51 **** public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; - public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; - public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; - public static final String ARGUMENTS_DEEP_ANALYSIS_N_CHARS = "DEEP_ANALYSIS_N_CHARS"; public static final int DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS = 1; --- 45,48 ---- *************** *** 100,117 **** AUTOCOMPLETE_ON_ALL_ASCII_CHARS, "Autocomplete on all letter chars and '_'?", p)); - - addField(new BooleanFieldEditor( - DEBUG_CODE_COMPLETION, "Debug code completion?", p)); - - } - - @Override - public boolean performOk() { - boolean ret = super.performOk(); - PyCodeCompletion.DEBUG_CODE_COMPLETION = isToDebugCodeCompletion(); - return ret; } - /* * (non-Javadoc) --- 97,102 ---- *************** *** 151,161 **** } - public static boolean isToDebugCodeCompletion() { - if(PydevPlugin.getDefault() == null){//testing - return false; - } - return PydevPrefs.getPreferences().getBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION); - } - public static int getAutocompleteDelay() { return PydevPrefs.getPreferences().getInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY); --- 136,139 ---- Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyCodeCompletion.java 28 Sep 2008 12:45:42 -0000 1.8 --- PyCodeCompletion.java 3 Oct 2008 00:43:54 -0000 1.9 *************** *** 43,46 **** --- 43,47 ---- import org.python.pydev.editor.codecompletion.revisited.visitors.FindScopeVisitor; import org.python.pydev.editor.codecompletion.shell.AbstractShell; + import org.python.pydev.logging.PyLoggingPreferencesPage; import org.python.pydev.parser.PyParser; import org.python.pydev.parser.jython.SimpleNode; *************** *** 68,72 **** * It is kept updated from the Preferences Page */ ! public static volatile boolean DEBUG_CODE_COMPLETION = PyCodeCompletionPreferencesPage.isToDebugCodeCompletion(); /** --- 69,73 ---- * It is kept updated from the Preferences Page */ ! public static volatile boolean DEBUG_CODE_COMPLETION = PyLoggingPreferencesPage.isToDebugCodeCompletion(); /** |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:43:51
|
Update of /cvsroot/pydev/org.python.pydev.core/META-INF In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10014/META-INF Modified Files: MANIFEST.MF Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: MANIFEST.MF =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/META-INF/MANIFEST.MF,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MANIFEST.MF 17 Jun 2007 12:21:26 -0000 1.20 --- MANIFEST.MF 3 Oct 2008 00:43:38 -0000 1.21 *************** *** 16,20 **** org.eclipse.core.resources, org.eclipse.ui.workbench.texteditor, ! org.eclipse.core.filebuffers Eclipse-LazyStart: true Export-Package: org.apache.commons.codec, --- 16,21 ---- org.eclipse.core.resources, org.eclipse.ui.workbench.texteditor, ! org.eclipse.core.filebuffers, ! org.eclipse.ui.console Eclipse-LazyStart: true Export-Package: org.apache.commons.codec, |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:43:50
|
Update of /cvsroot/pydev/org.python.pydev.site In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10027 Modified Files: site.xml Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: site.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.site/site.xml,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** site.xml 27 Sep 2008 19:58:08 -0000 1.76 --- site.xml 3 Oct 2008 00:43:43 -0000 1.77 *************** *** 21,24 **** --- 21,30 ---- + <feature url="features/org.python.pydev.feature_1.3.22.jar" id="org.python.pydev.feature" version="1.3.22"> + <category name="Pydev"/> + </feature> + + + <feature url="features/org.python.pydev.feature_1.3.20.jar" id="org.python.pydev.feature" version="1.3.20"> <category name="Pydev"/> |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:43:43
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/log In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10014/src/org/python/pydev/core/log Modified Files: Log.java Log Message: Synching with aptana svn repo for release 1.3.22 (see http://pydev.sourceforge.net/developers.html) Index: Log.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/log/Log.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Log.java 27 Sep 2008 19:57:34 -0000 1.10 --- Log.java 3 Oct 2008 00:43:38 -0000 1.11 *************** *** 7,16 **** import java.io.PrintStream; - import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.python.pydev.core.CorePlugin; import org.python.pydev.core.FullRepIterable; - import org.python.pydev.core.REF; --- 7,19 ---- import java.io.PrintStream; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; + import org.eclipse.jface.text.IDocument; + import org.eclipse.swt.widgets.Display; + import org.eclipse.ui.console.ConsolePlugin; + import org.eclipse.ui.console.IConsole; + import org.eclipse.ui.console.MessageConsole; import org.python.pydev.core.CorePlugin; import org.python.pydev.core.FullRepIterable; *************** *** 20,24 **** public class Log { ! /** * @param errorLevel IStatus.[OK|INFO|WARNING|ERROR] --- 23,31 ---- public class Log { ! /** ! * Console used to log contents ! */ ! private static MessageConsole fConsole; ! /** * @param errorLevel IStatus.[OK|INFO|WARNING|ERROR] *************** *** 47,51 **** ! //------------ Log that writes to .metadata/.plugins/org.python.pydev.core/PydevLog.log private final static Object lock = new Object(); --- 54,58 ---- ! //------------ Log that writes to a new console private final static Object lock = new Object(); *************** *** 69,90 **** } ! private synchronized static void toLogFile(String buffer) { ! synchronized(lock){ ! try{ ! CorePlugin default1 = CorePlugin.getDefault(); ! if(default1 == null){ ! //in tests ! System.out.println(buffer); ! return; } ! IPath stateLocation = default1.getStateLocation().append("PydevLog.log"); ! String file = stateLocation.toOSString(); ! REF.appendStrToFile(buffer+"\r\n", file); ! }catch(Throwable e){ ! log(e); //default logging facility } } } public static void toLogFile(Exception e) { String msg = getExceptionStr(e); --- 76,130 ---- } ! private synchronized static void toLogFile(final String buffer) { ! final Runnable r = new Runnable(){ ! ! public void run() { ! synchronized(lock){ ! try{ ! CorePlugin default1 = CorePlugin.getDefault(); ! if(default1 == null){ ! //in tests ! System.out.println(buffer); ! return; ! } ! ! //also print to console ! System.out.println(buffer); ! MessageConsole c = getConsole(); ! IDocument doc = c.getDocument(); ! doc.replace(doc.getLength(), 0, buffer.toString()+"\r\n"); ! ! // IPath stateLocation = default1.getStateLocation().append("PydevLog.log"); ! // String file = stateLocation.toOSString(); ! // REF.appendStrToFile(buffer+"\r\n", file); ! }catch(Throwable e){ ! log(e); //default logging facility ! } } ! ! } ! }; ! ! Display current = Display.getCurrent(); ! if(current != null && current.getThread() == Thread.currentThread ()){ ! //ok, just run it ! r.run(); ! }else{ ! if(current == null){ ! current = Display.getDefault(); ! current.asyncExec(r); } } } + + private static MessageConsole getConsole(){ + if (fConsole == null){ + fConsole = new MessageConsole("Pydev Logging", null); + ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{fConsole}); + } + return fConsole; + } + public static void toLogFile(Exception e) { String msg = getExceptionStr(e); |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:43:37
|
Update of /cvsroot/pydev/org.python.pydev/tests/pysrc/extendable/help In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9995/tests/pysrc/extendable/help Log Message: Directory /cvsroot/pydev/org.python.pydev/tests/pysrc/extendable/help added to the repository |
From: Fabio Z. <fa...@us...> - 2008-10-03 00:43:37
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/logging In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9995/src/org/python/pydev/logging Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/logging added to the repository |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:50:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/plugin Modified Files: PydevPlugin.java AbstractPydevPrefs.java StatusInfo.java PydevPrefs.java ColorEditor.java PydevPrefsInitializer.java PyunitPrefsPage.java OverlayPreferenceStore.java Added Files: DebugSettings.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: OverlayPreferenceStore.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/OverlayPreferenceStore.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OverlayPreferenceStore.java 20 Oct 2007 19:30:36 -0000 1.3 --- OverlayPreferenceStore.java 28 Sep 2008 12:45:44 -0000 1.4 *************** *** 25,488 **** */ public class OverlayPreferenceStore implements IPreferenceStore { ! ! ! public static final class TypeDescriptor { ! private TypeDescriptor() { ! } ! } ! ! public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); ! public static final TypeDescriptor DOUBLE= new TypeDescriptor(); ! public static final TypeDescriptor FLOAT= new TypeDescriptor(); ! public static final TypeDescriptor INT= new TypeDescriptor(); ! public static final TypeDescriptor LONG= new TypeDescriptor(); ! public static final TypeDescriptor STRING= new TypeDescriptor(); ! ! public static class OverlayKey { ! ! TypeDescriptor fDescriptor; ! String fKey; ! ! public OverlayKey(TypeDescriptor descriptor, String key) { ! fDescriptor= descriptor; ! fKey= key; ! } ! } ! ! private class PropertyListener implements IPropertyChangeListener { ! ! /* ! * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) ! */ ! public void propertyChange(PropertyChangeEvent event) { ! OverlayKey key= findOverlayKey(event.getProperty()); ! if (key != null) ! propagateProperty(fParent, key, fStore); ! } ! } ! ! ! private IPreferenceStore fParent; ! private IPreferenceStore fStore; ! private OverlayKey[] fOverlayKeys; ! ! private PropertyListener fPropertyListener; ! private boolean fLoaded; ! ! ! public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { ! fParent= parent; ! fOverlayKeys= overlayKeys; ! fStore= new PreferenceStore(); ! } ! ! private OverlayKey findOverlayKey(String key) { ! for (int i= 0; i < fOverlayKeys.length; i++) { ! if (fOverlayKeys[i].fKey.equals(key)) ! return fOverlayKeys[i]; ! } ! return null; ! } ! ! private boolean covers(String key) { ! return (findOverlayKey(key) != null); ! } ! ! private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { ! ! if (orgin.isDefault(key.fKey)) { ! if (!target.isDefault(key.fKey)) ! target.setToDefault(key.fKey); ! return; ! } ! ! TypeDescriptor d= key.fDescriptor; ! if (BOOLEAN == d) { ! ! boolean originValue= orgin.getBoolean(key.fKey); ! boolean targetValue= target.getBoolean(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (DOUBLE == d) { ! ! double originValue= orgin.getDouble(key.fKey); ! double targetValue= target.getDouble(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (FLOAT == d) { ! ! float originValue= orgin.getFloat(key.fKey); ! float targetValue= target.getFloat(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (INT == d) { ! int originValue= orgin.getInt(key.fKey); ! int targetValue= target.getInt(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! } else if (LONG == d) { ! long originValue= orgin.getLong(key.fKey); ! long targetValue= target.getLong(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! } else if (STRING == d) { ! String originValue= orgin.getString(key.fKey); ! String targetValue= target.getString(key.fKey); ! if (targetValue != null && originValue != null && !targetValue.equals(originValue)) ! target.setValue(key.fKey, originValue); ! } ! } ! ! public void propagate() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! propagateProperty(fStore, fOverlayKeys[i], fParent); ! } ! ! private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { ! TypeDescriptor d= key.fDescriptor; ! if (BOOLEAN == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, true); ! target.setValue(key.fKey, orgin.getBoolean(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); ! ! } else if (DOUBLE == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1.0D); ! target.setValue(key.fKey, orgin.getDouble(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); ! ! } else if (FLOAT == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1.0F); ! target.setValue(key.fKey, orgin.getFloat(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); ! ! } else if (INT == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1); ! target.setValue(key.fKey, orgin.getInt(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); ! ! } else if (LONG == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1L); ! target.setValue(key.fKey, orgin.getLong(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); ! ! } else if (STRING == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, "1"); //$NON-NLS-1$ ! target.setValue(key.fKey, orgin.getString(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); ! ! } ! } ! ! public void load() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! loadProperty(fParent, fOverlayKeys[i], fStore, true); ! ! fLoaded= true; ! ! } ! ! public void loadDefaults() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! setToDefault(fOverlayKeys[i].fKey); ! } ! ! public void start() { ! if (fPropertyListener == null) { ! fPropertyListener= new PropertyListener(); ! fParent.addPropertyChangeListener(fPropertyListener); ! } ! } ! ! public void stop() { ! if (fPropertyListener != null) { ! fParent.removePropertyChangeListener(fPropertyListener); ! fPropertyListener= null; ! } ! } ! ! /* ! * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) ! */ ! public void addPropertyChangeListener(IPropertyChangeListener listener) { ! fStore.addPropertyChangeListener(listener); ! } ! ! /* ! * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) ! */ ! public void removePropertyChangeListener(IPropertyChangeListener listener) { ! fStore.removePropertyChangeListener(listener); ! } ! ! /* ! * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) ! */ ! public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { ! fStore.firePropertyChangeEvent(name, oldValue, newValue); ! } ! /* ! * @see IPreferenceStore#contains(String) ! */ ! public boolean contains(String name) { ! return fStore.contains(name); ! } ! ! /* ! * @see IPreferenceStore#getBoolean(String) ! */ ! public boolean getBoolean(String name) { ! return fStore.getBoolean(name); ! } ! /* ! * @see IPreferenceStore#getDefaultBoolean(String) ! */ ! public boolean getDefaultBoolean(String name) { ! return fStore.getDefaultBoolean(name); ! } ! /* ! * @see IPreferenceStore#getDefaultDouble(String) ! */ ! public double getDefaultDouble(String name) { ! return fStore.getDefaultDouble(name); ! } ! /* ! * @see IPreferenceStore#getDefaultFloat(String) ! */ ! public float getDefaultFloat(String name) { ! return fStore.getDefaultFloat(name); ! } ! /* ! * @see IPreferenceStore#getDefaultInt(String) ! */ ! public int getDefaultInt(String name) { ! return fStore.getDefaultInt(name); ! } ! /* ! * @see IPreferenceStore#getDefaultLong(String) ! */ ! public long getDefaultLong(String name) { ! return fStore.getDefaultLong(name); ! } ! /* ! * @see IPreferenceStore#getDefaultString(String) ! */ ! public String getDefaultString(String name) { ! return fStore.getDefaultString(name); ! } ! /* ! * @see IPreferenceStore#getDouble(String) ! */ ! public double getDouble(String name) { ! return fStore.getDouble(name); ! } ! /* ! * @see IPreferenceStore#getFloat(String) ! */ ! public float getFloat(String name) { ! return fStore.getFloat(name); ! } ! /* ! * @see IPreferenceStore#getInt(String) ! */ ! public int getInt(String name) { ! return fStore.getInt(name); ! } ! /* ! * @see IPreferenceStore#getLong(String) ! */ ! public long getLong(String name) { ! return fStore.getLong(name); ! } ! /* ! * @see IPreferenceStore#getString(String) ! */ ! public String getString(String name) { ! return fStore.getString(name); ! } ! /* ! * @see IPreferenceStore#isDefault(String) ! */ ! public boolean isDefault(String name) { ! return fStore.isDefault(name); ! } ! /* ! * @see IPreferenceStore#needsSaving() ! */ ! public boolean needsSaving() { ! return fStore.needsSaving(); ! } ! /* ! * @see IPreferenceStore#putValue(String, String) ! */ ! public void putValue(String name, String value) { ! if (covers(name)) ! fStore.putValue(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, double) ! */ ! public void setDefault(String name, double value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, float) ! */ ! public void setDefault(String name, float value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, int) ! */ ! public void setDefault(String name, int value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, long) ! */ ! public void setDefault(String name, long value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, String) ! */ ! public void setDefault(String name, String value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, boolean) ! */ ! public void setDefault(String name, boolean value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setToDefault(String) ! */ ! public void setToDefault(String name) { ! fStore.setToDefault(name); ! } ! /* ! * @see IPreferenceStore#setValue(String, double) ! */ ! public void setValue(String name, double value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, float) ! */ ! public void setValue(String name, float value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, int) ! */ ! public void setValue(String name, int value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, long) ! */ ! public void setValue(String name, long value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, String) ! */ ! public void setValue(String name, String value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, boolean) ! */ ! public void setValue(String name, boolean value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /** ! * The keys to add to the list of overlay keys. ! * <p> ! * Note: This method must be called before {@link #load()} is called. ! * </p> ! * ! * @param keys ! * @since 3.0 ! */ ! public void addKeys(OverlayKey[] keys) { ! Assert.isTrue(!fLoaded); ! Assert.isNotNull(keys); ! ! int overlayKeysLength= fOverlayKeys.length; ! OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength]; ! for (int i= 0, length= overlayKeysLength; i < length; i++) ! result[i]= fOverlayKeys[i]; ! ! for (int i= 0, length= keys.length; i < length; i++) ! result[overlayKeysLength + i]= keys[i]; ! ! fOverlayKeys= result; ! ! if (fLoaded) ! load(); ! } } --- 25,488 ---- */ public class OverlayPreferenceStore implements IPreferenceStore { ! ! ! public static final class TypeDescriptor { ! private TypeDescriptor() { ! } ! } ! ! public static final TypeDescriptor BOOLEAN= new TypeDescriptor(); ! public static final TypeDescriptor DOUBLE= new TypeDescriptor(); ! public static final TypeDescriptor FLOAT= new TypeDescriptor(); ! public static final TypeDescriptor INT= new TypeDescriptor(); ! public static final TypeDescriptor LONG= new TypeDescriptor(); ! public static final TypeDescriptor STRING= new TypeDescriptor(); ! ! public static class OverlayKey { ! ! TypeDescriptor fDescriptor; ! String fKey; ! ! public OverlayKey(TypeDescriptor descriptor, String key) { ! fDescriptor= descriptor; ! fKey= key; ! } ! } ! ! private class PropertyListener implements IPropertyChangeListener { ! ! /* ! * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) ! */ ! public void propertyChange(PropertyChangeEvent event) { ! OverlayKey key= findOverlayKey(event.getProperty()); ! if (key != null) ! propagateProperty(fParent, key, fStore); ! } ! } ! ! ! private IPreferenceStore fParent; ! private IPreferenceStore fStore; ! private OverlayKey[] fOverlayKeys; ! ! private PropertyListener fPropertyListener; ! private boolean fLoaded; ! ! ! public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { ! fParent= parent; ! fOverlayKeys= overlayKeys; ! fStore= new PreferenceStore(); ! } ! ! private OverlayKey findOverlayKey(String key) { ! for (int i= 0; i < fOverlayKeys.length; i++) { ! if (fOverlayKeys[i].fKey.equals(key)) ! return fOverlayKeys[i]; ! } ! return null; ! } ! ! private boolean covers(String key) { ! return (findOverlayKey(key) != null); ! } ! ! private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { ! ! if (orgin.isDefault(key.fKey)) { ! if (!target.isDefault(key.fKey)) ! target.setToDefault(key.fKey); ! return; ! } ! ! TypeDescriptor d= key.fDescriptor; ! if (BOOLEAN == d) { ! ! boolean originValue= orgin.getBoolean(key.fKey); ! boolean targetValue= target.getBoolean(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (DOUBLE == d) { ! ! double originValue= orgin.getDouble(key.fKey); ! double targetValue= target.getDouble(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (FLOAT == d) { ! ! float originValue= orgin.getFloat(key.fKey); ! float targetValue= target.getFloat(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! ! } else if (INT == d) { ! int originValue= orgin.getInt(key.fKey); ! int targetValue= target.getInt(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! } else if (LONG == d) { ! long originValue= orgin.getLong(key.fKey); ! long targetValue= target.getLong(key.fKey); ! if (targetValue != originValue) ! target.setValue(key.fKey, originValue); ! } else if (STRING == d) { ! String originValue= orgin.getString(key.fKey); ! String targetValue= target.getString(key.fKey); ! if (targetValue != null && originValue != null && !targetValue.equals(originValue)) ! target.setValue(key.fKey, originValue); ! } ! } ! ! public void propagate() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! propagateProperty(fStore, fOverlayKeys[i], fParent); ! } ! ! private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { ! TypeDescriptor d= key.fDescriptor; ! if (BOOLEAN == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, true); ! target.setValue(key.fKey, orgin.getBoolean(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); ! ! } else if (DOUBLE == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1.0D); ! target.setValue(key.fKey, orgin.getDouble(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); ! ! } else if (FLOAT == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1.0F); ! target.setValue(key.fKey, orgin.getFloat(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); ! ! } else if (INT == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1); ! target.setValue(key.fKey, orgin.getInt(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); ! ! } else if (LONG == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, 1L); ! target.setValue(key.fKey, orgin.getLong(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); ! ! } else if (STRING == d) { ! ! if (forceInitialization) ! target.setValue(key.fKey, "1"); //$NON-NLS-1$ ! target.setValue(key.fKey, orgin.getString(key.fKey)); ! target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); ! ! } ! } ! ! public void load() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! loadProperty(fParent, fOverlayKeys[i], fStore, true); ! ! fLoaded= true; ! ! } ! ! public void loadDefaults() { ! for (int i= 0; i < fOverlayKeys.length; i++) ! setToDefault(fOverlayKeys[i].fKey); ! } ! ! public void start() { ! if (fPropertyListener == null) { ! fPropertyListener= new PropertyListener(); ! fParent.addPropertyChangeListener(fPropertyListener); ! } ! } ! ! public void stop() { ! if (fPropertyListener != null) { ! fParent.removePropertyChangeListener(fPropertyListener); ! fPropertyListener= null; ! } ! } ! ! /* ! * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) ! */ ! public void addPropertyChangeListener(IPropertyChangeListener listener) { ! fStore.addPropertyChangeListener(listener); ! } ! ! /* ! * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) ! */ ! public void removePropertyChangeListener(IPropertyChangeListener listener) { ! fStore.removePropertyChangeListener(listener); ! } ! ! /* ! * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) ! */ ! public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { ! fStore.firePropertyChangeEvent(name, oldValue, newValue); ! } ! /* ! * @see IPreferenceStore#contains(String) ! */ ! public boolean contains(String name) { ! return fStore.contains(name); ! } ! ! /* ! * @see IPreferenceStore#getBoolean(String) ! */ ! public boolean getBoolean(String name) { ! return fStore.getBoolean(name); ! } ! /* ! * @see IPreferenceStore#getDefaultBoolean(String) ! */ ! public boolean getDefaultBoolean(String name) { ! return fStore.getDefaultBoolean(name); ! } ! /* ! * @see IPreferenceStore#getDefaultDouble(String) ! */ ! public double getDefaultDouble(String name) { ! return fStore.getDefaultDouble(name); ! } ! /* ! * @see IPreferenceStore#getDefaultFloat(String) ! */ ! public float getDefaultFloat(String name) { ! return fStore.getDefaultFloat(name); ! } ! /* ! * @see IPreferenceStore#getDefaultInt(String) ! */ ! public int getDefaultInt(String name) { ! return fStore.getDefaultInt(name); ! } ! /* ! * @see IPreferenceStore#getDefaultLong(String) ! */ ! public long getDefaultLong(String name) { ! return fStore.getDefaultLong(name); ! } ! /* ! * @see IPreferenceStore#getDefaultString(String) ! */ ! public String getDefaultString(String name) { ! return fStore.getDefaultString(name); ! } ! /* ! * @see IPreferenceStore#getDouble(String) ! */ ! public double getDouble(String name) { ! return fStore.getDouble(name); ! } ! /* ! * @see IPreferenceStore#getFloat(String) ! */ ! public float getFloat(String name) { ! return fStore.getFloat(name); ! } ! /* ! * @see IPreferenceStore#getInt(String) ! */ ! public int getInt(String name) { ! return fStore.getInt(name); ! } ! /* ! * @see IPreferenceStore#getLong(String) ! */ ! public long getLong(String name) { ! return fStore.getLong(name); ! } ! /* ! * @see IPreferenceStore#getString(String) ! */ ! public String getString(String name) { ! return fStore.getString(name); ! } ! /* ! * @see IPreferenceStore#isDefault(String) ! */ ! public boolean isDefault(String name) { ! return fStore.isDefault(name); ! } ! /* ! * @see IPreferenceStore#needsSaving() ! */ ! public boolean needsSaving() { ! return fStore.needsSaving(); ! } ! /* ! * @see IPreferenceStore#putValue(String, String) ! */ ! public void putValue(String name, String value) { ! if (covers(name)) ! fStore.putValue(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, double) ! */ ! public void setDefault(String name, double value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, float) ! */ ! public void setDefault(String name, float value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, int) ! */ ! public void setDefault(String name, int value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, long) ! */ ! public void setDefault(String name, long value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, String) ! */ ! public void setDefault(String name, String value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setDefault(String, boolean) ! */ ! public void setDefault(String name, boolean value) { ! if (covers(name)) ! fStore.setDefault(name, value); ! } ! /* ! * @see IPreferenceStore#setToDefault(String) ! */ ! public void setToDefault(String name) { ! fStore.setToDefault(name); ! } ! /* ! * @see IPreferenceStore#setValue(String, double) ! */ ! public void setValue(String name, double value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, float) ! */ ! public void setValue(String name, float value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, int) ! */ ! public void setValue(String name, int value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, long) ! */ ! public void setValue(String name, long value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, String) ! */ ! public void setValue(String name, String value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /* ! * @see IPreferenceStore#setValue(String, boolean) ! */ ! public void setValue(String name, boolean value) { ! if (covers(name)) ! fStore.setValue(name, value); ! } ! /** ! * The keys to add to the list of overlay keys. ! * <p> ! * Note: This method must be called before {@link #load()} is called. ! * </p> ! * ! * @param keys ! * @since 3.0 ! */ ! public void addKeys(OverlayKey[] keys) { ! Assert.isTrue(!fLoaded); ! Assert.isNotNull(keys); ! ! int overlayKeysLength= fOverlayKeys.length; ! OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength]; ! for (int i= 0, length= overlayKeysLength; i < length; i++) ! result[i]= fOverlayKeys[i]; ! ! for (int i= 0, length= keys.length; i < length; i++) ! result[overlayKeysLength + i]= keys[i]; ! ! fOverlayKeys= result; ! ! if (fLoaded) ! load(); ! } } Index: StatusInfo.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/StatusInfo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StatusInfo.java 20 Oct 2007 19:30:36 -0000 1.2 --- StatusInfo.java 28 Sep 2008 12:45:44 -0000 1.3 *************** *** 24,176 **** */ public class StatusInfo implements IStatus { ! ! public static final IStatus OK_STATUS= new StatusInfo(); ! ! private String fStatusMessage; ! private int fSeverity; ! ! /** ! * Creates a status set to OK (no message) ! */ ! public StatusInfo() { ! this(OK, null); ! } ! /** ! * Creates a status . ! * @param severity The status severity: ERROR, WARNING, INFO and OK. ! * @param message The message of the status. Applies only for ERROR, ! * WARNING and INFO. ! */ ! public StatusInfo(int severity, String message) { ! fStatusMessage= message; ! fSeverity= severity; ! } ! ! /** ! * Returns if the status' severity is OK. ! */ ! public boolean isOK() { ! return fSeverity == IStatus.OK; ! } ! /** ! * Returns if the status' severity is WARNING. ! */ ! public boolean isWarning() { ! return fSeverity == IStatus.WARNING; ! } ! /** ! * Returns if the status' severity is INFO. ! */ ! public boolean isInfo() { ! return fSeverity == IStatus.INFO; ! } ! /** ! * Returns if the status' severity is ERROR. ! */ ! public boolean isError() { ! return fSeverity == IStatus.ERROR; ! } ! ! /** ! * @see IStatus#getMessage ! */ ! public String getMessage() { ! return fStatusMessage; ! } ! ! /** ! * Sets the status to ERROR. ! * @param errorMessage The error message (can be empty, but not null) ! */ ! public void setError(String errorMessage) { ! Assert.isNotNull(errorMessage); ! fStatusMessage= errorMessage; ! fSeverity= IStatus.ERROR; ! } ! /** ! * Sets the status to WARNING. ! * @param warningMessage The warning message (can be empty, but not null) ! */ ! public void setWarning(String warningMessage) { ! Assert.isNotNull(warningMessage); ! fStatusMessage= warningMessage; ! fSeverity= IStatus.WARNING; ! } ! /** ! * Sets the status to INFO. ! * @param infoMessage The info message (can be empty, but not null) ! */ ! public void setInfo(String infoMessage) { ! Assert.isNotNull(infoMessage); ! fStatusMessage= infoMessage; ! fSeverity= IStatus.INFO; ! } ! /** ! * Sets the status to OK. ! */ ! public void setOK() { ! fStatusMessage= null; ! fSeverity= IStatus.OK; ! } ! ! /* ! * @see IStatus#matches(int) ! */ ! public boolean matches(int severityMask) { ! return (fSeverity & severityMask) != 0; ! } ! /** ! * Returns always <code>false</code>. ! * @see IStatus#isMultiStatus() ! */ ! public boolean isMultiStatus() { ! return false; ! } ! /* ! * @see IStatus#getSeverity() ! */ ! public int getSeverity() { ! return fSeverity; ! } ! /* ! * @see IStatus#getPlugin() ! */ ! public String getPlugin() { ! return PydevPlugin.getDefault().getBundle().getSymbolicName(); ! } ! /** ! * Returns always <code>null</code>. ! * @see IStatus#getException() ! */ ! public Throwable getException() { ! return null; ! } ! /** ! * Returns always the error severity. ! * @see IStatus#getCode() ! */ ! public int getCode() { ! return fSeverity; ! } ! /** ! * Returns always <code>null</code>. ! * @see IStatus#getChildren() ! */ ! public IStatus[] getChildren() { ! return new IStatus[0]; ! } } --- 24,176 ---- */ public class StatusInfo implements IStatus { ! ! public static final IStatus OK_STATUS= new StatusInfo(); ! ! private String fStatusMessage; ! private int fSeverity; ! ! /** ! * Creates a status set to OK (no message) ! */ ! public StatusInfo() { ! this(OK, null); ! } ! /** ! * Creates a status . ! * @param severity The status severity: ERROR, WARNING, INFO and OK. ! * @param message The message of the status. Applies only for ERROR, ! * WARNING and INFO. ! */ ! public StatusInfo(int severity, String message) { ! fStatusMessage= message; ! fSeverity= severity; ! } ! ! /** ! * Returns if the status' severity is OK. ! */ ! public boolean isOK() { ! return fSeverity == IStatus.OK; ! } ! /** ! * Returns if the status' severity is WARNING. ! */ ! public boolean isWarning() { ! return fSeverity == IStatus.WARNING; ! } ! /** ! * Returns if the status' severity is INFO. ! */ ! public boolean isInfo() { ! return fSeverity == IStatus.INFO; ! } ! /** ! * Returns if the status' severity is ERROR. ! */ ! public boolean isError() { ! return fSeverity == IStatus.ERROR; ! } ! ! /** ! * @see IStatus#getMessage ! */ ! public String getMessage() { ! return fStatusMessage; ! } ! ! /** ! * Sets the status to ERROR. ! * @param errorMessage The error message (can be empty, but not null) ! */ ! public void setError(String errorMessage) { ! Assert.isNotNull(errorMessage); ! fStatusMessage= errorMessage; ! fSeverity= IStatus.ERROR; ! } ! /** ! * Sets the status to WARNING. ! * @param warningMessage The warning message (can be empty, but not null) ! */ ! public void setWarning(String warningMessage) { ! Assert.isNotNull(warningMessage); ! fStatusMessage= warningMessage; ! fSeverity= IStatus.WARNING; ! } ! /** ! * Sets the status to INFO. ! * @param infoMessage The info message (can be empty, but not null) ! */ ! public void setInfo(String infoMessage) { ! Assert.isNotNull(infoMessage); ! fStatusMessage= infoMessage; ! fSeverity= IStatus.INFO; ! } ! /** ! * Sets the status to OK. ! */ ! public void setOK() { ! fStatusMessage= null; ! fSeverity= IStatus.OK; ! } ! ! /* ! * @see IStatus#matches(int) ! */ ! public boolean matches(int severityMask) { ! return (fSeverity & severityMask) != 0; ! } ! /** ! * Returns always <code>false</code>. ! * @see IStatus#isMultiStatus() ! */ ! public boolean isMultiStatus() { ! return false; ! } ! /* ! * @see IStatus#getSeverity() ! */ ! public int getSeverity() { ! return fSeverity; ! } ! /* ! * @see IStatus#getPlugin() ! */ ! public String getPlugin() { ! return PydevPlugin.getDefault().getBundle().getSymbolicName(); ! } ! /** ! * Returns always <code>null</code>. ! * @see IStatus#getException() ! */ ! public Throwable getException() { ! return null; ! } ! /** ! * Returns always the error severity. ! * @see IStatus#getCode() ! */ ! public int getCode() { ! return fSeverity; ! } ! /** ! * Returns always <code>null</code>. ! * @see IStatus#getChildren() ! */ ! public IStatus[] getChildren() { ! return new IStatus[0]; ! } } Index: ColorEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/ColorEditor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ColorEditor.java 21 Mar 2005 16:42:36 -0000 1.2 --- ColorEditor.java 28 Sep 2008 12:45:44 -0000 1.3 *************** *** 34,122 **** */ public class ColorEditor { ! ! private Point fExtent; ! private Image fImage; ! private RGB fColorValue; ! private Color fColor; ! private Button fButton; ! ! public ColorEditor(Composite parent) { ! ! fButton= new Button(parent, SWT.PUSH); ! fExtent= computeImageSize(parent); ! fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); ! ! GC gc= new GC(fImage); ! gc.setBackground(fButton.getBackground()); ! gc.fillRectangle(0, 0, fExtent.x, fExtent.y); ! gc.dispose(); ! ! fButton.setImage(fImage); ! fButton.addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent event) { ! ColorDialog colorDialog= new ColorDialog(fButton.getShell()); ! colorDialog.setRGB(fColorValue); ! RGB newColor = colorDialog.open(); ! if (newColor != null) { ! fColorValue= newColor; ! updateColorImage(); ! } ! } ! }); ! ! fButton.addDisposeListener(new DisposeListener() { ! public void widgetDisposed(DisposeEvent event) { ! if (fImage != null) { ! fImage.dispose(); ! fImage= null; ! } ! if (fColor != null) { ! fColor.dispose(); ! fColor= null; ! } ! } ! }); ! } ! ! public RGB getColorValue() { ! return fColorValue; ! } ! ! public void setColorValue(RGB rgb) { ! fColorValue= rgb; ! updateColorImage(); ! } ! ! public Button getButton() { ! return fButton; ! } ! ! protected void updateColorImage() { ! ! Display display= fButton.getDisplay(); ! ! GC gc= new GC(fImage); ! gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); ! gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); ! ! if (fColor != null) ! fColor.dispose(); ! ! fColor= new Color(display, fColorValue); ! gc.setBackground(fColor); ! gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); ! gc.dispose(); ! ! fButton.setImage(fImage); ! } ! ! protected Point computeImageSize(Control window) { ! GC gc= new GC(window); ! Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); ! gc.setFont(f); ! int height= gc.getFontMetrics().getHeight(); ! gc.dispose(); ! Point p= new Point(height * 3 - 6, height); ! return p; ! } } --- 34,122 ---- */ public class ColorEditor { ! ! private Point fExtent; ! private Image fImage; ! private RGB fColorValue; ! private Color fColor; ! private Button fButton; ! ! public ColorEditor(Composite parent) { ! ! fButton= new Button(parent, SWT.PUSH); ! fExtent= computeImageSize(parent); ! fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); ! ! GC gc= new GC(fImage); ! gc.setBackground(fButton.getBackground()); ! gc.fillRectangle(0, 0, fExtent.x, fExtent.y); ! gc.dispose(); ! ! fButton.setImage(fImage); ! fButton.addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent event) { ! ColorDialog colorDialog= new ColorDialog(fButton.getShell()); ! colorDialog.setRGB(fColorValue); ! RGB newColor = colorDialog.open(); ! if (newColor != null) { ! fColorValue= newColor; ! updateColorImage(); ! } ! } ! }); ! ! fButton.addDisposeListener(new DisposeListener() { ! public void widgetDisposed(DisposeEvent event) { ! if (fImage != null) { ! fImage.dispose(); ! fImage= null; ! } ! if (fColor != null) { ! fColor.dispose(); ! fColor= null; ! } ! } ! }); ! } ! ! public RGB getColorValue() { ! return fColorValue; ! } ! ! public void setColorValue(RGB rgb) { ! fColorValue= rgb; ! updateColorImage(); ! } ! ! public Button getButton() { ! return fButton; ! } ! ! protected void updateColorImage() { ! ! Display display= fButton.getDisplay(); ! ! GC gc= new GC(fImage); ! gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); ! gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); ! ! if (fColor != null) ! fColor.dispose(); ! ! fColor= new Color(display, fColorValue); ! gc.setBackground(fColor); ! gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); ! gc.dispose(); ! ! fButton.setImage(fImage); ! } ! ! protected Point computeImageSize(Control window) { ! GC gc= new GC(window); ! Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); ! gc.setFont(f); ! int height= gc.getFontMetrics().getHeight(); ! gc.dispose(); ! Point p= new Point(height * 3 - 6, height); ! return p; ! } } Index: PydevPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** PydevPlugin.java 6 Aug 2008 16:23:19 -0000 1.90 --- PydevPlugin.java 28 Sep 2008 12:45:44 -0000 1.91 *************** *** 60,64 **** */ public class PydevPlugin extends AbstractUIPlugin implements Preferences.IPropertyChangeListener { ! public static final String version = "REPLACE_VERSION"; --- 60,64 ---- */ public class PydevPlugin extends AbstractUIPlugin implements Preferences.IPropertyChangeListener { ! public static final String version = "REPLACE_VERSION"; *************** *** 75,79 **** } // ----------------- END BUNDLE INFO THINGS -------------------------- ! private static IInterpreterManager pythonInterpreterManager; public static void setPythonInterpreterManager(IInterpreterManager interpreterManager) { --- 75,79 ---- } // ----------------- END BUNDLE INFO THINGS -------------------------- ! private static IInterpreterManager pythonInterpreterManager; public static void setPythonInterpreterManager(IInterpreterManager interpreterManager) { *************** *** 84,88 **** } public static IInterpreterManager getPythonInterpreterManager(boolean haltOnStub) { ! return pythonInterpreterManager; } --- 84,88 ---- } public static IInterpreterManager getPythonInterpreterManager(boolean haltOnStub) { ! return pythonInterpreterManager; } *************** *** 95,99 **** } public static IInterpreterManager getJythonInterpreterManager() { ! return getJythonInterpreterManager(false); } public static IInterpreterManager getJythonInterpreterManager(boolean haltOnStub) { --- 95,99 ---- } public static IInterpreterManager getJythonInterpreterManager() { ! return getJythonInterpreterManager(false); } public static IInterpreterManager getJythonInterpreterManager(boolean haltOnStub) { *************** *** 169,188 **** // // protected IStatus run(IProgressMonitor monitor) { ! // try{ ! // ! // IProject[] projects = getWorkspace().getRoot().getProjects(); ! // for (int i = 0; i < projects.length; i++) { ! // IProject project = projects[i]; ! // try { ! // if (project.isOpen() && project.hasNature(PythonNature.PYTHON_NATURE_ID)) { ! // PythonNature.addNature(project, monitor, null, null); ! // } ! // } catch (Exception e) { ! // PydevPlugin.log(e); ! // } ! // } ! // }catch(Throwable t){ ! // t.printStackTrace(); ! // } // return Status.OK_STATUS; // } --- 169,188 ---- // // protected IStatus run(IProgressMonitor monitor) { ! // try{ ! // ! // IProject[] projects = getWorkspace().getRoot().getProjects(); ! // for (int i = 0; i < projects.length; i++) { ! // IProject project = projects[i]; ! // try { ! // if (project.isOpen() && project.hasNature(PythonNature.PYTHON_NATURE_ID)) { ! // PythonNature.addNature(project, monitor, null, null); ! // } ! // } catch (Exception e) { ! // PydevPlugin.log(e); ! // } ! // } ! // }catch(Throwable t){ ! // t.printStackTrace(); ! // } // return Status.OK_STATUS; // } *************** *** 193,201 **** public static boolean isPythonInterpreterInitialized() { ! return true; ! } public static boolean isJythonInterpreterInitialized() { ! return true; } --- 193,201 ---- public static boolean isPythonInterpreterInitialized() { ! return true; ! } public static boolean isJythonInterpreterInitialized() { ! return true; } *************** *** 221,229 **** IProject project = projects[i]; if (project.isOpen()){ ! IProjectNature n = project.getNature(PythonNature.PYTHON_NATURE_ID); ! if(n instanceof PythonNature){ ! PythonNature nature = (PythonNature) n; ! nature.saveAstManager(); ! } } } catch (CoreException e) { --- 221,229 ---- IProject project = projects[i]; if (project.isOpen()){ ! IProjectNature n = project.getNature(PythonNature.PYTHON_NATURE_ID); ! if(n instanceof PythonNature){ ! PythonNature nature = (PythonNature) n; ! nature.saveAstManager(); ! } } } catch (CoreException e) { *************** *** 233,237 **** } finally{ ! super.stop(context); } } --- 233,237 ---- } finally{ ! super.stop(context); } } *************** *** 274,282 **** public void propertyChange(Preferences.PropertyChangeEvent event) { ! // System.out.println( event.getProperty() ! // + "\n\told setting: " ! // + event.getOldValue() ! // + "\n\tnew setting: " ! // + event.getNewValue()); } --- 274,282 ---- public void propertyChange(Preferences.PropertyChangeEvent event) { ! // System.out.println( event.getProperty() ! // + "\n\told setting: " ! // + event.getOldValue() ! // + "\n\tnew setting: " ! // + event.getNewValue()); } *************** *** 294,298 **** public static void logInfo(Exception e) { log(IStatus.INFO, e.getMessage(), e, true); ! } /** --- 294,298 ---- public static void logInfo(Exception e) { log(IStatus.INFO, e.getMessage(), e, true); ! } /** *************** *** 301,319 **** public static void log(int errorLevel, String message, Throwable e, boolean printToConsole) { if(printToConsole){ ! if(errorLevel == IStatus.ERROR){ ! System.out.println("Error received..."); ! }else{ ! System.out.println("Log received..."); ! } System.out.println(message); System.err.println(message); if(e != null){ ! e.printStackTrace(); } } try { ! Status s = new Status(errorLevel, getPluginID(), errorLevel, message, e); ! getDefault().getLog().log(s); } catch (Throwable e1) { //logging should never fail! --- 301,319 ---- public static void log(int errorLevel, String message, Throwable e, boolean printToConsole) { if(printToConsole){ ! if(errorLevel == IStatus.ERROR){ ! System.out.println("Error received..."); ! }else{ ! System.out.println("Log received..."); ! } System.out.println(message); System.err.println(message); if(e != null){ ! e.printStackTrace(); } } try { ! Status s = new Status(errorLevel, getPluginID(), errorLevel, message, e); ! getDefault().getLog().log(s); } catch (Throwable e1) { //logging should never fail! *************** *** 351,358 **** /** ! * Returns this plug-in's template store. ! * ! * @return the template store of this plug-in instance ! */ public TemplateStore getTemplateStore() { if (fStore == null) { --- 351,358 ---- /** ! * Returns this plug-in's template store. ! * ! * @return the template store of this plug-in instance ! */ public TemplateStore getTemplateStore() { if (fStore == null) { *************** *** 426,475 **** ! @SuppressWarnings("unchecked") public void addTestListener(ITestRunListener listener) { ! testListeners.add(listener); ! } ! ! public void removeTestListener(ITestRunListener listener) { ! testListeners.remove(listener); ! } ! public List getListeners() { ! return testListeners; ! } ! ! public void runTests(String moduleDir, String moduleName, IProject project) throws IOException, CoreException { ! new PyUnitTestRunner().runTests(moduleDir, moduleName, project); ! } ! ! public void fireTestsStarted(int count) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testsStarted(count); ! } ! } ! public void fireTestsFinished() { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testsFinished(); ! } ! } ! public void fireTestStarted(String klass, String methodName) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testStarted(klass, methodName); ! } ! } ! public void fireTestFailed(String klass, String methodName, String trace) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testFailed(klass, methodName, trace); ! } ! } ! ! /** * @param file the file we want to get info on. --- 426,475 ---- ! @SuppressWarnings("unchecked") public void addTestListener(ITestRunListener listener) { ! testListeners.add(listener); ! } ! ! public void removeTestListener(ITestRunListener listener) { ! testListeners.remove(listener); ! } ! public List getListeners() { ! return testListeners; ! } ! ! public void runTests(String moduleDir, String moduleName, IProject project) throws IOException, CoreException { ! new PyUnitTestRunner().runTests(moduleDir, moduleName, project); ! } ! ! public void fireTestsStarted(int count) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testsStarted(count); ! } ! } ! public void fireTestsFinished() { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testsFinished(); ! } ! } ! public void fireTestStarted(String klass, String methodName) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testStarted(klass, methodName); ! } ! } ! public void fireTestFailed(String klass, String methodName, String trace) { ! for (Iterator all=getListeners().iterator(); all.hasNext();) { ! ITestRunListener each = (ITestRunListener) all.next(); ! each.testFailed(klass, methodName, trace); ! } ! } ! ! /** * @param file the file we want to get info on. Index: PyunitPrefsPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PyunitPrefsPage.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyunitPrefsPage.java 18 Sep 2006 23:43:25 -0000 1.4 --- PyunitPrefsPage.java 28 Sep 2008 12:45:44 -0000 1.5 *************** *** 22,26 **** */ public class PyunitPrefsPage extends FieldEditorPreferencePage ! implements IWorkbenchPreferencePage{ public static final String PYUNIT_VERBOSITY = "PYUNIT_VERBOSITY"; --- 22,26 ---- */ public class PyunitPrefsPage extends FieldEditorPreferencePage ! implements IWorkbenchPreferencePage{ public static final String PYUNIT_VERBOSITY = "PYUNIT_VERBOSITY"; *************** *** 28,85 **** public static final String PYUNIT_TEST_FILTER = "PYUNIT_TEST_FILTER"; public static final String DEFAULT_PYUNIT_TEST_FILTER = ""; ! /** ! * Initializer sets the preference store ! */ ! public PyunitPrefsPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! } ! public void init(IWorkbench workbench) { ! } ! ! /** ! * Creates the editors ! */ ! protected void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! RadioGroupFieldEditor verbosity_editor= new RadioGroupFieldEditor( ! PYUNIT_VERBOSITY, ! "Verbosity", ! 1, ! new String[][] { ! {"Verbose - prints name of test as it runs", "2"}, ! {"Quiet - prints '.' as each test runs", "1"}, ! {"Silent - prints nothing", "0"}, ! }, ! p ! ); ! StringFieldEditor filter_editor = new StringFieldEditor( ! PYUNIT_TEST_FILTER, ! "Filter (regex)", ! p); String s = "filter examples:\n" + ! ".* or blank - all tests\n" + ! "_abc.* - any test with method name starting with 'test_abc'. \n" + ! " matches test_abc, test_abc123, test_abcXXXXXX, etc. \n" + ! "_abc,_123 - comma seperate (no spaces) filter for more values \n" + ! "\n" + ! "Note: this filters on the method names of all <TestCase>s found\n" + ! " the string 'test' is automatically prepended to the regex\n"; ! ! addField(verbosity_editor); ! addField(filter_editor); addField(new LabelFieldEditor("LabelFieldEditor", s, p)); ! } ! ! /** ! * Sets default preference values ! */ ! protected void initializeDefaultPreferences(Preferences prefs) { ! } } --- 28,85 ---- public static final String PYUNIT_TEST_FILTER = "PYUNIT_TEST_FILTER"; public static final String DEFAULT_PYUNIT_TEST_FILTER = ""; ! /** ! * Initializer sets the preference store ! */ ! public PyunitPrefsPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! } ! public void init(IWorkbench workbench) { ! } ! ! /** ! * Creates the editors ! */ ! protected void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! RadioGroupFieldEditor verbosity_editor= new RadioGroupFieldEditor( ! PYUNIT_VERBOSITY, ! "Verbosity", ! 1, ! new String[][] { ! {"Verbose - prints name of test as it runs", "2"}, ! {"Quiet - prints '.' as each test runs", "1"}, ! {"Silent - prints nothing", "0"}, ! }, ! p ! ); ! StringFieldEditor filter_editor = new StringFieldEditor( ! PYUNIT_TEST_FILTER, ! "Filter (regex)", ! p); String s = "filter examples:\n" + ! ".* or blank - all tests\n" + ! "_abc.* - any test with method name starting with 'test_abc'. \n" + ! " matches test_abc, test_abc123, test_abcXXXXXX, etc. \n" + ! "_abc,_123 - comma seperate (no spaces) filter for more values \n" + ! "\n" + ! "Note: this filters on the method names of all <TestCase>s found\n" + ! " the string 'test' is automatically prepended to the regex\n"; ! ! addField(verbosity_editor); ! addField(filter_editor); addField(new LabelFieldEditor("LabelFieldEditor", s, p)); ! } ! ! /** ! * Sets default preference values ! */ ! protected void initializeDefaultPreferences(Preferences prefs) { ! } } Index: AbstractPydevPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/AbstractPydevPrefs.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractPydevPrefs.java 16 Dec 2007 01:06:27 -0000 1.4 --- AbstractPydevPrefs.java 28 Sep 2008 12:45:44 -0000 1.5 *************** *** 69,72 **** --- 69,78 ---- /** + * Edition of translation paths. + */ + public static final String SOURCE_LOCATION_PATHS = "SOURCE_LOCATION_PATHS"; + + + /** * fields for automatically replacing a colon * @see *************** *** 302,307 **** overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AUTO_ADD_SELF)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, GUESS_TAB_SUBSTITUTION)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS)); - overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET)); //colors --- 308,311 ---- Index: PydevPrefsInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPrefsInitializer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PydevPrefsInitializer.java 19 Jul 2008 19:53:31 -0000 1.21 --- PydevPrefsInitializer.java 28 Sep 2008 12:45:44 -0000 1.22 *************** *** 5,8 **** --- 5,13 ---- import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; + import org.eclipse.core.runtime.preferences.DefaultScope; + import org.eclipse.jface.resource.StringConverter; + import org.osgi.service.prefs.Preferences; + import org.python.pydev.builder.PyDevBuilderPrefPage; + import org.python.pydev.builder.todo.PyTodoPrefPage; import org.python.pydev.editor.codefolding.PyDevCodeFoldingPrefPage; import org.python.pydev.editor.commentblocks.CommentBlocksPreferences; *************** *** 11,20 **** import org.python.pydev.ui.filetypes.FileTypesPreferencesPage; import org.python.pydev.ui.importsconf.ImportsPreferencesPage; - import org.eclipse.core.runtime.preferences.DefaultScope; - import org.eclipse.jface.resource.StringConverter; - import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; - import org.osgi.service.prefs.Preferences; - import org.python.pydev.builder.PyDevBuilderPrefPage; - import org.python.pydev.builder.todo.PyTodoPrefPage; public class PydevPrefsInitializer extends AbstractPreferenceInitializer{ --- 16,19 ---- *************** *** 47,52 **** node.putBoolean(PydevPrefs.AUTO_ADD_SELF, PydevPrefs.DEFAULT_AUTO_ADD_SELF); node.putBoolean(PydevPrefs.GUESS_TAB_SUBSTITUTION, PydevPrefs.DEFAULT_GUESS_TAB_SUBSTITUTION); - node.pu... [truncated message content] |
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyStringCodeCompletion.java PyCodeCompletionInitializer.java PyCodeCompletion.java PyContentAssistant.java AbstractPyCompletionProposalExtension2.java PyCompletionProposal.java PythonCompletionProcessor.java ProposalsComparator.java PyCodeCompletionPreferencesPage.java PythonStringCompletionProcessor.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: PyStringCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyStringCodeCompletion.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyStringCodeCompletion.java 1 May 2008 14:26:00 -0000 1.3 --- PyStringCodeCompletion.java 28 Sep 2008 12:45:42 -0000 1.4 *************** *** 35,40 **** */ public static String[] EPYDOC_FIELDS = new String[]{ ! //function or method ! "param", "param ${param}: ${cursor}", "A description of the parameter for a function or method.", "type", "type ${param}: ${cursor}", "The expected type for the parameter, var or property", "return", "return: ", "The return value for a function or method.", --- 35,40 ---- */ public static String[] EPYDOC_FIELDS = new String[]{ ! //function or method ! "param", "param ${param}: ${cursor}", "A description of the parameter for a function or method.", "type", "type ${param}: ${cursor}", "The expected type for the parameter, var or property", "return", "return: ", "The return value for a function or method.", *************** *** 111,148 **** PySelection ps = new PySelection(request.doc, request.documentOffset); try { ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! String trimmed = lineContentsToCursor.trim(); ! ! //only add params on param and type tags ! if(!trimmed.startsWith("@param") && !trimmed.startsWith("@type")){ ! return; ! } ! ! //for params, we never have an activation token (just a qualifier) ! if(request.activationToken.trim().length() != 0){ ! return; ! } ! ! String initial = request.qualifier; ! DocIterator iterator = new DocIterator(false, ps); ! while(iterator.hasNext()){ ! String line = iterator.next().trim(); ! if(line.startsWith("def ")){ ! int currentLine = iterator.getCurrentLine() + 1; ! PySelection selection = new PySelection(request.doc, currentLine, 0); ! if(selection.isInFunctionLine()){ ! Tuple<List<String>,Integer> insideParentesisToks = selection.getInsideParentesisToks(false); ! for (String str : insideParentesisToks.o1) { ! if(str.startsWith(initial)){ ! ret.add(new PyLinkedModeCompletionProposal(str, request.documentOffset - request.qlen, request.qlen, str.length(), ! PyCodeCompletionImages.getImageForType(IToken.TYPE_PARAM), null, null, "", 0, PyCompletionProposal.ON_APPLY_DEFAULT, "")); ! } ! } ! return; ! } ! } ! } ! } catch (BadLocationException e) { } --- 111,148 ---- PySelection ps = new PySelection(request.doc, request.documentOffset); try { ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! String trimmed = lineContentsToCursor.trim(); ! ! //only add params on param and type tags ! if(!trimmed.startsWith("@param") && !trimmed.startsWith("@type")){ ! return; ! } ! ! //for params, we never have an activation token (just a qualifier) ! if(request.activationToken.trim().length() != 0){ ! return; ! } ! ! String initial = request.qualifier; ! DocIterator iterator = new DocIterator(false, ps); ! while(iterator.hasNext()){ ! String line = iterator.next().trim(); ! if(line.startsWith("def ")){ ! int currentLine = iterator.getCurrentLine() + 1; ! PySelection selection = new PySelection(request.doc, currentLine, 0); ! if(selection.isInFunctionLine()){ ! Tuple<List<String>,Integer> insideParentesisToks = selection.getInsideParentesisToks(false); ! for (String str : insideParentesisToks.o1) { ! if(str.startsWith(initial)){ ! ret.add(new PyLinkedModeCompletionProposal(str, request.documentOffset - request.qlen, request.qlen, str.length(), ! PyCodeCompletionImages.getImageForType(IToken.TYPE_PARAM), null, null, "", 0, PyCompletionProposal.ON_APPLY_DEFAULT, "")); ! } ! } ! return; ! } ! } ! } ! } catch (BadLocationException e) { } *************** *** 152,179 **** * @param ret OUT: this is where the completions are stored */ ! private void fillWithEpydocFields(ITextViewer viewer, CompletionRequest request, ArrayList<ICompletionProposal> ret) { ! try{ ! Region region = new Region(request.documentOffset - request.qlen, request.qlen); ! Image image = PyCodeCompletionImages.getImageForType(IToken.TYPE_EPYDOC); ! TemplateContext context = createContext(viewer, region, request.doc); ! char c = request.doc.getChar(request.documentOffset - request.qualifier.length() -1); if(c == '@'){ //ok, looking for epydoc filters ! for (int i = 0; i < EPYDOC_FIELDS.length; i++) { ! String f = EPYDOC_FIELDS[i]; if(f.startsWith(request.qualifier)){ Template t = new Template(f, EPYDOC_FIELDS[i+2], "", EPYDOC_FIELDS[i+1], false); ret.add(new TemplateProposal(t, context, region, image, 5){ ! @Override ! public String getDisplayString() { ! try{ ! return super.getDisplayString(); ! }catch(NoClassDefFoundError e){ ! //just for tests ! return this.getPrefixCompletionText(null, 0).toString(); ! } ! ! } }); } --- 152,179 ---- * @param ret OUT: this is where the completions are stored */ ! private void fillWithEpydocFields(ITextViewer viewer, CompletionRequest request, ArrayList<ICompletionProposal> ret) { ! try{ ! Region region = new Region(request.documentOffset - request.qlen, request.qlen); ! Image image = PyCodeCompletionImages.getImageForType(IToken.TYPE_EPYDOC); ! TemplateContext context = createContext(viewer, region, request.doc); ! char c = request.doc.getChar(request.documentOffset - request.qualifier.length() -1); if(c == '@'){ //ok, looking for epydoc filters ! for (int i = 0; i < EPYDOC_FIELDS.length; i++) { ! String f = EPYDOC_FIELDS[i]; if(f.startsWith(request.qualifier)){ Template t = new Template(f, EPYDOC_FIELDS[i+2], "", EPYDOC_FIELDS[i+1], false); ret.add(new TemplateProposal(t, context, region, image, 5){ ! @Override ! public String getDisplayString() { ! try{ ! return super.getDisplayString(); ! }catch(NoClassDefFoundError e){ ! //just for tests ! return this.getPrefixCompletionText(null, 0).toString(); ! } ! ! } }); } *************** *** 184,190 **** //just ignore it } ! } ! ! /** --- 184,190 ---- //just ignore it } ! } ! ! /** Index: PyCompletionProposal.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCompletionProposal.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyCompletionProposal.java 18 May 2008 20:02:17 -0000 1.5 --- PyCompletionProposal.java 28 Sep 2008 12:45:42 -0000 1.6 *************** *** 16,37 **** */ public class PyCompletionProposal implements ICompletionProposal, IPyCompletionProposal, ICompletionProposalExtension4 { ! ! /** The string to be displayed in the completion proposal popup. */ ! protected String fDisplayString; ! /** The replacement string. */ ! protected String fReplacementString; ! /** The replacement offset. */ ! protected int fReplacementOffset; ! /** The replacement length. */ ! protected int fReplacementLength; ! /** The cursor position after this proposal has been applied. */ ! protected int fCursorPosition; ! /** The image to be displayed in the completion proposal popup. */ ! protected Image fImage; ! /** The context information of this proposal. */ ! protected IContextInformation fContextInformation; ! /** The additional info of this proposal. */ ! protected String fAdditionalProposalInfo; ! /** The priority for showing the proposal */ protected int priority; --- 16,37 ---- */ public class PyCompletionProposal implements ICompletionProposal, IPyCompletionProposal, ICompletionProposalExtension4 { ! ! /** The string to be displayed in the completion proposal popup. */ ! protected String fDisplayString; ! /** The replacement string. */ ! protected String fReplacementString; ! /** The replacement offset. */ ! protected int fReplacementOffset; ! /** The replacement length. */ ! protected int fReplacementLength; ! /** The cursor position after this proposal has been applied. */ ! protected int fCursorPosition; ! /** The image to be displayed in the completion proposal popup. */ ! protected Image fImage; ! /** The context information of this proposal. */ ! protected IContextInformation fContextInformation; ! /** The additional info of this proposal. */ ! protected String fAdditionalProposalInfo; ! /** The priority for showing the proposal */ protected int priority; *************** *** 57,125 **** public String fArgs; ! /** ! * Creates a new completion proposal based on the provided information. The replacement string is ! * considered being the display string too. All remaining fields are set to <code>null</code>. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, int priority) { ! this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null, priority); ! } ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority) { this(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo,priority, ON_APPLY_DEFAULT, ""); } ! /** ! * Creates a new completion proposal. All fields are initialized based on the provided information. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! * @param image the image to display for this proposal ! * @param displayString the string to be displayed for the proposal ! * @param contextInformation the context information associated with this proposal ! * @param additionalProposalInfo the additional information associated with this proposal * @param onApplyAction if we should not actually apply the changes when the completion is applied ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority, int onApplyAction, String args) { ! Assert.isNotNull(replacementString); ! Assert.isTrue(replacementOffset >= 0); ! Assert.isTrue(replacementLength >= 0); ! Assert.isTrue(cursorPosition >= 0); ! ! fReplacementString= replacementString; ! fReplacementOffset= replacementOffset; ! fReplacementLength= replacementLength; ! fCursorPosition= cursorPosition; ! fImage= image; ! fDisplayString= displayString; ! fContextInformation= contextInformation; ! fAdditionalProposalInfo= additionalProposalInfo; ! this.priority = priority; this.onApplyAction = onApplyAction; this.fArgs = args; ! } ! /* ! * @see ICompletionProposal#apply(IDocument) ! */ ! public void apply(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ return; } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! try { ! document.replace(fReplacementOffset, fReplacementLength, fReplacementString); ! } catch (BadLocationException x) { ! // ignore ! } return; } ! if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ ! try { String args; if(fArgs.length() > 0){ --- 57,125 ---- public String fArgs; ! /** ! * Creates a new completion proposal based on the provided information. The replacement string is ! * considered being the display string too. All remaining fields are set to <code>null</code>. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, int priority) { ! this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null, priority); ! } ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority) { this(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo,priority, ON_APPLY_DEFAULT, ""); } ! /** ! * Creates a new completion proposal. All fields are initialized based on the provided information. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! * @param image the image to display for this proposal ! * @param displayString the string to be displayed for the proposal ! * @param contextInformation the context information associated with this proposal ! * @param additionalProposalInfo the additional information associated with this proposal * @param onApplyAction if we should not actually apply the changes when the completion is applied ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority, int onApplyAction, String args) { ! Assert.isNotNull(replacementString); ! Assert.isTrue(replacementOffset >= 0); ! Assert.isTrue(replacementLength >= 0); ! Assert.isTrue(cursorPosition >= 0); ! ! fReplacementString= replacementString; ! fReplacementOffset= replacementOffset; ! fReplacementLength= replacementLength; ! fCursorPosition= cursorPosition; ! fImage= image; ! fDisplayString= displayString; ! fContextInformation= contextInformation; ! fAdditionalProposalInfo= additionalProposalInfo; ! this.priority = priority; this.onApplyAction = onApplyAction; this.fArgs = args; ! } ! /* ! * @see ICompletionProposal#apply(IDocument) ! */ ! public void apply(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ return; } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! try { ! document.replace(fReplacementOffset, fReplacementLength, fReplacementString); ! } catch (BadLocationException x) { ! // ignore ! } return; } ! if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ ! try { String args; if(fArgs.length() > 0){ *************** *** 127,148 **** document.replace(fReplacementOffset+fReplacementLength, 0, args); } ! } catch (BadLocationException x) { ! // ignore x.printStackTrace(); ! } ! return; } ! throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! ! /* ! * @see ICompletionProposal#getSelection(IDocument) ! */ ! public Point getSelection(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ ! return null; ! } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! return new Point(fReplacementOffset + fCursorPosition, 0); } if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ --- 127,148 ---- document.replace(fReplacementOffset+fReplacementLength, 0, args); } ! } catch (BadLocationException x) { ! // ignore x.printStackTrace(); ! } ! return; } ! throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! ! /* ! * @see ICompletionProposal#getSelection(IDocument) ! */ ! public Point getSelection(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ ! return null; ! } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! return new Point(fReplacementOffset + fCursorPosition, 0); } if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ *************** *** 150,186 **** } throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! /* ! * @see ICompletionProposal#getContextInformation() ! */ ! public IContextInformation getContextInformation() { ! return fContextInformation; ! } ! /* ! * @see ICompletionProposal#getImage() ! */ ! public Image getImage() { ! return fImage; ! } ! /* ! * @see ICompletionProposal#getDisplayString() ! */ ! public String getDisplayString() { ! if (fDisplayString != null) ! return fDisplayString; ! return fReplacementString; ! } ! /* ! * @see ICompletionProposal#getAdditionalProposalInfo() ! */ ! public String getAdditionalProposalInfo() { ! return fAdditionalProposalInfo; ! } ! /** * @see java.lang.Object#hashCode() */ --- 150,186 ---- } throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! /* ! * @see ICompletionProposal#getContextInformation() ! */ ! public IContextInformation getContextInformation() { ! return fContextInformation; ! } ! /* ! * @see ICompletionProposal#getImage() ! */ ! public Image getImage() { ! return fImage; ! } ! /* ! * @see ICompletionProposal#getDisplayString() ! */ ! public String getDisplayString() { ! if (fDisplayString != null) ! return fDisplayString; ! return fReplacementString; ! } ! /* ! * @see ICompletionProposal#getAdditionalProposalInfo() ! */ ! public String getAdditionalProposalInfo() { ! return fAdditionalProposalInfo; ! } ! /** * @see java.lang.Object#hashCode() */ *************** *** 190,194 **** ! /** * @see java.lang.Object#equals(java.lang.Object) */ --- 190,194 ---- ! /** * @see java.lang.Object#equals(java.lang.Object) */ Index: PythonStringCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PythonStringCompletionProcessor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonStringCompletionProcessor.java 25 Mar 2007 16:08:59 -0000 1.1 --- PythonStringCompletionProcessor.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 8,20 **** public class PythonStringCompletionProcessor extends PythonCompletionProcessor{ ! public PythonStringCompletionProcessor(PyEdit edit, PyContentAssistant pyContentAssistant) { ! super(edit, pyContentAssistant); ! } ! ! @Override ! public char[] getCompletionProposalAutoActivationCharacters() { ! //no auto-activation within strings. ! return new char[]{'@'}; ! } protected IPyCodeCompletion getCodeCompletionEngine() { --- 8,20 ---- public class PythonStringCompletionProcessor extends PythonCompletionProcessor{ ! public PythonStringCompletionProcessor(PyEdit edit, PyContentAssistant pyContentAssistant) { ! super(edit, pyContentAssistant); ! } ! ! @Override ! public char[] getCompletionProposalAutoActivationCharacters() { ! //no auto-activation within strings. ! return new char[]{'@'}; ! } protected IPyCodeCompletion getCodeCompletionEngine() { Index: PyContentAssistant.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyContentAssistant.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyContentAssistant.java 17 Aug 2008 00:26:46 -0000 1.8 --- PyContentAssistant.java 28 Sep 2008 12:45:42 -0000 1.9 *************** *** 44,50 **** try{ ! setRepeatedInvocationTrigger(KeyBindingHelper.getContentAssistProposalBinding()); }catch(Exception e){ ! //no need to log } --- 44,50 ---- try{ ! setRepeatedInvocationTrigger(KeyBindingHelper.getContentAssistProposalBinding()); }catch(Exception e){ ! //no need to log } *************** *** 52,56 **** setStatusLineVisible(true); }catch(Exception e){ ! //no need to log } } --- 52,56 ---- setStatusLineVisible(true); }catch(Exception e){ ! //no need to log } } Index: PyCodeCompletionInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionInitializer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyCodeCompletionInitializer.java 25 Mar 2007 16:08:59 -0000 1.1 --- PyCodeCompletionInitializer.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 15,27 **** Preferences node = new DefaultScope().getNode(PydevPlugin.DEFAULT_PYDEV_SCOPE); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_USE_CODECOMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ATTEMPTS_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_ATTEMPTS_CODECOMPLETION); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_DOT, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_DOT); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_ALL_ASCII_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE, PyCodeCompletionPreferencesPage.DEFAULT_USE_AUTOCOMPLETE); ! node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); ! node.putBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); } --- 15,27 ---- Preferences node = new DefaultScope().getNode(PydevPlugin.DEFAULT_PYDEV_SCOPE); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_USE_CODECOMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ATTEMPTS_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_ATTEMPTS_CODECOMPLETION); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_DOT, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_DOT); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_ALL_ASCII_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE, PyCodeCompletionPreferencesPage.DEFAULT_USE_AUTOCOMPLETE); ! node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); ! node.putBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); } Index: PyCodeCompletionPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionPreferencesPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCompletionPreferencesPage.java 15 Jun 2008 21:03:31 -0000 1.2 --- PyCodeCompletionPreferencesPage.java 28 Sep 2008 12:45:42 -0000 1.3 *************** *** 30,54 **** public static final int DEFAULT_ATTEMPTS_CODECOMPLETION = 20; ! public static final String AUTOCOMPLETE_ON_DOT = "AUTOCOMPLETE_ON_DOT"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_DOT = true; ! ! public static final String AUTOCOMPLETE_ON_ALL_ASCII_CHARS = "AUTOCOMPLETE_ON_ALL_ASCII_CHARS"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS = false; ! public static final String USE_AUTOCOMPLETE = "USE_AUTOCOMPLETE"; ! public static final boolean DEFAULT_USE_AUTOCOMPLETE = true; ! public static final String AUTOCOMPLETE_DELAY = "AUTOCOMPLETE_DELAY"; ! public static final int DEFAULT_AUTOCOMPLETE_DELAY = 0; ! public static final String AUTOCOMPLETE_ON_PAR = "AUTOCOMPLETE_ON_PAR"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; ! ! public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; ! public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; ! ! public static final String ARGUMENTS_DEEP_ANALYSIS_N_CHARS = "DEEP_ANALYSIS_N_CHARS"; ! public static final int DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS = 1; ! /** */ --- 30,54 ---- public static final int DEFAULT_ATTEMPTS_CODECOMPLETION = 20; ! public static final String AUTOCOMPLETE_ON_DOT = "AUTOCOMPLETE_ON_DOT"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_DOT = true; ! ! public static final String AUTOCOMPLETE_ON_ALL_ASCII_CHARS = "AUTOCOMPLETE_ON_ALL_ASCII_CHARS"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS = false; ! public static final String USE_AUTOCOMPLETE = "USE_AUTOCOMPLETE"; ! public static final boolean DEFAULT_USE_AUTOCOMPLETE = true; ! public static final String AUTOCOMPLETE_DELAY = "AUTOCOMPLETE_DELAY"; ! public static final int DEFAULT_AUTOCOMPLETE_DELAY = 0; ! public static final String AUTOCOMPLETE_ON_PAR = "AUTOCOMPLETE_ON_PAR"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; ! ! public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; ! public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; ! ! public static final String ARGUMENTS_DEEP_ANALYSIS_N_CHARS = "DEEP_ANALYSIS_N_CHARS"; ! public static final int DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS = 1; ! /** */ *************** *** 67,82 **** addField(new IntegerFieldEditor( ! ATTEMPTS_CODECOMPLETION, "Timeout to connect to shell (secs).", p)); ! addField(new IntegerFieldEditor( ! AUTOCOMPLETE_DELAY, "Autocompletion delay: ", p)); ! String tooltip = WordUtils.wrap("Determines the number of chars in the qualifier request " + ! "for which constructs such as 'from xxx import yyy' should be " + ! "analyzed to get its actual token and if it maps to a method, its paramaters will be added in the completion.", 80); ! IntegerFieldEditor deepAnalysisFieldEditor = new IntegerFieldEditor( ! ARGUMENTS_DEEP_ANALYSIS_N_CHARS, "Minimum number of chars in qualifier for\ndeep analysis for parameters in 'from' imports:", p); addField(deepAnalysisFieldEditor); deepAnalysisFieldEditor.getLabelControl(p).setToolTipText(tooltip); --- 67,82 ---- addField(new IntegerFieldEditor( ! ATTEMPTS_CODECOMPLETION, "Timeout to connect to shell (secs).", p)); ! addField(new IntegerFieldEditor( ! AUTOCOMPLETE_DELAY, "Autocompletion delay: ", p)); ! String tooltip = WordUtils.wrap("Determines the number of chars in the qualifier request " + ! "for which constructs such as 'from xxx import yyy' should be " + ! "analyzed to get its actual token and if it maps to a method, its paramaters will be added in the completion.", 80); ! IntegerFieldEditor deepAnalysisFieldEditor = new IntegerFieldEditor( ! ARGUMENTS_DEEP_ANALYSIS_N_CHARS, "Minimum number of chars in qualifier for\ndeep analysis for parameters in 'from' imports:", p); addField(deepAnalysisFieldEditor); deepAnalysisFieldEditor.getLabelControl(p).setToolTipText(tooltip); *************** *** 85,107 **** ! addField(new BooleanFieldEditor( ! USE_CODECOMPLETION, "Use code completion?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_DOT, "Autocomplete on '.'?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on ','?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_ALL_ASCII_CHARS, "Autocomplete on all letter chars and '_'?", p)); ! ! addField(new BooleanFieldEditor( DEBUG_CODE_COMPLETION, "Debug code completion?", p)); ! } --- 85,107 ---- ! addField(new BooleanFieldEditor( ! USE_CODECOMPLETION, "Use code completion?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_DOT, "Autocomplete on '.'?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on ','?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_ALL_ASCII_CHARS, "Autocomplete on all letter chars and '_'?", p)); ! ! addField(new BooleanFieldEditor( DEBUG_CODE_COMPLETION, "Debug code completion?", p)); ! } Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PythonCompletionProcessor.java 2 May 2008 23:24:14 -0000 1.6 --- PythonCompletionProcessor.java 28 Sep 2008 12:45:42 -0000 1.7 *************** *** 133,175 **** if(nature == null || !nature.startRequests()){ ! return new ICompletionProposal[0]; } try{ ! CompletionRequest request = new CompletionRequest(edit.getEditorFile(), ! nature, doc, documentOffset, codeCompletion); ! ! ! ! //SECOND: getting code completions and deciding if templates should be shown too. ! //Get code completion proposals ! if(PyCodeCompletionPreferencesPage.useCodeCompletion()){ ! if(whatToShow == SHOW_ALL){ ! try { ! pythonAndTemplateProposals.addAll(getPythonProposals(viewer, documentOffset, doc, request)); ! } catch (Throwable e) { ! setError(e); ! } ! } ! ! } ! ! ! String[] strs = PySelection.getActivationTokenAndQual(doc, documentOffset, false); ! ! String activationToken = strs[0]; ! String qualifier = strs[1]; ! ! ! //THIRD: Get template proposals (if asked for) ! if(request.showTemplates && (activationToken == null || activationToken.trim().length() == 0)){ ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier); ! pythonAndTemplateProposals.addAll(templateProposals); ! } ! ! ! //to show the valid ones, we'll get the qualifier from the initial request ! proposals = PyCodeCompletionUtils.onlyValidSorted(pythonAndTemplateProposals, request.qualifier, request.isInCalltip); }finally{ ! nature.endRequests(); } } catch (RuntimeException e) { --- 133,175 ---- if(nature == null || !nature.startRequests()){ ! return new ICompletionProposal[0]; } try{ ! CompletionRequest request = new CompletionRequest(edit.getEditorFile(), ! nature, doc, documentOffset, codeCompletion); ! ! ! ! //SECOND: getting code completions and deciding if templates should be shown too. ! //Get code completion proposals ! if(PyCodeCompletionPreferencesPage.useCodeCompletion()){ ! if(whatToShow == SHOW_ALL){ ! try { ! pythonAndTemplateProposals.addAll(getPythonProposals(viewer, documentOffset, doc, request)); ! } catch (Throwable e) { ! setError(e); ! } ! } ! ! } ! ! ! String[] strs = PySelection.getActivationTokenAndQual(doc, documentOffset, false); ! ! String activationToken = strs[0]; ! String qualifier = strs[1]; ! ! ! //THIRD: Get template proposals (if asked for) ! if(request.showTemplates && (activationToken == null || activationToken.trim().length() == 0)){ ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier); ! pythonAndTemplateProposals.addAll(templateProposals); ! } ! ! ! //to show the valid ones, we'll get the qualifier from the initial request ! proposals = PyCodeCompletionUtils.onlyValidSorted(pythonAndTemplateProposals, request.qualifier, request.isInCalltip); }finally{ ! nature.endRequests(); } } catch (RuntimeException e) { *************** *** 236,248 **** */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { ! //System.out.println("computeContextInformation"); ! if(viewer.getDocument() != this.contextInformationValidator.doc){ ! return null; ! } ! //System.out.println("this.contextInformationValidator.returnedFalseOnce:"+this.contextInformationValidator.returnedFalseOnce); ! //if we didn't return false at least once, it is already installed. ! if(this.contextInformationValidator.returnedFalseOnce && this.contextInformationValidator.isContextInformationValid(documentOffset)){ ! return new IContextInformation[]{this.contextInformationValidator.fInformation}; ! } return null; } --- 236,248 ---- */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { ! //System.out.println("computeContextInformation"); ! if(viewer.getDocument() != this.contextInformationValidator.doc){ ! return null; ! } ! //System.out.println("this.contextInformationValidator.returnedFalseOnce:"+this.contextInformationValidator.returnedFalseOnce); ! //if we didn't return false at least once, it is already installed. ! if(this.contextInformationValidator.returnedFalseOnce && this.contextInformationValidator.isContextInformationValid(documentOffset)){ ! return new IContextInformation[]{this.contextInformationValidator.fInformation}; ! } return null; } *************** *** 264,296 **** */ public static char[] getStaticCompletionProposalAutoActivationCharacters() { ! if(!listenerToClearAutoActivationAlreadySetup){ ! //clears the cache when the preferences are changed. ! IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore(); ! preferenceStore.addPropertyChangeListener(new IPropertyChangeListener(){ ! ! public void propertyChange(PropertyChangeEvent event) { ! activationChars = null; //clear the cache when it changes ! } ! ! }); ! listenerToClearAutoActivationAlreadySetup = true; ! } - if(activationChars == null){ //let's cache this ! ! if(!PyCodeCompletionPreferencesPage.useAutocomplete()){ ! activationChars = new char[0]; ! ! }else{ ! char[] c = new char[0]; ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnDot()) { ! c = addChar(c, '.'); ! } ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnPar()) { ! c = addChar(c, '('); ! } ! activationChars = c; ! } } return activationChars; --- 264,296 ---- */ public static char[] getStaticCompletionProposalAutoActivationCharacters() { ! if(!listenerToClearAutoActivationAlreadySetup){ ! //clears the cache when the preferences are changed. ! IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore(); ! preferenceStore.addPropertyChangeListener(new IPropertyChangeListener(){ ! ! public void propertyChange(PropertyChangeEvent event) { ! activationChars = null; //clear the cache when it changes ! } ! ! }); ! listenerToClearAutoActivationAlreadySetup = true; ! } ! if(activationChars == null){ //let's cache this ! ! if(!PyCodeCompletionPreferencesPage.useAutocomplete()){ ! activationChars = new char[0]; ! ! }else{ ! char[] c = new char[0]; ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnDot()) { ! c = addChar(c, '.'); ! } ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnPar()) { ! c = addChar(c, '('); ! } ! activationChars = c; ! } } return activationChars; Index: ProposalsComparator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/ProposalsComparator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProposalsComparator.java 24 Mar 2008 01:53:22 -0000 1.2 --- ProposalsComparator.java 28 Sep 2008 12:45:42 -0000 1.3 *************** *** 18,52 **** if(o1 instanceof IPyCompletionProposal && o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(p1.getPriority() < p2.getPriority()){ ! return -1; ! } ! if(p1.getPriority() > p2.getPriority()){ ! return 1; ! } } //if it is not an IPyCompletionProposal, it has default priority. else if(o1 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! if(p1.getPriority() < IPyCompletionProposal.PRIORITY_DEFAULT){ ! return -1; ! } ! if(p1.getPriority() > IPyCompletionProposal.PRIORITY_DEFAULT){ ! return 1; ! } } else if(o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(IPyCompletionProposal.PRIORITY_DEFAULT < p2.getPriority()){ ! return -1; ! } ! if(IPyCompletionProposal.PRIORITY_DEFAULT > p2.getPriority()){ ! return 1; ! } } --- 18,52 ---- if(o1 instanceof IPyCompletionProposal && o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(p1.getPriority() < p2.getPriority()){ ! return -1; ! } ! if(p1.getPriority() > p2.getPriority()){ ! return 1; ! } } //if it is not an IPyCompletionProposal, it has default priority. else if(o1 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! if(p1.getPriority() < IPyCompletionProposal.PRIORITY_DEFAULT){ ! return -1; ! } ! if(p1.getPriority() > IPyCompletionProposal.PRIORITY_DEFAULT){ ! return 1; ! } } else if(o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(IPyCompletionProposal.PRIORITY_DEFAULT < p2.getPriority()){ ! return -1; ! } ! if(IPyCompletionProposal.PRIORITY_DEFAULT > p2.getPriority()){ ! return 1; ! } } Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyCodeCompletion.java 13 Aug 2008 21:12:16 -0000 1.7 --- PyCodeCompletion.java 28 Sep 2008 12:45:42 -0000 1.8 *************** *** 79,86 **** */ public List getCodeCompletionProposals(ITextViewer viewer, CompletionRequest request) throws CoreException, BadLocationException { ! if(request.getPySelection().getCursorLineContents().trim().startsWith("#")){ ! //this may happen if the context is still not correctly computed in python ! return new PyStringCodeCompletion().getCodeCompletionProposals(viewer, request); ! } if(DEBUG_CODE_COMPLETION){ Log.toLogFile(this,"Starting getCodeCompletionProposals"); --- 79,86 ---- */ public List getCodeCompletionProposals(ITextViewer viewer, CompletionRequest request) throws CoreException, BadLocationException { ! if(request.getPySelection().getCursorLineContents().trim().startsWith("#")){ ! //this may happen if the context is still not correctly computed in python ! return new PyStringCodeCompletion().getCodeCompletionProposals(viewer, request); ! } if(DEBUG_CODE_COMPLETION){ Log.toLogFile(this,"Starting getCodeCompletionProposals"); *************** *** 110,118 **** List<Object> tokensList = new ArrayList<Object>(); try { ! lazyStartShell(request); ! } catch (NotConfiguredInterpreterException e) { ! Log.log(IStatus.WARNING, "Warning: unable to get code-completion for builtins: No interpreter configured.", null); ! } ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); --- 110,118 ---- List<Object> tokensList = new ArrayList<Object>(); try { ! lazyStartShell(request); ! } catch (NotConfiguredInterpreterException e) { ! Log.log(IStatus.WARNING, "Warning: unable to get code-completion for builtins: No interpreter configured.", null); ! } ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); *************** *** 190,199 **** } if(token2 == null || ! (token2.equals(token) && ! token2.getArgs().equals(token.getArgs()) && ! token2.getParentPackage().equals(token.getParentPackage()))){ ! ! token2.equals(token); ! break; } token = token2; --- 190,199 ---- } if(token2 == null || ! (token2.equals(token) && ! token2.getArgs().equals(token.getArgs()) && ! token2.getParentPackage().equals(token.getParentPackage()))){ ! ! token2.equals(token); ! break; } token = token2; *************** *** 215,224 **** changeItokenToCompletionPropostal(viewer, request, ret, tokensList, importsTip, state); } catch (CompletionRecursionException e) { ! if(onCompletionRecursionException != null){ ! onCompletionRecursionException.call(e); ! } ! if(DEBUG_CODE_COMPLETION){ ! Log.toLogFile(e); ! } //PydevPlugin.log(e); //ret.add(new CompletionProposal("",request.documentOffset,0,0,null,e.getMessage(), null,null)); --- 215,224 ---- changeItokenToCompletionPropostal(viewer, request, ret, tokensList, importsTip, state); } catch (CompletionRecursionException e) { ! if(onCompletionRecursionException != null){ ! onCompletionRecursionException.call(e); ! } ! if(DEBUG_CODE_COMPLETION){ ! Log.toLogFile(e); ! } //PydevPlugin.log(e); //ret.add(new CompletionProposal("",request.documentOffset,0,0,null,e.getMessage(), null,null)); *************** *** 338,342 **** } } catch (RuntimeException e) { ! throw e; } catch (Exception e) { throw new RuntimeException(e); --- 338,342 ---- } } catch (RuntimeException e) { ! throw e; } catch (Exception e) { throw new RuntimeException(e); *************** *** 369,412 **** */ @SuppressWarnings("unchecked") ! public static boolean getSelfOrClsCompletions(CompletionRequest request, List theList, ICompletionState state, ! boolean getOnlySupers, boolean checkIfInCorrectScope, String lookForRep) { ! SimpleNode s = PyParser.reparseDocument(new PyParser.ParserInfo(request.doc, true, request.nature, state.getLine())).o1; if(s != null){ ! FindScopeVisitor visitor = new FindScopeVisitor(state.getLine(), 0); ! try { ! s.accept(visitor); ! if(checkIfInCorrectScope){ ! boolean scopeCorrect = false; ! ! FastStack<SimpleNode> scopeStack = visitor.scope.getScopeStack(); ! for(Iterator<SimpleNode> it=scopeStack.topDownIterator();scopeCorrect == false && it.hasNext();){ ! SimpleNode node = it.next(); ! if (node instanceof FunctionDef) { ! FunctionDef funcDef = (FunctionDef) node; ! if(funcDef.args != null && funcDef.args.args != null || funcDef.args.args.length > 0){ ! //ok, we have some arg, let's check for self or cls ! String rep = NodeUtils.getRepresentationString(funcDef.args.args[0]); ! if(rep != null && (rep.equals("self") || rep.equals("cls"))){ ! scopeCorrect = true; ! } ! } ! } ! } ! if(!scopeCorrect){ ! return false; ! } ! } ! if(lookForRep.equals("self")){ ! state.setLookingFor(ICompletionState.LOOKING_FOR_INSTANCED_VARIABLE); ! }else{ ! state.setLookingFor(ICompletionState.LOOKING_FOR_CLASSMETHOD_VARIABLE); ! } ! getSelfOrClsCompletions(visitor.scope, request, theList, state, getOnlySupers); ! } catch (Exception e1) { ! PydevPlugin.log(e1); ! } ! return true; ! } return false; } --- 369,412 ---- */ @SuppressWarnings("unchecked") ! public static boolean getSelfOrClsCompletions(CompletionRequest request, List theList, ICompletionState state, ! boolean getOnlySupers, boolean checkIfInCorrectScope, String lookForRep) { ! SimpleNode s = PyParser.reparseDocument(new PyParser.ParserInfo(request.doc, true, request.nature, state.getLine())).o1; if(s != null){ ! FindScopeVisitor visitor = new FindScopeVisitor(state.getLine(), 0); ! try { ! s.accept(visitor); ! if(checkIfInCorrectScope){ ! boolean scopeCorrect = false; ! ! FastStack<SimpleNode> scopeStack = visitor.scope.getScopeStack(); ! for(Iterator<SimpleNode> it=scopeStack.topDownIterator();scopeCorrect == false && it.hasNext();){ ! SimpleNode node = it.next(); ! if (node instanceof FunctionDef) { ! FunctionDef funcDef = (FunctionDef) node; ! if(funcDef.args != null && funcDef.args.args != null || funcDef.args.args.length > 0){ ! //ok, we have some arg, let's check for self or cls ! String rep = NodeUtils.getRepresentationString(funcDef.args.args[0]); ! if(rep != null && (rep.equals("self") || rep.equals("cls"))){ ! scopeCorrect = true; ! } ! } ! } ! } ! if(!scopeCorrect){ ! return false; ! } ! } ! if(lookForRep.equals("self")){ ! state.setLookingFor(ICompletionState.LOOKING_FOR_INSTANCED_VARIABLE); ! }else{ ! state.setLookingFor(ICompletionState.LOOKING_FOR_CLASSMETHOD_VARIABLE); ! } ! getSelfOrClsCompletions(visitor.scope, request, theList, state, getOnlySupers); ! } catch (Exception e1) { ! PydevPlugin.log(e1); ! } ! return true; ! } return false; } *************** *** 427,438 **** if(d.bases[i] instanceof Name){ Name n = (Name) d.bases[i]; ! state.setActivationToken(n.id); ! IToken[] completions; ! try { ! completions = request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state); ! gottenComps.addAll(Arrays.asList(completions)); ! } catch (CompletionRecursionException e) { ! //ok... ! } } } --- 427,438 ---- if(d.bases[i] instanceof Name){ Name n = (Name) d.bases[i]; ! state.setActivationToken(n.id); ! IToken[] completions; ! try { ! completions = request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state); ! gottenComps.addAll(Arrays.asList(completions)); ! } catch (CompletionRecursionException e) { ! //ok... ! } } } *************** *** 452,461 **** //ok, it's just really self, let's get on to get the completions state.setActivationToken(NodeUtils.getNameFromNameTok((NameTok) d.name)); ! try { theList.addAll(Arrays.asList(request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state))); ! } catch (CompletionRecursionException e) { ! //ok ! } ! }else{ //it's not only self, so, first we have to get the definition of the token --- 452,461 ---- //ok, it's just really self, let's get on to get the completions state.setActivationToken(NodeUtils.getNameFromNameTok((NameTok) d.name)); ! try { theList.addAll(Arrays.asList(request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state))); ! } catch (CompletionRecursionException e) { ! //ok ! } ! }else{ //it's not only self, so, first we have to get the definition of the token Index: AbstractPyCompletionProposalExtension2.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/AbstractPyCompletionProposalExtension2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractPyCompletionProposalExtension2.java 15 Jun 2008 21:03:31 -0000 1.1 --- AbstractPyCompletionProposalExtension2.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 84,88 **** */ private boolean isValidChar(char c) { ! return Character.isJavaIdentifierPart(c); } --- 84,88 ---- */ private boolean isValidChar(char c) { ! return Character.isJavaIdentifierPart(c); } |
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: CompletionState.java SystemModulesManager.java CompletionStateWrapper.java PyCodeCompletionVisitor.java SystemASTManager.java AbstractToken.java AbstractASTManager.java AssignAnalysis.java ProjectModulesManager.java ASTManager.java ModulesManagerCache.java CompletionStateFactory.java PythonPathHelper.java SourceModuleProposal.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: SystemModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/SystemModulesManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SystemModulesManager.java 14 Jun 2008 22:14:55 -0000 1.10 --- SystemModulesManager.java 28 Sep 2008 12:45:45 -0000 1.11 *************** *** 62,66 **** */ public String[] getBuiltins(String defaultSelectedInterpreter) { ! return getBuiltins(); } --- 62,66 ---- */ public String[] getBuiltins(String defaultSelectedInterpreter) { ! return getBuiltins(); } *************** *** 73,104 **** ! public void setPythonNature(IPythonNature nature) { ! this.nature = nature; ! } ! public IPythonNature getNature() { ! return this.nature; ! } ! public ISystemModulesManager getSystemModulesManager() { ! return this; //itself ! } ! public IModule getModule(String name, IPythonNature nature, boolean checkSystemManager, boolean dontSearchInit) { ! return getModule(name, nature, dontSearchInit); ! } ! public String resolveModule(String full, boolean checkSystemManager) { ! return super.resolveModule(full); ! } ! public List<String> getCompletePythonPath(String interpreter) { ! return super.getPythonPath(); } ! public List<String> getCompletePythonPath(String interpreter, IPythonNature nature2) { if(interpreter == null){ ! return super.getPythonPath(); }else{ IInterpreterManager manager = nature2.getRelatedInterpreterManager(); --- 73,104 ---- ! public void setPythonNature(IPythonNature nature) { ! this.nature = nature; ! } ! public IPythonNature getNature() { ! return this.nature; ! } ! public ISystemModulesManager getSystemModulesManager() { ! return this; //itself ! } ! public IModule getModule(String name, IPythonNature nature, boolean checkSystemManager, boolean dontSearchInit) { ! return getModule(name, nature, dontSearchInit); ! } ! public String resolveModule(String full, boolean checkSystemManager) { ! return super.resolveModule(full); ! } ! public List<String> getCompletePythonPath(String interpreter) { ! return super.getPythonPath(); } ! public List<String> getCompletePythonPath(String interpreter, IPythonNature nature2) { if(interpreter == null){ ! return super.getPythonPath(); }else{ IInterpreterManager manager = nature2.getRelatedInterpreterManager(); *************** *** 106,119 **** return info.getPythonPath(); } ! } ! public IModule getRelativeModule(String name, IPythonNature nature) { ! return super.getModule(name, nature, true); ! } ! /** ! * Called after the pythonpath is changed. ! */ protected void onChangePythonpath(String defaultSelectedInterpreter, SortedMap<ModulesKey, ModulesKey> keys) { //create the builtin modules --- 106,119 ---- return info.getPythonPath(); } ! } ! public IModule getRelativeModule(String name, IPythonNature nature) { ! return super.getModule(name, nature, true); ! } ! /** ! * Called after the pythonpath is changed. ! */ protected void onChangePythonpath(String defaultSelectedInterpreter, SortedMap<ModulesKey, ModulesKey> keys) { //create the builtin modules Index: SystemASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/SystemASTManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SystemASTManager.java 31 Jul 2008 01:47:36 -0000 1.3 --- SystemASTManager.java 28 Sep 2008 12:45:45 -0000 1.4 *************** *** 13,41 **** @SuppressWarnings("serial") public class SystemASTManager extends AbstractASTManager{ ! ! private IInterpreterManager manager; ! public SystemASTManager(IInterpreterManager manager, IPythonNature nature) { ! this.manager = manager; ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); this.modulesManager = info.getModulesManager(); ! setNature(nature); ! } ! public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas) { ! throw new RuntimeException("Not implemented"); ! } ! public void rebuildModule(File file, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature) { ! throw new RuntimeException("Not implemented"); ! } ! public void removeModule(File file, IProject project, IProgressMonitor monitor) { ! throw new RuntimeException("Not implemented"); ! } ! public void changePythonPath(String pythonpath, IProject project, IProgressMonitor monitor, String defaultSelectedInterpreter) { ! throw new RuntimeException("Not implemented"); ! } } --- 13,41 ---- @SuppressWarnings("serial") public class SystemASTManager extends AbstractASTManager{ ! ! private IInterpreterManager manager; ! public SystemASTManager(IInterpreterManager manager, IPythonNature nature) { ! this.manager = manager; ! InterpreterInfo info = (InterpreterInfo) this.manager.getDefaultInterpreterInfo(new NullProgressMonitor()); this.modulesManager = info.getModulesManager(); ! setNature(nature); ! } ! public void setProject(IProject project, IPythonNature nature, boolean restoreDeltas) { ! throw new RuntimeException("Not implemented"); ! } ! public void rebuildModule(File file, IDocument doc, IProject project, IProgressMonitor monitor, IPythonNature nature) { ! throw new RuntimeException("Not implemented"); ! } ! public void removeModule(File file, IProject project, IProgressMonitor monitor) { ! throw new RuntimeException("Not implemented"); ! } ! public void changePythonPath(String pythonpath, IProject project, IProgressMonitor monitor, String defaultSelectedInterpreter) { ! throw new RuntimeException("Not implemented"); ! } } Index: PyCodeCompletionVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/PyCodeCompletionVisitor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyCodeCompletionVisitor.java 25 Mar 2007 16:09:03 -0000 1.1 --- PyCodeCompletionVisitor.java 28 Sep 2008 12:45:45 -0000 1.2 *************** *** 24,34 **** public class PyCodeCompletionVisitor extends PyDevBuilderVisitor { ! public static final int PRIORITY_CODE_COMPLETION = PRIORITY_DEFAULT; ! ! @Override ! protected int getPriority() { ! return PRIORITY_CODE_COMPLETION; ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#shouldVisitInitDependency() --- 24,34 ---- public class PyCodeCompletionVisitor extends PyDevBuilderVisitor { ! public static final int PRIORITY_CODE_COMPLETION = PRIORITY_DEFAULT; ! ! @Override ! protected int getPriority() { ! return PRIORITY_CODE_COMPLETION; ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#shouldVisitInitDependency() Index: CompletionState.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/CompletionState.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CompletionState.java 4 May 2008 16:48:46 -0000 1.8 --- CompletionState.java 28 Sep 2008 12:45:45 -0000 1.9 *************** *** 72,85 **** static class Memo<E>{ ! private int max; ! public Memo(){ ! this.max = MAX_NUMBER_OF_OCURRENCES; ! } ! ! public Memo(int max){ ! this.max = max; ! } ! /** * if more than this number of ocurrences is found, we are in a recursion --- 72,85 ---- static class Memo<E>{ ! private int max; ! public Memo(){ ! this.max = MAX_NUMBER_OF_OCURRENCES; ! } ! ! public Memo(int max){ ! this.max = max; ! } ! /** * if more than this number of ocurrences is found, we are in a recursion *************** *** 200,209 **** } ! public void checkFindDefinitionMemory(IModule mod, String tok) throws CompletionRecursionException { ! if(this.findDefinitionMemory.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found -- probably programming error -- (module: "+mod.getName()+", value: "+tok+") - stopping analysis."); ! } ! } ! /** * @param module --- 200,209 ---- } ! public void checkFindDefinitionMemory(IModule mod, String tok) throws CompletionRecursionException { ! if(this.findDefinitionMemory.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found -- probably programming error -- (module: "+mod.getName()+", value: "+tok+") - stopping analysis."); ! } ! } ! /** * @param module *************** *** 254,261 **** * @param base */ ! public void checkFindModuleCompletionsMemory(IModule mod, String tok) throws CompletionRecursionException{ ! if(this.findModuleCompletionsMemory.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found -- probably programming error -- (module: "+mod.getName()+", token: "+tok+") - stopping analysis."); ! } } --- 254,261 ---- * @param base */ ! public void checkFindModuleCompletionsMemory(IModule mod, String tok) throws CompletionRecursionException{ ! if(this.findModuleCompletionsMemory.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found -- probably programming error -- (module: "+mod.getName()+", token: "+tok+") - stopping analysis."); ! } } *************** *** 310,318 **** } ! public void raiseNFindTokensOnImportedModsCalled(IModule mod, String tok) throws CompletionRecursionException { ! if(this.importedModsCalled.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found (mod: "+mod.getName()+", tok: "+ tok +" ) - stopping analysis."); ! } ! } public boolean getIsInCalltip() { --- 310,318 ---- } ! public void raiseNFindTokensOnImportedModsCalled(IModule mod, String tok) throws CompletionRecursionException { ! if(this.importedModsCalled.isInRecursion(mod, tok)){ ! throw new CompletionRecursionException("Possible recursion found (mod: "+mod.getName()+", tok: "+ tok +" ) - stopping analysis."); ! } ! } public boolean getIsInCalltip() { Index: AssignAnalysis.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/AssignAnalysis.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AssignAnalysis.java 2 Mar 2008 20:00:46 -0000 1.6 --- AssignAnalysis.java 28 Sep 2008 12:45:45 -0000 1.7 *************** *** 90,96 **** String act = NodeUtils.getFullRepresentationString(return1.value); if(act == null){ ! return; //may happen if the return we're seeing is a return without anything } ! copy.setActivationToken (act); copy.setLine(return1.value.beginLine-1); copy.setCol(return1.value.beginColumn-1); --- 90,96 ---- String act = NodeUtils.getFullRepresentationString(return1.value); if(act == null){ ! return; //may happen if the return we're seeing is a return without anything } ! copy.setActivationToken (act); copy.setLine(return1.value.beginLine-1); copy.setCol(return1.value.beginColumn-1); Index: CompletionStateFactory.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/CompletionStateFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CompletionStateFactory.java 25 Feb 2008 11:21:34 -0000 1.4 --- CompletionStateFactory.java 28 Sep 2008 12:45:45 -0000 1.5 *************** *** 7,33 **** public class CompletionStateFactory { ! /** ! * @return a default completion state for globals (empty act. token) ! */ ! public static ICompletionState getEmptyCompletionState(IPythonNature nature, ICompletionCache completionCache) { ! return new CompletionState(-1, -1, "", nature, "", completionCache); ! } ! /** ! * @return a default completion state for globals (act token defined) ! */ ! public static ICompletionState getEmptyCompletionState(String token, IPythonNature nature, ICompletionCache completionCache) { ! return new CompletionState(-1, -1, token, nature, "", completionCache); ! } ! /** ! * @param line: start at 0 ! * @param col: start at 0 ! * @return a default completion state for globals (act token defined) ! */ ! public static ICompletionState getEmptyCompletionState(String token, IPythonNature nature, int line, int col, ! ICompletionCache completionCache) { ! return new CompletionState(line, col, token, nature, "", completionCache); ! } } --- 7,33 ---- public class CompletionStateFactory { ! /** ! * @return a default completion state for globals (empty act. token) ! */ ! public static ICompletionState getEmptyCompletionState(IPythonNature nature, ICompletionCache completionCache) { ! return new CompletionState(-1, -1, "", nature, "", completionCache); ! } ! /** ! * @return a default completion state for globals (act token defined) ! */ ! public static ICompletionState getEmptyCompletionState(String token, IPythonNature nature, ICompletionCache completionCache) { ! return new CompletionState(-1, -1, token, nature, "", completionCache); ! } ! /** ! * @param line: start at 0 ! * @param col: start at 0 ! * @return a default completion state for globals (act token defined) ! */ ! public static ICompletionState getEmptyCompletionState(String token, IPythonNature nature, int line, int col, ! ICompletionCache completionCache) { ! return new CompletionState(line, col, token, nature, "", completionCache); ! } } Index: CompletionStateWrapper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/CompletionStateWrapper.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CompletionStateWrapper.java 14 Jun 2008 22:14:55 -0000 1.8 --- CompletionStateWrapper.java 28 Sep 2008 12:45:45 -0000 1.9 *************** *** 169,176 **** public String toString() { FastStringBuffer buf = new FastStringBuffer(); ! buf.append("CompletionStateWrapper[ "); ! buf.append(this.activationToken); ! buf.append(" ]"); ! return buf.toString(); } --- 169,176 ---- public String toString() { FastStringBuffer buf = new FastStringBuffer(); ! buf.append("CompletionStateWrapper[ "); ! buf.append(this.activationToken); ! buf.append(" ]"); ! return buf.toString(); } Index: AbstractASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/AbstractASTManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractASTManager.java 31 Jul 2008 23:48:18 -0000 1.18 --- AbstractASTManager.java 28 Sep 2008 12:45:45 -0000 1.19 *************** *** 38,42 **** --- 38,44 ---- import org.python.pydev.editor.codecompletion.PyCodeCompletion; import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; + import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; import org.python.pydev.editor.codecompletion.revisited.modules.SourceToken; + import org.python.pydev.editor.codecompletion.revisited.visitors.GlobalModelVisitor; import org.python.pydev.parser.PyParser; import org.python.pydev.parser.jython.SimpleNode; *************** *** 47,63 **** [...974 lines suppressed...] ! //it with __init__ if it was the parent module ! if (mod.getName().length() <= parentModule.length()){ ! return new Tuple<IModule, String>(null, null); ! } } return new Tuple<IModule, String>((AbstractModule)mod, tok); --- 1289,1301 ---- if(dontSearchInit && currentModuleName != null && mod != null){ ! String parentModule = FullRepIterable.getParentModule(currentModuleName); ! //if we are looking for some relative import token, it can only match if the name found is not less than the parent ! //of the current module because of the way in that relative imports are meant to be written. ! ! //if it equal, it should not match either, as it was found as the parent module... this can not happen because it must find ! //it with __init__ if it was the parent module ! if (mod.getName().length() <= parentModule.length()){ ! return new Tuple<IModule, String>(null, null); ! } } return new Tuple<IModule, String>((AbstractModule)mod, tok); Index: PythonPathHelper.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/PythonPathHelper.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PythonPathHelper.java 13 Aug 2008 21:12:15 -0000 1.12 --- PythonPathHelper.java 28 Sep 2008 12:45:45 -0000 1.13 *************** *** 43,52 **** * This is a list of Files containg the pythonpath. */ ! private volatile List<String> pythonpath = new ArrayList<String>(); /** * Returns the default path given from the string. * @param str - * @param acceptPoint says if we can have dots in the str that has the path to be analyzed * @return a trimmed string with all the '\' converted to '/' */ --- 43,51 ---- * This is a list of Files containg the pythonpath. */ ! private final List<String> pythonpath = new ArrayList<String>(); /** * Returns the default path given from the string. * @param str * @return a trimmed string with all the '\' converted to '/' */ *************** *** 54,58 **** //this check is no longer done... could result in other problems // if(acceptPoint == false && str.indexOf(".") == 0){ //cannot start with a dot ! // throw new RuntimeException("The pythonpath can only have absolute paths (cannot start with '.', therefore, the path: '"+str+"' is not valid."); // } return StringUtils.replaceAllSlashes(str.trim()); --- 53,57 ---- //this check is no longer done... could result in other problems // if(acceptPoint == false && str.indexOf(".") == 0){ //cannot start with a dot ! // throw new RuntimeException("The pythonpath can only have absolute paths (cannot start with '.', therefore, the path: '"+str+"' is not valid."); // } return StringUtils.replaceAllSlashes(str.trim()); *************** *** 240,358 **** if (requireFileToExist && !moduleFile.exists()) { return null; ! } boolean isFile = moduleFile.isFile(); ! synchronized (pythonpath) { ! //go through our pythonpath and check the beggining ! for (Iterator<String> iter = pythonpath.iterator(); iter.hasNext();) { ! String element = getDefaultPathStr(iter.next()); ! if (fullPath.startsWith(element)) { ! int len = element.length(); ! String s = fullPath.substring(len); ! String sWithoutExtension = fullPathWithoutExtension.substring(len); ! if (s.startsWith("/")) { ! s = s.substring(1); ! } ! if (sWithoutExtension.startsWith("/")) { ! sWithoutExtension = sWithoutExtension.substring(1); ! } ! if (!isValidModule(sWithoutExtension)) { continue; } ! s = s.replaceAll("/", "."); ! if (s.indexOf(".") != -1) { ! File root = new File(element); ! if (root.exists() == false) { ! continue; ! } ! ! //this means that more than 1 module is specified, so, in order to get it, ! //we have to go and see if all the folders to that module have __init__.py in it... ! String[] modulesParts = StringUtils.dotSplit(s); ! if (modulesParts.length > 1 && isFile) { ! String[] t = new String[modulesParts.length - 1]; ! for (int i = 0; i < modulesParts.length - 1; i++) { ! t[i] = modulesParts[i]; ! } ! t[t.length - 1] = t[t.length - 1] + "." + modulesParts[modulesParts.length - 1]; ! modulesParts = t; } ! //here, in modulesParts, we have something like ! //["compiler", "ast.py"] - if file ! //["pywin","debugger"] - if folder ! // ! //root starts with the pythonpath folder that starts with the same ! //chars as the full path passed in. ! boolean isValid = true; ! for (int i = 0; i < modulesParts.length && root != null; i++) { ! root = new File(REF.getFileAbsolutePath(root) + "/" + modulesParts[i]); ! //check if file is in root... ! if (isValidFileMod(modulesParts[i])) { ! if (root.exists() && root.isFile()) { ! break; ! } ! } else { ! //this part is a folder part... check if it is a valid module (has init). ! if (isFileOrFolderWithInit(root) == false) { ! isValid = false; ! break; ! } ! //go on and check the next part. } } ! if (isValid) { ! if (isFile) { s = stripExtension(s); - } else if (moduleFile.exists() == false) { - //ok, it does not exist, so isFile will not work, let's just check if it is - //a valid module (ends with .py or .pyw) and if it is, strip the extension - if (isValidFileMod(s)) { - s = stripExtension(s); - } } - return s; - } - } else { - //simple part, we don't have to go into subfolders to check validity... - if (!isFile && moduleFile.isDirectory() && isFileOrFolderWithInit(moduleFile) == false) { - return null; } return s; } } - } ! //ok, it was not found in any existing way, so, if we don't require the file to exist, let's just do some simpler search and get the ! //first match (if any)... this is useful if the file we are looking for has just been deleted ! if (!requireFileToExist) { ! //we have to remove the last part (.py, .pyc, .pyw) ! for (String element : pythonpath) { ! element = getDefaultPathStr(element); ! if (fullPathWithoutExtension.startsWith(element)) { ! String s = fullPathWithoutExtension.substring(element.length()); ! if (s.startsWith("/")) { ! s = s.substring(1); ! } ! if (!isValidModule(s)) { ! continue; ! } ! s = s.replaceAll("/", "."); ! return s; } } } - return null; - } } --- 239,355 ---- if (requireFileToExist && !moduleFile.exists()) { return null; ! } boolean isFile = moduleFile.isFile(); ! List<String> pythonPathCopy = getPythonpath(); ! //go through our pythonpath and check the beggining ! for(String pathEntry : pythonPathCopy) { ! String element = getDefaultPathStr(pathEntry); ! if (fullPath.startsWith(element)) { ! int len = element.length(); ! String s = fullPath.substring(len); ! String sWithoutExtension = fullPathWithoutExtension.substring(len); ! if (s.startsWith("/")) { ! s = s.substring(1); ! } ! if (sWithoutExtension.startsWith("/")) { ! sWithoutExtension = sWithoutExtension.substring(1); ! } ! if (!isValidModule(sWithoutExtension)) { ! continue; ! } ! ! s = s.replaceAll("/", "."); ! if (s.indexOf(".") != -1) { ! File root = new File(element); ! if (root.exists() == false) { continue; } ! //this means that more than 1 module is specified, so, in order to get it, ! //we have to go and see if all the folders to that module have __init__.py in it... ! String[] modulesParts = StringUtils.dotSplit(s); ! if (modulesParts.length > 1 && isFile) { ! String[] t = new String[modulesParts.length - 1]; ! for (int i = 0; i < modulesParts.length - 1; i++) { ! t[i] = modulesParts[i]; } + t[t.length - 1] = t[t.length - 1] + "." + modulesParts[modulesParts.length - 1]; + modulesParts = t; + } ! //here, in modulesParts, we have something like ! //["compiler", "ast.py"] - if file ! //["pywin","debugger"] - if folder ! // ! //root starts with the pythonpath folder that starts with the same ! //chars as the full path passed in. ! boolean isValid = true; ! for (int i = 0; i < modulesParts.length && root != null; i++) { ! root = new File(REF.getFileAbsolutePath(root) + "/" + modulesParts[i]); ! //check if file is in root... ! if (isValidFileMod(modulesParts[i])) { ! if (root.exists() && root.isFile()) { ! break; ! } ! } else { ! //this part is a folder part... check if it is a valid module (has init). ! if (isFileOrFolderWithInit(root) == false) { ! isValid = false; ! break; } + //go on and check the next part. } ! } ! if (isValid) { ! if (isFile) { ! s = stripExtension(s); ! } else if (moduleFile.exists() == false) { ! //ok, it does not exist, so isFile will not work, let's just check if it is ! //a valid module (ends with .py or .pyw) and if it is, strip the extension ! if (isValidFileMod(s)) { s = stripExtension(s); } } return s; } + } else { + //simple part, we don't have to go into subfolders to check validity... + if (!isFile && moduleFile.isDirectory() && isFileOrFolderWithInit(moduleFile) == false) { + return null; + } + return s; } } ! ! } ! //ok, it was not found in any existing way, so, if we don't require the file to exist, let's just do some simpler search and get the ! //first match (if any)... this is useful if the file we are looking for has just been deleted ! if (!requireFileToExist) { ! //we have to remove the last part (.py, .pyc, .pyw) ! for (String element : pythonPathCopy) { ! element = getDefaultPathStr(element); ! if (fullPathWithoutExtension.startsWith(element)) { ! String s = fullPathWithoutExtension.substring(element.length()); ! if (s.startsWith("/")) { ! s = s.substring(1); } + if (!isValidModule(s)) { + continue; + } + s = s.replaceAll("/", "."); + return s; } } } + return null; } *************** *** 438,450 **** } public List<String> getPythonpath() { ! synchronized (pythonpath) { ! return new ArrayList<String>(pythonpath); ! } } /** ! * This method should traverse the pythonpath passed and return a structure with the info that could be collected ! * about the files that are related to python modules. */ public ModulesFoundStructure getModulesFoundStructure(IProgressMonitor monitor) { --- 435,453 ---- } + /** + * @return a list with the pythonpath, such that each element of the list is a part of + * the pythonpath + * @note returns a copy and not a reference to the internal list. + */ public List<String> getPythonpath() { ! synchronized (pythonpath) { ! return new ArrayList<String>(pythonpath); ! } } /** ! * This method should traverse the pythonpath passed and return a structure ! * with the info that could be collected about the files that are related to ! * python modules. */ public ModulesFoundStructure getModulesFoundStructure(IProgressMonitor monitor) { Index: ASTManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ASTManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ASTManager.java 13 Aug 2008 21:12:15 -0000 1.4 --- ASTManager.java 28 Sep 2008 12:45:45 -0000 1.5 *************** *** 39,46 **** public class ASTManager extends AbstractASTManager implements ICodeCompletionASTManager, Serializable{ ! ! /** ! * changed to 10L on release 1.0 ! */ protected static final long serialVersionUID = 10L; --- 39,46 ---- public class ASTManager extends AbstractASTManager implements ICodeCompletionASTManager, Serializable{ ! ! /** ! * changed to 10L on release 1.0 ! */ protected static final long serialVersionUID = 10L; *************** *** 70,80 **** * @return modules manager wrapped cast to the interface we expect. Creates it if needed. */ ! private synchronized IProjectModulesManager getProjectModulesManager() { ! if(modulesManager == null){ ! modulesManager = new ProjectModulesManager(); ! } ! return (IProjectModulesManager) modulesManager; ! } ! //----------------------- AUXILIARIES --- 70,80 ---- * @return modules manager wrapped cast to the interface we expect. Creates it if needed. */ ! private synchronized IProjectModulesManager getProjectModulesManager() { ! if(modulesManager == null){ ! modulesManager = new ProjectModulesManager(); ! } ! return (IProjectModulesManager) modulesManager; ! } ! //----------------------- AUXILIARIES *************** *** 121,125 **** return o; } catch (Exception e) { ! //ok, no need to log it. return null; } --- 121,125 ---- return o; } catch (Exception e) { ! //ok, no need to log it. return null; } Index: ModulesManagerCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ModulesManagerCache.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ModulesManagerCache.java 27 Oct 2007 12:22:05 -0000 1.3 --- ModulesManagerCache.java 28 Sep 2008 12:45:45 -0000 1.4 *************** *** 19,44 **** * The access to the cache is synchronized */ ! LRUCache<Tuple<ModulesKey, ModulesManager>, AbstractModule> internalCache; ! ModulesManagerCache() { internalCache = new LRUCache<Tuple<ModulesKey, ModulesManager>, AbstractModule>(MAX_NUMBER_OF_MODULES); ! } ! /** ! * Overriden so that if we do not find the key, we have the chance to create it. ! */ ! public AbstractModule getObj(ModulesKey key, ModulesManager modulesManager) { synchronized (modulesManager.modulesKeys) { ! Tuple<ModulesKey, ModulesManager> keyTuple = new Tuple<ModulesKey, ModulesManager>(key, modulesManager); AbstractModule obj = internalCache.getObj(keyTuple); ! if(obj == null && modulesManager.modulesKeys.containsKey(key)){ ! key = modulesManager.modulesKeys.get(key); //get the 'real' key ! obj = AbstractModule.createEmptyModule(key); internalCache.add(keyTuple, obj); ! } ! return obj; } ! } public void remove(ModulesKey key, ModulesManager modulesManager) { --- 19,44 ---- * The access to the cache is synchronized */ ! LRUCache<Tuple<ModulesKey, ModulesManager>, AbstractModule> internalCache; ! ModulesManagerCache() { internalCache = new LRUCache<Tuple<ModulesKey, ModulesManager>, AbstractModule>(MAX_NUMBER_OF_MODULES); ! } ! /** ! * Overriden so that if we do not find the key, we have the chance to create it. ! */ ! public AbstractModule getObj(ModulesKey key, ModulesManager modulesManager) { synchronized (modulesManager.modulesKeys) { ! Tuple<ModulesKey, ModulesManager> keyTuple = new Tuple<ModulesKey, ModulesManager>(key, modulesManager); AbstractModule obj = internalCache.getObj(keyTuple); ! if(obj == null && modulesManager.modulesKeys.containsKey(key)){ ! key = modulesManager.modulesKeys.get(key); //get the 'real' key ! obj = AbstractModule.createEmptyModule(key); internalCache.add(keyTuple, obj); ! } ! return obj; } ! } public void remove(ModulesKey key, ModulesManager modulesManager) { Index: SourceModuleProposal.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposal.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SourceModuleProposal.java 21 Aug 2008 20:56:29 -0000 1.3 --- SourceModuleProposal.java 28 Sep 2008 12:45:45 -0000 1.4 *************** *** 64,82 **** // // //if not preset, let's find it. ! // if(module.getFile() == null){ //its same ! // doc = dummy; ! // ! // }else{//another ! // IPath path = new Path(REF.getFileAbsolutePath(module.getFile())); ! // IEditorPart part = PyOpenEditor.doOpenEditor(path); ! // ! // if(part instanceof PyEdit){ ! // edit = (PyEdit) part; ! // doc = edit.getDocumentProvider().getDocument(edit.getEditorInput()); ! // }else{ ! // String contents = REF.getFileContents(module.getFile()); ! // doc = new Document(contents); ! // } ! // } // } // --- 64,82 ---- // // //if not preset, let's find it. ! // if(module.getFile() == null){ //its same ! // doc = dummy; ! // ! // }else{//another ! // IPath path = new Path(REF.getFileAbsolutePath(module.getFile())); ! // IEditorPart part = PyOpenEditor.doOpenEditor(path); ! // ! // if(part instanceof PyEdit){ ! // edit = (PyEdit) part; ! // doc = edit.getDocumentProvider().getDocument(edit.getEditorInput()); ! // }else{ ! // String contents = REF.getFileContents(module.getFile()); ! // doc = new Document(contents); ! // } ! // } // } // *************** *** 109,113 **** // // //return original... ! // return fReplacementOffset; // } // --- 109,113 ---- // // //return original... ! // return fReplacementOffset; // } // Index: AbstractToken.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/AbstractToken.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractToken.java 14 Jun 2008 22:14:55 -0000 1.5 --- AbstractToken.java 28 Sep 2008 12:45:45 -0000 1.6 *************** *** 215,225 **** */ public String getAsRelativeImport(String baseModule) { ! String completePath = getOriginalRep(true); ! ! return makeRelative(baseModule, completePath); } public String getAsAbsoluteImport() { ! return getAsRelativeImport("."); } --- 215,225 ---- */ public String getAsRelativeImport(String baseModule) { ! String completePath = getOriginalRep(true); ! ! return makeRelative(baseModule, completePath); } public String getAsAbsoluteImport() { ! return getAsRelativeImport("."); } *************** *** 234,257 **** public static String makeRelative(String baseModule, String completePath) { if(baseModule == null){ ! return completePath; ! } ! ! if(completePath.startsWith(baseModule)){ ! String relative = completePath.substring(baseModule.length()); ! baseModule = FullRepIterable.headAndTail(baseModule)[0]; ! ! if(baseModule.length() == 0){ ! if(relative.length() > 0 && relative.charAt(0) == '.'){ ! return relative.substring(1); ! } ! } ! if(relative.length() > 0 && relative.charAt(0) == '.'){ ! return baseModule+relative; ! }else{ ! return baseModule+'.'+relative; ! } ! } ! return completePath; } --- 234,257 ---- public static String makeRelative(String baseModule, String completePath) { if(baseModule == null){ ! return completePath; ! } ! ! if(completePath.startsWith(baseModule)){ ! String relative = completePath.substring(baseModule.length()); ! baseModule = FullRepIterable.headAndTail(baseModule)[0]; ! ! if(baseModule.length() == 0){ ! if(relative.length() > 0 && relative.charAt(0) == '.'){ ! return relative.substring(1); ! } ! } ! if(relative.length() > 0 && relative.charAt(0) == '.'){ ! return baseModule+relative; ! }else{ ! return baseModule+'.'+relative; ! } ! } ! return completePath; } *************** *** 272,281 **** */ public String getOriginalWithoutRep(){ ! int i = originalRep.length() - rep.length() -1; ! if(i > 0){ ! return originalRep.substring(0, i); ! }else{ ! return ""; ! } } --- 272,281 ---- */ public String getOriginalWithoutRep(){ ! int i = originalRep.length() - rep.length() -1; ! if(i > 0){ ! return originalRep.substring(0, i); ! }else{ ! return ""; ! } } *************** *** 293,297 **** public boolean isImportFrom() { ! return false; } --- 293,297 ---- public boolean isImportFrom() { ! return false; } *************** *** 308,312 **** */ public int[] getLineColEnd() { ! return new int[]{UNDEFINED, UNDEFINED}; } --- 308,312 ---- */ public int[] getLineColEnd() { ! return new int[]{UNDEFINED, UNDEFINED}; } Index: ProjectModulesManager.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/revisited/ProjectModulesManager.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ProjectModulesManager.java 13 Aug 2008 21:12:15 -0000 1.18 --- ProjectModulesManager.java 28 Sep 2008 12:45:45 -0000 1.19 *************** *** 20,24 **** import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; - import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; --- 20,23 ---- *************** *** 180,184 **** public ISystemModulesManager getSystemModulesManager(){ ! return getSystemModulesManager(null); } --- 179,183 ---- public ISystemModulesManager getSystemModulesManager(){ ! return getSystemModulesManager(null); } *************** *** 188,207 **** */ public ISystemModulesManager getSystemModulesManager(String defaultSelectedInterpreter){ ! if(nature == null){ ! PydevPlugin.log("Nature still not set"); ! return null; //still not set (initialization) ! } IInterpreterManager iMan = PydevPlugin.getInterpreterManager(nature); if(defaultSelectedInterpreter == null){ ! try { ! defaultSelectedInterpreter = iMan.getDefaultInterpreter(); ! } catch (NotConfiguredInterpreterException e) { ! return null; //not configured ! } } InterpreterInfo info = (InterpreterInfo) iMan.getInterpreterInfo(defaultSelectedInterpreter, new NullProgressMonitor()); if(info == null){ ! PydevPlugin.log("Info still not set"); ! return null; //may happen during initialization } return info.getModulesManager(); --- 187,206 ---- */ public ISystemModulesManager getSystemModulesManager(String defaultSelectedInterpreter){ ! if(nature == null){ ! PydevPlugin.log("Nature still not set"); ! return null; //still not set (initialization) ! } IInterpreterManager iMan = PydevPlugin.getInterpreterManager(nature); if(defaultSelectedInterpreter == null){ ! try { ! defaultSelectedInterpreter = iMan.getDefaultInterpreter(); ! } catch (NotConfiguredInterpreterException e) { ! return null; //not configured ! } } InterpreterInfo info = (InterpreterInfo) iMan.getInterpreterInfo(defaultSelectedInterpreter, new NullProgressMonitor()); if(info == null){ ! PydevPlugin.log("Info still not set"); ! return null; //may happen during initialization } return info.getModulesManager(); *************** *** 229,238 **** @Override public SortedMap<ModulesKey, ModulesKey> getAllModulesStartingWith(String strStartingWith) { ! SortedMap<ModulesKey, ModulesKey> ret = new TreeMap<ModulesKey, ModulesKey>(); ! IModulesManager[] managersInvolved = this.getManagersInvolved(true); ! for (int i = 0; i < managersInvolved.length; i++) { ! ret.putAll(managersInvolved[i].getAllDirectModulesStartingWith(strStartingWith)); ! } ! return ret; } --- 228,237 ---- @Override public SortedMap<ModulesKey, ModulesKey> getAllModulesStartingWith(String strStartingWith) { ! SortedMap<ModulesKey, ModulesKey> ret = new TreeMap<ModulesKey, ModulesKey>(); ! IModulesManager[] managersInvolved = this.getManagersInvolved(true); ! for (int i = 0; i < managersInvolved.length; i++) { ! ret.putAll(managersInvolved[i].getAllDirectModulesStartingWith(strStartingWith)); ! } ! return ret; } *************** *** 249,253 **** */ public IModule getRelativeModule(String name, IPythonNature nature) { ! return super.getModule(false, name, nature, true); //cannot be a compiled module } --- 248,252 ---- */ public IModule getRelativeModule(String name, IPythonNature nature) { ! return super.getModule(false, name, nature, true); //cannot be a compiled module } *************** *** 320,326 **** protected String getResolveModuleErr(IResource member) { ! return "Unable to find the path "+member+" in the project were it\n" + "is added as a source folder for pydev (project: "+project.getName()+")"; ! } /** --- 319,325 ---- protected String getResolveModuleErr(IResource member) { ! return "Unable to find the path "+member+" in the project were it\n" + "is added as a source folder for pydev (project: "+project.getName()+")"; ! } /** *************** *** 381,385 **** public String[] getBuiltins() { ! return getBuiltins(null); } --- 380,384 ---- public String[] getBuiltins() { ! return getBuiltins(null); } *************** *** 406,427 **** */ private synchronized IModulesManager[] getManagers(boolean checkSystemManager, boolean referenced) { ! if(this.completionCache != null){ ! IModulesManager[] ret = this.completionCache.getManagers(referenced); ! if(ret != null){ ! return ret; ! } ! } ArrayList<IModulesManager> list = new ArrayList<IModulesManager>(); ISystemModulesManager systemModulesManager = getSystemModulesManager(null); if(systemModulesManager == null){ ! //may happen in initialization ! // PydevPlugin.log("System modules manager still not available (still initializing or not set)."); ! return new IModulesManager[]{}; } //get the projects 1st if(project != null){ ! HashSet<IProject> projs = new HashSet<IProject>(); ! getProjectsRecursively(project, referenced, projs); addModuleManagers(list, projs); } --- 405,426 ---- */ private synchronized IModulesManager[] getManagers(boolean checkSystemManager, boolean referenced) { ! if(this.completionCache != null){ ! IModulesManager[] ret = this.completionCache.getManagers(referenced); ! if(ret != null){ ! return ret; ! } ! } ArrayList<IModulesManager> list = new ArrayList<IModulesManager>(); ISystemModulesManager systemModulesManager = getSystemModulesManager(null); if(systemModulesManager == null){ ! //may happen in initialization ! // PydevPlugin.log("System modules manager still not available (still initializing or not set)."); ! return new IModulesManager[]{}; } //get the projects 1st if(project != null){ ! HashSet<IProject> projs = new HashSet<IProject>(); ! getProjectsRecursively(project, referenced, projs); addModuleManagers(list, projs); } *************** *** 437,441 **** IModulesManager[] ret = (IModulesManager[]) list.toArray(new IModulesManager[list.size()]); if(this.completionCache != null){ ! this.completionCache.setManagers(ret, referenced); } return ret; --- 436,440 ---- IModulesManager[] ret = (IModulesManager[]) list.toArray(new IModulesManager[list.size()]); if(this.completionCache != null){ ! this.completionCache.setManagers(ret, referenced); } return ret; *************** *** 448,479 **** * @param memo (out) this is the place where all the projects will e available. */ ! public static void getProjectsRecursively(IProject project, boolean referenced, HashSet<IProject> memo) { ! IProject[] projects = null; ! try { ! if(referenced){ ! projects = project.getReferencedProjects(); ! }else{ ! projects = project.getReferencingProjects(); ! } ! } catch (CoreException e) { ! //ignore (it's closed) ! } ! ! ! HashSet<IProject> newFound = new HashSet<IProject>(); ! ! if(projects != null){ ! for (IProject p : projects) { ! if(!memo.contains(p)){ ! memo.add(p); ! newFound.add(p); ! } ! } ! } ! ! for (IProject p : newFound) { ! getProjectsRecursively(p, referenced, memo); ! } ! } --- 447,478 ---- * @param memo (out) this is the place where all the projects will e available. */ ! public static void getProjectsRecursively(IProject project, boolean referenced, HashSet<IProject> memo) { ! IProject[] projects = null; ! try { ! if(referenced){ ! projects = project.getReferencedProjects(); ! }else{ ! projects = project.getReferencingProjects(); ! } ! } catch (CoreException e) { ! //ignore (it's closed) ! } ! ! ! HashSet<IProject> newFound = new HashSet<IProject>(); ! ! if(projects != null){ ! for (IProject p : projects) { ! if(!memo.contains(p)){ ! memo.add(p); ! newFound.add(p); ! } ! } ! } ! ! for (IProject p : newFound) { ! getProjectsRecursively(p, referenced, memo); ! } ! } *************** *** 483,503 **** */ private void addModuleManagers(ArrayList<IModulesManager> list, Collection<IProject> projects) { ! for(IProject project:projects){ ! PythonNature nature = PythonNature.getPythonNature(project); ! if(nature!=null){ ! ICodeCompletionASTManager otherProjectAstManager = nature.getAstManager(); ! if(otherProjectAstManager != null){ ! IModulesManager projectModulesManager = otherProjectAstManager.getModulesManager(); ! if(projectModulesManager != null){ ! list.add((IModulesManager) projectModulesManager); ! } ! }else{ ! Log.log(IStatus.WARNING, "No ast manager configured for :"+project.getName(), null); ! } } - IModulesManager javaModulesManagerForProject = JavaProjectModulesManagerCreator.createJavaProjectModulesManagerIfPossible(project); - if(javaModulesManagerForProject != null){ - list.add(javaModulesManagerForProject); - } } } --- 482,502 ---- */ private void addModuleManagers(ArrayList<IModulesManager> list, Collection<IProject> projects) { ! for(IProject project:projects){ ! PythonNature nature = PythonNature.getPythonNature(project); ! if(nature!=null){ ! ICodeCompletionASTManager otherProjectAstManager = nature.getAstManager(); ! if(otherProjectAstManager != null){ ! IModulesManager projectModulesManager = otherProjectAstManager.getModulesManager(); ! if(projectModulesManager != null){ ! list.add((IModulesManager) projectModulesManager); ! } ! }else{ ! Log.log(IStatus.WARNING, "No ast manager configured for :"+project.getName(), null); ! } ! } ! IModulesManager javaModulesManagerForProject = JavaProjectModulesManagerCreator.createJavaProjectModulesManagerIfPossible(project); ! if(javaModulesManagerForProject != null){ ! list.add(javaModulesManagerForProject); } } } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:50:24
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313 Modified Files: plugin.xml Changes.txt Added Files: pydev_formatter_preferences.xml Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces --- NEW FILE: pydev_formatter_preferences.xml --- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <profiles version="11"> <profile kind="CodeFormatterProfile" name="Pydev" version="11"> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> <setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/> <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/> <setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/> <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> </profile> </profiles> Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.416 retrieving revision 1.417 diff -C2 -d -r1.416 -r1.417 *** Changes.txt 21 Aug 2008 20:56:28 -0000 1.416 --- Changes.txt 28 Sep 2008 12:45:46 -0000 1.417 *************** *** 1,2 **** --- 1,22 ---- + after 1.3.20 + + Pydev Extensions + <ul> + <li><strong>Code-analysis</strong>: only done when the file has really changed</li> + <li><strong>Code-analysis</strong>: only on active editor</li> + </ul> + + + 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> + after 1.3.19 *************** *** 5,8 **** --- 25,29 ---- <ul> <li><strong>Code Analysis</strong>: Show error if using token not defined in __all__ in wild import.</li> + <li><strong>Search</strong>: Working with eclipse 3.4.</li> </ul> *************** *** 14,25 **** <li><strong>Pydev debugger</strong>: Breakpoint properties accept new lines and tabs</li> <li><strong>Pydev debugger</strong>: Workaround for python bug when filenames don't have absolute paths correctly generated</li> ! <li><strong>Pydev code-completion</strong>Wild import will only show tokens defined in __all__ (if it's available)</li> <li><strong>Interactive console</strong>: Fixed problem when more attempts to connect were needed</li> <li><strong>Interactive console</strong>: Fixed console integration problem with other plugins because of interfaces not properly implemented</li> ! <li><strong>Incremental find</strong>: backspace works correctly</li> <li><strong>Launch icons</strong>: Transparent background (thanks to Radim Kubacki)</li> <li><strong>Code Formatter</strong>: Exponentials handled correctly</li> <li><strong>Launching</strong>: Unit-test and code-coverage may launch multiple folders/files at once</li> <li><strong>Code coverage</strong>: Number format exception no longer given when trying to show lines not executed in the editor and all lines are executed</li> </ul> --- 35,47 ---- <li><strong>Pydev debugger</strong>: Breakpoint properties accept new lines and tabs</li> <li><strong>Pydev debugger</strong>: Workaround for python bug when filenames don't have absolute paths correctly generated</li> ! <li><strong>Pydev code-completion</strong>: Wild import will only show tokens defined in __all__ (if it's available)</li> <li><strong>Interactive console</strong>: Fixed problem when more attempts to connect were needed</li> <li><strong>Interactive console</strong>: Fixed console integration problem with other plugins because of interfaces not properly implemented</li> ! <li><strong>Incremental find</strong>: Backspace works correctly</li> <li><strong>Launch icons</strong>: Transparent background (thanks to Radim Kubacki)</li> <li><strong>Code Formatter</strong>: Exponentials handled correctly</li> <li><strong>Launching</strong>: Unit-test and code-coverage may launch multiple folders/files at once</li> <li><strong>Code coverage</strong>: Number format exception no longer given when trying to show lines not executed in the editor and all lines are executed</li> + <li><strong>Auto-indent</strong>: Fixed issue when using tabs which could result in spaces being added</li> </ul> Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.209 retrieving revision 1.210 diff -C2 -d -r1.209 -r1.210 *** plugin.xml 13 Aug 2008 21:12:15 -0000 1.209 --- plugin.xml 28 Sep 2008 12:45:46 -0000 1.210 *************** *** 1388,1391 **** --- 1388,1394 ---- </extension> + <extension point="org.python.pydev.pydev_pyedit_listener"> + <pyedit_listener_participant class="org.python.pydev.builder.syntaxchecker.ClearSyntaxMarkersPyeditListener"/> + </extension> </plugin> |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:49:22
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/autoedit Modified Files: AbstractIndentPrefs.java DefaultIndentPrefs.java PyAutoIndentStrategy.java IIndentPrefs.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: PyAutoIndentStrategy.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/PyAutoIndentStrategy.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** PyAutoIndentStrategy.java 21 Aug 2008 18:25:18 -0000 1.72 --- PyAutoIndentStrategy.java 28 Sep 2008 12:45:49 -0000 1.73 *************** *** 60,64 **** private Tuple<String,Boolean> autoIndentNewline(IDocument document, int length, String text, int offset) throws BadLocationException { ! if (offset > 0) { PySelection selection = new PySelection(document, offset); --- 60,64 ---- private Tuple<String,Boolean> autoIndentNewline(IDocument document, int length, String text, int offset) throws BadLocationException { ! if (offset > 0) { PySelection selection = new PySelection(document, offset); *************** *** 84,106 **** //we have to check if smartIndent is -1 because otherwise we are inside some bracket if(smartIndent == -1 && DocUtils.isClosingPeer(lastChar)){ ! //ok, not inside brackets PythonPairMatcher matcher = new PythonPairMatcher(DocUtils.BRACKETS); int bracketOffset = selection.getLineOffset()+curr; IRegion region = matcher.match(document, bracketOffset+1); if(region != null){ ! if(!PySelection.endsInSameLine(document, region)){ ! //we might not have a match if there is an error in the program... ! //e.g. a single ')' without its counterpart. ! int openingBracketLine = document.getLineOfOffset(region.getOffset()); ! String openingBracketLineStr = PySelection.getLine(document, openingBracketLine); ! int first = PySelection.getFirstCharPosition(openingBracketLineStr); ! String initial = getCharsBeforeNewLine(text); ! text = initial + openingBracketLineStr.substring(0, first); ! return new Tuple<String, Boolean>(text, isInsidePar); ! } } } else if (smartIndent == -1 && lastChar == ':') { //we have to check if smartIndent is -1 because otherwise we are in a dict ! //ok, not inside brackets text = indentBasedOnStartingScope(text, selection, false); return new Tuple<String, Boolean>(text, isInsidePar); --- 84,106 ---- //we have to check if smartIndent is -1 because otherwise we are inside some bracket if(smartIndent == -1 && DocUtils.isClosingPeer(lastChar)){ ! //ok, not inside brackets PythonPairMatcher matcher = new PythonPairMatcher(DocUtils.BRACKETS); int bracketOffset = selection.getLineOffset()+curr; IRegion region = matcher.match(document, bracketOffset+1); if(region != null){ ! if(!PySelection.endsInSameLine(document, region)){ ! //we might not have a match if there is an error in the program... ! //e.g. a single ')' without its counterpart. ! int openingBracketLine = document.getLineOfOffset(region.getOffset()); ! String openingBracketLineStr = PySelection.getLine(document, openingBracketLine); ! int first = PySelection.getFirstCharPosition(openingBracketLineStr); ! String initial = getCharsBeforeNewLine(text); ! text = initial + openingBracketLineStr.substring(0, first); ! return new Tuple<String, Boolean>(text, isInsidePar); ! } } } else if (smartIndent == -1 && lastChar == ':') { //we have to check if smartIndent is -1 because otherwise we are in a dict ! //ok, not inside brackets text = indentBasedOnStartingScope(text, selection, false); return new Tuple<String, Boolean>(text, isInsidePar); *************** *** 139,256 **** * @return the text for the indent */ ! private String indentBasedOnStartingScope(String text, PySelection selection, boolean checkForLowestBeforeNewScope) { ! Tuple3<String,String, String> previousIfLine = selection.getPreviousLineThatStartsScope(); ! if(previousIfLine != null){ ! String initial = getCharsBeforeNewLine(text); ! ! if(previousIfLine.o2 == null){ //no dedent was found ! String indent = PySelection.getIndentationFromLine(previousIfLine.o1); ! if(checkForLowestBeforeNewScope && previousIfLine.o3 != null){ ! indent = PySelection.getIndentationFromLine(previousIfLine.o3); text = initial + indent; }else{ ! text = initial + indent + prefs.getIndentationString(); } ! ! }else{ //some dedent was found ! String indent = PySelection.getIndentationFromLine(previousIfLine.o2); ! String indentationString = prefs.getIndentationString(); ! ! final int i = indent.length() - indentationString.length(); ! if (i > 0 && indent.length() > i){ ! text = (initial+indent).substring(0, i+1); ! }else{ ! text = initial; // this can happen if we found a dedent that is 1 level deep ! } ! } ! ! } ! return text; ! } ! /** ! * Returns the first offset greater than <code>offset</code> and smaller than ! * <code>end</code> whose character is not a space or tab character. If no such ! * offset is found, <code>end</code> is returned. ! * ! * @param document the document to search in ! * @param offset the offset at which searching start ! * @param end the offset at which searching stops ! * @return the offset in the specified range whose character is not a space or tab ! * @exception BadLocationException if position is an invalid range in the given document ! */ ! private int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException { ! while (offset < end) { ! char c= document.getChar(offset); ! if (c != ' ' && c != '\t') { ! return offset; ! } ! offset++; ! } ! return end; ! } ! private void autoIndentSameAsPrevious(IDocument d, DocumentCommand c) { ! String txt = autoIndentSameAsPrevious(d, c.offset, c.text, true); ! if(txt != null){ ! c.text = txt; ! } ! } ! /** ! * Copies the indentation of the previous line. ! * ! * @param d the document to work on ! * @param text the string that should added to the start of the returned string ! * @param considerEmptyLines whether we should consider empty lines in this function ! * @param c the command to deal with ! * ! * @return a string with text+ the indentation found in the previous line (or previous non-empty line). ! */ ! private String autoIndentSameAsPrevious(IDocument d, int offset, String text, boolean considerEmptyLines) { ! if (offset == -1 || d.getLength() == 0) ! return null; ! try { ! // find start of line ! IRegion info= d.getLineInformationOfOffset(offset); ! String line = d.get(info.getOffset(), info.getLength()); ! ! if(!considerEmptyLines){ ! int currLine = d.getLineOfOffset(offset); ! while(PySelection.containsOnlyWhitespaces(line)){ ! currLine--; ! if(currLine <= 0){ ! break; ! } ! info= d.getLineInformation(currLine); ! line = d.get(info.getOffset(), info.getLength()); ! } ! } ! ! int start= info.getOffset(); ! // find white spaces ! int end= findEndOfWhiteSpace(d, start, offset); ! FastStringBuffer buf= new FastStringBuffer(text, end-start+1); ! if (end > start) { ! // append to input ! buf.append(d.get(start, end - start)); ! } ! return buf.toString(); ! } catch (BadLocationException excp) { ! // stop work ! return null; ! } ! } /** --- 139,256 ---- * @return the text for the indent */ ! private String indentBasedOnStartingScope(String text, PySelection selection, boolean checkForLowestBeforeNewScope) { ! Tuple3<String,String, String> previousIfLine = selection.getPreviousLineThatStartsScope(); ! if(previousIfLine != null){ ! String initial = getCharsBeforeNewLine(text); ! ! if(previousIfLine.o2 == null){ //no dedent was found ! String indent = PySelection.getIndentationFromLine(previousIfLine.o1); ! if(checkForLowestBeforeNewScope && previousIfLine.o3 != null){ ! indent = PySelection.getIndentationFromLine(previousIfLine.o3); text = initial + indent; }else{ ! text = initial + indent + prefs.getIndentationString(); } ! ! }else{ //some dedent was found ! String indent = PySelection.getIndentationFromLine(previousIfLine.o2); ! String indentationString = prefs.getIndentationString(); ! ! final int i = indent.length() - indentationString.length(); ! if (i > 0 && indent.length() > i){ ! text = (initial+indent).substring(0, i+1); ! }else{ ! text = initial; // this can happen if we found a dedent that is 1 level deep ! } ! } ! ! } ! return text; ! } ! /** ! * Returns the first offset greater than <code>offset</code> and smaller than ! * <code>end</code> whose character is not a space or tab character. If no such ! * offset is found, <code>end</code> is returned. ! * ! * @param document the document to search in ! * @param offset the offset at which searching start ! * @param end the offset at which searching stops ! * @return the offset in the specified range whose character is not a space or tab ! * @exception BadLocationException if position is an invalid range in the given document ! */ ! private int findEndOfWhiteSpace(IDocument document, int offset, int end) throws BadLocationException { ! while (offset < end) { ! char c= document.getChar(offset); ! if (c != ' ' && c != '\t') { ! return offset; ! } ! offset++; ! } ! return end; ! } ! private void autoIndentSameAsPrevious(IDocument d, DocumentCommand c) { ! String txt = autoIndentSameAsPrevious(d, c.offset, c.text, true); ! if(txt != null){ ! c.text = txt; ! } ! } ! /** ! * Copies the indentation of the previous line. ! * ! * @param d the document to work on ! * @param text the string that should added to the start of the returned string ! * @param considerEmptyLines whether we should consider empty lines in this function ! * @param c the command to deal with ! * ! * @return a string with text+ the indentation found in the previous line (or previous non-empty line). ! */ ! private String autoIndentSameAsPrevious(IDocument d, int offset, String text, boolean considerEmptyLines) { ! if (offset == -1 || d.getLength() == 0) ! return null; ! try { ! // find start of line ! IRegion info= d.getLineInformationOfOffset(offset); ! String line = d.get(info.getOffset(), info.getLength()); ! ! if(!considerEmptyLines){ ! int currLine = d.getLineOfOffset(offset); ! while(PySelection.containsOnlyWhitespaces(line)){ ! currLine--; ! if(currLine <= 0){ ! break; ! } ! info= d.getLineInformation(currLine); ! line = d.get(info.getOffset(), info.getLength()); ! } ! } ! ! int start= info.getOffset(); ! // find white spaces ! int end= findEndOfWhiteSpace(d, start, offset); ! FastStringBuffer buf= new FastStringBuffer(text, end-start+1); ! if (end > start) { ! // append to input ! buf.append(d.get(start, end - start)); ! } ! return buf.toString(); ! } catch (BadLocationException excp) { ! // stop work ! return null; ! } ! } /** *************** *** 287,301 **** public void customizeDocumentCommand(IDocument document, DocumentCommand command) { // super idents newlines the same amount as the previous line ! final boolean isNewLine = isNewLineText(document, command.length, command.text); ! String contentType = ParsingUtils.getContentType(document, command.offset); ! if(!contentType.equals(ParsingUtils.PY_DEFAULT)){ //the indentation is only valid for things in the code (comments should not be indented). //(that is, if it is not a new line... in this case, it may have to be indented) if(!isNewLine){ ! //we have to take care about tabs anyway ! getIndentPrefs().convertToStd(document, command); return; }else{ --- 287,301 ---- public void customizeDocumentCommand(IDocument document, DocumentCommand command) { // super idents newlines the same amount as the previous line ! final boolean isNewLine = isNewLineText(document, command.length, command.text); ! String contentType = ParsingUtils.getContentType(document, command.offset); ! if(!contentType.equals(ParsingUtils.PY_DEFAULT)){ //the indentation is only valid for things in the code (comments should not be indented). //(that is, if it is not a new line... in this case, it may have to be indented) if(!isNewLine){ ! //we have to take care about tabs anyway ! getIndentPrefs().convertToStd(document, command); return; }else{ *************** *** 310,349 **** try { ! if (isNewLine) { ! customizeNewLine(document, command); ! }else if(command.text.equals("\t")){ ! PySelection ps = new PySelection(document, command.offset); ! //it is a tab ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! int currSize = lineContentsToCursor.length(); ! int cursorLine = ps.getCursorLine(); ! if(cursorLine > 0){ ! //this is to know which would be expected if it was a new line in the previous line ! //(so that we know the 'expected' output ! IRegion prevLineInfo = document.getLineInformation(cursorLine-1); ! int prevLineEndOffset = prevLineInfo.getOffset()+prevLineInfo.getLength(); ! String prevExpectedIndent = autoIndentSameAsPrevious(document, prevLineEndOffset, "\n", false); String txt = prevExpectedIndent; ! Tuple<String, Boolean> prevLineTup = autoIndentNewline(document, 0, txt, prevLineEndOffset); txt = prevLineTup.o1; ! txt = txt.substring(1);//remove the newline prevExpectedIndent = prevExpectedIndent.substring(1); ! if (txt.length() > 0){ ! //now, we should not apply that indent if we are already at the 'max' indent in this line ! //(or better: we should go to that max if it would pass it) ! int sizeExpected = txt.length(); ! int sizeApplied = currSize + sizeExpected; ! if(currSize >= sizeExpected){ ! //ok, we already passed what we expected from the indentation, so, let's indent ! //to the next 'expected' position... ! ! boolean applied = false; ! //handle within parenthesis if(prevLineTup.o2){ ! int len = sizeApplied-sizeExpected; if(prevExpectedIndent.length() > len){ command.text = prevExpectedIndent.substring(len); --- 310,349 ---- try { ! if (isNewLine) { ! customizeNewLine(document, command); ! }else if(command.text.equals("\t")){ ! PySelection ps = new PySelection(document, command.offset); ! //it is a tab ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! int currSize = lineContentsToCursor.length(); ! int cursorLine = ps.getCursorLine(); ! if(cursorLine > 0){ ! //this is to know which would be expected if it was a new line in the previous line ! //(so that we know the 'expected' output ! IRegion prevLineInfo = document.getLineInformation(cursorLine-1); ! int prevLineEndOffset = prevLineInfo.getOffset()+prevLineInfo.getLength(); ! String prevExpectedIndent = autoIndentSameAsPrevious(document, prevLineEndOffset, "\n", false); String txt = prevExpectedIndent; ! Tuple<String, Boolean> prevLineTup = autoIndentNewline(document, 0, txt, prevLineEndOffset); txt = prevLineTup.o1; ! txt = txt.substring(1);//remove the newline prevExpectedIndent = prevExpectedIndent.substring(1); ! if (txt.length() > 0){ ! //now, we should not apply that indent if we are already at the 'max' indent in this line ! //(or better: we should go to that max if it would pass it) ! int sizeExpected = txt.length(); ! int sizeApplied = currSize + sizeExpected; ! if(currSize >= sizeExpected){ ! //ok, we already passed what we expected from the indentation, so, let's indent ! //to the next 'expected' position... ! ! boolean applied = false; ! //handle within parenthesis if(prevLineTup.o2){ ! int len = sizeApplied-sizeExpected; if(prevExpectedIndent.length() > len){ command.text = prevExpectedIndent.substring(len); *************** *** 353,375 **** if(!applied){ ! applyDefaultForTab(command, currSize); } ! }else if(sizeExpected == sizeApplied){ if(command.length == 0){ ! ps.deleteSpacesAfter(command.offset); } ! command.text = txt; ! }else if(sizeApplied > sizeExpected){ ! ps.deleteSpacesAfter(command.offset); ! command.text = txt.substring(0, sizeExpected - currSize); ! } ! }else{ ! applyDefaultForTab(command, currSize); ! } ! ! }else{ //cursorLine == 0 ! applyDefaultForTab(command, currSize); ! } } --- 353,375 ---- if(!applied){ ! applyDefaultForTab(command, currSize); } ! }else if(sizeExpected == sizeApplied){ if(command.length == 0){ ! ps.deleteSpacesAfter(command.offset); } ! command.text = txt; ! }else if(sizeApplied > sizeExpected){ ! ps.deleteSpacesAfter(command.offset); ! command.text = txt.substring(0, sizeExpected - currSize); ! } ! }else{ ! applyDefaultForTab(command, currSize); ! } ! ! }else{ //cursorLine == 0 ! applyDefaultForTab(command, currSize); ! } } *************** *** 377,399 **** ! if (prefs.getAutoParentesis() && (command.text.equals("[") || command.text.equals("{")) ) { ! PySelection ps = new PySelection(document, command.offset); ! char c = command.text.charAt(0); ! if (shouldClose(ps, c)) { ! command.shiftsCaret = false; command.text = c+""+DocUtils.getPeer(c); command.caretOffset = command.offset+1; ! } ! ! }else if (command.text.equals("(")) { ! /* ! * Now, let's also check if we are in an 'elif ' that must be dedented in the doc ! */ ! autoDedentElif(document, command); ! customizeParenthesis(document, command); } ! else if (command.text.equals(":")) { /* --- 377,399 ---- ! if (prefs.getAutoParentesis() && (command.text.equals("[") || command.text.equals("{")) ) { ! PySelection ps = new PySelection(document, command.offset); ! char c = command.text.charAt(0); ! if (shouldClose(ps, c)) { ! command.shiftsCaret = false; command.text = c+""+DocUtils.getPeer(c); command.caretOffset = command.offset+1; ! } ! ! }else if (command.text.equals("(")) { ! /* ! * Now, let's also check if we are in an 'elif ' that must be dedented in the doc ! */ ! autoDedentElif(document, command); ! customizeParenthesis(document, command); } ! else if (command.text.equals(":")) { /* *************** *** 422,449 **** */ else if (command.text.equals(" ")) { ! if( prefs.getAutoWriteImport()){ ! PySelection ps = new PySelection(document, command.offset); ! String completeLine = ps.getLineWithoutCommentsOrLiterals(); ! String lineToCursor = ps.getLineContentsToCursor().trim(); ! String lineContentsFromCursor = ps.getLineContentsFromCursor(); ! ! if( completeLine.indexOf(" import ") == -1 && ! StringUtils.leftTrim(completeLine).startsWith("from ")&& ! !completeLine.startsWith("import ")&& ! !completeLine.endsWith(" import") && ! !lineContentsFromCursor.startsWith("import")){ ! ! String importsTipperStr = ImportsSelection.getImportsTipperStr(lineToCursor, false).importsTipperStr; ! if(importsTipperStr.length() > 0){ ! command.text = " import "; ! } ! } ! } ! ! ! /* ! * Now, let's also check if we are in an 'elif ' that must be dedented in the doc ! */ ! autoDedentElif(document, command); } --- 422,449 ---- */ else if (command.text.equals(" ")) { ! if( prefs.getAutoWriteImport()){ ! PySelection ps = new PySelection(document, command.offset); ! String completeLine = ps.getLineWithoutCommentsOrLiterals(); ! String lineToCursor = ps.getLineContentsToCursor().trim(); ! String lineContentsFromCursor = ps.getLineContentsFromCursor(); ! ! if( completeLine.indexOf(" import ") == -1 && ! StringUtils.leftTrim(completeLine).startsWith("from ")&& ! !completeLine.startsWith("import ")&& ! !completeLine.endsWith(" import") && ! !lineContentsFromCursor.startsWith("import")){ ! ! String importsTipperStr = ImportsSelection.getImportsTipperStr(lineToCursor, false).importsTipperStr; ! if(importsTipperStr.length() > 0){ ! command.text = " import "; ! } ! } ! } ! ! ! /* ! * Now, let's also check if we are in an 'elif ' that must be dedented in the doc ! */ ! autoDedentElif(document, command); } *************** *** 487,491 **** public void customizeParenthesis(IDocument document, DocumentCommand command) throws BadLocationException { if(prefs.getAutoParentesis()){ ! PySelection ps = new PySelection(document, command.offset); String line = ps.getLine(); --- 487,491 ---- public void customizeParenthesis(IDocument document, DocumentCommand command) throws BadLocationException { if(prefs.getAutoParentesis()){ ! PySelection ps = new PySelection(document, command.offset); String line = ps.getLine(); *************** *** 557,570 **** PySelection selection = new PySelection(document, command.offset); if(selection.getCursorLineContents().trim().length() > 0){ ! command.text = autoIndentNewline(document, command.length, command.text, command.offset).o1; ! if(PySelection.containsOnlyWhitespaces(selection.getLineContentsToCursor())){ ! command.caretOffset = command.offset + selection.countSpacesAfter(command.offset); ! } } }else{ ! PySelection selection = new PySelection(document, command.offset); ! if(selection.getLineContentsToCursor().trim().endsWith(":")){ ! command.text += prefs.getIndentationString(); ! } } } --- 557,570 ---- PySelection selection = new PySelection(document, command.offset); if(selection.getCursorLineContents().trim().length() > 0){ ! command.text = autoIndentNewline(document, command.length, command.text, command.offset).o1; ! if(PySelection.containsOnlyWhitespaces(selection.getLineContentsToCursor())){ ! command.caretOffset = command.offset + selection.countSpacesAfter(command.offset); ! } } }else{ ! PySelection selection = new PySelection(document, command.offset); ! if(selection.getLineContentsToCursor().trim().endsWith(":")){ ! command.text += prefs.getIndentationString(); ! } } } *************** *** 575,590 **** * @param lineContentsToCursorLen the current cursor position at the current line */ ! private void applyDefaultForTab(DocumentCommand command, int lineContentsToCursorLen) { ! IIndentPrefs prefs = getIndentPrefs(); ! if(prefs.getUseSpaces()){ ! int tabWidth = getIndentPrefs().getTabWidth(); ! ! int mod = (lineContentsToCursorLen+tabWidth) % tabWidth; ! command.text = DocUtils.createSpaceString(tabWidth-mod); ! }else{ ! //do nothing (a tab is already a tab) ! } ! ! } /** --- 575,590 ---- * @param lineContentsToCursorLen the current cursor position at the current line */ ! private void applyDefaultForTab(DocumentCommand command, int lineContentsToCursorLen) { ! IIndentPrefs prefs = getIndentPrefs(); ! if(prefs.getUseSpaces()){ ! int tabWidth = getIndentPrefs().getTabWidth(); ! ! int mod = (lineContentsToCursorLen+tabWidth) % tabWidth; ! command.text = DocUtils.createSpaceString(tabWidth-mod); ! }else{ ! //do nothing (a tab is already a tab) ! } ! ! } /** *************** *** 637,641 **** */ public Tuple<String, Integer> autoDedentElif(IDocument document, DocumentCommand command) throws BadLocationException { ! return autoDedentAfterColon(document, command, "elif", PySelection.TOKENS_BEFORE_ELSE); } --- 637,641 ---- */ public Tuple<String, Integer> autoDedentElif(IDocument document, DocumentCommand command) throws BadLocationException { ! return autoDedentAfterColon(document, command, "elif", PySelection.TOKENS_BEFORE_ELSE); } *************** *** 768,783 **** try{ ! char peer = DocUtils.getPeer(c); ! ! FastStringBuffer doc = new FastStringBuffer(document.get(), 2); ! //it is not enough just counting the chars, we have to ignore those that are within comments or literals. ! ParsingUtils.removeCommentsWhitespacesAndLiterals(doc); ! int chars = PyAction.countChars(c, doc); ! int peers = PyAction.countChars(peer, doc); ! ! boolean skipChar = chars == peers; ! return skipChar; }catch(NoPeerAvailableException e){ ! return false; } } --- 768,783 ---- try{ ! char peer = DocUtils.getPeer(c); ! ! FastStringBuffer doc = new FastStringBuffer(document.get(), 2); ! //it is not enough just counting the chars, we have to ignore those that are within comments or literals. ! ParsingUtils.removeCommentsWhitespacesAndLiterals(doc); ! int chars = PyAction.countChars(c, doc); ! int peers = PyAction.countChars(peer, doc); ! ! boolean skipChar = chars == peers; ! return skipChar; }catch(NoPeerAvailableException e){ ! return false; } } *************** *** 812,832 **** /** ! * Return smart indent amount for new line. This should be done for ! * multiline structures like function parameters, tuples, lists and ! * dictionaries. ! * ! * Example: ! * ! * a=foo(1, # ! * ! * We would return the indentation needed to place the caret at the # ! * position. ! * ! * @param document The document ! * @param offset The document offset of the last character on the previous line * @param ps ! * @return indent, or -1 if smart indent could not be determined (fall back to default) * and a boolean indicating if we're inside a parenthesis ! */ public static Tuple<Integer,Boolean> determineSmartIndent(int offset, PySelection ps, IIndentPrefs prefs) throws BadLocationException { --- 812,832 ---- /** ! * Return smart indent amount for new line. This should be done for ! * multiline structures like function parameters, tuples, lists and ! * dictionaries. ! * ! * Example: ! * ! * a=foo(1, # ! * ! * We would return the indentation needed to place the caret at the # ! * position. ! * ! * @param document The document ! * @param offset The document offset of the last character on the previous line * @param ps ! * @return indent, or -1 if smart indent could not be determined (fall back to default) * and a boolean indicating if we're inside a parenthesis ! */ public static Tuple<Integer,Boolean> determineSmartIndent(int offset, PySelection ps, IIndentPrefs prefs) throws BadLocationException { *************** *** 848,887 **** String contents = ""; if(prefs.getIndentToParLevel()){ ! ! ! //now, there's a little catch here, if we are in a line with an opening peer, ! //we have to choose whether to indent to the opening peer or a little further ! //e.g.: if the line is ! //method( self <<- a new line here should indent to the start of the self and not ! //to the opening peer. ! if(openingPeerOffset < offset){ ! String fromParToCursor = document.get(openingPeerOffset, offset-openingPeerOffset); ! if(fromParToCursor.length() > 0 && fromParToCursor.charAt(0) == '('){ ! fromParToCursor = fromParToCursor.substring(1); ! if(!PySelection.containsOnlyWhitespaces(fromParToCursor)){ ! final int firstCharPosition = PySelection.getFirstCharPosition(fromParToCursor); ! openingPeerOffset += firstCharPosition; ! } ! } ! } ! ! ! int openingPeerLineOffset = lineInformationOfOffset.getOffset(); ! len = openingPeerOffset - openingPeerLineOffset; ! contents = document.get(openingPeerLineOffset, len); }else{ ! //ok, we have to get the ! int line = document.getLineOfOffset(openingPeerOffset); ! final String indent = prefs.getIndentationString(); ! contents = PySelection.getLine(document, line); ! contents = PySelection.getIndentationFromLine(contents); ! contents += indent.substring(0, indent.length()-1); //we have to make it -1 (that's what the smartindent expects) ! len = contents.length(); } //add more spaces for each tab for(int i = 0; i<contents.length(); i++){ ! if(contents.charAt(i) == '\t'){ ! len += prefs.getTabWidth() - 1; ! } } return new Tuple<Integer,Boolean>(len, true); --- 848,887 ---- String contents = ""; if(prefs.getIndentToParLevel()){ ! ! ! //now, there's a little catch here, if we are in a line with an opening peer, ! //we have to choose whether to indent to the opening peer or a little further ! //e.g.: if the line is ! //method( self <<- a new line here should indent to the start of the self and not ! //to the opening peer. ! if(openingPeerOffset < offset){ ! String fromParToCursor = document.get(openingPeerOffset, offset-openingPeerOffset); ! if(fromParToCursor.length() > 0 && fromParToCursor.charAt(0) == '('){ ! fromParToCursor = fromParToCursor.substring(1); ! if(!PySelection.containsOnlyWhitespaces(fromParToCursor)){ ! final int firstCharPosition = PySelection.getFirstCharPosition(fromParToCursor); ! openingPeerOffset += firstCharPosition; ! } ! } ! } ! ! ! int openingPeerLineOffset = lineInformationOfOffset.getOffset(); ! len = openingPeerOffset - openingPeerLineOffset; ! contents = document.get(openingPeerLineOffset, len); }else{ ! //ok, we have to get the ! int line = document.getLineOfOffset(openingPeerOffset); ! final String indent = prefs.getIndentationString(); ! contents = PySelection.getLine(document, line); ! contents = PySelection.getIndentationFromLine(contents); ! contents += indent.substring(0, indent.length()-1); //we have to make it -1 (that's what the smartindent expects) ! len = contents.length(); } //add more spaces for each tab for(int i = 0; i<contents.length(); i++){ ! if(contents.charAt(i) == '\t'){ ! len += prefs.getTabWidth() - 1; ! } } return new Tuple<Integer,Boolean>(len, true); Index: AbstractIndentPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/AbstractIndentPrefs.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractIndentPrefs.java 28 Jul 2008 15:53:31 -0000 1.6 --- AbstractIndentPrefs.java 28 Sep 2008 12:45:48 -0000 1.7 *************** *** 43,48 **** * Converts spaces to tabs or vice-versa depending on the user preferences */ ! public void convertToStd(IDocument document, DocumentCommand command){ ! try { if (getUseSpaces()) { command.text = convertTabsToSpaces(document, command.length, command.text, command.offset, getIndentationString()); --- 43,48 ---- * Converts spaces to tabs or vice-versa depending on the user preferences */ ! public void convertToStd(IDocument document, DocumentCommand command){ ! try { if (getUseSpaces()) { command.text = convertTabsToSpaces(document, command.length, command.text, command.offset, getIndentationString()); *************** *** 56,168 **** } ! } - - - //------------------------------------------------------------- UTILS ! /** ! * Replaces tabs if needed by ident string or just a space depending of the ! * tab location ! * ! */ ! private String convertTabsToSpaces( ! IDocument document, int length, String text, int offset, ! String indentString) throws BadLocationException ! { ! // only interresting if it contains a tab (also if it is a tab only) ! if (text.indexOf("\t") != -1) { ! // get some text infos ! ! if (text.equals("\t")) { ! //only a single tab? ! deleteWhitespaceAfter(document, offset); ! text = indentString; ! ! } else { ! // contains a char (pasted text) ! byte[] byteLine = text.getBytes(); ! FastStringBuffer newText = new FastStringBuffer(); ! for (int count = 0; count < byteLine.length; count++) { ! if (byteLine[count] == '\t'){ ! newText.append(indentString); ! ! } else { // if it is not a tab add the char ! newText.append((char) byteLine[count]); ! } ! } ! text = newText.toString(); ! } ! } ! return text; ! } ! ! /** ! * Converts spaces to strings. Useful when pasting ! */ ! private String convertSpacesToTabs(IDocument document, int length, ! String text, int offset, String indentString) ! throws BadLocationException ! { ! String spaceStr = DocUtils.createSpaceString(getTabWidth()); ! while(text.startsWith(spaceStr)){ ! text = text.replaceAll(spaceStr, "\t"); ! } return text; ! } ! /** ! * When hitting TAB, delete the whitespace after the cursor in the line ! */ ! private void deleteWhitespaceAfter(IDocument document, int offset) ! throws BadLocationException { ! if (offset < document.getLength() && !endsWithNewline(document, document.get(offset, 1))) { ! ! int lineLength = document.getLineInformationOfOffset(offset).getLength(); ! int lineStart = document.getLineInformationOfOffset(offset).getOffset(); ! String textAfter = document.get(offset, (lineStart + lineLength) - offset); ! ! if (textAfter.length() > 0 ! && isWhitespace(textAfter)) { ! document.replace(offset, textAfter.length(), DocUtils.EMPTY_STRING); ! } ! } ! } ! /** ! * Checks if the string is solely composed of spaces ! * ! * @param s the string analyzed ! * @return true if it's only composed of spaces and false otherwise. ! */ ! private boolean isWhitespace(String s) { ! int len = s.length(); ! ! //it's done backwards because the chance of finding a non-whitespace char is higher at the end of the string ! //than at the beggining ! for (int i = len - 1; i > -1 ; i--){ ! if (!Character.isWhitespace(s.charAt(i))){ ! return false; ! } ! } ! return true; ! } ! ! /** ! * True if text ends with a newline delimiter ! */ ! public static boolean endsWithNewline(IDocument document, String text) { ! String[] newlines = document.getLegalLineDelimiters(); ! boolean ends = false; ! for (int i = 0; i < newlines.length; i++) { ! String delimiter = newlines[i]; ! if (text.indexOf(delimiter) != -1) ! ends = true; ! } ! return ends; ! } } --- 56,168 ---- } ! } ! ! //------------------------------------------------------------- UTILS ! ! /** ! * Replaces tabs if needed by ident string or just a space depending of the ! * tab location ! * ! */ ! private String convertTabsToSpaces( ! IDocument document, int length, String text, int offset, ! String indentString) throws BadLocationException ! { ! // only interresting if it contains a tab (also if it is a tab only) ! if (text.indexOf("\t") != -1) { ! // get some text infos ! ! if (text.equals("\t")) { ! //only a single tab? ! deleteWhitespaceAfter(document, offset); ! text = indentString; ! ! } else { ! // contains a char (pasted text) ! byte[] byteLine = text.getBytes(); ! FastStringBuffer newText = new FastStringBuffer(); ! for (int count = 0; count < byteLine.length; count++) { ! if (byteLine[count] == '\t'){ ! newText.append(indentString); ! ! } else { // if it is not a tab add the char ! newText.append((char) byteLine[count]); ! } ! } ! text = newText.toString(); ! } ! } return text; ! } ! ! /** ! * Converts spaces to strings. Useful when pasting ! */ ! private String convertSpacesToTabs(IDocument document, int length, ! String text, int offset, String indentString) ! throws BadLocationException ! { ! String spaceStr = DocUtils.createSpaceString(getTabWidth()); ! while(text.startsWith(spaceStr)){ ! text = text.replaceAll(spaceStr, "\t"); ! } ! return text; ! } ! /** ! * When hitting TAB, delete the whitespace after the cursor in the line ! */ ! private void deleteWhitespaceAfter(IDocument document, int offset) ! throws BadLocationException { ! if (offset < document.getLength() && !endsWithNewline(document, document.get(offset, 1))) { ! ! int lineLength = document.getLineInformationOfOffset(offset).getLength(); ! int lineStart = document.getLineInformationOfOffset(offset).getOffset(); ! String textAfter = document.get(offset, (lineStart + lineLength) - offset); ! ! if (textAfter.length() > 0 ! && isWhitespace(textAfter)) { ! document.replace(offset, textAfter.length(), DocUtils.EMPTY_STRING); ! } ! } ! } ! /** ! * Checks if the string is solely composed of spaces ! * ! * @param s the string analyzed ! * @return true if it's only composed of spaces and false otherwise. ! */ ! private boolean isWhitespace(String s) { ! int len = s.length(); ! ! //it's done backwards because the chance of finding a non-whitespace char is higher at the end of the string ! //than at the beggining ! for (int i = len - 1; i > -1 ; i--){ ! if (!Character.isWhitespace(s.charAt(i))){ ! return false; ! } ! } ! return true; ! } ! ! /** ! * True if text ends with a newline delimiter ! */ ! public static boolean endsWithNewline(IDocument document, String text) { ! String[] newlines = document.getLegalLineDelimiters(); ! boolean ends = false; ! for (int i = 0; i < newlines.length; i++) { ! String delimiter = newlines[i]; ! if (text.indexOf(delimiter) != -1) ! ends = true; ! } ! return ends; ! } } Index: IIndentPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/IIndentPrefs.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IIndentPrefs.java 19 May 2006 13:47:15 -0000 1.9 --- IIndentPrefs.java 28 Sep 2008 12:45:49 -0000 1.10 *************** *** 41,82 **** * @return the indentation string based on the current settings. */ ! public String getIndentationString(); ! /** ! * Given the current settings, convert the current string to tabs or spaces. ! */ ! public void convertToStd(IDocument document, DocumentCommand command); ! ! /** ! * @return whether we should auto-close parentesis ! */ ! public boolean getAutoParentesis(); ! ! /** ! * Get whether or not to do colon detection. ! * @return true iff colon detection is turned on ! */ ! public boolean getAutoColon(); ! ! /** ! * Get whether or not to auto-skip braces insertion ! * @return iff auto-skip braces is ENABLED ! */ ! public boolean getAutoBraces(); ! ! /** ! * Get whether we should auto-write 'import' if we are in a from xxx import fff ! */ ! public boolean getAutoWriteImport(); ! ! /** ! * Get whether we should smart-indent after a '(' ! */ ! public boolean getSmartIndentPar(); ! ! /** ! * Get whether we should add 'self' automatically when declaring method ! */ ! public boolean getAutoAddSelf(); /** --- 41,82 ---- * @return the indentation string based on the current settings. */ ! public String getIndentationString(); ! /** ! * Given the current settings, convert the current string to tabs or spaces. ! */ ! public void convertToStd(IDocument document, DocumentCommand command); ! ! /** ! * @return whether we should auto-close parentesis ! */ ! public boolean getAutoParentesis(); ! ! /** ! * Get whether or not to do colon detection. ! * @return true iff colon detection is turned on ! */ ! public boolean getAutoColon(); ! ! /** ! * Get whether or not to auto-skip braces insertion ! * @return iff auto-skip braces is ENABLED ! */ ! public boolean getAutoBraces(); ! ! /** ! * Get whether we should auto-write 'import' if we are in a from xxx import fff ! */ ! public boolean getAutoWriteImport(); ! ! /** ! * Get whether we should smart-indent after a '(' ! */ ! public boolean getSmartIndentPar(); ! ! /** ! * Get whether we should add 'self' automatically when declaring method ! */ ! public boolean getAutoAddSelf(); /** *************** *** 93,96 **** * Should be called to regenerate the indent string that's in the cache. */ ! public void regenerateIndentString(); } --- 93,96 ---- * Should be called to regenerate the indent string that's in the cache. */ ! public void regenerateIndentString(); } Index: DefaultIndentPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/DefaultIndentPrefs.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** DefaultIndentPrefs.java 28 Jul 2008 15:53:31 -0000 1.13 --- DefaultIndentPrefs.java 28 Sep 2008 12:45:49 -0000 1.14 *************** *** 14,18 **** */ public class DefaultIndentPrefs extends AbstractIndentPrefs { ! /** * Cache for indentation string --- 14,18 ---- */ public class DefaultIndentPrefs extends AbstractIndentPrefs { ! /** * Cache for indentation string *************** *** 24,32 **** private int tabWidth; ! private static PyPreferencesCache cache; ! /** ! * Singleton instance for the preferences ! */ private static IIndentPrefs indentPrefs; --- 24,32 ---- private int tabWidth; ! private static PyPreferencesCache cache; ! /** ! * Singleton instance for the preferences ! */ private static IIndentPrefs indentPrefs; *************** *** 40,66 **** return indentPrefs; } ! /** * @return a cache for the preferences. */ ! private PyPreferencesCache getCache(){ ! if(cache == null){ ! cache = new PyPreferencesCache(PydevPlugin.getDefault().getPreferenceStore()); ! } ! return cache; ! } ! ! /** ! * Not singleton (each pyedit may force to use tabs or not). ! */ ! DefaultIndentPrefs(){ ! PyPreferencesCache c = getCache(); ! useSpaces = c.getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! tabWidth = c.getInt(PydevPrefs.TAB_WIDTH, 4); ! } public boolean getUseSpaces() { PyPreferencesCache c = getCache(); ! if(useSpaces != c.getBoolean(PydevPrefs.SUBSTITUTE_TABS)){ useSpaces = c.getBoolean(PydevPrefs.SUBSTITUTE_TABS); regenerateIndentString(); --- 40,66 ---- return indentPrefs; } ! /** * @return a cache for the preferences. */ ! private PyPreferencesCache getCache(){ ! if(cache == null){ ! cache = new PyPreferencesCache(PydevPlugin.getDefault().getPreferenceStore()); ! } ! return cache; ! } ! ! /** ! * Not singleton (each pyedit may force to use tabs or not). ! */ ! DefaultIndentPrefs(){ ! PyPreferencesCache c = getCache(); ! useSpaces = c.getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! tabWidth = c.getInt(PydevPrefs.TAB_WIDTH, 4); ! } public boolean getUseSpaces() { PyPreferencesCache c = getCache(); ! if(useSpaces != c.getBoolean(PydevPrefs.SUBSTITUTE_TABS)){ useSpaces = c.getBoolean(PydevPrefs.SUBSTITUTE_TABS); regenerateIndentString(); *************** *** 91,97 **** public void regenerateIndentString(){ ! PyPreferencesCache c = getCache(); c.clear(PydevPrefs.TAB_WIDTH); ! c.clear(PydevPrefs.SUBSTITUTE_TABS); indentString = super.getIndentationString(); } --- 91,97 ---- public void regenerateIndentString(){ ! PyPreferencesCache c = getCache(); c.clear(PydevPrefs.TAB_WIDTH); ! c.clear(PydevPrefs.SUBSTITUTE_TABS); indentString = super.getIndentationString(); } *************** *** 118,122 **** public boolean getIndentToParLevel() { ! return getCache().getBoolean(PydevPrefs.AUTO_INDENT_TO_PAR_LEVEL); } --- 118,122 ---- public boolean getIndentToParLevel() { ! return getCache().getBoolean(PydevPrefs.AUTO_INDENT_TO_PAR_LEVEL); } *************** *** 134,143 **** public boolean getSmartIndentPar() { ! return getCache().getBoolean(PydevPrefs.SMART_INDENT_PAR); } ! public boolean getAutoAddSelf() { ! return getCache().getBoolean(PydevPrefs.AUTO_ADD_SELF); ! } public boolean getAutoDedentElse() { --- 134,143 ---- public boolean getSmartIndentPar() { ! return getCache().getBoolean(PydevPrefs.SMART_INDENT_PAR); } ! public boolean getAutoAddSelf() { ! return getCache().getBoolean(PydevPrefs.AUTO_ADD_SELF); ! } public boolean getAutoDedentElse() { |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/builder/pylint Modified Files: PyLintPrefPage.java PyLintVisitor.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: PyLintVisitor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint/PyLintVisitor.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** PyLintVisitor.java 21 May 2008 01:38:09 -0000 1.41 --- PyLintVisitor.java 28 Sep 2008 12:45:49 -0000 1.42 *************** *** 94,133 **** try { if(canPassPyLint()){ ! ! IOConsoleOutputStream out=null; ! try { ! MessageConsole console = getConsole(); ! if(console != null){ ! out = console.newOutputStream(); ! } ! } catch (MalformedURLException e3) { ! throw new RuntimeException(e3); ! } ! passPyLint(resource, out); ! ! new Job("Adding markers"){ ! ! protected IStatus run(IProgressMonitor monitor) { ! ! ArrayList<MarkerInfo> lst = new ArrayList<PydevMarkerUtils.MarkerInfo>(); ! ! for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { ! Object[] el = iter.next(); ! ! String tok = (String) el[0]; ! int priority = ((Integer)el[1]).intValue(); ! String id = (String) el[2]; ! int line = ((Integer)el[3]).intValue(); ! ! lst.add(new PydevMarkerUtils.MarkerInfo(document, "ID:" + id + " " + tok, PYLINT_PROBLEM_MARKER, priority, false, false, line, 0, line, 0, null)); ! } ! ! PydevMarkerUtils.replaceMarkers(lst, resource, PYLINT_PROBLEM_MARKER); ! ! return PydevPlugin.makeStatus(Status.OK, "", null); ! } ! }.schedule(); } --- 94,133 ---- try { if(canPassPyLint()){ ! ! IOConsoleOutputStream out=null; ! try { ! MessageConsole console = getConsole(); ! if(console != null){ ! out = console.newOutputStream(); ! } ! } catch (MalformedURLException e3) { ! throw new RuntimeException(e3); ! } ! passPyLint(resource, out); ! ! new Job("Adding markers"){ ! ! protected IStatus run(IProgressMonitor monitor) { ! ! ArrayList<MarkerInfo> lst = new ArrayList<PydevMarkerUtils.MarkerInfo>(); ! ! for (Iterator<Object[]> iter = markers.iterator(); iter.hasNext();) { ! Object[] el = iter.next(); ! ! String tok = (String) el[0]; ! int priority = ((Integer)el[1]).intValue(); ! String id = (String) el[2]; ! int line = ((Integer)el[3]).intValue(); ! ! lst.add(new PydevMarkerUtils.MarkerInfo(document, "ID:" + id + " " + tok, PYLINT_PROBLEM_MARKER, priority, false, false, line, 0, line, 0, null)); ! } ! ! PydevMarkerUtils.replaceMarkers(lst, resource, PYLINT_PROBLEM_MARKER); ! ! return PydevPlugin.makeStatus(Status.OK, "", null); ! } ! }.schedule(); } *************** *** 148,162 **** } ! private MessageConsole getConsole() throws MalformedURLException { ! if(PyLintPrefPage.useConsole()){ ! if (fConsole == null){ ! fConsole = new MessageConsole("", PydevPlugin.getImageCache().getDescriptor(UIConstants.PY_ICON)); ! ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{fConsole}); ! } ! }else{ ! return null; ! } ! return fConsole; ! } --- 148,162 ---- } ! private MessageConsole getConsole() throws MalformedURLException { ! if(PyLintPrefPage.useConsole()){ ! if (fConsole == null){ ! fConsole = new MessageConsole("", PydevPlugin.getImageCache().getDescriptor(UIConstants.PY_ICON)); ! ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{fConsole}); ! } ! }else{ ! return null; ! } ! return fConsole; ! } *************** *** 198,209 **** String scriptToExe = REF.getFileAbsolutePath(script); ! String[] paramsToExe = list.toArray(new String[0]); ! write("Pylint: Executing command line:'", out, scriptToExe, paramsToExe, "'"); ! ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputFromPythonScript(scriptToExe, paramsToExe, arg.getParentFile(), project); ! write("Pylint: The stdout of the command line is: "+outTup.o1, out); ! write("Pylint: The stderr of the command line is: "+outTup.o2, out); ! ! String output = outTup.o1; StringTokenizer tokenizer = new StringTokenizer(output, "\r\n"); --- 198,209 ---- String scriptToExe = REF.getFileAbsolutePath(script); ! String[] paramsToExe = list.toArray(new String[0]); ! write("Pylint: Executing command line:'", out, scriptToExe, paramsToExe, "'"); ! ! Tuple<String, String> outTup = new SimplePythonRunner().runAndGetOutputFromPythonScript(scriptToExe, paramsToExe, arg.getParentFile(), project); ! write("Pylint: The stdout of the command line is: "+outTup.o1, out); ! write("Pylint: The stderr of the command line is: "+outTup.o2, out); ! ! String output = outTup.o1; StringTokenizer tokenizer = new StringTokenizer(output, "\r\n"); *************** *** 228,233 **** } if(outTup.o2.indexOf("Traceback (most recent call last):") != -1){ ! PydevPlugin.log(new RuntimeException("PyLint ERROR: \n"+outTup.o2)); ! return; } while(tokenizer.hasMoreTokens()){ --- 228,233 ---- } if(outTup.o2.indexOf("Traceback (most recent call last):") != -1){ ! PydevPlugin.log(new RuntimeException("PyLint ERROR: \n"+outTup.o2)); ! return; } while(tokenizer.hasMoreTokens()){ *************** *** 244,275 **** if(indexOfDoublePoints != -1){ ! if(tok.startsWith("C")&& useC){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = cSeverity; ! } ! else if(tok.startsWith("R") && useR ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = rSeverity; ! } ! else if(tok.startsWith("W") && useW ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = wSeverity; ! } ! else if(tok.startsWith("E") && useE ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = eSeverity; ! } ! else if(tok.startsWith("F") && useF ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = fSeverity; ! }else{ ! continue; ! } ! }else{ continue; --- 244,275 ---- if(indexOfDoublePoints != -1){ ! if(tok.startsWith("C")&& useC){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = cSeverity; ! } ! else if(tok.startsWith("R") && useR ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = rSeverity; ! } ! else if(tok.startsWith("W") && useW ){ ! found=true; ! //priority = IMarker.SEVERITY_WARNING; ! priority = wSeverity; ! } ! else if(tok.startsWith("E") && useE ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = eSeverity; ! } ! else if(tok.startsWith("F") && useF ){ ! found=true; ! //priority = IMarker.SEVERITY_ERROR; ! priority = fSeverity; ! }else{ ! continue; ! } ! }else{ continue; *************** *** 329,333 **** public void visitChangedResource(IResource resource, IDocument document, IProgressMonitor monitor) { if(document == null){ ! return; } if(PyLintPrefPage.usePyLint() == false){ --- 329,333 ---- public void visitChangedResource(IResource resource, IDocument document, IProgressMonitor monitor) { if(document == null){ ! return; } if(PyLintPrefPage.usePyLint() == false){ *************** *** 362,389 **** public static void write(String cmdLineToExe, IOConsoleOutputStream out, Object ... args) { ! try { ! if(fConsole != null && out != null){ ! synchronized(fConsole){ ! if(args != null){ ! for (Object arg : args) { ! if(arg instanceof String){ ! cmdLineToExe += " "+arg; ! }else if(arg instanceof String[]){ String[] strings = (String[]) arg; for (String string : strings) { cmdLineToExe += " "+string; } ! } } ! } ! out.write(cmdLineToExe); ! } ! } ! } catch (IOException e) { ! PydevPlugin.log(e); ! } ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#visitRemovedResource(org.eclipse.core.resources.IResource, org.eclipse.jface.text.IDocument) */ --- 362,389 ---- public static void write(String cmdLineToExe, IOConsoleOutputStream out, Object ... args) { ! try { ! if(fConsole != null && out != null){ ! synchronized(fConsole){ ! if(args != null){ ! for (Object arg : args) { ! if(arg instanceof String){ ! cmdLineToExe += " "+arg; ! }else if(arg instanceof String[]){ String[] strings = (String[]) arg; for (String string : strings) { cmdLineToExe += " "+string; } ! } } ! } ! out.write(cmdLineToExe); ! } ! } ! } catch (IOException e) { ! PydevPlugin.log(e); ! } ! } ! /** * @see org.python.pydev.builder.PyDevBuilderVisitor#visitRemovedResource(org.eclipse.core.resources.IResource, org.eclipse.jface.text.IDocument) */ Index: PyLintPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/builder/pylint/PyLintPrefPage.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyLintPrefPage.java 23 Jun 2007 12:07:09 -0000 1.18 --- PyLintPrefPage.java 28 Sep 2008 12:45:49 -0000 1.19 *************** *** 34,49 **** public class PyLintPrefPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { ! public static final String PYLINT_FILE_LOCATION = "PYLINT_FILE_LOCATION"; ! public static final String USE_PYLINT = "USE_PYLINT"; ! public static final boolean DEFAULT_USE_PYLINT = false; ! ! public static final int SEVERITY_IGNORE = -1; ! ! public static final int COLS = 4; ! ! ! public static final String[][] LABEL_AND_VALUE = new String[][]{ {"Error" , String.valueOf(IMarker.SEVERITY_ERROR)}, {"Warning", String.valueOf(IMarker.SEVERITY_WARNING)}, --- 34,49 ---- public class PyLintPrefPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { ! public static final String PYLINT_FILE_LOCATION = "PYLINT_FILE_LOCATION"; ! public static final String USE_PYLINT = "USE_PYLINT"; ! public static final boolean DEFAULT_USE_PYLINT = false; ! ! public static final int SEVERITY_IGNORE = -1; ! ! public static final int COLS = 4; ! ! ! public static final String[][] LABEL_AND_VALUE = new String[][]{ {"Error" , String.valueOf(IMarker.SEVERITY_ERROR)}, {"Warning", String.valueOf(IMarker.SEVERITY_WARNING)}, *************** *** 53,276 **** ! ! // errors ! public static final String SEVERITY_ERRORS = "SEVERITY_ERRORS"; ! ! public static final int DEFAULT_SEVERITY_ERRORS = IMarker.SEVERITY_ERROR; ! ! //warnings ! public static final String SEVERITY_WARNINGS = "SEVERITY_WARNINGS"; ! ! public static final int DEFAULT_SEVERITY_WARNINGS = IMarker.SEVERITY_WARNING; ! //fatal ! public static final String SEVERITY_FATAL = "SEVERITY_FATAL"; ! ! public static final int DEFAULT_SEVERITY_FATAL = IMarker.SEVERITY_ERROR; ! ! //coding std ! public static final String SEVERITY_CODING_STANDARD = "SEVERITY_CODING_STANDARD"; ! ! public static final int DEFAULT_SEVERITY_CODING_STANDARD = SEVERITY_IGNORE; ! ! //refactor ! public static final String SEVERITY_REFACTOR = "SEVERITY_REFACTOR"; ! ! public static final int DEFAULT_SEVERITY_REFACTOR = SEVERITY_IGNORE; ! ! //console ! public static final String USE_CONSOLE = "USE_CONSOLE"; ! public static final boolean DEFAULT_USE_CONSOLE = true; ! ! //args ! public static final String PYLINT_ARGS = "PYLINT_ARGS"; ! public static final String DEFAULT_PYLINT_ARGS = ""; ! ! //delta ! public static final String MAX_PYLINT_DELTA = "MAX_PYLINT_DELTA"; ! public static final int DEFAULT_MAX_PYLINT_DELTA = 4; ! public PyLintPrefPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Pylint"); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() ! */ ! protected void createFieldEditors() { ! final Composite p = getFieldEditorParent(); ! addField(new BooleanFieldEditor(USE_PYLINT, "Use pylint?", p)); ! addField(new BooleanFieldEditor(USE_CONSOLE, "Redirect Pylint output to console?", p)); ! addField(new IntegerFieldEditor(MAX_PYLINT_DELTA, "Max simultaneous processes for PyLint?", p)); ! FileFieldEditor fileField = new FileFieldEditor(PYLINT_FILE_LOCATION, "Location of pylint (lint.py):", true, p); ! addField(fileField); ! addField(new RadioGroupFieldEditor(SEVERITY_FATAL, "FATAL Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_ERRORS, "ERRORS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_WARNINGS, "WARNINGS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_CODING_STANDARD, "CONVENTIONS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_REFACTOR, "REFACTOR Severity", COLS, LABEL_AND_VALUE, p, true)); ! CustomizableFieldEditor stringFieldEditor = new CustomizableFieldEditor(PYLINT_ARGS, "Arguments to pass to pylint (customize its output).\n" ! + "The --include-ids=y is always included and does not appear here..", p); ! addField(stringFieldEditor); ! String w = ""; ! Button button = new Button(p, SWT.NONE); ! button.addSelectionListener(new SelectionListener(){ ! public void widgetSelected(SelectionEvent e) { ! final String w = "\n\nTo ignore some warning on a line in a file, you can put the comment: \n" + ! "#IGNORE:ID, so that the id is the warning that you want to ignore. \n" + ! "E.g.: if you have the code:\n\n" + ! "from foo import * #IGNORE:W0401\n\n" + ! "The wildcard import will be ignored.\n\n" + ! "NOTE:for warnings to appear in the problems view, you have\n" + ! "to set your filter to accept the org.python.pydev.pylintproblem type!\n\n" + ! "NOTE2: Make sure that your file is a valid module in the PYTHONPATH, because\n" + ! "pylint doesn't analyze the file itself, but the module itself (you should\n" + ! "be able to import it from python without giving the file path)."; ! ! MessageDialog.openInformation(p.getShell(), "Help", w); ! } ! public void widgetDefaultSelected(SelectionEvent e) { ! } ! ! }); ! button.setText("Click for help (ignoring errors and troubleshooting)"); ! GridData d = new GridData(); ! d.horizontalAlignment = GridData.FILL; ! d.grabExcessHorizontalSpace = true; ! button.setLayoutData(d); ! ! FieldEditor fe = new LabelFieldEditor("Help", w, p); ! addField(fe); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! /** ! * @return ! */ ! public static String getPyLintLocation() { ! return PydevPrefs.getPreferences().getString(PYLINT_FILE_LOCATION); ! } ! private static boolean communicatedOnce = false; ! /** ! * should we use py lint? ! * ! * @return ! */ ! public static boolean usePyLint() { ! boolean b = PydevPrefs.getPreferences().getBoolean(USE_PYLINT); ! if (!isPylintConfigured(PyLintPrefPage.getPyLintLocation())) { ! if (b && !communicatedOnce) { ! communicatedOnce = true; ! PydevPlugin.log("Unable to use pylint because it is not properly configured."); ! } ! return false; ! } ! return b; ! } ! /** ! * Checks if location of pylint is properly configured. ! */ ! public static boolean isPylintConfigured(String pylintLocation) { ! File pylint = new File(pylintLocation); ! if (!pylint.exists() && pylint.isFile()) { ! return false; ! } ! return true; ! } ! public static boolean useErrors() { ! return eSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useWarnings() { ! return wSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useFatal() { ! return fSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useCodingStandard() { ! return cSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useRefactorTips() { ! return rSeverity() != SEVERITY_IGNORE; ! } ! ! ! public static boolean useConsole() { ! return PydevPrefs.getPreferences().getBoolean(USE_CONSOLE); ! } ! public static String getPylintArgs() { ! return PydevPrefs.getPreferences().getString(PYLINT_ARGS); ! } ! public static int getMaxPyLintDelta() { ! return PydevPrefs.getPreferences().getInt(MAX_PYLINT_DELTA); ! } ! ! ! public static int wSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_WARNINGS); ! } ! public static int eSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_ERRORS); ! } ! public static int fSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_FATAL); ! } ! public static int cSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_CODING_STANDARD); ! } ! public static int rSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_REFACTOR); ! } } \ No newline at end of file --- 53,276 ---- ! ! // errors ! public static final String SEVERITY_ERRORS = "SEVERITY_ERRORS"; ! ! public static final int DEFAULT_SEVERITY_ERRORS = IMarker.SEVERITY_ERROR; ! ! //warnings ! public static final String SEVERITY_WARNINGS = "SEVERITY_WARNINGS"; ! ! public static final int DEFAULT_SEVERITY_WARNINGS = IMarker.SEVERITY_WARNING; ! //fatal ! public static final String SEVERITY_FATAL = "SEVERITY_FATAL"; ! ! public static final int DEFAULT_SEVERITY_FATAL = IMarker.SEVERITY_ERROR; ! ! //coding std ! public static final String SEVERITY_CODING_STANDARD = "SEVERITY_CODING_STANDARD"; ! ! public static final int DEFAULT_SEVERITY_CODING_STANDARD = SEVERITY_IGNORE; ! ! //refactor ! public static final String SEVERITY_REFACTOR = "SEVERITY_REFACTOR"; ! ! public static final int DEFAULT_SEVERITY_REFACTOR = SEVERITY_IGNORE; ! ! //console ! public static final String USE_CONSOLE = "USE_CONSOLE"; ! public static final boolean DEFAULT_USE_CONSOLE = true; ! ! //args ! public static final String PYLINT_ARGS = "PYLINT_ARGS"; ! public static final String DEFAULT_PYLINT_ARGS = ""; ! ! //delta ! public static final String MAX_PYLINT_DELTA = "MAX_PYLINT_DELTA"; ! public static final int DEFAULT_MAX_PYLINT_DELTA = 4; ! public PyLintPrefPage() { ! super(FLAT); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Pylint"); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() ! */ ! protected void createFieldEditors() { ! final Composite p = getFieldEditorParent(); ! addField(new BooleanFieldEditor(USE_PYLINT, "Use pylint?", p)); ! addField(new BooleanFieldEditor(USE_CONSOLE, "Redirect Pylint output to console?", p)); ! addField(new IntegerFieldEditor(MAX_PYLINT_DELTA, "Max simultaneous processes for PyLint?", p)); ! FileFieldEditor fileField = new FileFieldEditor(PYLINT_FILE_LOCATION, "Location of pylint (lint.py):", true, p); ! addField(fileField); ! addField(new RadioGroupFieldEditor(SEVERITY_FATAL, "FATAL Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_ERRORS, "ERRORS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_WARNINGS, "WARNINGS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_CODING_STANDARD, "CONVENTIONS Severity", COLS, LABEL_AND_VALUE, p, true)); ! ! addField(new RadioGroupFieldEditor(SEVERITY_REFACTOR, "REFACTOR Severity", COLS, LABEL_AND_VALUE, p, true)); ! CustomizableFieldEditor stringFieldEditor = new CustomizableFieldEditor(PYLINT_ARGS, "Arguments to pass to pylint (customize its output).\n" ! + "The --include-ids=y is always included and does not appear here..", p); ! addField(stringFieldEditor); ! String w = ""; ! Button button = new Button(p, SWT.NONE); ! button.addSelectionListener(new SelectionListener(){ ! public void widgetSelected(SelectionEvent e) { ! final String w = "\n\nTo ignore some warning on a line in a file, you can put the comment: \n" + ! "#IGNORE:ID, so that the id is the warning that you want to ignore. \n" + ! "E.g.: if you have the code:\n\n" + ! "from foo import * #IGNORE:W0401\n\n" + ! "The wildcard import will be ignored.\n\n" + ! "NOTE:for warnings to appear in the problems view, you have\n" + ! "to set your filter to accept the org.python.pydev.pylintproblem type!\n\n" + ! "NOTE2: Make sure that your file is a valid module in the PYTHONPATH, because\n" + ! "pylint doesn't analyze the file itself, but the module itself (you should\n" + ! "be able to import it from python without giving the file path)."; ! ! MessageDialog.openInformation(p.getShell(), "Help", w); ! } ! public void widgetDefaultSelected(SelectionEvent e) { ! } ! ! }); ! button.setText("Click for help (ignoring errors and troubleshooting)"); ! GridData d = new GridData(); ! d.horizontalAlignment = GridData.FILL; ! d.grabExcessHorizontalSpace = true; ! button.setLayoutData(d); ! ! FieldEditor fe = new LabelFieldEditor("Help", w, p); ! addField(fe); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! /** ! * @return ! */ ! public static String getPyLintLocation() { ! return PydevPrefs.getPreferences().getString(PYLINT_FILE_LOCATION); ! } ! private static boolean communicatedOnce = false; ! /** ! * should we use py lint? ! * ! * @return ! */ ! public static boolean usePyLint() { ! boolean b = PydevPrefs.getPreferences().getBoolean(USE_PYLINT); ! if (!isPylintConfigured(PyLintPrefPage.getPyLintLocation())) { ! if (b && !communicatedOnce) { ! communicatedOnce = true; ! PydevPlugin.log("Unable to use pylint because it is not properly configured."); ! } ! return false; ! } ! return b; ! } ! /** ! * Checks if location of pylint is properly configured. ! */ ! public static boolean isPylintConfigured(String pylintLocation) { ! File pylint = new File(pylintLocation); ! if (!pylint.exists() && pylint.isFile()) { ! return false; ! } ! return true; ! } ! public static boolean useErrors() { ! return eSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useWarnings() { ! return wSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useFatal() { ! return fSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useCodingStandard() { ! return cSeverity() != SEVERITY_IGNORE; ! } ! public static boolean useRefactorTips() { ! return rSeverity() != SEVERITY_IGNORE; ! } ! ! ! public static boolean useConsole() { ! return PydevPrefs.getPreferences().getBoolean(USE_CONSOLE); ! } ! public static String getPylintArgs() { ! return PydevPrefs.getPreferences().getString(PYLINT_ARGS); ! } ! public static int getMaxPyLintDelta() { ! return PydevPrefs.getPreferences().getInt(MAX_PYLINT_DELTA); ! } ! ! ! public static int wSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_WARNINGS); ! } ! public static int eSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_ERRORS); ! } ! public static int fSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_FATAL); ! } ! public static int cSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_CODING_STANDARD); ! } ! public static int rSeverity() { ! return PydevPrefs.getPreferences().getInt(SEVERITY_REFACTOR); ! } } \ No newline at end of file |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:29
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editorinput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editorinput Modified Files: PySourceLocatorBase.java PyOpenEditor.java Added Files: PySourceLocatorPrefs.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: PySourceLocatorPrefs.java --- package org.python.pydev.editorinput; import java.io.File; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.preference.IPreferenceStore; import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; /** * Class used to deal with the source locator prefs (even though they're edited in the SourceLocatorPrefsPage that's in * org.python.pydev.debug * * @author Fabio */ public class PySourceLocatorPrefs { /** * Constant used to define that a path should not be asked for (so, the translation will return nothing and * the user won't be bothered by that) */ public static final String DONTASK = "DONTASK"; /** * Checks if a translation path passed is valid. * * @param translation the translation path entered by the user * @return null if it's valid or the error message to be shown to the user */ public static String isValid(String[] translation) { if(translation.length != 2){ return "Input must have 2 elements."; } if(translation[1].equals(DONTASK)){ return null; } if(!new File(translation[1]).exists()){ return StringUtils.format("The file: %s does not exist and doesn't match 'DONTASK'.", translation[1]); } return null; } /** * @see #addPathTranslation(String) -- with toOSString for each path and a comma separator */ public static void addPathTranslation(IPath path, IPath location) { addPathTranslation(new String[]{path.toOSString(), location.toOSString()}); } /** * Any request to the passed path translation will be ignored. * @param path the path that should have the translation ignored (silently) */ public static void setIgnorePathTranslation(IPath path) { addPathTranslation(new String[]{path.toOSString(), DONTASK}); } /** * Adds a path to the translation table. * * @param translation the translation path to be added. * E.g.: * path asked, new path -- means that a request for the "path asked" should return the "new path" * path asked, DONTASK -- means that if some request for that file was asked it should silently ignore it * * E.g.: * c:\foo\c.py,c:\temp\c.py * c:\foo\c.py,DONTASK */ private static void addPathTranslation(String[] translation){ String valid = isValid(translation); if(valid != null){ throw new RuntimeException(valid); } IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String available = store.getString(PydevPrefs.SOURCE_LOCATION_PATHS); if(available == null || available.trim().length() == 0){ available = StringUtils.join(",", translation); }else{ String pathAsked = translation[0].trim(); String existent = getPathTranslation(pathAsked); if(existent != null){ String[] splitted = StringUtils.split(available, '\n'); for(int i=0;i<splitted.length;i++){ String s = splitted[i]; String initialPart = StringUtils.split(s, ',')[0].trim(); if(initialPart.equals(pathAsked)){ splitted[i] = StringUtils.join(",", translation); break; } } available = StringUtils.join("\n", splitted); }else{ available += "\n"; available += StringUtils.join(",", translation); } } store.putValue(PydevPrefs.SOURCE_LOCATION_PATHS, available); } /** * @see #getPathTranslation(String) -- with toOSString from path. */ public static String getPathTranslation(IPath pathToTranslate){ return getPathTranslation(pathToTranslate.toOSString()); } /** * Translates a path given the current translation settings * * @param pathToTranslate the path to be translated * @return the translated path or DONTASK or null if no translation path was found for it */ public static String getPathTranslation(String pathToTranslate){ pathToTranslate = pathToTranslate.trim(); IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore(); String available = store.getString(PydevPrefs.SOURCE_LOCATION_PATHS); if(available == null || available.trim().length() == 0){ return null; //nothing available }else{ String[] splitted = StringUtils.split(available, '\n'); for (String string : splitted) { String[] translation = StringUtils.split(string, ','); if(translation.length == 2){ if(translation[0].trim().equals(pathToTranslate)){ return translation[1].trim(); } } } } return null; } /** * @param words words to be gotten as string * @return a string with all the passed words separated by '\n' */ public static String wordsAsString(List<String[]> words){ StringBuffer buf = new StringBuffer(); for (String[] string : words) { buf.append(string[0].trim()); buf.append(','); buf.append(string[1].trim()); buf.append('\n'); } return buf.toString(); } /** * @param string the string that has to be returned as a list of strings * @return an array of strings from the passed string (reverse logic from wordsAsString) */ public static List<String[]> stringAsWords(String string){ ArrayList<String[]> strs = new ArrayList<String[]>(); for(String str: StringUtils.split(string, '\n')){ strs.add(StringUtils.split(str, ',')); } return strs; } } Index: PyOpenEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editorinput/PyOpenEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyOpenEditor.java 6 Aug 2008 16:23:18 -0000 1.1 --- PyOpenEditor.java 28 Sep 2008 12:45:45 -0000 1.2 *************** *** 24,114 **** public class PyOpenEditor { ! /** ! * Opens some editor from an editor input (See PySourceLocatorBase for obtaining it) ! * ! * @param file the editor input ! * @return the part correspondent to the editor ! * @throws PartInitException ! */ ! public static IEditorPart openEditorInput(IEditorInput file) throws PartInitException { ! final IWorkbench workbench = PydevPlugin.getDefault().getWorkbench(); ! if(workbench == null){ ! throw new RuntimeException("workbench cannot be null"); ! } ! ! IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); ! if(activeWorkbenchWindow == null){ ! throw new RuntimeException("activeWorkbenchWindow cannot be null (we have to be in a ui thread for this to work)"); ! } ! ! IWorkbenchPage wp = activeWorkbenchWindow.getActivePage(); ! ! // File is inside the workspace ! return IDE.openEditor(wp, file, PyEdit.EDITOR_ID); ! } ! /** ! * Opens some editor from an IFile ! * ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(IFile f) { ! if (f == null) ! return null; ! ! try { ! FileEditorInput file = new FileEditorInput(f); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening path " + f.toString(), e); ! return null; ! } ! } ! ! ! /** ! * Utility function that opens an editor on a given path. ! * ! * @return part that is the editor ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(IPath path) { ! if (path == null){ ! return null; ! } ! ! try { ! IEditorInput file = PySourceLocatorBase.createEditorInput(path); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening path " + path.toString(), e); ! return null; ! } ! } ! /** ! * Utility function that opens an editor on a given path within a zip file. ! * ! * @return part that is the editor ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(File zipFile, String zipFilePath) { ! if (zipFile == null || zipFilePath == null){ ! return null; ! } ! ! try { ! IEditorInput file = new PydevZipFileEditorInput(new PydevZipFileStorage(zipFile, zipFilePath)); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening zip file " + zipFile.getAbsolutePath()+ " - "+zipFilePath, e); ! return null; ! } ! } } --- 24,114 ---- public class PyOpenEditor { ! /** ! * Opens some editor from an editor input (See PySourceLocatorBase for obtaining it) ! * ! * @param file the editor input ! * @return the part correspondent to the editor ! * @throws PartInitException ! */ ! public static IEditorPart openEditorInput(IEditorInput file) throws PartInitException { ! final IWorkbench workbench = PydevPlugin.getDefault().getWorkbench(); ! if(workbench == null){ ! throw new RuntimeException("workbench cannot be null"); ! } ! ! IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); ! if(activeWorkbenchWindow == null){ ! throw new RuntimeException("activeWorkbenchWindow cannot be null (we have to be in a ui thread for this to work)"); ! } ! ! IWorkbenchPage wp = activeWorkbenchWindow.getActivePage(); ! ! // File is inside the workspace ! return IDE.openEditor(wp, file, PyEdit.EDITOR_ID); ! } ! /** ! * Opens some editor from an IFile ! * ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(IFile f) { ! if (f == null) ! return null; ! ! try { ! FileEditorInput file = new FileEditorInput(f); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening path " + f.toString(), e); ! return null; ! } ! } ! ! ! /** ! * Utility function that opens an editor on a given path. ! * ! * @return part that is the editor ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(IPath path) { ! if (path == null){ ! return null; ! } ! ! try { ! IEditorInput file = new PySourceLocatorBase().createEditorInput(path); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening path " + path.toString(), e); ! return null; ! } ! } ! /** ! * Utility function that opens an editor on a given path within a zip file. ! * ! * @return part that is the editor ! * @see #openEditorInput(IEditorInput) ! */ ! public static IEditorPart doOpenEditor(File zipFile, String zipFilePath) { ! if (zipFile == null || zipFilePath == null){ ! return null; ! } ! ! try { ! IEditorInput file = new PydevZipFileEditorInput(new PydevZipFileStorage(zipFile, zipFilePath)); ! return openEditorInput(file); ! ! } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error opening zip file " + zipFile.getAbsolutePath()+ " - "+zipFilePath, e); ! return null; ! } ! } } Index: PySourceLocatorBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editorinput/PySourceLocatorBase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PySourceLocatorBase.java 6 Aug 2008 16:23:18 -0000 1.1 --- PySourceLocatorBase.java 28 Sep 2008 12:45:45 -0000 1.2 *************** *** 41,58 **** */ public class PySourceLocatorBase { ! ! /** ! * This method will try to find the most likely file that matches the given path, ! * considering: ! * - The workspace files ! * - The open editors ! * ! * and if all fails, it'll still ask the user which path should be used. ! * ! * ! * @param path ! * @return ! */ ! public static IEditorInput createEditorInput(IPath path) { return createEditorInput(path, true); } --- 41,58 ---- */ public class PySourceLocatorBase { ! ! /** ! * This method will try to find the most likely file that matches the given path, ! * considering: ! * - The workspace files ! * - The open editors ! * ! * and if all fails, it'll still ask the user which path should be used. ! * ! * ! * @param path ! * @return ! */ ! public IEditorInput createEditorInput(IPath path) { return createEditorInput(path, true); } *************** *** 63,67 **** * @return a workspace file that matches the given file. */ ! public static IFile getWorkspaceFile(File file) { IFile[] files = getWorkspaceFiles(file); return selectWorkspaceFile(files); --- 63,67 ---- * @return a workspace file that matches the given file. */ ! public IFile getWorkspaceFile(File file) { IFile[] files = getWorkspaceFiles(file); return selectWorkspaceFile(files); *************** *** 73,77 **** * @return a workspace file that matches the given file. */ ! public static IFile[] getWorkspaceFiles(File file) { IWorkspace workspace= ResourcesPlugin.getWorkspace(); IPath location= Path.fromOSString(file.getAbsolutePath()); --- 73,77 ---- * @return a workspace file that matches the given file. */ ! public IFile[] getWorkspaceFiles(File file) { IWorkspace workspace= ResourcesPlugin.getWorkspace(); IPath location= Path.fromOSString(file.getAbsolutePath()); *************** *** 98,112 **** * @return the editor input found or none if None was available for the given path */ ! private static IEditorInput createEditorInput(IPath path, boolean askIfDoesNotExist) { IEditorInput edInput = null; IWorkspace w = ResourcesPlugin.getWorkspace(); - - //let's start with the 'easy' way - IFile fileForLocation = w.getRoot().getFileForLocation(path); - if(fileForLocation != null && fileForLocation.exists()){ - return new FileEditorInput(fileForLocation); - } - IFile files[] = w.getRoot().findFilesForLocation(path); --- 98,121 ---- * @return the editor input found or none if None was available for the given path */ ! private IEditorInput createEditorInput(IPath path, boolean askIfDoesNotExist) { ! String pathTranslation = PySourceLocatorPrefs.getPathTranslation(path); ! if(pathTranslation != null){ ! if(!pathTranslation.equals(PySourceLocatorPrefs.DONTASK)){ ! //change it for the registered translation ! path = Path.fromOSString(pathTranslation); ! }else{ ! //DONTASK!! ! askIfDoesNotExist = false; ! } ! } ! IEditorInput edInput = null; IWorkspace w = ResourcesPlugin.getWorkspace(); + //let's start with the 'easy' way + IFile fileForLocation = w.getRoot().getFileForLocation(path); + if(fileForLocation != null && fileForLocation.exists()){ + return new FileEditorInput(fileForLocation); + } IFile files[] = w.getRoot().findFilesForLocation(path); *************** *** 118,129 **** }else if(askIfDoesNotExist){ ! //here we can do one more thing: if the file matches some opened editor, let's use it... ! //(this is done because when debugging, we don't want to be asked over and over ! //for the same file) ! IEditorInput input = getEditorInputFromExistingEditors(systemFile.getName()); ! if(input != null){ return input; } ! //this is the last resort... First we'll try to check for a 'good' match, //and if there's more than one we'll ask it to the user --- 127,138 ---- }else if(askIfDoesNotExist){ ! //here we can do one more thing: if the file matches some opened editor, let's use it... ! //(this is done because when debugging, we don't want to be asked over and over ! //for the same file) ! IEditorInput input = getEditorInputFromExistingEditors(systemFile.getName()); ! if(input != null){ return input; } ! //this is the last resort... First we'll try to check for a 'good' match, //and if there's more than one we'll ask it to the user *************** *** 131,147 **** IFile iFile = selectWorkspaceFile(likelyFiles.toArray(new IFile[0])); if(iFile != null){ return new FileEditorInput(iFile); } //ok, ask the user for any file in the computer ! input = selectFilesystemFileForPath(path); if(input != null){ return input; } } }else{ //file exists IFile workspaceFile = selectWorkspaceFile(files); if(workspaceFile != null){ ! edInput = new FileEditorInput(workspaceFile); } } --- 140,161 ---- IFile iFile = selectWorkspaceFile(likelyFiles.toArray(new IFile[0])); if(iFile != null){ + PySourceLocatorPrefs.addPathTranslation(path, iFile.getLocation()); return new FileEditorInput(iFile); } //ok, ask the user for any file in the computer ! PydevFileEditorInput pydevFileEditorInput = selectFilesystemFileForPath(path); ! input = pydevFileEditorInput; if(input != null){ + PySourceLocatorPrefs.addPathTranslation(path, pydevFileEditorInput.getPath()); return input; } + + PySourceLocatorPrefs.setIgnorePathTranslation(path); } }else{ //file exists IFile workspaceFile = selectWorkspaceFile(files); if(workspaceFile != null){ ! edInput = new FileEditorInput(workspaceFile); } } *************** *** 154,212 **** * @return an editor input from an existing editor available */ ! private static IEditorInput getEditorInputFromExistingEditors(final String matchName) { ! final Tuple<IWorkbenchWindow, IEditorInput> workbenchAndReturn = new Tuple<IWorkbenchWindow, IEditorInput>(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), null); ! Runnable r = new Runnable(){ ! public void run() { ! IWorkbenchWindow workbenchWindow = workbenchAndReturn.o1; ! if(workbenchWindow == null){ ! workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ! } ! if(workbenchWindow == null){ ! return; ! } ! ! IWorkbenchPage activePage = workbenchWindow.getActivePage(); ! if(activePage == null){ ! return; ! } ! ! IEditorReference[] editorReferences = activePage.getEditorReferences(); ! for (IEditorReference editorReference : editorReferences) { ! IEditorPart editor = editorReference.getEditor(false); ! if(editor != null){ ! if(editor instanceof PyEdit){ ! PyEdit pyEdit = (PyEdit) editor; ! IEditorInput editorInput = pyEdit.getEditorInput(); ! if(editorInput instanceof IPathEditorInput){ ! IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput; ! IPath localPath = pathEditorInput.getPath(); ! if(localPath != null){ ! String considerName = localPath.segment(localPath.segmentCount()-1); ! if(matchName.equals(considerName)){ ! workbenchAndReturn.o2 = editorInput; ! return; ! } ! } ! }else{ ! File editorFile = pyEdit.getEditorFile(); ! if(editorFile != null){ ! if(editorFile.getName().equals(matchName)){ ! workbenchAndReturn.o2 = editorInput; ! return; ! } ! } ! } ! } ! } ! } ! } ! }; ! ! ! if(workbenchAndReturn.o1 == null){ //not ui-thread Display.getDefault().syncExec(r); }else{ --- 168,226 ---- * @return an editor input from an existing editor available */ ! private IEditorInput getEditorInputFromExistingEditors(final String matchName) { ! final Tuple<IWorkbenchWindow, IEditorInput> workbenchAndReturn = new Tuple<IWorkbenchWindow, IEditorInput>(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), null); ! Runnable r = new Runnable(){ ! public void run() { ! IWorkbenchWindow workbenchWindow = workbenchAndReturn.o1; ! if(workbenchWindow == null){ ! workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ! } ! if(workbenchWindow == null){ ! return; ! } ! ! IWorkbenchPage activePage = workbenchWindow.getActivePage(); ! if(activePage == null){ ! return; ! } ! ! IEditorReference[] editorReferences = activePage.getEditorReferences(); ! for (IEditorReference editorReference : editorReferences) { ! IEditorPart editor = editorReference.getEditor(false); ! if(editor != null){ ! if(editor instanceof PyEdit){ ! PyEdit pyEdit = (PyEdit) editor; ! IEditorInput editorInput = pyEdit.getEditorInput(); ! if(editorInput instanceof IPathEditorInput){ ! IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput; ! IPath localPath = pathEditorInput.getPath(); ! if(localPath != null){ ! String considerName = localPath.segment(localPath.segmentCount()-1); ! if(matchName.equals(considerName)){ ! workbenchAndReturn.o2 = editorInput; ! return; ! } ! } ! }else{ ! File editorFile = pyEdit.getEditorFile(); ! if(editorFile != null){ ! if(editorFile.getName().equals(matchName)){ ! workbenchAndReturn.o2 = editorInput; ! return; ! } ! } ! } ! } ! } ! } ! } ! }; ! ! ! if(workbenchAndReturn.o1 == null){ //not ui-thread Display.getDefault().syncExec(r); }else{ *************** *** 214,221 **** } ! return workbenchAndReturn.o2; ! } --- 228,235 ---- } ! return workbenchAndReturn.o2; ! } *************** *** 223,227 **** * This is the last resort... pointing to some filesystem file to get the editor for some path. */ ! private static IEditorInput selectFilesystemFileForPath(final IPath path) { final List<String> l = new ArrayList<String>(); Runnable r = new Runnable(){ --- 237,241 ---- * This is the last resort... pointing to some filesystem file to get the editor for some path. */ ! protected PydevFileEditorInput selectFilesystemFileForPath(final IPath path) { final List<String> l = new ArrayList<String>(); Runnable r = new Runnable(){ *************** *** 254,258 **** * be a match to some path (use only as an almost 'last-resort'). */ ! private static List<IFile> getLikelyFiles(IPath path, IWorkspace w) { List<IFile> ret = new ArrayList<IFile>(); try { --- 268,272 ---- * be a match to some path (use only as an almost 'last-resort'). */ ! private List<IFile> getLikelyFiles(IPath path, IWorkspace w) { List<IFile> ret = new ArrayList<IFile>(); try { *************** *** 268,272 **** * Used to recursively get the likely files given the first set of containers */ ! private static void getLikelyFiles(IPath path, List<IFile> ret, IResource[] resources) throws CoreException { String strPath = path.removeFileExtension().lastSegment().toLowerCase(); //this will return something as 'foo' --- 282,286 ---- * Used to recursively get the likely files given the first set of containers */ ! private void getLikelyFiles(IPath path, List<IFile> ret, IResource[] resources) throws CoreException { String strPath = path.removeFileExtension().lastSegment().toLowerCase(); //this will return something as 'foo' *************** *** 291,295 **** * @return the editor input that'll open the passed file. */ ! private static IEditorInput createEditorInput(File file) { IFile[] workspaceFile= getWorkspaceFiles(file); if (workspaceFile != null && workspaceFile.length > 0){ --- 305,309 ---- * @return the editor input that'll open the passed file. */ ! private IEditorInput createEditorInput(File file) { IFile[] workspaceFile= getWorkspaceFiles(file); if (workspaceFile != null && workspaceFile.length > 0){ *************** *** 309,313 **** * @return a new array of IFile with only the files that actually exist. */ ! private static IFile[] filterNonExistentFiles(IFile[] files){ if (files == null) return null; --- 323,327 ---- * @return a new array of IFile with only the files that actually exist. */ ! private IFile[] filterNonExistentFiles(IFile[] files){ if (files == null) return null; *************** *** 330,334 **** * selection or if the user cancelled it. */ ! private static IFile selectWorkspaceFile(final IFile[] files) { if(files == null || files.length == 0){ return null; --- 344,348 ---- * selection or if the user cancelled it. */ ! private IFile selectWorkspaceFile(final IFile[] files) { if(files == null || files.length == 0){ return null; |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:25
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/model Modified Files: LengthEstimator.java ItemPointer.java IModelListener.java Location.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: LengthEstimator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/LengthEstimator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LengthEstimator.java 20 Mar 2006 19:37:56 -0000 1.6 --- LengthEstimator.java 28 Sep 2008 12:45:47 -0000 1.7 *************** *** 66,359 **** public class LengthEstimator extends VisitorBase { ! int length = 0; ! int getLength() { ! return length; ! } ! protected Object unhandled_node(SimpleNode node) throws Exception { ! return null; ! } ! public void traverse(SimpleNode node) throws Exception { ! node.traverse(this); ! } ! ! public Object visitName(Name node) throws Exception { ! length += node.id.length(); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! length += ((NameTok)node.attr).id.length() + 1; // +1 for '.' ! node.traverse(this); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! LengthEstimator e2 = new LengthEstimator(); ! node.traverse(e2); ! length += e2.getLength(); ! return null; ! } ! public Object visitAssert(Assert node) throws Exception { ! // System.out.println("lenVisitAssert:" + node.toString("")); ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! // System.out.println("lenVisitAssign:" + node.toString("")); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! // System.out.println("lenVisitAugAssign:" + node.toString("")); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! // System.out.println("lenVisitBinOp:" + node.toString("")); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! // System.out.println("lenVisitBoolOp:" + node.toString("")); ! return null; ! } ! public Object visitBreak(Break node) throws Exception { ! // System.out.println("lenVisitBreak:" + node.toString("")); ! return null; ! } ! public Object visitClassDef(ClassDef node) throws Exception { ! // System.out.println("lenVisitClassDef:" + node.name); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! // System.out.println("lenVisitCompare:" + node.toString("")); ! return null; ! } ! public Object visitContinue(Continue node) throws Exception { ! // System.out.println("lenVisitContinue:" + node.toString("")); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! // System.out.println("lenVisitDelete:" + node.toString("")); ! return null; ! } ! public Object visitDict(Dict node) throws Exception { ! // System.out.println("lenVisitDict:" + node.toString("")); ! return null; ! } ! public Object visitEllipsis(Ellipsis node) throws Exception { ! // System.out.println("lenVisitEllipsis:" + node.toString("")); ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! // System.out.println("lenVisitExec:" + node.toString("")); ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! // System.out.println("lenVisitExpr:" + node.toString("")); ! return null; ! } ! public Object visitExpression(Expression node) throws Exception { ! // System.out.println("lenVisitExpression:" + node.toString("")); ! return null; ! } ! public Object visitExtSlice(ExtSlice node) throws Exception { ! // System.out.println("lenVisitExtSlice:" + node.toString("")); ! return null; ! } ! public Object visitFor(For node) throws Exception { ! // System.out.println("lenVisitFor:" + node.toString("")); ! return null; ! } ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! // System.out.println("lenVisitFunctionDef:" + node.toString("")); ! return null; ! } ! public Object visitGlobal(Global node) throws Exception { ! // System.out.println("lenVisitGlobal:" + node.toString("")); ! return null; ! } ! public Object visitIf(If node) throws Exception { ! // System.out.println("lenVisitIf:" + node.toString("")); ! return null; ! } ! public Object visitImport(Import node) throws Exception { ! // System.out.println("lenVisitImport:" + node.toString("")); ! return null; ! } ! public Object visitImportFrom(ImportFrom node) throws Exception { ! // System.out.println("lenVisitImportFrom:" + node.toString("")); ! return null; ! } ! public Object visitIndex(Index node) throws Exception { ! // System.out.println("lenVisitIndex:" + node.toString("")); ! return null; ! } ! public Object visitInteractive(Interactive node) throws Exception { ! // System.out.println("lenVisitInteractive:" + node.toString("")); ! return null; ! } ! public Object visitLambda(Lambda node) throws Exception { ! // System.out.println("lenVisitLambda:" + node.toString("")); ! return null; ! } ! public Object visitList(List node) throws Exception { ! // System.out.println("lenVisitList:" + node.toString("")); ! return null; ! } ! public Object visitListComp(ListComp node) throws Exception { ! // System.out.println("lenVisitListComp:" + node.toString("")); ! return null; ! } ! public Object visitModule(Module node) throws Exception { ! // System.out.println("lenVisitModule:" + node.toString("")); ! return null; ! } ! public Object visitNum(Num node) throws Exception { ! // System.out.println("lenVisitNum:" + node.toString("")); ! return null; ! } ! public Object visitPass(Pass node) throws Exception { ! // System.out.println("lenVisitPass:" + node.toString("")); ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! // System.out.println("lenVisitPrint:" + node.toString("")); ! return null; ! } ! public Object visitRaise(Raise node) throws Exception { ! // System.out.println("lenVisitRaise:" + node.toString("")); ! return null; ! } ! public Object visitRepr(Repr node) throws Exception { ! // System.out.println("lenVisitRepr:" + node.toString("")); ! return null; ! } ! public Object visitReturn(Return node) throws Exception { ! // System.out.println("lenVisitReturn:" + node.toString("")); ! return null; ! } ! public Object visitSlice(Slice node) throws Exception { ! // System.out.println("lenVisitSlice:" + node.toString("")); ! return null; ! } ! public Object visitStr(Str node) throws Exception { ! // System.out.println("lenVisitStr:" + node.toString("")); ! return null; ! } ! public Object visitSubscript(Subscript node) throws Exception { ! // System.out.println("lenVisitSubscript:" + node.toString("")); ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! // System.out.println("lenVisitSuite:" + node.toString("")); ! return null; ! } ! public Object visitTryExcept(TryExcept node) throws Exception { ! // System.out.println("lenVisitTryExcept:" + node.toString("")); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! // System.out.println("lenVisitTryFinally:" + node.toString("")); ! return null; ! } ! public Object visitTuple(Tuple node) throws Exception { ! // System.out.println("lenVisitTuple:" + node.toString("")); ! return null; ! } ! public Object visitUnaryOp(UnaryOp node) throws Exception { ! // System.out.println("lenVisitUnaryOp:" + node.toString("")); ! return null; ! } ! public Object visitWhile(While node) throws Exception { ! // System.out.println("lenVisitWhile:" + node.toString("")); ! return null; ! } ! public Object visitYield(Yield node) throws Exception { ! // System.out.println("lenVisitYield:" + node.toString("")); ! return null; ! } } --- 66,359 ---- public class LengthEstimator extends VisitorBase { ! int length = 0; ! int getLength() { ! return length; ! } ! protected Object unhandled_node(SimpleNode node) throws Exception { ! return null; ! } ! public void traverse(SimpleNode node) throws Exception { ! node.traverse(this); ! } ! ! public Object visitName(Name node) throws Exception { ! length += node.id.length(); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! length += ((NameTok)node.attr).id.length() + 1; // +1 for '.' ! node.traverse(this); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! LengthEstimator e2 = new LengthEstimator(); ! node.traverse(e2); ! length += e2.getLength(); ! return null; ! } ! public Object visitAssert(Assert node) throws Exception { ! // System.out.println("lenVisitAssert:" + node.toString("")); ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! // System.out.println("lenVisitAssign:" + node.toString("")); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! // System.out.println("lenVisitAugAssign:" + node.toString("")); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! // System.out.println("lenVisitBinOp:" + node.toString("")); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! // System.out.println("lenVisitBoolOp:" + node.toString("")); ! return null; ! } ! public Object visitBreak(Break node) throws Exception { ! // System.out.println("lenVisitBreak:" + node.toString("")); ! return null; ! } ! public Object visitClassDef(ClassDef node) throws Exception { ! // System.out.println("lenVisitClassDef:" + node.name); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! // System.out.println("lenVisitCompare:" + node.toString("")); ! return null; ! } ! public Object visitContinue(Continue node) throws Exception { ! // System.out.println("lenVisitContinue:" + node.toString("")); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! // System.out.println("lenVisitDelete:" + node.toString("")); ! return null; ! } ! public Object visitDict(Dict node) throws Exception { ! // System.out.println("lenVisitDict:" + node.toString("")); ! return null; ! } ! public Object visitEllipsis(Ellipsis node) throws Exception { ! // System.out.println("lenVisitEllipsis:" + node.toString("")); ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! // System.out.println("lenVisitExec:" + node.toString("")); ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! // System.out.println("lenVisitExpr:" + node.toString("")); ! return null; ! } ! public Object visitExpression(Expression node) throws Exception { ! // System.out.println("lenVisitExpression:" + node.toString("")); ! return null; ! } ! public Object visitExtSlice(ExtSlice node) throws Exception { ! // System.out.println("lenVisitExtSlice:" + node.toString("")); ! return null; ! } ! public Object visitFor(For node) throws Exception { ! // System.out.println("lenVisitFor:" + node.toString("")); ! return null; ! } ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! // System.out.println("lenVisitFunctionDef:" + node.toString("")); ! return null; ! } ! public Object visitGlobal(Global node) throws Exception { ! // System.out.println("lenVisitGlobal:" + node.toString("")); ! return null; ! } ! public Object visitIf(If node) throws Exception { ! // System.out.println("lenVisitIf:" + node.toString("")); ! return null; ! } ! public Object visitImport(Import node) throws Exception { ! // System.out.println("lenVisitImport:" + node.toString("")); ! return null; ! } ! public Object visitImportFrom(ImportFrom node) throws Exception { ! // System.out.println("lenVisitImportFrom:" + node.toString("")); ! return null; ! } ! public Object visitIndex(Index node) throws Exception { ! // System.out.println("lenVisitIndex:" + node.toString("")); ! return null; ! } ! public Object visitInteractive(Interactive node) throws Exception { ! // System.out.println("lenVisitInteractive:" + node.toString("")); ! return null; ! } ! public Object visitLambda(Lambda node) throws Exception { ! // System.out.println("lenVisitLambda:" + node.toString("")); ! return null; ! } ! public Object visitList(List node) throws Exception { ! // System.out.println("lenVisitList:" + node.toString("")); ! return null; ! } ! public Object visitListComp(ListComp node) throws Exception { ! // System.out.println("lenVisitListComp:" + node.toString("")); ! return null; ! } ! public Object visitModule(Module node) throws Exception { ! // System.out.println("lenVisitModule:" + node.toString("")); ! return null; ! } ! public Object visitNum(Num node) throws Exception { ! // System.out.println("lenVisitNum:" + node.toString("")); ! return null; ! } ! public Object visitPass(Pass node) throws Exception { ! // System.out.println("lenVisitPass:" + node.toString("")); ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! // System.out.println("lenVisitPrint:" + node.toString("")); ! return null; ! } ! public Object visitRaise(Raise node) throws Exception { ! // System.out.println("lenVisitRaise:" + node.toString("")); ! return null; ! } ! public Object visitRepr(Repr node) throws Exception { ! // System.out.println("lenVisitRepr:" + node.toString("")); ! return null; ! } ! public Object visitReturn(Return node) throws Exception { ! // System.out.println("lenVisitReturn:" + node.toString("")); ! return null; ! } ! public Object visitSlice(Slice node) throws Exception { ! // System.out.println("lenVisitSlice:" + node.toString("")); ! return null; ! } ! public Object visitStr(Str node) throws Exception { ! // System.out.println("lenVisitStr:" + node.toString("")); ! return null; ! } ! public Object visitSubscript(Subscript node) throws Exception { ! // System.out.println("lenVisitSubscript:" + node.toString("")); ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! // System.out.println("lenVisitSuite:" + node.toString("")); ! return null; ! } ! public Object visitTryExcept(TryExcept node) throws Exception { ! // System.out.println("lenVisitTryExcept:" + node.toString("")); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! // System.out.println("lenVisitTryFinally:" + node.toString("")); ! return null; ! } ! public Object visitTuple(Tuple node) throws Exception { ! // System.out.println("lenVisitTuple:" + node.toString("")); ! return null; ! } ! public Object visitUnaryOp(UnaryOp node) throws Exception { ! // System.out.println("lenVisitUnaryOp:" + node.toString("")); ! return null; ! } ! public Object visitWhile(While node) throws Exception { ! // System.out.println("lenVisitWhile:" + node.toString("")); ! return null; ! } ! public Object visitYield(Yield node) throws Exception { ! // System.out.println("lenVisitYield:" + node.toString("")); ! return null; ! } } Index: ItemPointer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ItemPointer.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ItemPointer.java 17 Aug 2008 00:26:46 -0000 1.8 --- ItemPointer.java 28 Sep 2008 12:45:47 -0000 1.9 *************** *** 17,38 **** public class ItemPointer { ! /** ! * IFile or File object (may be null) ! */ ! public final Object file; ! ! /** ! * Position of the 1st character ! */ ! public final Location start; ! ! /** ! * Position of the last character ! */ ! public final Location end; ! ! /** ! * The definition that originated this ItemPointer (good chance of being null). ! */ public final Definition definition; --- 17,38 ---- public class ItemPointer { ! /** ! * IFile or File object (may be null) ! */ ! public final Object file; ! ! /** ! * Position of the 1st character ! */ ! public final Location start; ! ! /** ! * Position of the last character ! */ ! public final Location end; ! ! /** ! * The definition that originated this ItemPointer (good chance of being null). ! */ public final Definition definition; *************** *** 41,51 **** */ public final String zipFilePath; - ! public ItemPointer(Object file) { ! this(file, new Location(), new Location()); ! } ! public ItemPointer(Object file, SimpleNode n) { int line = n.beginLine; int col = n.beginColumn; --- 41,51 ---- */ public final String zipFilePath; ! ! public ItemPointer(Object file) { ! this(file, new Location(), new Location()); ! } ! public ItemPointer(Object file, SimpleNode n) { int line = n.beginLine; int col = n.beginColumn; *************** *** 58,69 **** } ! public ItemPointer(Object file, Location start, Location end) { ! this(file, start, end, null, null); ! } public ItemPointer(Object file, Location start, Location end, Definition definition, String zipFilePath) { ! this.file = file; ! this.start = start; ! this.end = end; this.definition = definition; this.zipFilePath = zipFilePath; --- 58,69 ---- } ! public ItemPointer(Object file, Location start, Location end) { ! this(file, start, end, null, null); ! } public ItemPointer(Object file, Location start, Location end, Definition definition, String zipFilePath) { ! this.file = file; ! this.start = start; ! this.end = end; this.definition = definition; this.zipFilePath = zipFilePath; *************** *** 104,108 **** @Override public int hashCode() { ! int colLineBasedHash = (this.end.column + this.start.line + 7) * 3; if(this.file != null){ return this.file.hashCode() + colLineBasedHash; --- 104,108 ---- @Override public int hashCode() { ! int colLineBasedHash = (this.end.column + this.start.line + 7) * 3; if(this.file != null){ return this.file.hashCode() + colLineBasedHash; Index: Location.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/Location.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Location.java 26 Jan 2007 16:01:52 -0000 1.4 --- Location.java 28 Sep 2008 12:45:47 -0000 1.5 *************** *** 16,72 **** public class Location { ! /** ! * Location: line and col start at 0 ! */ ! public int line; ! public int column; ! static Location MIN_LOCATION = new Location(0,0); ! static Location MAX_LOCATION = new Location(Integer.MAX_VALUE, Integer.MAX_VALUE); ! ! public Location() { ! line = column = 0; ! } ! public Location(int line, int column) { ! this.line = line; ! this.column = column; ! } ! ! /** ! * Conversion to document coordinates. ! */ ! public int toOffset(IDocument document) throws BadLocationException { ! return document.getLineOffset(line) + column; ! } ! /** ! * @return true if location is completely enclosed between start & end. ! */ ! public boolean contained(Location start, Location end) { ! boolean startOk = (line > start.line || line == start.line && column >= start.column); ! boolean endOk = startOk ? (line < end.line || line == end.line && column <= end.column): false; ! return startOk && endOk; ! } ! ! public String toString() { ! return "L:" + Integer.toString(line) + " C:" + Integer.toString(column); ! } ! ! /** ! * standard compare ! * @return 1 means I win, -1 means argument wins, 0 means equal ! */ ! public int compareTo(Location l) { ! if (line > l.line) ! return 1; ! if (line < l.line) ! return -1; ! if (column > l.column) ! return 1; ! if (column < l.column) ! return -1; ! return 0; ! } @Override --- 16,72 ---- public class Location { ! /** ! * Location: line and col start at 0 ! */ ! public int line; ! public int column; ! static Location MIN_LOCATION = new Location(0,0); ! static Location MAX_LOCATION = new Location(Integer.MAX_VALUE, Integer.MAX_VALUE); ! ! public Location() { ! line = column = 0; ! } ! public Location(int line, int column) { ! this.line = line; ! this.column = column; ! } ! ! /** ! * Conversion to document coordinates. ! */ ! public int toOffset(IDocument document) throws BadLocationException { ! return document.getLineOffset(line) + column; ! } ! /** ! * @return true if location is completely enclosed between start & end. ! */ ! public boolean contained(Location start, Location end) { ! boolean startOk = (line > start.line || line == start.line && column >= start.column); ! boolean endOk = startOk ? (line < end.line || line == end.line && column <= end.column): false; ! return startOk && endOk; ! } ! ! public String toString() { ! return "L:" + Integer.toString(line) + " C:" + Integer.toString(column); ! } ! ! /** ! * standard compare ! * @return 1 means I win, -1 means argument wins, 0 means equal ! */ ! public int compareTo(Location l) { ! if (line > l.line) ! return 1; ! if (line < l.line) ! return -1; ! if (column > l.column) ! return 1; ! if (column < l.column) ! return -1; ! return 0; ! } @Override *************** *** 83,99 **** return (line * 99) + (column * 5); } ! ! /** ! * Utility: Converts document's offset to Location ! * @return Location ! */ ! static public Location offsetToLocation(IDocument document, int offset) { ! try { ! int line = document.getLineOfOffset(offset); ! int line_start = document.getLineOffset(line); ! return new Location(line, offset - line_start); ! } catch (BadLocationException e) { ! return new Location(); ! } ! } } --- 83,99 ---- return (line * 99) + (column * 5); } ! ! /** ! * Utility: Converts document's offset to Location ! * @return Location ! */ ! static public Location offsetToLocation(IDocument document, int offset) { ! try { ! int line = document.getLineOfOffset(offset); ! int line_start = document.getLineOffset(line); ! return new Location(line, offset - line_start); ! } catch (BadLocationException e) { ! return new Location(); ! } ! } } Index: IModelListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/IModelListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IModelListener.java 1 May 2007 13:57:28 -0000 1.5 --- IModelListener.java 28 Sep 2008 12:45:47 -0000 1.6 *************** *** 6,10 **** package org.python.pydev.editor.model; ! import org.python.pydev.editor.ErrorDescription; import org.python.pydev.parser.jython.SimpleNode; --- 6,10 ---- package org.python.pydev.editor.model; ! import org.python.pydev.parser.ErrorDescription; import org.python.pydev.parser.jython.SimpleNode; *************** *** 15,28 **** */ public interface IModelListener { ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root - the root of the new model ! */ ! void modelChanged(SimpleNode root); /** * Every time the document changes its error state, it generates this notification */ ! void errorChanged(ErrorDescription errorDesc); } --- 15,28 ---- */ public interface IModelListener { ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root - the root of the new model ! */ ! void modelChanged(SimpleNode root); /** * Every time the document changes its error state, it generates this notification */ ! void errorChanged(ErrorDescription errorDesc); } |
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:24
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/partitioner In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/partitioner Modified Files: BufferedDocumentScanner.java FastPythonPartitionScanner.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: FastPythonPartitionScanner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/partitioner/FastPythonPartitionScanner.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FastPythonPartitionScanner.java 26 May 2006 14:31:25 -0000 1.3 --- FastPythonPartitionScanner.java 28 Sep 2008 12:45:47 -0000 1.4 *************** *** 16,217 **** */ public class FastPythonPartitionScanner implements IPartitionTokenScanner, IPythonPartitions{ ! ! // states ! private static final int PYTHON= 0; ! private static final int COMMENT= 1; ! private static final int SINGLE_LINE_STRING1= 2; //' ! private static final int SINGLE_LINE_STRING2= 3; //" ! private static final int MULTI_LINE_STRING1= 4; //' ! private static final int MULTI_LINE_STRING2= 5; //"" ! private static final int BACKQUOTES= 6; ! ! ! /** The scanner. */ ! private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000); // faster implementation ! private final IToken[] fTokens= new IToken[] { ! new Token(null), ! new Token(PY_COMMENT), ! new Token(PY_SINGLELINE_STRING1), ! new Token(PY_SINGLELINE_STRING2), ! new Token(PY_MULTILINE_STRING1), ! new Token(PY_MULTILINE_STRING2), ! new Token(PY_BACKQUOTES), ! }; ! private int fTokenOffset; ! private int fTokenLength; ! private String currContentType; ! ! public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) { ! if(partitionOffset != -1 && partitionOffset < offset){ ! fScanner.setRange(document, partitionOffset, length+(offset-partitionOffset)); ! fTokenOffset= partitionOffset; ! fTokenLength= 0; ! currContentType = null; ! ! }else{ ! fScanner.setRange(document, offset, length); ! fTokenOffset= offset; ! fTokenLength= 0; ! currContentType = contentType; ! } ! } ! public void setRange(IDocument document, int offset, int length) { ! currContentType = null; ! fScanner.setRange(document, offset, length); ! fTokenOffset= offset; ! fTokenLength= 0; ! } ! public int getTokenOffset() { ! return fTokenOffset; ! } ! public int getTokenLength() { ! return fTokenLength; ! } ! /* ! * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken() ! */ ! public IToken nextToken() { ! fTokenOffset += fTokenLength; ! fTokenLength= 0; ! ! int ch= fScanner.read(); ! if(ch == ICharacterScanner.EOF){ ! fTokenLength++; ! return Token.EOF; ! } ! if(currContentType != null){ ! if(currContentType.equals(PY_COMMENT)){ ! return handleComment(ch); ! } ! if(currContentType.equals(PY_SINGLELINE_STRING1)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_SINGLELINE_STRING2)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_MULTILINE_STRING1)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_MULTILINE_STRING2)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_BACKQUOTES)){ ! ! } ! ! } ! ! ! // characters ! switch (ch) { ! case '#': ! return handleComment(ch); ! ! case '"': ! case '\'': ! return handleSingleQuotedString(ch); ! ! default: ! fTokenLength++; ! return fTokens[PYTHON]; ! } ! } ! private IToken handleSingleQuotedString(int ch) { ! int initialChar = ch; ! int offsetEnd = fTokenOffset; ! ! if(isMultiLiteral(ch)){ ! offsetEnd += 2; //ok, it is a multi-line with single quotes ! return handleMultiSingleQuotedString(ch, offsetEnd, initialChar); ! } ! ! //it is a single-line string ! ch = fScanner.read(); ! offsetEnd++; ! ! while(ch!= '\n' && ch != '\r' && ch != initialChar && ch != ICharacterScanner.EOF){ ! ch = fScanner.read(); ! offsetEnd++; ! } ! ! offsetEnd++; ! fTokenLength = offsetEnd-fTokenOffset; ! if(initialChar == '\''){ ! return fTokens[SINGLE_LINE_STRING1]; ! }else{ ! return fTokens[SINGLE_LINE_STRING2]; ! } ! } ! ! private IToken handleMultiSingleQuotedString(int ch, int offsetEnd, int initialChar) { ! //it is a multi-line string ! ch = fScanner.read(); ! offsetEnd++; ! ! while(ch != ICharacterScanner.EOF){ ! if(ch == initialChar){ ! if(isMultiLiteral(ch)){ ! offsetEnd+=2; ! if(initialChar == '\''){ ! return fTokens[MULTI_LINE_STRING1]; ! }else{ ! return fTokens[MULTI_LINE_STRING2]; ! } ! } ! } ! ch = fScanner.read(); ! offsetEnd++; ! } ! ! if(initialChar == '\''){ ! return fTokens[SINGLE_LINE_STRING1]; ! }else{ ! return fTokens[SINGLE_LINE_STRING2]; ! } ! } ! private boolean isMultiLiteral(int ch) { ! int c1 = fScanner.read(); ! if(c1 == ch){ ! int c2 = fScanner.read(); ! if(c2 == ch){ ! return true; ! } ! if(c2 != ICharacterScanner.EOF){ ! fScanner.unread(); ! } ! } ! if(c1 != ICharacterScanner.EOF){ ! fScanner.unread(); ! } ! return false; ! } ! private IToken handleComment(int ch) { ! int offsetEnd = fTokenOffset; ! ! while(ch!= '\n' && ch != '\r' && ch != ICharacterScanner.EOF){ ! ch = fScanner.read(); ! offsetEnd++; ! } ! fTokenLength = offsetEnd-fTokenOffset; ! return fTokens[COMMENT]; ! } } --- 16,217 ---- */ public class FastPythonPartitionScanner implements IPartitionTokenScanner, IPythonPartitions{ ! ! // states ! private static final int PYTHON= 0; ! private static final int COMMENT= 1; ! private static final int SINGLE_LINE_STRING1= 2; //' ! private static final int SINGLE_LINE_STRING2= 3; //" ! private static final int MULTI_LINE_STRING1= 4; //' ! private static final int MULTI_LINE_STRING2= 5; //"" ! private static final int BACKQUOTES= 6; ! ! ! /** The scanner. */ ! private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000); // faster implementation ! private final IToken[] fTokens= new IToken[] { ! new Token(null), ! new Token(PY_COMMENT), ! new Token(PY_SINGLELINE_STRING1), ! new Token(PY_SINGLELINE_STRING2), ! new Token(PY_MULTILINE_STRING1), ! new Token(PY_MULTILINE_STRING2), ! new Token(PY_BACKQUOTES), ! }; ! private int fTokenOffset; ! private int fTokenLength; ! private String currContentType; ! ! public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) { ! if(partitionOffset != -1 && partitionOffset < offset){ ! fScanner.setRange(document, partitionOffset, length+(offset-partitionOffset)); ! fTokenOffset= partitionOffset; ! fTokenLength= 0; ! currContentType = null; ! ! }else{ ! fScanner.setRange(document, offset, length); ! fTokenOffset= offset; ! fTokenLength= 0; ! currContentType = contentType; ! } ! } ! public void setRange(IDocument document, int offset, int length) { ! currContentType = null; ! fScanner.setRange(document, offset, length); ! fTokenOffset= offset; ! fTokenLength= 0; ! } ! public int getTokenOffset() { ! return fTokenOffset; ! } ! public int getTokenLength() { ! return fTokenLength; ! } ! /* ! * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken() ! */ ! public IToken nextToken() { ! fTokenOffset += fTokenLength; ! fTokenLength= 0; ! ! int ch= fScanner.read(); ! if(ch == ICharacterScanner.EOF){ ! fTokenLength++; ! return Token.EOF; ! } ! if(currContentType != null){ ! if(currContentType.equals(PY_COMMENT)){ ! return handleComment(ch); ! } ! if(currContentType.equals(PY_SINGLELINE_STRING1)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_SINGLELINE_STRING2)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_MULTILINE_STRING1)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_MULTILINE_STRING2)){ ! return handleSingleQuotedString(ch); ! ! } ! if(currContentType.equals(PY_BACKQUOTES)){ ! ! } ! ! } ! ! ! // characters ! switch (ch) { ! case '#': ! return handleComment(ch); ! ! case '"': ! case '\'': ! return handleSingleQuotedString(ch); ! ! default: ! fTokenLength++; ! return fTokens[PYTHON]; ! } ! } ! private IToken handleSingleQuotedString(int ch) { ! int initialChar = ch; ! int offsetEnd = fTokenOffset; ! ! if(isMultiLiteral(ch)){ ! offsetEnd += 2; //ok, it is a multi-line with single quotes ! return handleMultiSingleQuotedString(ch, offsetEnd, initialChar); ! } ! ! //it is a single-line string ! ch = fScanner.read(); ! offsetEnd++; ! ! while(ch!= '\n' && ch != '\r' && ch != initialChar && ch != ICharacterScanner.EOF){ ! ch = fScanner.read(); ! offsetEnd++; ! } ! ! offsetEnd++; ! fTokenLength = offsetEnd-fTokenOffset; ! if(initialChar == '\''){ ! return fTokens[SINGLE_LINE_STRING1]; ! }else{ ! return fTokens[SINGLE_LINE_STRING2]; ! } ! } ! ! private IToken handleMultiSingleQuotedString(int ch, int offsetEnd, int initialChar) { ! //it is a multi-line string ! ch = fScanner.read(); ! offsetEnd++; ! ! while(ch != ICharacterScanner.EOF){ ! if(ch == initialChar){ ! if(isMultiLiteral(ch)){ ! offsetEnd+=2; ! if(initialChar == '\''){ ! return fTokens[MULTI_LINE_STRING1]; ! }else{ ! return fTokens[MULTI_LINE_STRING2]; ! } ! } ! } ! ch = fScanner.read(); ! offsetEnd++; ! } ! ! if(initialChar == '\''){ ! return fTokens[SINGLE_LINE_STRING1]; ! }else{ ! return fTokens[SINGLE_LINE_STRING2]; ! } ! } ! private boolean isMultiLiteral(int ch) { ! int c1 = fScanner.read(); ! if(c1 == ch){ ! int c2 = fScanner.read(); ! if(c2 == ch){ ! return true; ! } ! if(c2 != ICharacterScanner.EOF){ ! fScanner.unread(); ! } ! } ! if(c1 != ICharacterScanner.EOF){ ! fScanner.unread(); ! } ! return false; ! } ! private IToken handleComment(int ch) { ! int offsetEnd = fTokenOffset; ! ! while(ch!= '\n' && ch != '\r' && ch != ICharacterScanner.EOF){ ! ch = fScanner.read(); ! offsetEnd++; ! } ! fTokenLength = offsetEnd-fTokenOffset; ! return fTokens[COMMENT]; ! } } Index: BufferedDocumentScanner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/partitioner/BufferedDocumentScanner.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BufferedDocumentScanner.java 20 Oct 2007 19:30:36 -0000 1.2 --- BufferedDocumentScanner.java 28 Sep 2008 12:45:47 -0000 1.3 *************** *** 16,147 **** public final class BufferedDocumentScanner implements ICharacterScanner { ! /** The document being scanned. */ ! private IDocument fDocument; ! /** The offset of the document range to scan. */ ! private int fRangeOffset; ! /** The length of the document range to scan. */ ! private int fRangeLength; ! /** The delimiters of the document. */ ! private char[][] fDelimiters; ! /** The buffer. */ ! private final char[] fBuffer; ! /** The offset of the buffer within the document. */ ! private int fBufferOffset; ! /** The valid length of the buffer for access. */ ! private int fBufferLength; ! /** The offset of the scanner within the buffer. */ ! private int fOffset; ! /** ! * Creates a new buffered document scanner. ! * The buffer size is set to the given number of characters. ! * ! * @param size the buffer size ! */ ! public BufferedDocumentScanner(int size) { ! Assert.isTrue(size >= 1); ! fBuffer= new char[size]; ! } ! /** ! * Fills the buffer with the contens of the document starting at the given offset. ! * ! * @param offset the document offset at which the buffer starts ! */ ! private final void updateBuffer(int offset) { ! fBufferOffset= offset; ! if (fBufferOffset + fBuffer.length > fRangeOffset + fRangeLength) ! fBufferLength= fRangeLength - (fBufferOffset - fRangeOffset); ! else ! fBufferLength= fBuffer.length; ! try { ! final String content= fDocument.get(fBufferOffset, fBufferLength); ! content.getChars(0, fBufferLength, fBuffer, 0); ! } catch (BadLocationException e) { ! } ! } ! /** ! * Configures the scanner by providing access to the document range over which to scan. ! * ! * @param document the document to scan ! * @param offset the offset of the document range to scan ! * @param length the length of the document range to scan ! */ ! public final void setRange(IDocument document, int offset, int length) { ! fDocument= document; ! fRangeOffset= offset; ! fRangeLength= length; ! String[] delimiters= document.getLegalLineDelimiters(); ! fDelimiters= new char[delimiters.length][]; ! for (int i= 0; i < delimiters.length; i++) ! fDelimiters[i]= delimiters[i].toCharArray(); ! updateBuffer(offset); ! fOffset= 0; ! } ! /* ! * @see ICharacterScanner#read() ! */ ! public final int read() { ! if (fOffset == fBufferLength) { ! if (fBufferOffset + fBufferLength == fDocument.getLength()) ! return EOF; ! else { ! updateBuffer(fBufferOffset + fBufferLength); ! fOffset= 0; ! } ! } ! return fBuffer[fOffset++]; ! } ! /* ! * @see ICharacterScanner#unread ! */ ! public final void unread() { ! if (fOffset == 0) { ! if (fBufferOffset == fRangeOffset) { ! // error: BOF ! } else { ! updateBuffer(fBufferOffset - fBuffer.length); ! fOffset= fBuffer.length - 1; ! } ! } else { ! --fOffset; ! } ! } ! /* ! * @see ICharacterScanner#getColumn() ! */ ! public final int getColumn() { ! try { ! final int offset= fBufferOffset + fOffset; ! final int line= fDocument.getLineOfOffset(offset); ! final int start= fDocument.getLineOffset(line); ! return offset - start; ! } catch (BadLocationException e) { ! } ! return -1; ! } ! /* ! * @see ICharacterScanner#getLegalLineDelimiters() ! */ ! public final char[][] getLegalLineDelimiters() { ! return fDelimiters; ! } } --- 16,147 ---- public final class BufferedDocumentScanner implements ICharacterScanner { ! /** The document being scanned. */ ! private IDocument fDocument; ! /** The offset of the document range to scan. */ ! private int fRangeOffset; ! /** The length of the document range to scan. */ ! private int fRangeLength; ! /** The delimiters of the document. */ ! private char[][] fDelimiters; ! /** The buffer. */ ! private final char[] fBuffer; ! /** The offset of the buffer within the document. */ ! private int fBufferOffset; ! /** The valid length of the buffer for access. */ ! private int fBufferLength; ! /** The offset of the scanner within the buffer. */ ! private int fOffset; ! /** ! * Creates a new buffered document scanner. ! * The buffer size is set to the given number of characters. ! * ! * @param size the buffer size ! */ ! public BufferedDocumentScanner(int size) { ! Assert.isTrue(size >= 1); ! fBuffer= new char[size]; ! } ! /** ! * Fills the buffer with the contens of the document starting at the given offset. ! * ! * @param offset the document offset at which the buffer starts ! */ ! private final void updateBuffer(int offset) { ! fBufferOffset= offset; ! if (fBufferOffset + fBuffer.length > fRangeOffset + fRangeLength) ! fBufferLength= fRangeLength - (fBufferOffset - fRangeOffset); ! else ! fBufferLength= fBuffer.length; ! try { ! final String content= fDocument.get(fBufferOffset, fBufferLength); ! content.getChars(0, fBufferLength, fBuffer, 0); ! } catch (BadLocationException e) { ! } ! } ! /** ! * Configures the scanner by providing access to the document range over which to scan. ! * ! * @param document the document to scan ! * @param offset the offset of the document range to scan ! * @param length the length of the document range to scan ! */ ! public final void setRange(IDocument document, int offset, int length) { ! fDocument= document; ! fRangeOffset= offset; ! fRangeLength= length; ! String[] delimiters= document.getLegalLineDelimiters(); ! fDelimiters= new char[delimiters.length][]; ! for (int i= 0; i < delimiters.length; i++) ! fDelimiters[i]= delimiters[i].toCharArray(); ! updateBuffer(offset); ! fOffset= 0; ! } ! /* ! * @see ICharacterScanner#read() ! */ ! public final int read() { ! if (fOffset == fBufferLength) { ! if (fBufferOffset + fBufferLength == fDocument.getLength()) ! return EOF; ! else { ! updateBuffer(fBufferOffset + fBufferLength); ! fOffset= 0; ! } ! } ! return fBuffer[fOffset++]; ! } ! /* ! * @see ICharacterScanner#unread ! */ ! public final void unread() { ! if (fOffset == 0) { ! if (fBufferOffset == fRangeOffset) { ! // error: BOF ! } else { ! updateBuffer(fBufferOffset - fBuffer.length); ! fOffset= fBuffer.length - 1; ! } ! } else { ! --fOffset; ! } ! } ! /* ! * @see ICharacterScanner#getColumn() ! */ ! public final int getColumn() { ! try { ! final int offset= fBufferOffset + fOffset; ! final int line= fDocument.getLineOfOffset(offset); ! final int start= fDocument.getLineOffset(line); ! return offset - start; ! } catch (BadLocationException e) { ! } ! return -1; ! } ! /* ! * @see ICharacterScanner#getLegalLineDelimiters() ! */ ! public final char[][] getLegalLineDelimiters() { ! return fDelimiters; ! } } |