mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 562997 - Switch CDT doxygen to use new Equinox preferences API
Switched from "org.eclipse.cdt.core.options" to "org.eclipse.core.runtime.preferences" Change-Id: Ie01d955079a7a54875270bb2d259c9232d30e7ea Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
parent
1d38d997dc
commit
73982472ee
9 changed files with 59 additions and 50 deletions
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.doxygen;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
||||
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||
|
||||
/**
|
||||
* The metadata for options to configure doxygen
|
||||
|
@ -30,7 +30,7 @@ public interface DoxygenMetadata {
|
|||
*
|
||||
* @see DoxygenOptions#useBriefTags()
|
||||
*/
|
||||
OptionMetadata<Boolean> useBriefTagOption();
|
||||
PreferenceMetadata<Boolean> useBriefTagOption();
|
||||
|
||||
/**
|
||||
* Returns the metadata for the "Use structural commands" option, must not return <code>null</code>.
|
||||
|
@ -39,7 +39,7 @@ public interface DoxygenMetadata {
|
|||
*
|
||||
* @see DoxygenOptions#useStructuralCommands()
|
||||
*/
|
||||
OptionMetadata<Boolean> useStructuralCommandsOption();
|
||||
PreferenceMetadata<Boolean> useStructuralCommandsOption();
|
||||
|
||||
/**
|
||||
* Returns the metadata for the "Use javadoc style for tags" option, must not return <code>null</code>.
|
||||
|
@ -48,7 +48,7 @@ public interface DoxygenMetadata {
|
|||
*
|
||||
* @see DoxygenOptions#useJavadocStyle()
|
||||
*/
|
||||
OptionMetadata<Boolean> useJavadocStyleOption();
|
||||
PreferenceMetadata<Boolean> useJavadocStyleOption();
|
||||
|
||||
/**
|
||||
* Returns the metadata for the "Add new line after brief tag" option, must not return <code>null</code>.
|
||||
|
@ -57,7 +57,7 @@ public interface DoxygenMetadata {
|
|||
*
|
||||
* @see DoxygenOptions#newLineAfterBrief()
|
||||
*/
|
||||
OptionMetadata<Boolean> newLineAfterBriefOption();
|
||||
PreferenceMetadata<Boolean> newLineAfterBriefOption();
|
||||
|
||||
/**
|
||||
* Returns the metadata for the "Add pre/post tags to functions" option, must not return <code>null</code>.
|
||||
|
@ -66,13 +66,13 @@ public interface DoxygenMetadata {
|
|||
*
|
||||
* @see DoxygenOptions#usePrePostTag()
|
||||
*/
|
||||
OptionMetadata<Boolean> usePrePostTagOption();
|
||||
PreferenceMetadata<Boolean> usePrePostTagOption();
|
||||
|
||||
/**
|
||||
* Returns the list of available boolean options to be shown in UI, must not return <code>null</code>.
|
||||
*
|
||||
* @return the list of boolean options
|
||||
*/
|
||||
List<OptionMetadata<Boolean>> booleanOptions();
|
||||
List<PreferenceMetadata<Boolean>> booleanOptions();
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.doxygen.core;
|
||||
|
||||
import org.eclipse.cdt.core.options.OptionStorage;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||
|
||||
public interface DoxygenPreferences {
|
||||
|
||||
|
@ -24,7 +24,7 @@ public interface DoxygenPreferences {
|
|||
*
|
||||
* @return the workspace storage for doxygen options
|
||||
*/
|
||||
OptionStorage workspaceStorage();
|
||||
IPreferenceMetadataStore workspaceStorage();
|
||||
|
||||
/**
|
||||
* Returns the project-specific storage for doxygen options to be used in UI, must not return <code>null</code>
|
||||
|
@ -32,7 +32,7 @@ public interface DoxygenPreferences {
|
|||
* @param project scope for the storage, must not be <code>null</code>
|
||||
* @return the project-specific storage for doxygen options
|
||||
*/
|
||||
OptionStorage projectStorage(IProject project);
|
||||
IPreferenceMetadataStore projectStorage(IProject project);
|
||||
|
||||
/**
|
||||
* Return the metadata for the options to be used in UI, must not return <code>null</code>
|
||||
|
|
|
@ -27,6 +27,7 @@ public class DoxygenCoreMessages extends NLS {
|
|||
public static String DoxygenMetadataDefaults_use_pre_post_tags_name;
|
||||
public static String DoxygenMetadataDefaults_use_structured_commands_description;
|
||||
public static String DoxygenMetadataDefaults_use_structured_commands_name;
|
||||
public static String DoxygenPreferenceAccess_e_get_preferences;
|
||||
public static String DoxygenPreferenceAccess_e_null_project;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
|
|
|
@ -22,4 +22,5 @@ DoxygenMetadataDefaults_use_pre_post_tags_description=Use always pre/post tags i
|
|||
DoxygenMetadataDefaults_use_pre_post_tags_name=Add pre/post tags to functions
|
||||
DoxygenMetadataDefaults_use_structured_commands_description=Use always structured commands in auto-generation of doxygen comment
|
||||
DoxygenMetadataDefaults_use_structured_commands_name=Use structural commands
|
||||
DoxygenPreferenceAccess_e_get_preferences=Unable to get preferences for node: {0}.{1}
|
||||
DoxygenPreferenceAccess_e_null_project=Project must not be null
|
||||
|
|
|
@ -16,33 +16,32 @@ package org.eclipse.cdt.doxygen.internal.core;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.options.BaseOption;
|
||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||
|
||||
final class DoxygenMetadataDefaults implements DoxygenMetadata {
|
||||
|
||||
private final OptionMetadata<Boolean> useBriefTagOption;
|
||||
private final OptionMetadata<Boolean> useStructuralCommandsOption;
|
||||
private final OptionMetadata<Boolean> useJavadocStyleOption;
|
||||
private final OptionMetadata<Boolean> newLineAfterBriefOption;
|
||||
private final OptionMetadata<Boolean> usePrePostTagOption;
|
||||
private final List<OptionMetadata<Boolean>> booleanOptions;
|
||||
private final PreferenceMetadata<Boolean> useBriefTagOption;
|
||||
private final PreferenceMetadata<Boolean> useStructuralCommandsOption;
|
||||
private final PreferenceMetadata<Boolean> useJavadocStyleOption;
|
||||
private final PreferenceMetadata<Boolean> newLineAfterBriefOption;
|
||||
private final PreferenceMetadata<Boolean> usePrePostTagOption;
|
||||
private final List<PreferenceMetadata<Boolean>> booleanOptions;
|
||||
|
||||
public DoxygenMetadataDefaults() {
|
||||
this.useBriefTagOption = new BaseOption<>(Boolean.class, "doxygen_use_brief_tag", false, //$NON-NLS-1$
|
||||
this.useBriefTagOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_brief_tag", false, //$NON-NLS-1$
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_name,
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_brief_tag_description);
|
||||
this.useStructuralCommandsOption = new BaseOption<>(Boolean.class, "doxygen_use_structural_commands", false, //$NON-NLS-1$
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_name,
|
||||
this.useStructuralCommandsOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_structural_commands", //$NON-NLS-1$
|
||||
false, DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_name,
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_description);
|
||||
this.useJavadocStyleOption = new BaseOption<>(Boolean.class, "doxygen_use_javadoc_tags", true, //$NON-NLS-1$
|
||||
this.useJavadocStyleOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_javadoc_tags", true, //$NON-NLS-1$
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_name,
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_javadoc_style_description);
|
||||
this.newLineAfterBriefOption = new BaseOption<>(Boolean.class, "doxygen_new_line_after_brief", true, //$NON-NLS-1$
|
||||
this.newLineAfterBriefOption = new PreferenceMetadata<>(Boolean.class, "doxygen_new_line_after_brief", true, //$NON-NLS-1$
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_name,
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_new_line_after_brief_description);
|
||||
this.usePrePostTagOption = new BaseOption<>(Boolean.class, "doxygen_use_pre_tag", false, //$NON-NLS-1$
|
||||
this.usePrePostTagOption = new PreferenceMetadata<>(Boolean.class, "doxygen_use_pre_tag", false, //$NON-NLS-1$
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_name,
|
||||
DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_description);
|
||||
this.booleanOptions = new ArrayList<>();
|
||||
|
@ -54,32 +53,32 @@ final class DoxygenMetadataDefaults implements DoxygenMetadata {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OptionMetadata<Boolean> useBriefTagOption() {
|
||||
public PreferenceMetadata<Boolean> useBriefTagOption() {
|
||||
return useBriefTagOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionMetadata<Boolean> useStructuralCommandsOption() {
|
||||
public PreferenceMetadata<Boolean> useStructuralCommandsOption() {
|
||||
return useStructuralCommandsOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionMetadata<Boolean> useJavadocStyleOption() {
|
||||
public PreferenceMetadata<Boolean> useJavadocStyleOption() {
|
||||
return useJavadocStyleOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionMetadata<Boolean> newLineAfterBriefOption() {
|
||||
public PreferenceMetadata<Boolean> newLineAfterBriefOption() {
|
||||
return newLineAfterBriefOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionMetadata<Boolean> usePrePostTagOption() {
|
||||
public PreferenceMetadata<Boolean> usePrePostTagOption() {
|
||||
return usePrePostTagOption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OptionMetadata<Boolean>> booleanOptions() {
|
||||
public List<PreferenceMetadata<Boolean>> booleanOptions() {
|
||||
return new ArrayList<>(booleanOptions);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,16 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.doxygen.internal.core;
|
||||
|
||||
import org.eclipse.cdt.core.options.OptionStorage;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
||||
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||
|
||||
final class DoxygenOptionsAccess implements DoxygenOptions {
|
||||
|
||||
private final OptionStorage optionStorage;
|
||||
private final IPreferenceMetadataStore optionStorage;
|
||||
private final DoxygenMetadata doxygenMetadata;
|
||||
|
||||
public DoxygenOptionsAccess(OptionStorage optionStorage, DoxygenMetadata doxygenMetadata) {
|
||||
public DoxygenOptionsAccess(IPreferenceMetadataStore optionStorage, DoxygenMetadata doxygenMetadata) {
|
||||
this.optionStorage = optionStorage;
|
||||
this.doxygenMetadata = doxygenMetadata;
|
||||
}
|
||||
|
|
|
@ -14,20 +14,22 @@
|
|||
package org.eclipse.cdt.doxygen.internal.core;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.options.OptionStorage;
|
||||
import org.eclipse.cdt.core.options.OsgiPreferenceStorage;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
import org.eclipse.cdt.doxygen.DoxygenOptions;
|
||||
import org.eclipse.cdt.doxygen.core.DoxygenConfiguration;
|
||||
import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||
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.prefs.Preferences;
|
||||
|
||||
@Component
|
||||
public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPreferences {
|
||||
|
@ -39,14 +41,14 @@ public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPre
|
|||
}
|
||||
|
||||
@Override
|
||||
public OptionStorage workspaceStorage() {
|
||||
return new OsgiPreferenceStorage(preferences(InstanceScope.INSTANCE));
|
||||
public IPreferenceMetadataStore workspaceStorage() {
|
||||
return new OsgiPreferenceMetadataStore(preferences(InstanceScope.INSTANCE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionStorage projectStorage(IProject project) {
|
||||
public IPreferenceMetadataStore projectStorage(IProject project) {
|
||||
Objects.requireNonNull(DoxygenCoreMessages.DoxygenPreferenceAccess_e_null_project);
|
||||
return new OsgiPreferenceStorage(preferences(new ProjectScope(project)));
|
||||
return new OsgiPreferenceMetadataStore(preferences(new ProjectScope(project)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,8 +67,14 @@ public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPre
|
|||
return new DoxygenOptionsAccess(projectStorage(project), doxygenMetadata);
|
||||
}
|
||||
|
||||
private Preferences preferences(IScopeContext scope) {
|
||||
return scope.getNode(nodeQualifier()).node(nodePath());
|
||||
private IEclipsePreferences preferences(IScopeContext scope) {
|
||||
return Optional.ofNullable(scope.getNode(nodeQualifier()))//
|
||||
.map(n -> n.node(nodePath()))//
|
||||
.filter(IEclipsePreferences.class::isInstance)//
|
||||
.map(IEclipsePreferences.class::cast)//
|
||||
.orElseThrow(() -> new IllegalStateException(//
|
||||
NLS.bind(DoxygenCoreMessages.DoxygenPreferenceAccess_e_get_preferences, //
|
||||
nodeQualifier(), nodePath())));
|
||||
}
|
||||
|
||||
private String nodeQualifier() {
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.options.OptionStorage;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
|
@ -38,6 +37,7 @@ import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
|
|||
import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenMultilineAutoEditStrategy;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||
import org.eclipse.e4.core.contexts.EclipseContextFactory;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.Document;
|
||||
|
@ -52,7 +52,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
|
|||
private HashMap<String, String> fOptions;
|
||||
protected ICProject fCProject;
|
||||
private DoxygenPreferences doxygenPreferences;
|
||||
private OptionStorage workspaceStorage;
|
||||
private IPreferenceMetadataStore workspaceStorage;
|
||||
private DoxygenMetadata doxygenMetadata;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,13 +18,13 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.options.OptionMetadata;
|
||||
import org.eclipse.cdt.core.options.OptionStorage;
|
||||
import org.eclipse.cdt.doxygen.DoxygenMetadata;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
|
||||
import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
|
||||
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.core.runtime.preferences.IPreferenceMetadataStore;
|
||||
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
|
||||
import org.eclipse.jface.layout.GridDataFactory;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
|
@ -44,7 +44,7 @@ public class DocCommentOwnerArea {
|
|||
private final Combo combo;
|
||||
private final IDocCommentOwner owners[];
|
||||
|
||||
private final Map<OptionMetadata<Boolean>, Button> buttons;
|
||||
private final Map<PreferenceMetadata<Boolean>, Button> buttons;
|
||||
|
||||
public DocCommentOwnerArea(Composite pane, DoxygenMetadata metadata, String descriptionText,
|
||||
String comboLabelText) {
|
||||
|
@ -73,7 +73,7 @@ public class DocCommentOwnerArea {
|
|||
return created;
|
||||
}
|
||||
|
||||
private Button createCheckBox(Composite parent, OptionMetadata<Boolean> option) {
|
||||
private Button createCheckBox(Composite parent, PreferenceMetadata<Boolean> option) {
|
||||
Button checkBox = new Button(parent, SWT.CHECK);
|
||||
checkBox.setText(option.name());
|
||||
checkBox.setToolTipText(option.description());
|
||||
|
@ -98,7 +98,7 @@ public class DocCommentOwnerArea {
|
|||
return result.toArray(new IDocCommentOwner[result.size()]);
|
||||
}
|
||||
|
||||
public void initialize(IDocCommentOwner initial, OptionStorage storage) {
|
||||
public void initialize(IDocCommentOwner initial, IPreferenceMetadataStore storage) {
|
||||
selectDocumentOwner(initial, combo);
|
||||
buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class DocCommentOwnerArea {
|
|||
return index == 0 ? NullDocCommentOwner.INSTANCE : owners[index - 1];
|
||||
}
|
||||
|
||||
public void apply(OptionStorage storage) {
|
||||
public void apply(IPreferenceMetadataStore storage) {
|
||||
buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue