diff --git a/core/org.eclipse.cdt.core/.classpath b/core/org.eclipse.cdt.core/.classpath
index 51ccf9ff55a..0b404cf8b0f 100644
--- a/core/org.eclipse.cdt.core/.classpath
+++ b/core/org.eclipse.cdt.core/.classpath
@@ -9,5 +9,6 @@
+
diff --git a/core/org.eclipse.cdt.core/.project b/core/org.eclipse.cdt.core/.project
index 6773654ae7f..a7aa6e98d34 100644
--- a/core/org.eclipse.cdt.core/.project
+++ b/core/org.eclipse.cdt.core/.project
@@ -25,6 +25,11 @@
+
+ org.eclipse.pde.ds.core.builder
+
+
+
org.eclipse.jdt.core.javanature
diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.pde.ds.annotations.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.pde.ds.annotations.prefs
new file mode 100644
index 00000000000..73a356b6d05
--- /dev/null
+++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.pde.ds.annotations.prefs
@@ -0,0 +1,8 @@
+classpath=true
+dsVersion=V1_3
+eclipse.preferences.version=1
+enabled=true
+generateBundleActivationPolicyLazy=true
+path=OSGI-INF
+validationErrorLevel=error
+validationErrorLevel.missingImplicitUnbindMethod=error
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 049200245a2..829d873b99e 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -45,6 +45,8 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.templateengine,
org.eclipse.cdt.core.templateengine.process,
org.eclipse.cdt.core.templateengine.process.processes,
+ org.eclipse.cdt.doxygen;x-friends:="org.eclipse.cdt.ui",
+ org.eclipse.cdt.doxygen.core;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core;
x-friends:="org.eclipse.cdt.codan.core.cxx,
org.eclipse.cdt.debug.core,
@@ -82,7 +84,7 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.debug.ui,
org.eclipse.cdt.codan.ui",
org.eclipse.cdt.internal.core.model.ext;x-friends:="org.eclipse.cdt.ui",
- org.eclipse.cdt.internal.core.options;x-friends:="org.eclipse.cdt.ui",
+ org.eclipse.cdt.internal.core.options;x-internal:=true,
org.eclipse.cdt.internal.core.parser;x-internal:=true,
org.eclipse.cdt.internal.core.parser.problem;x-internal:=true,
org.eclipse.cdt.internal.core.parser.scanner;x-friends:="org.eclipse.cdt.ui",
@@ -129,6 +131,7 @@ Require-Bundle: org.eclipse.cdt.core.native;bundle-version="[5.10.100,6.0.0)";vi
org.eclipse.core.runtime;bundle-version="[3.16.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.4.600,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.10.200,4.0.0)",
+ org.eclipse.osgi.services;bundle-version="[3.8.0,4.0.0)",
org.eclipse.text;bundle-version="[3.9.0,4.0.0)",
com.ibm.icu;bundle-version="4.4.2",
com.google.gson,
@@ -137,4 +140,5 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.xml.bind;version="2.2.0"
Automatic-Module-Name: org.eclipse.cdt.core
+Service-Component: OSGI-INF/*.xml
diff --git a/core/org.eclipse.cdt.core/OSGI-INF/org.eclipse.cdt.doxygen.internal.core.DoxygenPreferenceAccess.xml b/core/org.eclipse.cdt.core/OSGI-INF/org.eclipse.cdt.doxygen.internal.core.DoxygenPreferenceAccess.xml
new file mode 100644
index 00000000000..5dfe6a36142
--- /dev/null
+++ b/core/org.eclipse.cdt.core/OSGI-INF/org.eclipse.cdt.doxygen.internal.core.DoxygenPreferenceAccess.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/build.properties b/core/org.eclipse.cdt.core/build.properties
index bade6f71b65..45300e0b71b 100644
--- a/core/org.eclipse.cdt.core/build.properties
+++ b/core/org.eclipse.cdt.core/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2015 IBM Corporation and others.
+# Copyright (c) 2003, 2020 IBM Corporation and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -11,13 +11,15 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Martin Oberhuber (Wind River) - [303083] Split out the Spawner
+# Alexander Fedorov - Bug 559193
###############################################################################
bin.includes = plugin.xml,\
plugin.properties,\
about.html,\
.,\
META-INF/,\
- .options
+ .options,\
+ OSGI-INF/
src.includes = schema/,\
about.html
javadoc.packages = org.eclipse.cdt.core.*,\
@@ -33,4 +35,5 @@ source.. = src/,\
browser/,\
templateengine/,\
options/,\
+ doxygen/,\
utils/
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenMetadata.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenMetadata.java
new file mode 100644
index 00000000000..fb9a2fc81f3
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenMetadata.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.doxygen;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.options.OptionMetadata;
+
+/**
+ * The metadata for options to configure doxygen
+ *
+ */
+public interface DoxygenMetadata {
+
+ /**
+ * Returns the metadata for the "Use brief tag" option, must not return null
.
+ *
+ * @return the metadata for the "Use brief tag" option
+ *
+ * @see DoxygenOptions#useBriefTags()
+ */
+ OptionMetadata useBriefTagOption();
+
+ /**
+ * Returns the metadata for the "Use structural commands" option, must not return null
.
+ *
+ * @return the metadata for the "Use structural commands" option
+ *
+ * @see DoxygenOptions#useStructuralCommands()
+ */
+ OptionMetadata useStructuralCommandsOption();
+
+ /**
+ * Returns the metadata for the "Use javadoc style for tags" option, must not return null
.
+ *
+ * @return the metadata for the "Use javadoc style for tags" option
+ *
+ * @see DoxygenOptions#useJavadocStyle()
+ */
+ OptionMetadata useJavadocStyleOption();
+
+ /**
+ * Returns the metadata for the "Add new line after brief tag" option, must not return null
.
+ *
+ * @return the metadata for the "Add new line after brief tag" option
+ *
+ * @see DoxygenOptions#newLineAfterBrief()
+ */
+ OptionMetadata newLineAfterBriefOption();
+
+ /**
+ * Returns the metadata for the "Add pre/post tags to functions" option, must not return null
.
+ *
+ * @return the metadata for the "Add pre/post tags to functions" option
+ *
+ * @see DoxygenOptions#usePrePostTag()
+ */
+ OptionMetadata usePrePostTagOption();
+
+ /**
+ * Returns the list of available boolean options to be shown in UI, must not return null
.
+ *
+ * @return the list of boolean options
+ */
+ List> booleanOptions();
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenOptions.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenOptions.java
new file mode 100644
index 00000000000..1140811e770
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/DoxygenOptions.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.doxygen;
+
+/**
+ * Options to configure doxygen
+ *
+ */
+public interface DoxygenOptions {
+
+ /**
+ * Use always brief tag in auto-generation of doxygen comment
+ *
+ */
+ boolean useBriefTags();
+
+ /**
+ * Use always structured commands in auto-generation of doxygen comment
+ *
+ */
+ boolean useStructuralCommands();
+
+ /**
+ * Use always javadoc tag style in auto-generation of doxygen comment
+ *
+ */
+ boolean useJavadocStyle();
+
+ /**
+ * Use always a new line after brief tag in auto-generation of doxygen comment
+ *
+ */
+ boolean newLineAfterBrief();
+
+ /**
+ * Use always pre/post tags in auto-generation of doxygen comment
+ *
+ */
+ boolean usePrePostTag();
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenConfiguration.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenConfiguration.java
new file mode 100644
index 00000000000..973bc40ee9b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenConfiguration.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.doxygen.core;
+
+import org.eclipse.cdt.doxygen.DoxygenOptions;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * Provides access to the doxygen options according to the required preference scope
+ *
+ */
+public interface DoxygenConfiguration {
+
+ /**
+ * Returns the doxygen options for the workspace scope, must not return null
+ *
+ * @return doxygen options for the workspace scope
+ */
+ DoxygenOptions workspaceOptions();
+
+ /**
+ * Returns the doxygen options for the given project scope, must not return null
+ *
+ * @param project scope for doxygen options, must not be null
+ * @return doxygen options for the given project scope
+ */
+ DoxygenOptions projectOptions(IProject project);
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenPreferences.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenPreferences.java
new file mode 100644
index 00000000000..efef3545eda
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/core/DoxygenPreferences.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+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;
+
+public interface DoxygenPreferences {
+
+ /**
+ * Returns the workspace storage for doxygen options to be used in UI, must not return null
+ *
+ * @return the workspace storage for doxygen options
+ */
+ OptionStorage workspaceStorage();
+
+ /**
+ * Returns the project-specific storage for doxygen options to be used in UI, must not return null
+ *
+ * @param project scope for the storage, must not be null
+ * @return the project-specific storage for doxygen options
+ */
+ OptionStorage projectStorage(IProject project);
+
+ /**
+ * Return the metadata for the options to be used in UI, must not return null
+ *
+ * @return the doxygen option metadata
+ */
+ DoxygenMetadata metadata();
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.java
new file mode 100644
index 00000000000..fa43895cdb4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.doxygen.internal.core;
+
+import org.eclipse.osgi.util.NLS;
+
+public class DoxygenCoreMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.doxygen.internal.core.DoxygenCoreMessages"; //$NON-NLS-1$
+ public static String DoxygenMetadataDefaults_new_line_after_brief_description;
+ public static String DoxygenMetadataDefaults_new_line_after_brief_name;
+ public static String DoxygenMetadataDefaults_use_brief_tag_description;
+ public static String DoxygenMetadataDefaults_use_brief_tag_name;
+ public static String DoxygenMetadataDefaults_use_javadoc_style_description;
+ public static String DoxygenMetadataDefaults_use_javadoc_style_name;
+ public static String DoxygenMetadataDefaults_use_pre_post_tags_description;
+ 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_null_project;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, DoxygenCoreMessages.class);
+ }
+
+ private DoxygenCoreMessages() {
+ }
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.properties b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.properties
new file mode 100644
index 00000000000..582017dec52
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenCoreMessages.properties
@@ -0,0 +1,25 @@
+###############################################################################
+# Copyright (c) 2020 ArSysOp and others.
+#
+# This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License 2.0
+# which accompanies this distribution, and is available at
+# https://www.eclipse.org/legal/epl-2.0/
+#
+# SPDX-License-Identifier: EPL-2.0
+#
+# Contributors:
+# Alexander Fedorov - Initial API and implementation
+###############################################################################
+
+DoxygenMetadataDefaults_new_line_after_brief_description=Use always a new line after brief tag in auto-generation of doxygen comment
+DoxygenMetadataDefaults_new_line_after_brief_name=Add new line after brief tag
+DoxygenMetadataDefaults_use_brief_tag_description=Use always brief tag in auto-generation of doxygen comment
+DoxygenMetadataDefaults_use_brief_tag_name=Use brief tag
+DoxygenMetadataDefaults_use_javadoc_style_description=Use always javadoc tag style in auto-generation of doxygen comment
+DoxygenMetadataDefaults_use_javadoc_style_name=Use javadoc style for tags
+DoxygenMetadataDefaults_use_pre_post_tags_description=Use always pre/post tags in auto-generation of doxygen comment
+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_null_project=Project must not be null
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenMetadataDefaults.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenMetadataDefaults.java
new file mode 100644
index 00000000000..8c0753c6913
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenMetadataDefaults.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+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;
+
+final class DoxygenMetadataDefaults implements DoxygenMetadata {
+
+ private final OptionMetadata useBriefTagOption;
+ private final OptionMetadata useStructuralCommandsOption;
+ private final OptionMetadata useJavadocStyleOption;
+ private final OptionMetadata newLineAfterBriefOption;
+ private final OptionMetadata usePrePostTagOption;
+ private final List> booleanOptions;
+
+ public DoxygenMetadataDefaults() {
+ this.useBriefTagOption = new BaseOption<>(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,
+ DoxygenCoreMessages.DoxygenMetadataDefaults_use_structured_commands_description);
+ this.useJavadocStyleOption = new BaseOption<>(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$
+ 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$
+ DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_name,
+ DoxygenCoreMessages.DoxygenMetadataDefaults_use_pre_post_tags_description);
+ this.booleanOptions = new ArrayList<>();
+ booleanOptions.add(useBriefTagOption);
+ booleanOptions.add(useStructuralCommandsOption);
+ booleanOptions.add(useJavadocStyleOption);
+ booleanOptions.add(newLineAfterBriefOption);
+ booleanOptions.add(usePrePostTagOption);
+ }
+
+ @Override
+ public OptionMetadata useBriefTagOption() {
+ return useBriefTagOption;
+ }
+
+ @Override
+ public OptionMetadata useStructuralCommandsOption() {
+ return useStructuralCommandsOption;
+ }
+
+ @Override
+ public OptionMetadata useJavadocStyleOption() {
+ return useJavadocStyleOption;
+ }
+
+ @Override
+ public OptionMetadata newLineAfterBriefOption() {
+ return newLineAfterBriefOption;
+ }
+
+ @Override
+ public OptionMetadata usePrePostTagOption() {
+ return usePrePostTagOption;
+ }
+
+ @Override
+ public List> booleanOptions() {
+ return new ArrayList<>(booleanOptions);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenOptionsAccess.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenOptionsAccess.java
new file mode 100644
index 00000000000..8a7e241b4c0
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenOptionsAccess.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+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;
+
+final class DoxygenOptionsAccess implements DoxygenOptions {
+
+ private final OptionStorage optionStorage;
+ private final DoxygenMetadata doxygenMetadata;
+
+ public DoxygenOptionsAccess(OptionStorage optionStorage, DoxygenMetadata doxygenMetadata) {
+ this.optionStorage = optionStorage;
+ this.doxygenMetadata = doxygenMetadata;
+ }
+
+ @Override
+ public boolean useBriefTags() {
+ return optionStorage.load(doxygenMetadata.useBriefTagOption());
+ }
+
+ @Override
+ public boolean useStructuralCommands() {
+ return optionStorage.load(doxygenMetadata.useStructuralCommandsOption());
+ }
+
+ @Override
+ public boolean useJavadocStyle() {
+ return optionStorage.load(doxygenMetadata.useJavadocStyleOption());
+ }
+
+ @Override
+ public boolean newLineAfterBrief() {
+ return optionStorage.load(doxygenMetadata.newLineAfterBriefOption());
+ }
+
+ @Override
+ public boolean usePrePostTag() {
+ return optionStorage.load(doxygenMetadata.usePrePostTagOption());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenPreferenceAccess.java b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenPreferenceAccess.java
new file mode 100644
index 00000000000..a79c9bba4f8
--- /dev/null
+++ b/core/org.eclipse.cdt.core/doxygen/org/eclipse/cdt/doxygen/internal/core/DoxygenPreferenceAccess.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Alexander Fedorov - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.doxygen.internal.core;
+
+import java.util.Objects;
+
+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.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.prefs.Preferences;
+
+@Component
+public class DoxygenPreferenceAccess implements DoxygenConfiguration, DoxygenPreferences {
+
+ private final DoxygenMetadata doxygenMetadata;
+
+ public DoxygenPreferenceAccess() {
+ this.doxygenMetadata = new DoxygenMetadataDefaults();
+ }
+
+ @Override
+ public OptionStorage workspaceStorage() {
+ return new OsgiPreferenceStorage(preferences(InstanceScope.INSTANCE));
+ }
+
+ @Override
+ public OptionStorage projectStorage(IProject project) {
+ Objects.requireNonNull(DoxygenCoreMessages.DoxygenPreferenceAccess_e_null_project);
+ return new OsgiPreferenceStorage(preferences(new ProjectScope(project)));
+ }
+
+ @Override
+ public DoxygenMetadata metadata() {
+ return doxygenMetadata;
+ }
+
+ @Override
+ public DoxygenOptions workspaceOptions() {
+ return new DoxygenOptionsAccess(workspaceStorage(), doxygenMetadata);
+ }
+
+ @Override
+ public DoxygenOptions projectOptions(IProject project) {
+ Objects.requireNonNull(DoxygenCoreMessages.DoxygenPreferenceAccess_e_null_project);
+ return new DoxygenOptionsAccess(projectStorage(project), doxygenMetadata);
+ }
+
+ private Preferences preferences(IScopeContext scope) {
+ return scope.getNode(nodeQualifier()).node(nodePath());
+ }
+
+ private String nodeQualifier() {
+ return CCorePlugin.PLUGIN_ID;
+ }
+
+ private String nodePath() {
+ return "doxygen"; //$NON-NLS-1$
+ }
+}
diff --git a/core/org.eclipse.cdt.core/options/org/eclipse/cdt/internal/core/options/OptionMessages.properties b/core/org.eclipse.cdt.core/options/org/eclipse/cdt/internal/core/options/OptionMessages.properties
index 1b370c4d3d6..39319868e2a 100644
--- a/core/org.eclipse.cdt.core/options/org/eclipse/cdt/internal/core/options/OptionMessages.properties
+++ b/core/org.eclipse.cdt.core/options/org/eclipse/cdt/internal/core/options/OptionMessages.properties
@@ -9,7 +9,7 @@
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
-# Alexander Fedorov - Initial implementation
+# Alexander Fedorov - Initial API and implementation
###############################################################################
BaseOption_e_null_default_value=Option default value must not be null
diff --git a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF
index 8ffb0d2cff2..d27c3c03c21 100644
--- a/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui.tests/META-INF/MANIFEST.MF
@@ -39,6 +39,7 @@ Require-Bundle: org.eclipse.jface.text,
org.eclipse.core.filesystem;bundle-version="1.2.0",
org.eclipse.ltk.ui.refactoring,
org.eclipse.osgi,
+ org.eclipse.e4.core.contexts;bundle-version="[1.8.300,2.0.0)",
org.mockito,
org.hamcrest
Bundle-ActivationPolicy: lazy
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java
index 60ba475db90..2674032ed48 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java
@@ -13,7 +13,7 @@
* Sergey Prigogin (Google)
* Andrew Ferguson (Symbian)
* Marco Stornelli - Bug 333134
- * Alexander Fedorov - Bug 333134
+ * Alexander Fedorov - Bug 333134, Bug 559193
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.doctools.doxygen;
@@ -23,12 +23,14 @@ 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;
+import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.ui.text.CAutoIndentStrategy;
import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.tests.text.AbstractAutoEditTest;
import org.eclipse.cdt.ui.text.ICPartitions;
@@ -36,6 +38,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.e4.core.contexts.EclipseContextFactory;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@@ -48,6 +51,9 @@ import junit.framework.Test;
public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
private HashMap fOptions;
protected ICProject fCProject;
+ private DoxygenPreferences doxygenPreferences;
+ private OptionStorage workspaceStorage;
+ private DoxygenMetadata doxygenMetadata;
/**
* @param name
@@ -65,14 +71,12 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
super.setUp();
fOptions = CCorePlugin.getOptions();
fCProject = CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null);
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
- DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
- DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
+ DoxygenPreferences doxygenPreferences = EclipseContextFactory
+ .getServiceContext(CCorePlugin.getDefault().getBundle().getBundleContext())
+ .get(DoxygenPreferences.class);
+ doxygenMetadata = doxygenPreferences.metadata();
+ workspaceStorage = doxygenPreferences.workspaceStorage();
+ doxygenMetadata.booleanOptions().forEach(o -> workspaceStorage.save(o.defaultValue(), o));
}
/*
@@ -733,8 +737,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// */
//void foo() {}
public void testAutoDocCommentBrief() throws CoreException {
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
+ workspaceStorage.save(true, doxygenMetadata.useBriefTagOption());
assertAutoEditBehaviour();
}
@@ -746,9 +749,8 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// */
//void foo() {}
public void testAutoDocCommentBriefNoNewLine() throws CoreException {
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF, false);
+ workspaceStorage.save(true, doxygenMetadata.useBriefTagOption());
+ workspaceStorage.save(false, doxygenMetadata.newLineAfterBriefOption());
assertAutoEditBehaviour();
}
@@ -760,8 +762,7 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// */
//void foo() {}
public void testAutoDocCommentStructured() throws CoreException {
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS, true);
+ workspaceStorage.save(true, doxygenMetadata.useStructuralCommandsOption());
assertAutoEditBehaviour();
}
@@ -774,9 +775,8 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// */
//void foo() {}
public void testAutoDocCommentNoJavadoc() throws CoreException {
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS, false);
+ workspaceStorage.save(true, doxygenMetadata.useBriefTagOption());
+ workspaceStorage.save(false, doxygenMetadata.useJavadocStyleOption());
assertAutoEditBehaviour();
}
@@ -791,9 +791,8 @@ public class DoxygenCCommentAutoEditStrategyTest extends AbstractAutoEditTest {
// */
//void foo() {}
public void testAutoDocCommentPrePostTags() throws CoreException {
- DoxygenPreferences pref = new DoxygenPreferences();
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG, true);
- pref.putBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS, true);
+ workspaceStorage.save(true, doxygenMetadata.useBriefTagOption());
+ workspaceStorage.save(true, doxygenMetadata.usePrePostTagOption());
assertAutoEditBehaviour();
}
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 734a8662157..cd923f59d23 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -109,6 +109,7 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="[6.9.0,7.0.0)",
org.eclipse.core.resources;bundle-version="[3.13.500,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.16.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.4.600,4.0.0)",
+ org.eclipse.e4.core.contexts;bundle-version="[1.8.300,2.0.0)",
org.eclipse.help;bundle-version="[3.8.500,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.15.300,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.10.200,4.0.0)",
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
index 3824a4db737..b3041bd8943 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
@@ -15,7 +15,7 @@
* Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
* Marco Stornelli - Bug 333134
- * Alexander Fedorov - Bug 333134
+ * Alexander Fedorov - Bug 333134, Bug 559193
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
@@ -26,18 +26,19 @@ import static org.eclipse.cdt.ui.PreferenceConstants.FORMATTING_SCOPE_STATEMENT;
import java.util.ArrayList;
+import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
-import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.dialogs.DocCommentOwnerComposite;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.ColorSelector;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -59,6 +60,7 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;
/**
@@ -94,7 +96,9 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
super();
Bundle jfaceText = Platform.getBundle("org.eclipse.jface.text"); //$NON-NLS-1$
formattingScopeForEmptySelectionSupported = jfaceText.getVersion().compareTo(new Version(3, 10, 0)) >= 0;
- doxygenPreferences = new DoxygenPreferences();
+ doxygenPreferences = EclipseContextFactory
+ .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext())
+ .get(DoxygenPreferences.class);
}
@Override
@@ -350,6 +354,7 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
String msg = PreferencesMessages.CEditorPreferencePage_WorkspaceDefaultLabel;
IDocCommentOwner workspaceOwner = DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
fDocCommentOwnerComposite = new DocCommentOwnerComposite(contents, workspaceOwner, dsc, msg);
+ fDocCommentOwnerComposite.setDoxygenMetadata(doxygenPreferences.metadata());
fDocCommentOwnerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
initialize();
@@ -368,14 +373,14 @@ public class CEditorPreferencePage extends AbstractPreferencePage {
fAppearanceColorList.select(0);
handleAppearanceColorListSelection();
});
- fDocCommentOwnerComposite.initialize(doxygenPreferences);
+ fDocCommentOwnerComposite.initialize(doxygenPreferences.workspaceStorage());
}
@Override
public boolean performOk() {
DocCommentOwnerManager.getInstance()
.setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
- fDocCommentOwnerComposite.apply(doxygenPreferences);
+ fDocCommentOwnerComposite.apply(doxygenPreferences.workspaceStorage());
return super.performOk();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DoxygenPreferences.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DoxygenPreferences.java
deleted file mode 100644
index 8d7d6346af1..00000000000
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DoxygenPreferences.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2020 Marco Stornelli and others
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Marco Stornelli - Initial implementation
- * Alexander Fedorov - Bug 333134
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.text.doctools;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.Preferences;
-
-/**
- * Encapsulates access to the Doxygen-related preferences according to the current scope
-
- * @since 6.7
- *
- */
-public final class DoxygenPreferences {
- /**
- * Use always brief tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final String DOXYGEN_USE_BRIEF_TAG = "doxygen_use_brief_tag"; //$NON-NLS-1$
-
- /**
- * Use always structured commands in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final String DOXYGEN_USE_STRUCTURAL_COMMANDS = "doxygen_use_structural_commands"; //$NON-NLS-1$
-
- /**
- * Use always javadoc tag style in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final String DOXYGEN_USE_JAVADOC_TAGS = "doxygen_use_javadoc_tags"; //$NON-NLS-1$
-
- /**
- * Use always a new line after brief tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final String DOXYGEN_NEW_LINE_AFTER_BRIEF = "doxygen_new_line_after_brief"; //$NON-NLS-1$
-
- /**
- * Use always a pre tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final String DOXYGEN_USE_PRE_POST_TAGS = "doxygen_use_pre_tag"; //$NON-NLS-1$
-
- /**
- * Default use always brief tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final boolean DEF_DOXYGEN_USE_BRIEF_TAG = false;
-
- /**
- * Default use always structured commands in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final boolean DEF_DOXYGEN_USE_STRUCTURED_COMMANDS = false;
-
- /**
- * Default use always javadoc tag style in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final boolean DEF_DOXYGEN_USE_JAVADOC_TAGS = true;
-
- /**
- * Default use always a new line after brief tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final boolean DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF = true;
-
- /**
- * Default use always a pre tag in auto-generation of doxygen comment
- * @since 6.7
- * @noreference This field is not intended to be referenced by clients.
- */
- public static final boolean DEF_DOXYGEN_USE_PRE_POST_TAGS = false;
-
- private final Preferences preferences;
-
- public DoxygenPreferences() {
- this(InstanceScope.INSTANCE);
- }
-
- public DoxygenPreferences(IProject project) {
- this(new ProjectScope(project));
- }
-
- public DoxygenPreferences(IScopeContext scope) {
- this.preferences = scope.getNode(getNodeQualifier()).node(getNodePath());
- }
-
- private String getNodeQualifier() {
- return CCorePlugin.PLUGIN_ID;
- }
-
- private String getNodePath() {
- return "doxygen"; //$NON-NLS-1$
- }
-
- /**
- * Get boolean preference value
- * @param key A preference key
- * @param defaultValue A default value
- * @return The preference value
- *
- * @since 6.7
- */
- public boolean getBoolean(String key, boolean defaultValue) {
- return preferences.getBoolean(key, defaultValue);
- }
-
- /**
- * Put boolean preference value
- * @param key A preference key
- * @param defaultValue A default value
- *
- * @since 6.7
- */
- public void putBoolean(String key, boolean value) {
- preferences.putBoolean(key, value);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
index db851635cda..b68f24f65e9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2020 Wind River Systems, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,11 +9,12 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Markus Schorn - initial API and implementation
- * IBM Corporation
- * Andrew Ferguson (Symbian)
- * Sergey Prigogin (Google)
- * Marc-Andre Laperle (Ericsson)
+ * Markus Schorn - initial API and implementation
+ * IBM Corporation
+ * Andrew Ferguson (Symbian)
+ * Sergey Prigogin (Google)
+ * Marc-Andre Laperle (Ericsson)
+ * Alexander Fedorov - Bug 559193
*******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
@@ -54,11 +55,6 @@ class DialogsMessages extends NLS {
public static String DocCommentOwnerBlock_SelectDocToolDescription;
public static String DocCommentOwnerCombo_None;
public static String DocCommentOwnerComposite_DocumentationToolGroupTitle;
- public static String DocCommentOwnerComposite_UseBriefTagTitle;
- public static String DocCommentOwnerComposite_UseStructuralCommandsTitle;
- public static String DocCommentOwnerComposite_UseTagJavadocStyleTitle;
- public static String DocCommentOwnerComposite_NewLineAfterBriefTitle;
- public static String DocCommentOwnerComposite_AddPrePostTagsTitle;
public static String RegexErrorParserOptionPage_ConsumeNo;
public static String RegexErrorParserOptionPage_ConsumeYes;
public static String RegexErrorParserOptionPage_DescriptionColumn;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
index a11adca6966..e07ff483329 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+# Copyright (c) 2007, 2020 Wind River Systems, Inc. and others.
#
# This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -10,10 +10,11 @@
#
# Contributors:
# Markus Schorn (Wind River Systems)
-# IBM Corporation
+# IBM Corporation
# Andrew Ferguson (Symbian)
-# Sergey Prigogin (Google)
+# Sergey Prigogin (Google)
# Marc-Andre Laperle (Ericsson)
+# Alexander Fedorov - Bug 559193
###############################################################################
PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
PreferenceScopeBlock_storeWithProject=Store settings with project
@@ -44,11 +45,6 @@ DocCommentOwnerBlock_EnableProjectSpecificSettings=Enable project specific setti
DocCommentOwnerBlock_SelectDocToolDescription=Select the documentation tool to be used to determine editor behaviors in this project
DocCommentOwnerCombo_None=None
DocCommentOwnerComposite_DocumentationToolGroupTitle=Documentation tool comments
-DocCommentOwnerComposite_UseBriefTagTitle=Use brief tag
-DocCommentOwnerComposite_UseStructuralCommandsTitle=Use structural commands
-DocCommentOwnerComposite_UseTagJavadocStyleTitle=Use javadoc style for tags
-DocCommentOwnerComposite_NewLineAfterBriefTitle=Add new line after brief tag
-DocCommentOwnerComposite_AddPrePostTagsTitle=Add pre/post tags to functions
IndexerBlock_fixedBuildConfig=Use a fixed build configuration
IndexerBlock_indexerOptions=Indexer options
IndexerBlock_buildConfigGroup=Build configuration for the indexer
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
index 8bfe7c53eec..10034b20ea6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
@@ -11,17 +11,18 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Marco Stornelli - Bug 333134
- * Alexander Fedorov - Bug 333134
+ * Alexander Fedorov - Bug 333134, Bug 559193
*******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
+import org.eclipse.cdt.doxygen.core.DoxygenPreferences;
import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
-import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -32,6 +33,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.osgi.framework.FrameworkUtil;
/**
* Project property page for setting documentation comment owner.
@@ -49,8 +51,13 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
protected Button fCheckbox;
protected Link fLink;
+ private final DoxygenPreferences doxygenPreferences;
+
public DocCommentOwnerBlock() {
fManager = DocCommentOwnerManager.getInstance();
+ doxygenPreferences = EclipseContextFactory
+ .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext())
+ .get(DoxygenPreferences.class);
}
void handleCheckBox() {
@@ -93,11 +100,11 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
IProject project = getProject();
IDocCommentOwner prjOwner = DocCommentOwnerManager.getInstance().getCommentOwner(project);
fDocComboComposite = new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
+ fDocComboComposite.setDoxygenMetadata(doxygenPreferences.metadata());
fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
fCheckbox.setSelection(fManager.projectDefinesOwnership(project));
- DoxygenPreferences preferences = new DoxygenPreferences(project);
- fDocComboComposite.initialize(preferences);
+ fDocComboComposite.initialize(doxygenPreferences.projectStorage(project));
handleCheckBox();
}
@@ -110,8 +117,7 @@ public class DocCommentOwnerBlock extends AbstractCOptionPage {
IDocCommentOwner newOwner = fDocComboComposite.getSelectedDocCommentOwner();
fManager.setCommentOwner(project, newOwner, true);
}
- DoxygenPreferences preferences = new DoxygenPreferences(project);
- fDocComboComposite.apply(preferences);
+ fDocComboComposite.apply(doxygenPreferences.projectStorage(project));
}
public IProject getProject() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
index 4c3da14e946..2634b91a3f0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
@@ -11,26 +11,17 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Marco Stornelli - Bug 333134
- * Alexander Fedorov - Bug 333134
+ * Alexander Fedorov - Bug 333134, Bug 559193
*******************************************************************************/
package org.eclipse.cdt.ui.dialogs;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS;
-import static org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS;
-
import java.util.LinkedHashMap;
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.DoxygenPreferences;
import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.layout.GridDataFactory;
@@ -54,13 +45,11 @@ public class DocCommentOwnerComposite extends Composite {
protected Label desc, comboLabel;
protected Group group;
- private final Map buttons;
- private final Map defaults;
+ private final Map, Button> buttons;
public DocCommentOwnerComposite(Composite parent, IDocCommentOwner initialOwner, String description, String label) {
super(parent, SWT.NONE);
buttons = new LinkedHashMap<>();
- defaults = new LinkedHashMap<>();
GridLayout gl = new GridLayout();
gl.marginHeight = gl.marginWidth = 0;
setLayout(gl);
@@ -83,27 +72,31 @@ public class DocCommentOwnerComposite extends Composite {
gd = GridDataFactory.fillDefaults().grab(true, false).create();
fDocCombo.setLayoutData(gd);
fDocCombo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> recheckButtons()));
- createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseBriefTagTitle, DOXYGEN_USE_BRIEF_TAG,
- DEF_DOXYGEN_USE_BRIEF_TAG);
- createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseStructuralCommandsTitle,
- DOXYGEN_USE_STRUCTURAL_COMMANDS, DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
- createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_UseTagJavadocStyleTitle,
- DOXYGEN_USE_JAVADOC_TAGS, DEF_DOXYGEN_USE_JAVADOC_TAGS);
- createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_NewLineAfterBriefTitle,
- DOXYGEN_NEW_LINE_AFTER_BRIEF, DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
- createCheckBox(group, DialogsMessages.DocCommentOwnerComposite_AddPrePostTagsTitle, DOXYGEN_USE_PRE_POST_TAGS,
- DEF_DOXYGEN_USE_PRE_POST_TAGS);
}
- private Button createCheckBox(Composite parent, String label, String key, boolean value) {
+ /**
+ * Creates widgets required to represent doxygen options, extracted from constructor to keep it unchanged.
+ * Needs to be invoked only once just after the constructor
+ *
+ * @param metadata the doxygen metadata to use for checkbox creation
+ *
+ * @since 6.7
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ public void setDoxygenMetadata(DoxygenMetadata metadata) {
+ metadata.booleanOptions().forEach(o -> createCheckBox(group, o));
+ }
+
+ private Button createCheckBox(Composite parent, OptionMetadata option) {
Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText(label);
+ checkBox.setText(option.name());
+ checkBox.setToolTipText(option.description());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent = 0;
gd.horizontalSpan = 2;
checkBox.setLayoutData(gd);
- buttons.put(key, checkBox);
- defaults.put(key, value);
+ buttons.put(option, checkBox);
return checkBox;
}
@@ -112,33 +105,29 @@ public class DocCommentOwnerComposite extends Composite {
}
/**
- * Initializes widget values from the given preference instance
+ * Initializes widget values from the given option storage instance
*
- * @param preferences the preferences to initialize from
+ * @param storage the option storage to initialize from
*
* @since 6.7
*
* @noreference This method is not intended to be referenced by clients.
*/
- public void initialize(DoxygenPreferences preferences) {
- buttons.entrySet().stream().forEach(e -> initialize(e.getValue(), preferences, e.getKey()));
- }
-
- void initialize(Button button, DoxygenPreferences pref, String key) {
- button.setSelection(pref.getBoolean(key, defaults.get(key)));
+ public void initialize(OptionStorage storage) {
+ buttons.entrySet().stream().forEach(e -> e.getValue().setSelection(storage.load(e.getKey())));
}
/**
- * Apply widget values to the given preference instance
+ * Apply widget values to the given option storage instance
*
- * @param preferences the preferences to apply to
+ * @param storage the option storage to apply to
*
* @since 6.7
*
* @noreference This method is not intended to be referenced by clients.
*/
- public void apply(DoxygenPreferences preferences) {
- buttons.entrySet().stream().forEach(e -> preferences.putBoolean(e.getKey(), e.getValue().getSelection()));
+ public void apply(OptionStorage storage) {
+ buttons.entrySet().stream().forEach(e -> storage.save(e.getValue().getSelection(), e.getKey()));
}
@Override
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
index 3788b85fa5b..db8a825826b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
@@ -12,7 +12,7 @@
* Andrew Ferguson (Symbian) - Initial implementation
* Anton Leherbauer (Wind River Systems)
* Marco Stornelli - Bug 333134
- * Alexander Fedorov - Bug 333134
+ * Alexander Fedorov - Bug 333134, Bug 559193
*******************************************************************************/
package org.eclipse.cdt.ui.text.doctools.doxygen;
@@ -49,17 +49,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
import org.eclipse.cdt.core.parser.IToken;
+import org.eclipse.cdt.doxygen.DoxygenOptions;
+import org.eclipse.cdt.doxygen.core.DoxygenConfiguration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.model.ASTStringUtil;
-import org.eclipse.cdt.internal.ui.text.doctools.DoxygenPreferences;
import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
import org.eclipse.core.resources.IProject;
+import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
+import org.osgi.framework.FrameworkUtil;
/**
* {@link IAutoEditStrategy} for adding Doxygen tags for comments.
@@ -105,23 +108,23 @@ public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAut
private boolean newLineAfterBrief;
private boolean usePrePostTag;
+ private final DoxygenConfiguration doxygenConfiguration;
+
public DoxygenMultilineAutoEditStrategy() {
+ doxygenConfiguration = EclipseContextFactory
+ .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext())
+ .get(DoxygenConfiguration.class);
}
private void refreshPreferences() {
Optional project = getProject();
- DoxygenPreferences pref = project.isPresent() ? new DoxygenPreferences(project.get())
- : new DoxygenPreferences();
- newLineAfterBrief = pref.getBoolean(DoxygenPreferences.DOXYGEN_NEW_LINE_AFTER_BRIEF,
- DoxygenPreferences.DEF_DOXYGEN_NEW_LINE_AFTER_BRIEF);
- useBriefTag = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_BRIEF_TAG,
- DoxygenPreferences.DEF_DOXYGEN_USE_BRIEF_TAG);
- useJavadocStyle = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_JAVADOC_TAGS,
- DoxygenPreferences.DEF_DOXYGEN_USE_JAVADOC_TAGS);
- usePrePostTag = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_PRE_POST_TAGS,
- DoxygenPreferences.DEF_DOXYGEN_USE_PRE_POST_TAGS);
- useStructuralCommands = pref.getBoolean(DoxygenPreferences.DOXYGEN_USE_STRUCTURAL_COMMANDS,
- DoxygenPreferences.DEF_DOXYGEN_USE_STRUCTURED_COMMANDS);
+ DoxygenOptions options = project.isPresent() ? doxygenConfiguration.projectOptions(project.get())
+ : doxygenConfiguration.workspaceOptions();
+ newLineAfterBrief = options.newLineAfterBrief();
+ useBriefTag = options.useBriefTags();
+ useJavadocStyle = options.useJavadocStyle();
+ usePrePostTag = options.usePrePostTag();
+ useStructuralCommands = options.useStructuralCommands();
}
private String getPrefix() {