From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:37
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/correctionassist/docstrings Modified Files: AssistDocString.java DocstringsPrefPage.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: DocstringsPrefPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings/DocstringsPrefPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DocstringsPrefPage.java 24 Jan 2007 20:29:30 -0000 1.2 --- DocstringsPrefPage.java 28 Sep 2008 12:45:47 -0000 1.3 *************** *** 23,59 **** public class DocstringsPrefPage extends FieldEditorPreferencePage implements ! IWorkbenchPreferencePage, IPropertyChangeListener { ! /* Preference identifiers */ ! public static final String P_DOCSTRINGCHARACTER = "DOCSTRING CHARACTER"; ! public static final String DEFAULT_P_DOCSTRINGCHARACTER = "'"; ! public static final String TYPETAG_GENERATION_NEVER = "Never"; ! public static final String TYPETAG_GENERATION_ALWAYS = "Always"; ! public static final String TYPETAG_GENERATION_CUSTOM = "Custom"; ! public static final String P_TYPETAGGENERATION = "TYPETAGGENERATION"; ! public static final String DEFAULT_P_TYPETAGGENERATION = TYPETAG_GENERATION_NEVER; ! public static final String P_DONT_GENERATE_TYPETAGS = "DONT_GENERATE_TYPETAGS_PREFIXES"; ! public static final String DEFAULT_P_DONT_GENERATE_TYPETAGS = "sz\0n\0f"; ! public DocstringsPrefPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Docstring preferences"); ! } ! /** ! * Getter for the preferred docstring character. Only a shortcut. ! * ! * @return ! */ ! public static String getPreferredDocstringCharacter() { PydevPlugin plugin = PydevPlugin.getDefault(); if(plugin == null){ --- 23,59 ---- public class DocstringsPrefPage extends FieldEditorPreferencePage implements ! IWorkbenchPreferencePage, IPropertyChangeListener { ! /* Preference identifiers */ ! public static final String P_DOCSTRINGCHARACTER = "DOCSTRING CHARACTER"; ! public static final String DEFAULT_P_DOCSTRINGCHARACTER = "'"; ! public static final String TYPETAG_GENERATION_NEVER = "Never"; ! public static final String TYPETAG_GENERATION_ALWAYS = "Always"; ! public static final String TYPETAG_GENERATION_CUSTOM = "Custom"; ! public static final String P_TYPETAGGENERATION = "TYPETAGGENERATION"; ! public static final String DEFAULT_P_TYPETAGGENERATION = TYPETAG_GENERATION_NEVER; ! public static final String P_DONT_GENERATE_TYPETAGS = "DONT_GENERATE_TYPETAGS_PREFIXES"; ! public static final String DEFAULT_P_DONT_GENERATE_TYPETAGS = "sz\0n\0f"; ! public DocstringsPrefPage() { ! super(GRID); ! setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); ! setDescription("Docstring preferences"); ! } ! /** ! * Getter for the preferred docstring character. Only a shortcut. ! * ! * @return ! */ ! public static String getPreferredDocstringCharacter() { PydevPlugin plugin = PydevPlugin.getDefault(); if(plugin == null){ *************** *** 61,163 **** } ! Preferences preferences = PydevPrefs.getPreferences(); return preferences.getString(P_DOCSTRINGCHARACTER); ! } ! /** ! * ! * @return The string that should be used to mark the beginning or end of a ! * docstring. (""") or (''') ! */ ! public static String getDocstringMarker() { ! String docstringChar = getPreferredDocstringCharacter(); ! return docstringChar + docstringChar + docstringChar; ! } ! /** ! * Determines, from the preferences, whether a type tag should be generated ! * for a function / method parameter. ! * ! * @param parameterName The name of the parameter. ! * @return true if it should be generated and false otherwise ! */ ! public static boolean getTypeTagShouldBeGenerated(String parameterName) { if(PydevPlugin.getDefault() == null){ //on tests return true; } ! String preference = PydevPrefs.getPreferences().getString(P_TYPETAGGENERATION); ! if (preference.equals(TYPETAG_GENERATION_NEVER)) { ! return false; ! } else if (preference.equals(TYPETAG_GENERATION_ALWAYS)) { ! return true; ! } else {// TYPETAG_GENERATION_CUSTOM - check prefix. ! String prefixesString = PydevPrefs.getPreferences().getString(P_DONT_GENERATE_TYPETAGS); ! StringTokenizer st = new StringTokenizer(prefixesString, "\0"); // "\0" is the separator ! ! while (st.hasMoreTokens()) ! { ! if (parameterName.startsWith(st.nextToken())) ! { ! return false; ! } ! } ! ! return true; // No match ! } ! } ! /** ! * Creates the field editors. Field editors are abstractions of the common ! * GUI blocks needed to manipulate various types of preferences. Each field ! * editor knows how to save and restore itself. ! */ ! public void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! ! Composite p2 = new Composite(p, 0); ! p2.setLayout(new RowLayout()); ! ! RadioGroupFieldEditor docstringCharEditor = ! new RadioGroupFieldEditor(P_DOCSTRINGCHARACTER, ! "Docstring character", 1, new String[][] { ! { "Quotation mark (\")", "\"" }, ! { "Apostrophe (')", "'" } }, p2, true); ! addField(docstringCharEditor); ! ! Group typeDoctagGroup = new Group(p2, 0); ! typeDoctagGroup.setText("Type doctag generation (@type x:...)"); ! typeDoctagEditor = new RadioGroupFieldEditor(P_TYPETAGGENERATION, ! "", 1, new String[][] { ! { "&Always", TYPETAG_GENERATION_ALWAYS }, ! { "&Never", TYPETAG_GENERATION_NEVER}, ! { "&Custom", TYPETAG_GENERATION_CUSTOM } }, typeDoctagGroup); ! addField(typeDoctagEditor); ! typeDoctagEditor.setPropertyChangeListener(this); ! addField(new ParameterNamePrefixListEditor(P_DONT_GENERATE_TYPETAGS, ! "Don't create for parameters with prefix", typeDoctagGroup)); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! ! public void propertyChange(PropertyChangeEvent event) { ! InputDialog d = new InputDialog(getShell(), ! "Type doctag generation", ! "Enter a parameter prefix", ! null, ! null); ! d.open(); ! } ! private RadioGroupFieldEditor typeDoctagEditor; } --- 61,163 ---- } ! Preferences preferences = PydevPrefs.getPreferences(); return preferences.getString(P_DOCSTRINGCHARACTER); ! } ! /** ! * ! * @return The string that should be used to mark the beginning or end of a ! * docstring. (""") or (''') ! */ ! public static String getDocstringMarker() { ! String docstringChar = getPreferredDocstringCharacter(); ! return docstringChar + docstringChar + docstringChar; ! } ! /** ! * Determines, from the preferences, whether a type tag should be generated ! * for a function / method parameter. ! * ! * @param parameterName The name of the parameter. ! * @return true if it should be generated and false otherwise ! */ ! public static boolean getTypeTagShouldBeGenerated(String parameterName) { if(PydevPlugin.getDefault() == null){ //on tests return true; } ! String preference = PydevPrefs.getPreferences().getString(P_TYPETAGGENERATION); ! if (preference.equals(TYPETAG_GENERATION_NEVER)) { ! return false; ! } else if (preference.equals(TYPETAG_GENERATION_ALWAYS)) { ! return true; ! } else {// TYPETAG_GENERATION_CUSTOM - check prefix. ! String prefixesString = PydevPrefs.getPreferences().getString(P_DONT_GENERATE_TYPETAGS); ! StringTokenizer st = new StringTokenizer(prefixesString, "\0"); // "\0" is the separator ! ! while (st.hasMoreTokens()) ! { ! if (parameterName.startsWith(st.nextToken())) ! { ! return false; ! } ! } ! ! return true; // No match ! } ! } ! /** ! * Creates the field editors. Field editors are abstractions of the common ! * GUI blocks needed to manipulate various types of preferences. Each field ! * editor knows how to save and restore itself. ! */ ! public void createFieldEditors() { ! Composite p = getFieldEditorParent(); ! ! Composite p2 = new Composite(p, 0); ! p2.setLayout(new RowLayout()); ! ! RadioGroupFieldEditor docstringCharEditor = ! new RadioGroupFieldEditor(P_DOCSTRINGCHARACTER, ! "Docstring character", 1, new String[][] { ! { "Quotation mark (\")", "\"" }, ! { "Apostrophe (')", "'" } }, p2, true); ! addField(docstringCharEditor); ! ! Group typeDoctagGroup = new Group(p2, 0); ! typeDoctagGroup.setText("Type doctag generation (@type x:...)"); ! typeDoctagEditor = new RadioGroupFieldEditor(P_TYPETAGGENERATION, ! "", 1, new String[][] { ! { "&Always", TYPETAG_GENERATION_ALWAYS }, ! { "&Never", TYPETAG_GENERATION_NEVER}, ! { "&Custom", TYPETAG_GENERATION_CUSTOM } }, typeDoctagGroup); ! addField(typeDoctagEditor); ! typeDoctagEditor.setPropertyChangeListener(this); ! addField(new ParameterNamePrefixListEditor(P_DONT_GENERATE_TYPETAGS, ! "Don't create for parameters with prefix", typeDoctagGroup)); ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) ! */ ! public void init(IWorkbench workbench) { ! } ! ! public void propertyChange(PropertyChangeEvent event) { ! InputDialog d = new InputDialog(getShell(), ! "Type doctag generation", ! "Enter a parameter prefix", ! null, ! null); ! d.open(); ! } ! private RadioGroupFieldEditor typeDoctagEditor; } Index: AssistDocString.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/docstrings/AssistDocString.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AssistDocString.java 14 Jun 2008 22:14:56 -0000 1.6 --- AssistDocString.java 28 Sep 2008 12:45:47 -0000 1.7 *************** *** 85,89 **** */ public boolean isValid(PySelection ps, String sel, PyEdit edit, int offset) { ! return ps.isInFunctionLine() || ps.isInClassLine(); } --- 85,89 ---- */ public boolean isValid(PySelection ps, String sel, PyEdit edit, int offset) { ! return ps.isInFunctionLine() || ps.isInClassLine(); } |