mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 564274 - Switch CDT cmake to use new Equinox preferences API
Replace "org.eclipse.cdt.core.options" with "org.eclipse.core.runtime.preferences" Change-Id: I6ac4813b680ebf34336c85bfd3bc1721d6656dc4 Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
fe2daff197
commit
a5dce82d54
7 changed files with 38 additions and 27 deletions
|
@ -16,7 +16,7 @@ import java.util.regex.PatternSyntaxException;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesAccess;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesAccess;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
||||||
import org.eclipse.jface.layout.GridDataFactory;
|
import org.eclipse.jface.layout.GridDataFactory;
|
||||||
import org.eclipse.jface.preference.PreferencePage;
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
@ -155,7 +155,7 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor
|
||||||
* @param text text to display on the check-box
|
* @param text text to display on the check-box
|
||||||
*/
|
*/
|
||||||
private static Button createCheckbox(Composite parent, int horizontalAlignment, int horizontalSpan,
|
private static Button createCheckbox(Composite parent, int horizontalAlignment, int horizontalSpan,
|
||||||
OptionMetadata<Boolean> option) {
|
PreferenceMetadata<Boolean> option) {
|
||||||
Button b = new Button(parent, SWT.CHECK);
|
Button b = new Button(parent, SWT.CHECK);
|
||||||
b.setText(option.name());
|
b.setText(option.name());
|
||||||
b.setToolTipText(option.description());
|
b.setToolTipText(option.description());
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.cmake.is.core;
|
package org.eclipse.cdt.cmake.is.core;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The metadata for options to configure the {@code compile_commands.json} parser.
|
* The metadata for options to configure the {@code compile_commands.json} parser.
|
||||||
|
@ -24,19 +24,19 @@ public interface IParserPreferencesMetadata {
|
||||||
*
|
*
|
||||||
* @return the metadata for the preference option, never {@null}
|
* @return the metadata for the preference option, never {@null}
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> tryVersionSuffix();
|
PreferenceMetadata<Boolean> tryVersionSuffix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the {@link IParserPreferences#getVersionSuffixPattern()} preference.
|
* Returns the metadata for the {@link IParserPreferences#getVersionSuffixPattern()} preference.
|
||||||
*
|
*
|
||||||
* @return the metadata for the preference option, never {@null}
|
* @return the metadata for the preference option, never {@null}
|
||||||
*/
|
*/
|
||||||
OptionMetadata<String> versionSuffixPattern();
|
PreferenceMetadata<String> versionSuffixPattern();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the metadata for the {@link IParserPreferences#getAllocateConsole()} preference.
|
* Returns the metadata for the {@link IParserPreferences#getAllocateConsole()} preference.
|
||||||
*
|
*
|
||||||
* @return the metadata for the preference option, never {@null}
|
* @return the metadata for the preference option, never {@null}
|
||||||
*/
|
*/
|
||||||
OptionMetadata<Boolean> allocateConsole();
|
PreferenceMetadata<Boolean> allocateConsole();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
*/
|
*/
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.internal.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.cmake.is.core.internal.messages"; //$NON-NLS-1$
|
||||||
|
public static String ParserPreferencesAccess_e_get_preferences;
|
||||||
public static String ParserPreferencesMetadata_label_console;
|
public static String ParserPreferencesMetadata_label_console;
|
||||||
public static String ParserPreferencesMetadata_label_suffix;
|
public static String ParserPreferencesMetadata_label_suffix;
|
||||||
public static String ParserPreferencesMetadata_label_try_suffix;
|
public static String ParserPreferencesMetadata_label_try_suffix;
|
||||||
|
|
|
@ -15,17 +15,17 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author weber
|
* @author weber
|
||||||
*/
|
*/
|
||||||
final class ParserPreferences implements IParserPreferences {
|
final class ParserPreferences implements IParserPreferences {
|
||||||
|
|
||||||
private final OptionStorage optionStorage;
|
private final IPreferenceMetadataStore optionStorage;
|
||||||
private final IParserPreferencesMetadata metadata;
|
private final IParserPreferencesMetadata metadata;
|
||||||
|
|
||||||
public ParserPreferences(OptionStorage optionStorage, IParserPreferencesMetadata metadata) {
|
public ParserPreferences(IPreferenceMetadataStore optionStorage, IParserPreferencesMetadata metadata) {
|
||||||
this.optionStorage = Objects.requireNonNull(optionStorage, "optionStorage"); //$NON-NLS-1$
|
this.optionStorage = Objects.requireNonNull(optionStorage, "optionStorage"); //$NON-NLS-1$
|
||||||
this.metadata = Objects.requireNonNull(metadata, "metadata"); //$NON-NLS-1$
|
this.metadata = Objects.requireNonNull(metadata, "metadata"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,18 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.cmake.is.core.internal;
|
package org.eclipse.cdt.cmake.is.core.internal;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferences;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesAccess;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesAccess;
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
||||||
import org.eclipse.cdt.core.options.OptionStorage;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.cdt.core.options.OsgiPreferenceStorage;
|
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.OsgiPreferenceMetadataStore;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
import org.osgi.service.prefs.Preferences;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author weber
|
* @author weber
|
||||||
|
@ -33,8 +36,8 @@ public class ParserPreferencesAccess implements IParserPreferencesAccess {
|
||||||
this.metadata = new ParserPreferencesMetadata();
|
this.metadata = new ParserPreferencesMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OptionStorage workspaceStorage() {
|
private IPreferenceMetadataStore workspaceStorage() {
|
||||||
return new OsgiPreferenceStorage(preferences(InstanceScope.INSTANCE));
|
return new OsgiPreferenceMetadataStore(preferences(InstanceScope.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,8 +50,14 @@ public class ParserPreferencesAccess implements IParserPreferencesAccess {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Preferences preferences(IScopeContext scope) {
|
private IEclipsePreferences preferences(IScopeContext scope) {
|
||||||
return scope.getNode(nodeQualifier()).node(nodePath());
|
return Optional.ofNullable(scope.getNode(nodeQualifier()))//
|
||||||
|
.map(n -> n.node(nodePath()))//
|
||||||
|
.filter(IEclipsePreferences.class::isInstance)//
|
||||||
|
.map(IEclipsePreferences.class::cast)//
|
||||||
|
.orElseThrow(() -> new IllegalStateException(//
|
||||||
|
NLS.bind(Messages.ParserPreferencesAccess_e_get_preferences, //
|
||||||
|
nodeQualifier(), nodePath())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String nodeQualifier() {
|
private String nodeQualifier() {
|
||||||
|
|
|
@ -12,40 +12,40 @@
|
||||||
package org.eclipse.cdt.cmake.is.core.internal;
|
package org.eclipse.cdt.cmake.is.core.internal;
|
||||||
|
|
||||||
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
import org.eclipse.cdt.cmake.is.core.IParserPreferencesMetadata;
|
||||||
import org.eclipse.cdt.core.options.BaseOption;
|
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author weber
|
* @author weber
|
||||||
*/
|
*/
|
||||||
final class ParserPreferencesMetadata implements IParserPreferencesMetadata {
|
final class ParserPreferencesMetadata implements IParserPreferencesMetadata {
|
||||||
|
|
||||||
private final OptionMetadata<Boolean> tryVersionSuffixOption;
|
private final PreferenceMetadata<Boolean> tryVersionSuffixOption;
|
||||||
private final OptionMetadata<String> versionSuffixPatternOption;
|
private final PreferenceMetadata<String> versionSuffixPatternOption;
|
||||||
private final OptionMetadata<Boolean> allocateConsoleOption;
|
private final PreferenceMetadata<Boolean> allocateConsoleOption;
|
||||||
|
|
||||||
public ParserPreferencesMetadata() {
|
public ParserPreferencesMetadata() {
|
||||||
this.tryVersionSuffixOption = new BaseOption<>(Boolean.class, "versionSuffixPatternEnabled", false, //$NON-NLS-1$
|
this.tryVersionSuffixOption = new PreferenceMetadata<>(Boolean.class, "versionSuffixPatternEnabled", false, //$NON-NLS-1$
|
||||||
Messages.ParserPreferencesMetadata_label_try_suffix,
|
Messages.ParserPreferencesMetadata_label_try_suffix,
|
||||||
Messages.ParserPreferencesMetadata_ttip_try_suffix);
|
Messages.ParserPreferencesMetadata_ttip_try_suffix);
|
||||||
this.versionSuffixPatternOption = new BaseOption<>(String.class, "versionSuffixPattern", "-?\\d+(\\.\\d+)*", //$NON-NLS-1$ //$NON-NLS-2$
|
this.versionSuffixPatternOption = new PreferenceMetadata<>(String.class, "versionSuffixPattern", //$NON-NLS-1$
|
||||||
|
"-?\\d+(\\.\\d+)*", //$NON-NLS-1$
|
||||||
Messages.ParserPreferencesMetadata_label_suffix, Messages.ParserPreferencesMetadata_ttip_suffix);
|
Messages.ParserPreferencesMetadata_label_suffix, Messages.ParserPreferencesMetadata_ttip_suffix);
|
||||||
this.allocateConsoleOption = new BaseOption<>(Boolean.class, "allocateConsole", false, //$NON-NLS-1$
|
this.allocateConsoleOption = new PreferenceMetadata<>(Boolean.class, "allocateConsole", false, //$NON-NLS-1$
|
||||||
Messages.ParserPreferencesMetadata_label_console);
|
Messages.ParserPreferencesMetadata_label_console);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> tryVersionSuffix() {
|
public PreferenceMetadata<Boolean> tryVersionSuffix() {
|
||||||
return tryVersionSuffixOption;
|
return tryVersionSuffixOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<String> versionSuffixPattern() {
|
public PreferenceMetadata<String> versionSuffixPattern() {
|
||||||
return versionSuffixPatternOption;
|
return versionSuffixPatternOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OptionMetadata<Boolean> allocateConsole() {
|
public PreferenceMetadata<Boolean> allocateConsole() {
|
||||||
return allocateConsoleOption;
|
return allocateConsoleOption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Martin Weber - initial API and implementation
|
# Martin Weber - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
ParserPreferencesAccess_e_get_preferences=Unable to get preferences for node: {0}.{1}
|
||||||
ParserPreferencesMetadata_label_console=&Show output of compiler built-in detection in a console in the Console View
|
ParserPreferencesMetadata_label_console=&Show output of compiler built-in detection in a console in the Console View
|
||||||
ParserPreferencesMetadata_label_suffix=&Suffix pattern:
|
ParserPreferencesMetadata_label_suffix=&Suffix pattern:
|
||||||
ParserPreferencesMetadata_label_try_suffix=&Also try with version suffix
|
ParserPreferencesMetadata_label_try_suffix=&Also try with version suffix
|
||||||
|
|
Loading…
Add table
Reference in a new issue