Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always initialize preference defaults using the extension point #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/com.python.pydev.analysis/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@


<extension point="org.eclipse.core.runtime.preferences">
<initializer class="com.python.pydev.analysis.pylint.PyLintPrefInitializer"/>
<initializer class="com.python.pydev.analysis.AnalysisPreferenceInitializer"/>
<initializer class="com.python.pydev.analysis.mypy.MypyPrefInitializer"/>
</extension>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import org.python.pydev.shared_core.structure.Location;

import com.python.pydev.analysis.additionalinfo.ReferenceSearchesLucene;
import com.python.pydev.analysis.mypy.MypyPrefInitializer;
import com.python.pydev.analysis.pylint.PyLintPrefInitializer;

/**
* The main plugin class to be used in the desktop.
Expand All @@ -62,10 +60,6 @@ public AnalysisPlugin() {
public void start(BundleContext context) throws Exception {
super.start(context);

// As it starts things in the org.python.pydev node for backward-compatibility, we must
// initialize it now.
PyLintPrefInitializer.initializeDefaultPreferences();
MypyPrefInitializer.initializeDefaultPreferences();
stateLocation = AnalysisPlugin.getDefault().getStateLocation();

// Leaving code around to know when we get to the PyDev perspective in the active window (may be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class AnalysisPreferenceInitializer extends AbstractPreferenceInitializer {

public static final String DEFAULT_SCOPE = "com.python.pydev.analysis";
public static final String DEFAULT_QUALIFIER = "com.python.pydev.analysis";

public static final String SEVERITY_UNUSED_PARAMETER = "SEVERITY_UNUSED_PARAMETER";
public static final int DEFAULT_SEVERITY_UNUSED_PARAMETER = IMarker.SEVERITY_INFO;
Expand Down Expand Up @@ -103,7 +103,7 @@ public class AnalysisPreferenceInitializer extends AbstractPreferenceInitializer

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_QUALIFIER);

for (int i = 0; i < AnalysisPreferences.completeSeverityMap.length; i++) {
Object[] s = AnalysisPreferences.completeSeverityMap[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
*/
package com.python.pydev.analysis.mypy;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.osgi.service.prefs.Preferences;
import org.python.pydev.shared_core.SharedCorePlugin;

