diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.core.prefs b/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.core.prefs index efd8b5044a2..2b6ecff8a01 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.core.prefs +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.core.prefs @@ -151,7 +151,6 @@ org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false org.eclipse.jdt.core.formatter.align_with_spaces=false -org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 @@ -160,27 +159,20 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 -org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 @@ -190,9 +182,7 @@ org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 @@ -201,7 +191,6 @@ org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line @@ -220,17 +209,15 @@ org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true -org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=false org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.indent_tag_description=false org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true @@ -277,15 +264,11 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert @@ -312,14 +295,10 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declar org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert @@ -344,20 +323,13 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert @@ -401,13 +373,10 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_decla org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert @@ -444,12 +413,9 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert @@ -461,33 +427,17 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_decla org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines @@ -502,20 +452,12 @@ org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.text_block_indentation=0 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true -org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true -org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true -org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.ui.prefs b/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.ui.prefs index c6bcc526587..e44576346c4 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/.settings/org.eclipse.jdt.ui.prefs @@ -61,7 +61,7 @@ cleanup_settings_version=2 eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_CDT -formatter_settings_version=18 +formatter_settings_version=14 internal.default.compliance=user org.eclipse.jdt.ui.exception.name=e org.eclipse.jdt.ui.gettersetter.use.is=true diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/META-INF/MANIFEST.MF b/cmake/org.eclipse.cdt.cmake.is.core.ui/META-INF/MANIFEST.MF index 09939e39083..321c1f55703 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core.ui/META-INF/MANIFEST.MF +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/META-INF/MANIFEST.MF @@ -11,3 +11,5 @@ Require-Bundle: org.eclipse.core.runtime, Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Automatic-Module-Name: org.eclipse.cdt.cmake.is.core.ui Bundle-ActivationPolicy: lazy +Import-Package: org.eclipse.cdt.core.options, + org.eclipse.e4.core.contexts diff --git a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java index e359edb4b0b..d2368a5180b 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java +++ b/cmake/org.eclipse.cdt.cmake.is.core.ui/src/org/eclipse/cdt/cmake/is/core/ui/internal/IndexerSupportPreferencePage.java @@ -13,11 +13,12 @@ package org.eclipse.cdt.cmake.is.core.ui.internal; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import org.eclipse.cdt.cmake.is.core.language.settings.providers.PreferenceConstants; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferences; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesAccess; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesMetadata; +import org.eclipse.cdt.core.options.OptionMetadata; +import org.eclipse.e4.core.contexts.EclipseContextFactory; import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusAdapter; @@ -33,6 +34,7 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.osgi.framework.FrameworkUtil; /** * Preference page for indexer support. @@ -42,28 +44,29 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor private Text pattern; private Button btnVersionsEnabled; private Button btnWithConsole; + private final IParserPreferencesAccess prefsAccess; public IndexerSupportPreferencePage() { + prefsAccess = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) + .get(IParserPreferencesAccess.class); setDescription("Configure how macros and include paths get extracted from the compile_commands.json file"); } /** - * Creates the field editors. Field editors are abstractions of the common GUI - * blocks needed to manipulate various types of preferences. Each field editor - * knows how to save and restore itself. + * Creates the field editors. */ @Override protected Control createContents(Composite parent) { - IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.cmake.is.core"); //$NON-NLS-1$ + final IParserPreferencesMetadata prefsMeta = prefsAccess.metadata(); + final IParserPreferences prefs = prefsAccess.getWorkspacePreferences(); + final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); GridDataFactory.swtDefaults().applyTo(composite); final Group gr = createGroup(composite, SWT.FILL, 1, "For compilers with version in name", 2); - btnVersionsEnabled = createCheckbox(gr, SWT.BEGINNING, 2, "&Also try with version suffix"); - btnVersionsEnabled.setToolTipText("Can recognize gcc-12.9.2, clang++-7.5.4, ..."); - // TODO use OptionMetadata based implementation - btnVersionsEnabled.setSelection(preferences.getBoolean(PreferenceConstants.P_PATTERN_ENABLED, false)); + btnVersionsEnabled = createCheckbox(gr, SWT.BEGINNING, 2, prefsMeta.tryVersionSuffix()); + btnVersionsEnabled.setSelection(prefs.getTryVersionSuffix()); { Label label = new Label(gr, SWT.NONE); label.setText("&Suffix pattern:"); @@ -72,10 +75,9 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor pattern = new Text(gr, SWT.SINGLE | SWT.BORDER); GridDataFactory.defaultsFor(pattern).applyTo(pattern); - pattern.setToolTipText("Specify a Java regular expression pattern here"); + pattern.setToolTipText(prefsMeta.versionSuffixPattern().description()); pattern.setEnabled(btnVersionsEnabled.getSelection()); - // TODO use OptionMetadata based implementation - pattern.setText(preferences.get(PreferenceConstants.P_PATTERN, "-?\\d+(\\.\\d+)*")); + pattern.setText(prefs.getVersionSuffixPattern()); pattern.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { @@ -105,10 +107,8 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor } }); - btnWithConsole = createCheckbox(composite, SWT.BEGINNING, 1, - "&Show output of compiler built-in detection in a console in the Console View"); - // TODO use OptionMetadata based implementation - btnWithConsole.setSelection(preferences.getBoolean(PreferenceConstants.P_WITH_CONSOLE, false)); + btnWithConsole = createCheckbox(composite, SWT.BEGINNING, 1, prefsMeta.allocateConsole()); + btnWithConsole.setSelection(prefs.getAllocateConsole()); return composite; } @@ -124,23 +124,20 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor @Override protected void performDefaults() { - // TODO IEclipsePreferences preferenceStore = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.cmake.is.core"); //$NON-NLS-1$ - - IPreferenceStore preferenceStore = getPreferenceStore(); - btnVersionsEnabled.setSelection(preferenceStore.getDefaultBoolean(PreferenceConstants.P_PATTERN_ENABLED)); - pattern.setText(preferenceStore.getDefaultString(PreferenceConstants.P_PATTERN)); - btnWithConsole.setSelection(preferenceStore.getDefaultBoolean(PreferenceConstants.P_WITH_CONSOLE)); + final IParserPreferencesMetadata prefsMeta = prefsAccess.metadata(); + btnVersionsEnabled.setSelection(prefsMeta.tryVersionSuffix().defaultValue()); + pattern.setText(prefsMeta.versionSuffixPattern().defaultValue()); + btnWithConsole.setSelection(prefsMeta.allocateConsole().defaultValue()); setErrorMessage(null); super.performDefaults(); } @Override public boolean performOk() { - // TODO IPreferenceStore preferenceStore = getPreferenceStore(); - IEclipsePreferences preferenceStore = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.cmake.is.core"); //$NON-NLS-1$ - preferenceStore.putBoolean(PreferenceConstants.P_PATTERN_ENABLED, btnVersionsEnabled.getSelection()); - preferenceStore.put(PreferenceConstants.P_PATTERN, pattern.getText()); - preferenceStore.putBoolean(PreferenceConstants.P_WITH_CONSOLE, btnWithConsole.getSelection()); + final IParserPreferences prefs = prefsAccess.getWorkspacePreferences(); + prefs.setTryVersionSuffix(btnVersionsEnabled.getSelection()); + prefs.setVersionSuffixPattern(pattern.getText()); + prefs.setAllocateConsole(btnWithConsole.getSelection()); return true; } @@ -156,9 +153,11 @@ public class IndexerSupportPreferencePage extends PreferencePage implements IWor * that the control will take up. * @param text text to display on the check-box */ - private static Button createCheckbox(Composite parent, int horizontalAlignment, int horizontalSpan, String text) { + private static Button createCheckbox(Composite parent, int horizontalAlignment, int horizontalSpan, + OptionMetadata option) { Button b = new Button(parent, SWT.CHECK); - b.setText(text); + b.setText(option.name()); + b.setToolTipText(option.description()); GridDataFactory.defaultsFor(b).align(horizontalAlignment, SWT.CENTER).span(horizontalSpan, 1).grab(true, false) .applyTo(b); return b; diff --git a/cmake/org.eclipse.cdt.cmake.is.core/.project b/cmake/org.eclipse.cdt.cmake.is.core/.project index e2569a8ca81..a7dc02110c5 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/.project +++ b/cmake/org.eclipse.cdt.cmake.is.core/.project @@ -25,6 +25,11 @@ + + org.eclipse.pde.ds.core.builder + + + org.eclipse.m2e.core.maven2Nature diff --git a/cmake/org.eclipse.cdt.cmake.is.core/.settings/org.eclipse.pde.ds.annotations.prefs b/cmake/org.eclipse.cdt.cmake.is.core/.settings/org.eclipse.pde.ds.annotations.prefs new file mode 100644 index 00000000000..73a356b6d05 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.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/cmake/org.eclipse.cdt.cmake.is.core/META-INF/MANIFEST.MF b/cmake/org.eclipse.cdt.cmake.is.core/META-INF/MANIFEST.MF index d91ed574547..0c4791e8c2d 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/META-INF/MANIFEST.MF +++ b/cmake/org.eclipse.cdt.cmake.is.core/META-INF/MANIFEST.MF @@ -22,3 +22,6 @@ Require-Bundle: org.eclipse.ui.workbench;bundle-version="3.8.0", com.google.gson, org.apache.commons.io;bundle-version="2.6.0" Automatic-Module-Name: org.eclipse.cdt.cmake.is.core +Import-Package: org.eclipse.e4.core.contexts;version="1.7.0", + org.osgi.service.component.annotations;version="1.2.0" +Service-Component: OSGI-INF/org.eclipse.cdt.cmake.is.core.internal.ParserPreferencesAccess.xml diff --git a/cmake/org.eclipse.cdt.cmake.is.core/OSGI-INF/org.eclipse.cdt.cmake.is.core.internal.ParserPreferencesAccess.xml b/cmake/org.eclipse.cdt.cmake.is.core/OSGI-INF/org.eclipse.cdt.cmake.is.core.internal.ParserPreferencesAccess.xml new file mode 100644 index 00000000000..aa9cc6c7138 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/OSGI-INF/org.eclipse.cdt.cmake.is.core.internal.ParserPreferencesAccess.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/cmake/org.eclipse.cdt.cmake.is.core/build.properties b/cmake/org.eclipse.cdt.cmake.is.core/build.properties index 97f20e727d5..0569ba8dca6 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/build.properties +++ b/cmake/org.eclipse.cdt.cmake.is.core/build.properties @@ -6,4 +6,5 @@ bin.includes = META-INF/,\ plugin.properties,\ about.html,\ .options,\ - schema/ + schema/,\ + OSGI-INF/org.eclipse.cdt.cmake.is.core.internal.ParserPreferencesAccess.xml diff --git a/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml b/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml index 38f0f891804..1da39483055 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml +++ b/cmake/org.eclipse.cdt.cmake.is.core/plugin.xml @@ -10,10 +10,4 @@ id="org.eclipse.cdt.cmake.is.core.detectorConsole"> - - - - diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferences.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferences.java new file mode 100644 index 00000000000..fc204e04210 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferences.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.internal; + +import java.util.Objects; + +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferences; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesMetadata; +import org.eclipse.cdt.core.options.OptionStorage; + +/** + * @author weber + */ +final class ParserPreferences implements IParserPreferences { + + private final OptionStorage optionStorage; + private final IParserPreferencesMetadata metadata; + + public ParserPreferences(OptionStorage optionStorage, IParserPreferencesMetadata metadata) { + this.optionStorage = Objects.requireNonNull(optionStorage, "optionStorage"); //$NON-NLS-1$ + this.metadata = Objects.requireNonNull(metadata, "metadata"); //$NON-NLS-1$ + } + + @Override + public boolean getTryVersionSuffix() { + return optionStorage.load(metadata.tryVersionSuffix()); + } + + @Override + public void setTryVersionSuffix(boolean tryVersionSuffix) { + optionStorage.save(tryVersionSuffix, metadata.tryVersionSuffix()); + } + + @Override + public String getVersionSuffixPattern() { + return optionStorage.load(metadata.versionSuffixPattern()); + } + + @Override + public void setVersionSuffixPattern(String versionSuffixPattern) { + Objects.requireNonNull(versionSuffixPattern); + optionStorage.save(versionSuffixPattern, metadata.versionSuffixPattern()); + } + + @Override + public boolean getAllocateConsole() { + return optionStorage.load(metadata.allocateConsole()); + } + + @Override + public void setAllocateConsole(boolean allocateConsole) { + optionStorage.save(allocateConsole, metadata.allocateConsole()); + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesAccess.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesAccess.java new file mode 100644 index 00000000000..fb3bbedec19 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesAccess.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.internal; + +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferences; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesAccess; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesMetadata; +import org.eclipse.cdt.core.options.OptionStorage; +import org.eclipse.cdt.core.options.OsgiPreferenceStorage; +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; + +/** + * @author weber + */ +@Component +public class ParserPreferencesAccess implements IParserPreferencesAccess { + + private final ParserPreferencesMetadata metadata; + + public ParserPreferencesAccess() { + this.metadata = new ParserPreferencesMetadata(); + } + + private OptionStorage workspaceStorage() { + return new OsgiPreferenceStorage(preferences(InstanceScope.INSTANCE)); + } + + @Override + public IParserPreferences getWorkspacePreferences() { + return new ParserPreferences(workspaceStorage(), metadata); + } + + @Override + public IParserPreferencesMetadata metadata() { + return metadata; + } + + private Preferences preferences(IScopeContext scope) { + return scope.getNode(nodeQualifier()).node(nodePath()); + } + + private String nodeQualifier() { + return Plugin.PLUGIN_ID; + } + + private String nodePath() { + return "parser"; //$NON-NLS-1$ + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java new file mode 100644 index 00000000000..fecd4854ae7 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/ParserPreferencesMetadata.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.internal; + +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesMetadata; +import org.eclipse.cdt.core.options.BaseOption; +import org.eclipse.cdt.core.options.OptionMetadata; + +/** + * @author weber + */ +final class ParserPreferencesMetadata implements IParserPreferencesMetadata { + + private final OptionMetadata tryVersionSuffixOption; + private final OptionMetadata versionSuffixPatternOption; + private final OptionMetadata allocateConsoleOption; + + public ParserPreferencesMetadata() { + this.tryVersionSuffixOption = new BaseOption<>(Boolean.class, "versionSuffixPatternEnabled", false, //$NON-NLS-1$ + "&Also try with version suffix", "Can recognize gcc-12.9.2, clang++-7.5.4, ..."); + this.versionSuffixPatternOption = new BaseOption<>(String.class, "versionSuffixPattern", "-?\\d+(\\.\\d+)*", //$NON-NLS-1$ //$NON-NLS-2$ + "&Suffix pattern:", "Specify a Java regular expression pattern here"); + this.allocateConsoleOption = new BaseOption<>(Boolean.class, "allocateConsole", false, //$NON-NLS-1$ + "&Show output of compiler built-in detection in a console in the Console View"); + } + + @Override + public OptionMetadata tryVersionSuffix() { + return tryVersionSuffixOption; + } + + @Override + public OptionMetadata versionSuffixPattern() { + return versionSuffixPatternOption; + } + + @Override + public OptionMetadata allocateConsole() { + return allocateConsoleOption; + } +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/PreferenceInitializer.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/PreferenceInitializer.java deleted file mode 100644 index e2b1d342c96..00000000000 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/PreferenceInitializer.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 Martin Weber. - * - * 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 - *******************************************************************************/ -package org.eclipse.cdt.cmake.is.core.internal; - -import org.eclipse.cdt.cmake.is.core.language.settings.providers.PreferenceConstants; -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Class used to initialize default preference values. - */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { - @Override - public void initializeDefaultPreferences() { - IPreferenceStore store = Plugin.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.P_WITH_CONSOLE, false); - store.setDefault(PreferenceConstants.P_PATTERN_ENABLED, false); - store.setDefault(PreferenceConstants.P_PATTERN, "-?\\d+(\\.\\d+)*"); //$NON-NLS-1$ - } -} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java index fec20f43d42..1d0a96b5352 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/internal/builtins/CompilerBuiltinsDetector.java @@ -24,7 +24,8 @@ import org.eclipse.cdt.cmake.is.core.builtins.IBuiltinsDetectionBehavior; import org.eclipse.cdt.cmake.is.core.builtins.IBuiltinsOutputProcessor; import org.eclipse.cdt.cmake.is.core.builtins.OutputSniffer; import org.eclipse.cdt.cmake.is.core.internal.Plugin; -import org.eclipse.cdt.cmake.is.core.language.settings.providers.PreferenceConstants; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferences; +import org.eclipse.cdt.cmake.is.core.language.settings.providers.IParserPreferencesAccess; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ICommandLauncher; @@ -40,7 +41,8 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.e4.core.contexts.EclipseContextFactory; +import org.osgi.framework.FrameworkUtil; /** * Detects preprocessor macros and include paths that are built-in to a @@ -239,8 +241,10 @@ public class CompilerBuiltinsDetector { */ @SuppressWarnings("nls") private IConsole startOutputConsole(IConsole console) throws CoreException { - IPreferenceStore prefStore = Plugin.getDefault().getPreferenceStore(); - if (!prefStore.getBoolean(PreferenceConstants.P_WITH_CONSOLE)) { + IParserPreferences prefs = EclipseContextFactory + .getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) + .get(IParserPreferencesAccess.class).getWorkspacePreferences(); + if (!prefs.getAllocateConsole()) { return null; // no console to allocate } else { IProject project = buildConfiguration.getProject(); diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/CompileCommandsJsonParser.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/CompileCommandsJsonParser.java index b618d253836..35a65697617 100644 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/CompileCommandsJsonParser.java +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/CompileCommandsJsonParser.java @@ -53,7 +53,8 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.e4.core.contexts.EclipseContextFactory; +import org.osgi.framework.FrameworkUtil; import com.google.gson.Gson; import com.google.gson.JsonIOException; @@ -92,6 +93,7 @@ public class CompileCommandsJsonParser { private final CBuildConfiguration cBuildConfiguration; private final IIndexerInfoConsumer indexerInfoConsumer; + private final IParserPreferencesAccess prefsAccess; /** * last known working tool detector and its tool option parsers or {@code null}, @@ -135,6 +137,8 @@ public class CompileCommandsJsonParser { public CompileCommandsJsonParser(CBuildConfiguration buildConfiguration, IIndexerInfoConsumer indexerInfoConsumer) { this.cBuildConfiguration = Objects.requireNonNull(buildConfiguration, "buildConfiguration"); this.indexerInfoConsumer = Objects.requireNonNull(indexerInfoConsumer, "indexerInfoConsumer"); + prefsAccess = EclipseContextFactory.getServiceContext(FrameworkUtil.getBundle(getClass()).getBundleContext()) + .get(IParserPreferencesAccess.class); } /** @@ -377,8 +381,8 @@ public class CompileCommandsJsonParser { * returned. */ private ParserDetectionResult fastDetermineDetector(String line) { + final IParserPreferences prefs = prefsAccess.getWorkspacePreferences(); // try last known matching detector first... - IPreferenceStore prefStore = Plugin.getDefault().getPreferenceStore(); if (lastDetector != null) { Optional matchResult = Optional.empty(); final IToolDetectionParticipant detector = lastDetector.getToolDetectionParticipant(); @@ -390,15 +394,15 @@ public class CompileCommandsJsonParser { matchResult = detector.basenameWithExtensionMatches(line, lastDetector.isMatchBackslash()); break; case WITH_VERSION: - if (prefStore.getBoolean(PreferenceConstants.P_PATTERN_ENABLED)) { + if (prefs.getTryVersionSuffix()) { matchResult = detector.basenameWithVersionMatches(line, lastDetector.isMatchBackslash(), - prefStore.getString(PreferenceConstants.P_PATTERN)); + prefs.getVersionSuffixPattern()); } break; case WITH_VERSION_EXTENSION: - if (prefStore.getBoolean(PreferenceConstants.P_PATTERN_ENABLED)) { + if (prefs.getTryVersionSuffix()) { matchResult = detector.basenameWithVersionAndExtensionMatches(line, lastDetector.isMatchBackslash(), - prefStore.getString(PreferenceConstants.P_PATTERN)); + prefs.getVersionSuffixPattern()); } break; default: @@ -412,9 +416,7 @@ public class CompileCommandsJsonParser { } // no working detector found, determine a new one... - String versionPattern = prefStore.getBoolean(PreferenceConstants.P_PATTERN_ENABLED) - ? prefStore.getString(PreferenceConstants.P_PATTERN) - : null; + String versionPattern = prefs.getTryVersionSuffix() ? prefs.getVersionSuffixPattern() : null; ParserDetection.ParserDetectionResult result = ParserDetection.determineDetector(line, versionPattern, File.separatorChar == '\\'); if (result != null) { diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferences.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferences.java new file mode 100644 index 00000000000..90ebd06e13b --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferences.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.language.settings.providers; + +/** + * Preferences to configure the {@code compile_commands.json} parser. + * + * @author weber + */ +public interface IParserPreferences { + /** Gets whether to also try a version suffix to detect a compiler. */ + boolean getTryVersionSuffix(); + + /** Sets whether to also try a version suffix to detect a compiler. */ + void setTryVersionSuffix(boolean tryVersionSuffix); + + /** Sets the version suffix to detect a compiler. This is interpreted as a regular expression pattern. */ + String getVersionSuffixPattern(); + + /** Sets the version suffix to detect a compiler. + * + * @param versionSuffixPattern The version suffix as a regular expression pattern + */ + void setVersionSuffixPattern(String versionSuffixPattern); + + /** Gets whether to allocate a console showing the output of compiler built-ins detection. */ + boolean getAllocateConsole(); + + /** Sets whether to allocate a console showing the output of compiler built-ins detection. */ + void setAllocateConsole(boolean allocateConsole); +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesAccess.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesAccess.java new file mode 100644 index 00000000000..07307799123 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesAccess.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.language.settings.providers; + +/** + * Provides access to the {@code compile_commands.json} parser preferences and its preference metadata.
+ * + * A concrete implementation object of this interface can be retrieved through the OSGI service feature. + * + * @author weber + */ +public interface IParserPreferencesAccess { + /** + * Gets the workspace {@code compile_commands.json} parser preferences. + */ + IParserPreferences getWorkspacePreferences(); + + /** + * Gets the metadata for the parser preferences to be used in UI. + * + * @return the parser option metadata + */ + IParserPreferencesMetadata metadata(); +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesMetadata.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesMetadata.java new file mode 100644 index 00000000000..81f5b0eb215 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/IParserPreferencesMetadata.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2020 Martin Weber. + * + * 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 + *******************************************************************************/ + +package org.eclipse.cdt.cmake.is.core.language.settings.providers; + +import org.eclipse.cdt.core.options.OptionMetadata; + +/** + * The metadata for options to configure the {@code compile_commands.json} parser. + * + * @author weber + */ +public interface IParserPreferencesMetadata { + /** + * Returns the metadata for the {@link IParserPreferences#getTryVersionSuffix()} preference. + * + * @return the metadata for the preference option, never {@null} + */ + OptionMetadata tryVersionSuffix(); + + /** + * Returns the metadata for the {@link IParserPreferences#getVersionSuffixPattern()} preference. + * + * @return the metadata for the preference option, never {@null} + */ + OptionMetadata versionSuffixPattern(); + + /** + * Returns the metadata for the {@link IParserPreferences#getAllocateConsole()} preference. + * + * @return the metadata for the preference option, never {@null} + */ + OptionMetadata allocateConsole(); +} diff --git a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/PreferenceConstants.java b/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/PreferenceConstants.java deleted file mode 100644 index ba60be90c72..00000000000 --- a/cmake/org.eclipse.cdt.cmake.is.core/src/main/java/org/eclipse/cdt/cmake/is/core/language/settings/providers/PreferenceConstants.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 Martin Weber. - * - * 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 - *******************************************************************************/ -package org.eclipse.cdt.cmake.is.core.language.settings.providers; - -/** - * Constant definitions for plug-in preferences - */ -public class PreferenceConstants { - - /** preferences key for version suffix regex pattern */ - public static final String P_PATTERN = "vPattern"; //$NON-NLS-1$ - /** preferences key for version suffix regex pattern enabled */ - public static final String P_PATTERN_ENABLED = "vPatternEnabled"; //$NON-NLS-1$ - /** preferences key for built-ins detection output showing a console */ - public static final String P_WITH_CONSOLE = "console"; //$NON-NLS-1$ -}