From 5306e23019b39118762323941fbb252ec7816d7d Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Sun, 22 Sep 2024 09:40:06 -0300 Subject: [PATCH] wip2 --- .../AbstractPyCreateClassOrMethodOrField.java | 2 +- .../org.python.pydev.ast/META-INF/MANIFEST.MF | 1 + .../ast/assist_assign}/AssistAssign.java | 8 +-- .../org/python/pydev/core}/ICodingStd.java | 2 +- .../PyDevCodeStylePreferences.java | 43 +++++++++++++ .../PydevConsoleQuickAssistProcessor.java | 2 +- .../request/GeneratePropertiesRequest.java | 8 +-- .../GeneratePropertiesRequestTest.java | 8 +-- .../DefaultCompletionProposalFactory.java | 2 +- .../AssistAssignCompletionProposal.java | 2 +- .../PythonCorrectionProcessor.java | 2 +- .../PyCodeStylePreferencesPage.java | 61 +++---------------- .../preferences/PydevPrefsInitializer.java | 9 +-- .../heuristics/AssistAssignTest.java | 3 +- 14 files changed, 79 insertions(+), 74 deletions(-) rename plugins/{org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics => org.python.pydev.ast/src/org/python/pydev/ast/assist_assign}/AssistAssign.java (98%) rename plugins/{org.python.pydev/src/org/python/pydev/codingstd => org.python.pydev.core/src/org/python/pydev/core}/ICodingStd.java (93%) create mode 100644 plugins/org.python.pydev.core/src/org/python/pydev/core/preferences/PyDevCodeStylePreferences.java rename plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/{heuristics => }/AssistAssignCompletionProposal.java (98%) diff --git a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractPyCreateClassOrMethodOrField.java b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractPyCreateClassOrMethodOrField.java index b7f434c941..adf72a7926 100644 --- a/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractPyCreateClassOrMethodOrField.java +++ b/plugins/com.python.pydev.refactoring/src/com/python/pydev/refactoring/tdd/AbstractPyCreateClassOrMethodOrField.java @@ -19,13 +19,13 @@ import org.python.pydev.ast.adapters.offsetstrategy.BeginOffset; import org.python.pydev.ast.adapters.offsetstrategy.EndOffset; import org.python.pydev.ast.adapters.offsetstrategy.IOffsetStrategy; +import org.python.pydev.ast.assist_assign.AssistAssign; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.docutils.PySelection.LineStartingScope; import org.python.pydev.core.docutils.PyStringUtils; import org.python.pydev.core.log.Log; import org.python.pydev.core.proposals.CompletionProposalFactory; import org.python.pydev.core.templates.PyDocumentTemplateContext; -import org.python.pydev.editor.correctionassist.heuristics.AssistAssign; import org.python.pydev.parser.jython.ast.ClassDef; import org.python.pydev.parser.jython.ast.Pass; import org.python.pydev.parser.visitors.NodeUtils; diff --git a/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF b/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF index cc80eef98d..7f0920ac1f 100644 --- a/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF +++ b/plugins/org.python.pydev.ast/META-INF/MANIFEST.MF @@ -22,6 +22,7 @@ Export-Package: org.python.pydev.ast, org.python.pydev.ast.adapters.visitors.selection, org.python.pydev.ast.analysis, org.python.pydev.ast.analysis.messages, + org.python.pydev.ast.assist_assign, org.python.pydev.ast.builder, org.python.pydev.ast.codecompletion, org.python.pydev.ast.codecompletion.revisited, diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssign.java b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/assist_assign/AssistAssign.java similarity index 98% rename from plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssign.java rename to plugins/org.python.pydev.ast/src/org/python/pydev/ast/assist_assign/AssistAssign.java index a76d80e281..ffd29b17c3 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssign.java +++ b/plugins/org.python.pydev.ast/src/org/python/pydev/ast/assist_assign/AssistAssign.java @@ -9,7 +9,7 @@ * * @author Fabio Zadrozny */ -package org.python.pydev.editor.correctionassist.heuristics; +package org.python.pydev.ast.assist_assign; import java.io.File; import java.util.ArrayList; @@ -20,8 +20,8 @@ import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.templates.TemplateContext; import org.eclipse.jface.text.templates.TemplateContextType; -import org.python.pydev.codingstd.ICodingStd; import org.python.pydev.core.IAssistProps; +import org.python.pydev.core.ICodingStd; import org.python.pydev.core.IIndentPrefs; import org.python.pydev.core.IPyEdit; import org.python.pydev.core.IPythonNature; @@ -31,10 +31,10 @@ import org.python.pydev.core.docutils.PyStringUtils; import org.python.pydev.core.docutils.SyntaxErrorException; import org.python.pydev.core.log.Log; +import org.python.pydev.core.preferences.PyDevCodeStylePreferences; import org.python.pydev.core.proposals.CompletionProposalFactory; import org.python.pydev.core.templates.PyAddTemplateResolvers; import org.python.pydev.core.templates.PyDocumentTemplateContext; -import org.python.pydev.plugin.preferences.PyCodeStylePreferencesPage; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; import org.python.pydev.shared_core.code_completion.IPyCompletionProposal; import org.python.pydev.shared_core.image.IImageCache; @@ -56,7 +56,7 @@ public AssistAssign() { @Override public boolean localsAndAttrsCamelcase() { - return PyCodeStylePreferencesPage.useLocalsAndAttrsCamelCase(); + return PyDevCodeStylePreferences.useLocalsAndAttrsCamelCase(); } }); diff --git a/plugins/org.python.pydev/src/org/python/pydev/codingstd/ICodingStd.java b/plugins/org.python.pydev.core/src/org/python/pydev/core/ICodingStd.java similarity index 93% rename from plugins/org.python.pydev/src/org/python/pydev/codingstd/ICodingStd.java rename to plugins/org.python.pydev.core/src/org/python/pydev/core/ICodingStd.java index a7e7eb54f5..d22d314f8a 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/codingstd/ICodingStd.java +++ b/plugins/org.python.pydev.core/src/org/python/pydev/core/ICodingStd.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package org.python.pydev.codingstd; +package org.python.pydev.core; public interface ICodingStd { diff --git a/plugins/org.python.pydev.core/src/org/python/pydev/core/preferences/PyDevCodeStylePreferences.java b/plugins/org.python.pydev.core/src/org/python/pydev/core/preferences/PyDevCodeStylePreferences.java new file mode 100644 index 0000000000..66133346bb --- /dev/null +++ b/plugins/org.python.pydev.core/src/org/python/pydev/core/preferences/PyDevCodeStylePreferences.java @@ -0,0 +1,43 @@ +package org.python.pydev.core.preferences; + +import org.python.pydev.shared_core.SharedCorePlugin; + +public class PyDevCodeStylePreferences { + + public static final String USE_LOCALS_AND_ATTRS_CAMELCASE = "USE_LOCALS_AND_ATTRS_CAMELCASE"; + public static final String USE_METHODS_FORMAT = "USE_METHODS_FORMAT"; + public static final boolean DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE = false; + public static final int METHODS_FORMAT_CAMELCASE_FIRST_LOWER = 0; + public static final int METHODS_FORMAT_CAMELCASE_FIRST_UPPER = 1; + public static final int METHODS_FORMAT_UNDERSCORE_SEPARATED = 2; + public static final int DEFAULT_USE_METHODS_FORMAT = METHODS_FORMAT_UNDERSCORE_SEPARATED; + + public static final String[][] LABEL_AND_VALUE = new String[][] { + { "underscore_separated", String.valueOf(METHODS_FORMAT_UNDERSCORE_SEPARATED) }, + { "CamelCase() with first upper", String.valueOf(METHODS_FORMAT_CAMELCASE_FIRST_UPPER) }, + { "camelCase() with first lower", String.valueOf(METHODS_FORMAT_CAMELCASE_FIRST_LOWER) }, }; + + public static final String[][] LOCALS_LABEL_AND_VALUE = new String[][] { + { "underscore_separated", String.valueOf(false) }, + { "camelCase with first lower", String.valueOf(true) }, }; + + public static int TESTING_METHOD_FORMAT = DEFAULT_USE_METHODS_FORMAT; + + public static int useMethodsCamelCase() { + if (SharedCorePlugin.inTestMode()) { + return TESTING_METHOD_FORMAT; + } + return PydevPrefs.getEclipsePreferences().getInt(USE_METHODS_FORMAT, DEFAULT_USE_METHODS_FORMAT); + } + + public static boolean TESTING_METHOD_LOCALS_AND_ATTRS_CAMEL_CASE = DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE; + + public static boolean useLocalsAndAttrsCamelCase() { + if (SharedCorePlugin.inTestMode()) { + return TESTING_METHOD_LOCALS_AND_ATTRS_CAMEL_CASE; + } + return PydevPrefs.getEclipsePreferences().getBoolean(USE_LOCALS_AND_ATTRS_CAMELCASE, + DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE); + } + +} diff --git a/plugins/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleQuickAssistProcessor.java b/plugins/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleQuickAssistProcessor.java index bd72b74a98..b50a1f2815 100644 --- a/plugins/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleQuickAssistProcessor.java +++ b/plugins/org.python.pydev.debug/src_console/org/python/pydev/debug/newconsole/PydevConsoleQuickAssistProcessor.java @@ -18,12 +18,12 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.viewers.ISelection; +import org.python.pydev.ast.assist_assign.AssistAssign; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.log.Log; import org.python.pydev.editor.PySelectionFromEditor; import org.python.pydev.editor.codecompletion.ConvertCompletionProposals; import org.python.pydev.editor.correctionassist.PyCorrectionAssistant; -import org.python.pydev.editor.correctionassist.heuristics.AssistAssign; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; import org.python.pydev.shared_interactive_console.console.ui.internal.ScriptConsoleViewer; import org.python.pydev.shared_ui.SharedUiPlugin; diff --git a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/codegenerator/generateproperties/request/GeneratePropertiesRequest.java b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/codegenerator/generateproperties/request/GeneratePropertiesRequest.java index ba75ca5e43..81b38a401b 100644 --- a/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/codegenerator/generateproperties/request/GeneratePropertiesRequest.java +++ b/plugins/org.python.pydev.refactoring/src/org/python/pydev/refactoring/codegenerator/generateproperties/request/GeneratePropertiesRequest.java @@ -30,10 +30,10 @@ import org.python.pydev.ast.adapters.IClassDefAdapter; import org.python.pydev.ast.adapters.INodeAdapter; import org.python.pydev.ast.adapters.PropertyTextAdapter; +import org.python.pydev.core.preferences.PyDevCodeStylePreferences; import org.python.pydev.parser.jython.SimpleNode; import org.python.pydev.parser.jython.ast.factory.AdapterPrefs; import org.python.pydev.parser.jython.ast.factory.NodeHelper; -import org.python.pydev.plugin.preferences.PyCodeStylePreferencesPage; import org.python.pydev.refactoring.core.request.IRefactoringRequest; import org.python.pydev.shared_core.string.StringUtils; @@ -122,11 +122,11 @@ public String getPropertyName() { */ public static String getAccessorName(String accessType, String attributeName) { accessType += "_" + attributeName; - int useMethodsCamelCase = PyCodeStylePreferencesPage.useMethodsCamelCase(); - if (useMethodsCamelCase == PyCodeStylePreferencesPage.METHODS_FORMAT_CAMELCASE_FIRST_LOWER) { + int useMethodsCamelCase = PyDevCodeStylePreferences.useMethodsCamelCase(); + if (useMethodsCamelCase == PyDevCodeStylePreferences.METHODS_FORMAT_CAMELCASE_FIRST_LOWER) { return StringUtils.asStyleCamelCaseFirstLower(accessType); } - if (useMethodsCamelCase == PyCodeStylePreferencesPage.METHODS_FORMAT_CAMELCASE_FIRST_UPPER) { + if (useMethodsCamelCase == PyDevCodeStylePreferences.METHODS_FORMAT_CAMELCASE_FIRST_UPPER) { return StringUtils.asStyleCamelCaseFirstUpper(accessType); } //default is underscore diff --git a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesRequestTest.java b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesRequestTest.java index 81e55a94e7..5063e3a544 100644 --- a/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesRequestTest.java +++ b/plugins/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/generateproperties/GeneratePropertiesRequestTest.java @@ -11,7 +11,7 @@ ******************************************************************************/ package org.python.pydev.refactoring.tests.codegenerator.generateproperties; -import org.python.pydev.plugin.preferences.PyCodeStylePreferencesPage; +import org.python.pydev.core.preferences.PyDevCodeStylePreferences; import org.python.pydev.refactoring.codegenerator.generateproperties.request.GeneratePropertiesRequest; import junit.framework.TestCase; @@ -31,13 +31,13 @@ public static void main(String[] args) { } public void testCodingStd() { - PyCodeStylePreferencesPage.TESTING_METHOD_FORMAT = PyCodeStylePreferencesPage.METHODS_FORMAT_CAMELCASE_FIRST_LOWER; + PyDevCodeStylePreferences.TESTING_METHOD_FORMAT = PyDevCodeStylePreferences.METHODS_FORMAT_CAMELCASE_FIRST_LOWER; assertEquals("delMyAttr", GeneratePropertiesRequest.getAccessorName("del", "my_attr")); - PyCodeStylePreferencesPage.TESTING_METHOD_FORMAT = PyCodeStylePreferencesPage.METHODS_FORMAT_CAMELCASE_FIRST_UPPER; + PyDevCodeStylePreferences.TESTING_METHOD_FORMAT = PyDevCodeStylePreferences.METHODS_FORMAT_CAMELCASE_FIRST_UPPER; assertEquals("DelMyAttr", GeneratePropertiesRequest.getAccessorName("del", "my_attr")); - PyCodeStylePreferencesPage.TESTING_METHOD_FORMAT = PyCodeStylePreferencesPage.METHODS_FORMAT_UNDERSCORE_SEPARATED; + PyDevCodeStylePreferences.TESTING_METHOD_FORMAT = PyDevCodeStylePreferences.METHODS_FORMAT_UNDERSCORE_SEPARATED; assertEquals("del_my_attr", GeneratePropertiesRequest.getAccessorName("del", "my_attr")); } diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java b/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java index 4ea86f6b61..88cc81459f 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java +++ b/plugins/org.python.pydev/src/org/python/pydev/editor/codecompletion/proposals/DefaultCompletionProposalFactory.java @@ -21,13 +21,13 @@ import org.python.pydev.core.proposals.ICompletionProposalFactory; import org.python.pydev.editor.codecompletion.PyTemplateProposal; import org.python.pydev.editor.codefolding.PyCalltipsContextInformationFromIToken; +import org.python.pydev.editor.correctionassist.AssistAssignCompletionProposal; import org.python.pydev.editor.correctionassist.FixCompletionProposal; import org.python.pydev.editor.correctionassist.IgnoreCompletionProposal; import org.python.pydev.editor.correctionassist.IgnoreCompletionProposalInSameLine; import org.python.pydev.editor.correctionassist.IgnoreFlake8CompletionProposalInSameLine; import org.python.pydev.editor.correctionassist.IgnorePyLintCompletionProposalInSameLine; import org.python.pydev.editor.correctionassist.docstrings.AssistDocstringCompletionProposal; -import org.python.pydev.editor.correctionassist.heuristics.AssistAssignCompletionProposal; import org.python.pydev.shared_core.code_completion.ICompletionProposalHandle; import org.python.pydev.shared_core.code_completion.IPyCompletionProposal.ICompareContext; import org.python.pydev.shared_core.image.IImageHandle; diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssignCompletionProposal.java b/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/AssistAssignCompletionProposal.java similarity index 98% rename from plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssignCompletionProposal.java rename to plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/AssistAssignCompletionProposal.java index 84c4f785a0..219a696278 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/heuristics/AssistAssignCompletionProposal.java +++ b/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/AssistAssignCompletionProposal.java @@ -4,7 +4,7 @@ * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ -package org.python.pydev.editor.correctionassist.heuristics; +package org.python.pydev.editor.correctionassist; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; diff --git a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java b/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java index ae4dd9604d..0146210314 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java +++ b/plugins/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java @@ -28,6 +28,7 @@ import org.eclipse.ui.texteditor.spelling.SpellingAnnotation; import org.eclipse.ui.texteditor.spelling.SpellingCorrectionProcessor; import org.eclipse.ui.texteditor.spelling.SpellingProblem; +import org.python.pydev.ast.assist_assign.AssistAssign; import org.python.pydev.ast.codecompletion.ProposalsComparator; import org.python.pydev.ast.surround_with.AssistSurroundWith; import org.python.pydev.core.ExtensionHelper; @@ -40,7 +41,6 @@ import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.log.Log; import org.python.pydev.editor.PyEdit; -import org.python.pydev.editor.correctionassist.heuristics.AssistAssign; import org.python.pydev.editor.correctionassist.heuristics.AssistImport; import org.python.pydev.editor.correctionassist.heuristics.AssistImportToLocal; import org.python.pydev.editor.correctionassist.heuristics.AssistPercentToFormat; diff --git a/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PyCodeStylePreferencesPage.java b/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PyCodeStylePreferencesPage.java index cd937064b3..9cb98b23c7 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PyCodeStylePreferencesPage.java +++ b/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PyCodeStylePreferencesPage.java @@ -14,33 +14,11 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; -import org.python.pydev.core.preferences.PydevPrefs; +import org.python.pydev.core.preferences.PyDevCodeStylePreferences; import org.python.pydev.plugin.PydevPlugin; -import org.python.pydev.shared_core.SharedCorePlugin; public class PyCodeStylePreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - public static final String USE_LOCALS_AND_ATTRS_CAMELCASE = "USE_LOCALS_AND_ATTRS_CAMELCASE"; - - public static final String USE_METHODS_FORMAT = "USE_METHODS_FORMAT"; - - public static final boolean DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE = false; - - public static final int METHODS_FORMAT_CAMELCASE_FIRST_LOWER = 0; - public static final int METHODS_FORMAT_CAMELCASE_FIRST_UPPER = 1; - public static final int METHODS_FORMAT_UNDERSCORE_SEPARATED = 2; - - public static final int DEFAULT_USE_METHODS_FORMAT = METHODS_FORMAT_UNDERSCORE_SEPARATED; - - public static final String[][] LABEL_AND_VALUE = new String[][] { - { "underscore_separated", String.valueOf(METHODS_FORMAT_UNDERSCORE_SEPARATED) }, - { "CamelCase() with first upper", String.valueOf(METHODS_FORMAT_CAMELCASE_FIRST_UPPER) }, - { "camelCase() with first lower", String.valueOf(METHODS_FORMAT_CAMELCASE_FIRST_LOWER) }, }; - - public static final String[][] LOCALS_LABEL_AND_VALUE = new String[][] { - { "underscore_separated", String.valueOf(false) }, - { "camelCase with first lower", String.valueOf(true) }, }; - private Label labelLocalsFormat; private Label labelMethodsFormat; @@ -59,19 +37,19 @@ public PyCodeStylePreferencesPage() { public void createFieldEditors() { Composite p = getFieldEditorParent(); - useLocalsAndAttrsCamelCase = new RadioGroupFieldEditor(USE_LOCALS_AND_ATTRS_CAMELCASE, - "Locals and attributes format (used for assign quick-assist)?", 1, LOCALS_LABEL_AND_VALUE, p, true); + useLocalsAndAttrsCamelCase = new RadioGroupFieldEditor(PyDevCodeStylePreferences.USE_LOCALS_AND_ATTRS_CAMELCASE, + "Locals and attributes format (used for assign quick-assist)?", 1, PyDevCodeStylePreferences.LOCALS_LABEL_AND_VALUE, p, true); addField(useLocalsAndAttrsCamelCase); - useMethodsFormat = new RadioGroupFieldEditor(USE_METHODS_FORMAT, - "Methods format (used for generate properties refactoring)", 1, LABEL_AND_VALUE, p, true); + useMethodsFormat = new RadioGroupFieldEditor(PyDevCodeStylePreferences.USE_METHODS_FORMAT, + "Methods format (used for generate properties refactoring)", 1, PyDevCodeStylePreferences.LABEL_AND_VALUE, p, true); addField(useMethodsFormat); labelLocalsFormat = new Label(p, SWT.NONE); labelMethodsFormat = new Label(p, SWT.NONE); - updateLabelLocalsAndAttrs(useLocalsAndAttrsCamelCase()); - updateLabelMethods(useMethodsCamelCase()); + updateLabelLocalsAndAttrs(PyDevCodeStylePreferences.useLocalsAndAttrsCamelCase()); + updateLabelMethods(PyDevCodeStylePreferences.useMethodsCamelCase()); } @@ -80,10 +58,10 @@ public void createFieldEditors() { */ private void updateLabelMethods(int useMethodsFormat) { - if (useMethodsFormat == METHODS_FORMAT_CAMELCASE_FIRST_UPPER) { + if (useMethodsFormat == PyDevCodeStylePreferences.METHODS_FORMAT_CAMELCASE_FIRST_UPPER) { labelMethodsFormat.setText("Refactoring property methods in the format def MyMethod() "); - } else if (useMethodsFormat == METHODS_FORMAT_UNDERSCORE_SEPARATED) { + } else if (useMethodsFormat == PyDevCodeStylePreferences.METHODS_FORMAT_UNDERSCORE_SEPARATED) { labelMethodsFormat.setText("Refactoring property methods in the format def my_method() "); } else { @@ -107,25 +85,6 @@ private void updateLabelLocalsAndAttrs(boolean useCamelCase) { public void init(IWorkbench workbench) { } - public static int TESTING_METHOD_FORMAT = DEFAULT_USE_METHODS_FORMAT; - - public static int useMethodsCamelCase() { - if (SharedCorePlugin.inTestMode()) { - return TESTING_METHOD_FORMAT; - } - return PydevPrefs.getEclipsePreferences().getInt(USE_METHODS_FORMAT, DEFAULT_USE_METHODS_FORMAT); - } - - public static boolean TESTING_METHOD_LOCALS_AND_ATTRS_CAMEL_CASE = DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE; - - public static boolean useLocalsAndAttrsCamelCase() { - if (SharedCorePlugin.inTestMode()) { - return TESTING_METHOD_LOCALS_AND_ATTRS_CAMEL_CASE; - } - return PydevPrefs.getEclipsePreferences().getBoolean(USE_LOCALS_AND_ATTRS_CAMELCASE, - DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE); - } - @Override public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); @@ -140,7 +99,7 @@ public void propertyChange(PropertyChangeEvent event) { String newValue = (String) event.getNewValue(); val = Integer.parseInt(newValue); } catch (NumberFormatException e) { - val = DEFAULT_USE_METHODS_FORMAT; + val = PyDevCodeStylePreferences.DEFAULT_USE_METHODS_FORMAT; } updateLabelMethods(val); diff --git a/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PydevPrefsInitializer.java b/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PydevPrefsInitializer.java index 4fc02ceda8..6bace53f07 100644 --- a/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PydevPrefsInitializer.java +++ b/plugins/org.python.pydev/src/org/python/pydev/plugin/preferences/PydevPrefsInitializer.java @@ -16,6 +16,7 @@ import org.python.pydev.builder.todo.PyTodoPrefPage; import org.python.pydev.core.docstrings.DocstringPreferences; import org.python.pydev.core.imports.ImportPreferences; +import org.python.pydev.core.preferences.PyDevCodeStylePreferences; import org.python.pydev.editor.codefolding.PyDevCodeFoldingPrefPage; import org.python.pydev.editor.commentblocks.CommentBlocksPreferences; import org.python.pydev.editor.hover.PyHoverPreferencesPage; @@ -220,10 +221,10 @@ public void initializeDefaultPreferences() { //[[[end]]] //coding style - node.putBoolean(PyCodeStylePreferencesPage.USE_LOCALS_AND_ATTRS_CAMELCASE, - PyCodeStylePreferencesPage.DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE); - node.putInt(PyCodeStylePreferencesPage.USE_METHODS_FORMAT, - PyCodeStylePreferencesPage.DEFAULT_USE_METHODS_FORMAT); + node.putBoolean(PyDevCodeStylePreferences.USE_LOCALS_AND_ATTRS_CAMELCASE, + PyDevCodeStylePreferences.DEFAULT_USE_LOCALS_AND_ATTRS_CAMELCASE); + node.putInt(PyDevCodeStylePreferences.USE_METHODS_FORMAT, + PyDevCodeStylePreferences.DEFAULT_USE_METHODS_FORMAT); //Editor title node.putBoolean(PyTitlePreferencesPage.TITLE_EDITOR_NAMES_UNIQUE, diff --git a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistAssignTest.java b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistAssignTest.java index fd7a0698c8..65970e8b61 100644 --- a/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistAssignTest.java +++ b/plugins/org.python.pydev/tests/org/python/pydev/editor/correctionassist/heuristics/AssistAssignTest.java @@ -15,7 +15,8 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; -import org.python.pydev.codingstd.ICodingStd; +import org.python.pydev.ast.assist_assign.AssistAssign; +import org.python.pydev.core.ICodingStd; import org.python.pydev.core.docutils.PySelection; import org.python.pydev.core.proposals.CompletionProposalFactory; import org.python.pydev.editor.codecompletion.proposals.DefaultCompletionProposalFactory;