public class MypyPrefInitializer {
public class MypyPrefInitializer extends AbstractPreferenceInitializer {

public static void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);

node.put(MypyPreferences.MYPY_FILE_LOCATION, "");
node.putBoolean(MypyPreferences.USE_MYPY, MypyPreferences.DEFAULT_USE_MYPY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
*/
package com.python.pydev.analysis.pylint;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.osgi.service.prefs.Preferences;
import org.python.pydev.shared_core.SharedCorePlugin;

public class PyLintPrefInitializer {
public class PyLintPrefInitializer extends AbstractPreferenceInitializer {

public static void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);

node.put(PyLintPreferences.PYLINT_FILE_LOCATION, "");
node.putBoolean(PyLintPreferences.USE_PYLINT, PyLintPreferences.DEFAULT_USE_PYLINT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public DebugPlugin() {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
new DebugPluginPrefsInitializer().initializeDefaultPreferences();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DebugPluginPrefsInitializer extends AbstractPreferenceInitializer {

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);
node.putInt(PYDEV_REMOTE_DEBUGGER_PORT, DEFAULT_REMOTE_DEBUGGER_PORT);

node.putInt(DEBUG_SERVER_STARTUP, DEFAULT_DEBUG_SERVER_ALWAYS_ON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import com.python.pydev.refactoring.ui.MarkOccurrencesPreferencesPage;

public class RefactoringPreferencesInitializer extends AbstractPreferenceInitializer {
public static final String DEFAULT_SCOPE = "com.python.pydev.analysis.refactoring";
public static final String DEFAULT_QUALIFIER = "com.python.pydev.analysis.refactoring";

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_QUALIFIER);
node.putBoolean(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES,
MarkOccurrencesPreferencesPage.DEFAULT_USE_MARK_OCCURRENCES);
node.putBoolean(MarkOccurrencesPreferencesPage.USE_MARK_OCCURRENCES_IN_STRINGS,
Expand Down
4 changes: 4 additions & 0 deletions plugins/org.python.pydev.ast/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@
<run class="org.python.pydev.ast.builder.PyDevBuilder"/>
</builder>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.python.pydev.ast.codecompletion.PyCodeCompletionInitializer"/>
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
import org.python.pydev.ast.codecompletion.PyCodeCompletionInitializer;

/**
* The main plugin class to be used in the desktop.
Expand Down Expand Up @@ -41,9 +40,6 @@ public AstPlugin() {
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
// Just called to initialize org.python.pydev.ast.codecompletion.PyCodeCompletionInitializer
// because we're actually initializing things in the "org.python.pydev" node.
new PyCodeCompletionInitializer().initializeDefaultPreferences();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class PyCodeCompletionInitializer extends AbstractPreferenceInitializer {

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);

//use?
node.putBoolean(PyCodeCompletionPreferences.USE_CODECOMPLETION,
Expand Down
3 changes: 2 additions & 1 deletion plugins/org.python.pydev.core/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ bin.includes = META-INF/,\
core.jar,\
LICENSE.txt,\
pysrc/,\
helpers/
helpers/,\
plugin.xml
jars.compile.order = core.jar
bin.excludes = pysrc/__pycache__/,\
pysrc/*$py.class,\
Expand Down
9 changes: 9 additions & 0 deletions plugins/org.python.pydev.core/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.python.pydev.core.preferences.PyDevCorePreferencesInitializer"/>
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.eclipse.core.runtime.QualifiedName;
import org.osgi.framework.BundleContext;
import org.python.pydev.core.log.Log;
import org.python.pydev.core.preferences.PyDevCorePreferencesInitializer;
import org.python.pydev.shared_core.io.FileUtils;

/**
Expand Down Expand Up @@ -55,10 +54,6 @@ public static void setBundleInfo(ICoreBundleInfo b) {
public CorePlugin() {
super();

// As it starts things in the org.python.pydev node for backward-compatibility, we must
// initialize it now.
PyDevCorePreferencesInitializer.initializeDefaultPreferences();

plugin = this;
try {
resourceBundle = ResourceBundle.getBundle("org.python.pydev.core.CorePluginResources");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package org.python.pydev.core.preferences;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.osgi.service.prefs.Preferences;
import org.python.pydev.core.IInterpreterManager;
import org.python.pydev.core.formatter.PyFormatterPreferences;
import org.python.pydev.shared_core.SharedCorePlugin;

public class PyDevCorePreferencesInitializer {
public class PyDevCorePreferencesInitializer extends AbstractPreferenceInitializer {

public static void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);

//ironpython
node.put(IInterpreterManager.IRONPYTHON_INTERNAL_SHELL_VM_ARGS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static String getString(String setting, IAdaptable projectAdaptable, Stri
}

public static IScopedPreferences get() {
return ScopedPreferences.get(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
return ScopedPreferences.get(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);
}

}
4 changes: 4 additions & 0 deletions plugins/org.python.pydev.debug/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,10 @@
priority="50">
</pyTextHover>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.python.pydev.debug.model.PyVariablesPreferences"/>
</extension>

</plugin>

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.osgi.service.prefs.Preferences;
import org.python.pydev.debug.model.PyVariablesPreferences;
import org.python.pydev.debug.pyunit.PyUnitView;

public class PydevDebugPreferencesInitializer extends AbstractPreferenceInitializer {
Expand Down Expand Up @@ -60,9 +59,6 @@ public void initializeDefaultPreferences() {

//Note: the preferences for the debug which appear in the preferences page are actually in
//the PydevEditorPrefs (as we use the pydev preferences store there).

// Delegate to the variables preferences
PyVariablesPreferences.initializeDefaultPreferences();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
******************************************************************************/
package org.python.pydev.debug.model;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.python.pydev.debug.core.PydevDebugPlugin;
import org.python.pydev.shared_core.SharedCorePlugin;

public class PyVariablesPreferences {
public class PyVariablesPreferences extends AbstractPreferenceInitializer {

public static final String DEBUG_UI_VARIABLES_SHOW_PRIVATE_REFERENCES = "DEBUG_UI_VARIABLES_SHOW_PRIVATE_REFERENCES";
public static final boolean DEBUG_UI_VARIABLES_DEFAULT_SHOW_PRIVATE_REFERENCES = true;
Expand Down Expand Up @@ -93,7 +94,8 @@ public static void setShowFunctionAndModuleReferences(boolean value) {
setHelper(PyVariablesPreferences.DEBUG_UI_VARIABLES_SHOW_FUNCTION_AND_MODULE_REFERENCES, value);
}

public static void initializeDefaultPreferences() {
@Override
public void initializeDefaultPreferences() {
setDefaultHelper(PyVariablesPreferences.DEBUG_UI_VARIABLES_SHOW_PRIVATE_REFERENCES,
PyVariablesPreferences.DEBUG_UI_VARIABLES_DEFAULT_SHOW_PRIVATE_REFERENCES);
setDefaultHelper(PyVariablesPreferences.DEBUG_UI_VARIABLES_SHOW_CAPITALIZED_REFERENCES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.python.pydev.jython.ui.JyScriptingPreferencesPage;

public class ScriptingExtensionInitializer extends AbstractPreferenceInitializer {
public static final String DEFAULT_SCOPE = "org.python.pydev.jython";
public static final String DEFAULT_QUALIFIER = "org.python.pydev.jython";

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(DEFAULT_QUALIFIER);

node.putBoolean(JyScriptingPreferencesPage.SHOW_SCRIPTING_OUTPUT,
JyScriptingPreferencesPage.DEFAULT_SHOW_SCRIPTING_OUTPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SharedCorePlugin extends Plugin {

public static final String PYDEV_PLUGIN_ID = "org.python.pydev";

public static final String DEFAULT_PYDEV_PREFERENCES_SCOPE = "org.python.pydev";
public static final String DEFAULT_PYDEV_PREFERENCES_QUALIFIER = "org.python.pydev";

//The shared instance.
private static SharedCorePlugin plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ protected void createFieldEditors() {
"Assume tab spacing when files contain tabs?", p));
addField(new BooleanFieldEditor(PyDevCoreEditorPreferences.TAB_STOP_IN_COMMENT, "Allow tab stops in comments?", p));

addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void widgetSelected(SelectionEvent e) {
addField(new LabelFieldEditor("__UNUSED__", "Note: smart move line up/down change applied on editor restart.",
p));

addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
addField(new LabelFieldEditor("__dummy__",
"I.e.: __updated__=\"2010-01-01\" will be synched on save.", p));

addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
labelExample.setLayoutData(layoutData);

addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));
}

private void createTabs(Composite p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class PydevPrefsInitializer extends AbstractPreferenceInitializer {

@Override
public void initializeDefaultPreferences() {
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE);
Preferences node = DefaultScope.INSTANCE.getNode(SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER);

node.putInt(IWizardNewProjectNameAndLocationPage.PYDEV_NEW_PROJECT_CREATE_PREFERENCES,
IWizardNewProjectNameAndLocationPage.PYDEV_NEW_PROJECT_CREATE_PROJECT_AS_SRC_FOLDER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
layoutTestRunnerOptions(stackLayout, getTestRunner(null), contentPanel);

addField(
new ScopedPreferencesFieldEditor(parentAll, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
new ScopedPreferencesFieldEditor(parentAll, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));
}

private void add(String linkText, String flag, String tooltip, Composite p) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void widgetDefaultSelected(SelectionEvent e) {
}
}));

addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_SCOPE, this));
addField(new ScopedPreferencesFieldEditor(p, SharedCorePlugin.DEFAULT_PYDEV_PREFERENCES_QUALIFIER, this));
}

private void updateEnablement(Composite p, String importEngine) {
Expand Down