From 5a5de4b1db175e02c38f3e197589489f6d2bc653 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 15 Mar 2016 15:58:01 -0400 Subject: [PATCH] Bug 489563 - API change for Language Settings Providers. Use IBuildConfiguration instead of ICConfigurationDescription. Add adapters to convert back and forth between these. Create IBuildConfiguration objects when configuration descriptors are created. Clean up formating of the code involved. Change-Id: Iec5ca132dddbf990f116f96b4680ef5f7318e28b --- .../LibtoolGCCBuildCommandParserTest.java | 10 +- .../.settings/org.eclipse.jdt.core.prefs | 259 +-- .../.settings/org.eclipse.jdt.ui.prefs | 2 + .../tests/BuiltinSpecsDetectorTest.java | 177 +- .../tests/GCCBuildCommandParserTest.java | 876 +++++---- .../LanguageSettingsProvidersMBSTest.java | 32 +- .../.settings/org.eclipse.jdt.core.prefs | 259 +-- .../.settings/org.eclipse.jdt.ui.prefs | 2 + .../MBSLanguageSettingsProvider.java | 54 +- .../providers/AbstractBuildCommandParser.java | 131 +- .../AbstractBuiltinSpecsDetector.java | 264 ++- ...AbstractLanguageSettingsOutputScanner.java | 431 +++-- .../.settings/org.eclipse.jdt.core.prefs | 286 +-- .../.settings/org.eclipse.jdt.ui.prefs | 1 - .../LanguageSettingsListenersTests.java | 418 +++-- .../LanguageSettingsManagerTests.java | 318 ++-- ...nguageSettingsPersistenceProjectTests.java | 505 ++++-- ...ttingsProviderReferencedProjectsTests.java | 107 +- ...guageSettingsScannerInfoProviderTests.java | 129 +- ...uageSettingsSerializableProviderTests.java | 307 ++-- .../MockLanguageSettingsProvider.java | 4 +- .../cdt/core/testplugin/CModelMock.java | 89 +- .../.settings/org.eclipse.jdt.core.prefs | 285 +-- .../.settings/org.eclipse.jdt.ui.prefs | 1 - ...ILanguageSettingsBroadcastingProvider.java | 21 +- .../ILanguageSettingsEditableProvider.java | 64 +- .../providers/ILanguageSettingsProvider.java | 127 +- .../LanguageSettingsBaseProvider.java | 165 +- .../providers/LanguageSettingsManager.java | 270 +-- .../LanguageSettingsSerializableProvider.java | 265 +-- .../org/eclipse/cdt/core/model/CoreModel.java | 712 ++++---- .../model/util/PathEntryTranslator.java | 639 ++++--- .../LanguageSettingsProvidersSerializer.java | 669 ++++--- .../LanguageSettingsScannerInfoProvider.java | 92 +- ...ryScannerInfoLanguageSettingsProvider.java | 39 +- ...encedProjectsLanguageSettingsProvider.java | 20 +- ...InfoExtensionLanguageSettingsProvider.java | 34 +- .../model/BuildConfigAdapterFactory.java | 38 + .../model/CConfigurationAdapterFactory.java | 73 + .../settings/model/CProjectDescription.java | 109 +- .../model/CProjectDescriptionManager.java | 1568 +++++++++-------- core/org.eclipse.cdt.core/plugin.xml | 17 + .../src/org/eclipse/cdt/core/CCorePlugin.java | 305 ++-- .../.settings/org.eclipse.jdt.core.prefs | 285 +-- .../.settings/org.eclipse.jdt.ui.prefs | 1 - .../providers/LanguageSettingsEntriesTab.java | 216 ++- .../CustomBuildSettingsDecorator.java | 47 +- .../cdt/internal/qt/core/QtIncludePaths.java | 139 +- .../qt/core/QtIncludePathsProvider.java | 66 +- 49 files changed, 5729 insertions(+), 5199 deletions(-) create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.ui.prefs create mode 100644 build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.ui.prefs create mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/BuildConfigAdapterFactory.java create mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationAdapterFactory.java diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java index 162d40ec2fc..0e18e4a203b 100644 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java @@ -25,8 +25,10 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Adapters; import org.junit.Test; /** @@ -61,6 +63,8 @@ public class LibtoolGCCBuildCommandParserTest { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); IFile file1 = ResourceHelper.createFile(project, "file1.cpp"); IFile file2 = ResourceHelper.createFile(project, "file2.cpp"); @@ -77,11 +81,11 @@ public class LibtoolGCCBuildCommandParserTest { parser.processLine("libtool: compile: g++ -I/path0 file2.cpp"); parser.processLine("libtool: compile: cc -I/path0 file3.cpp"); parser.shutdown(); - List entries = parser.getSettingEntries(cfgDescription, file1, languageId); + List entries = parser.getSettingEntries(config, file1, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); - entries = parser.getSettingEntries(cfgDescription, file2, languageId); + entries = parser.getSettingEntries(config, file2, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); - entries = parser.getSettingEntries(cfgDescription, file3, languageId); + entries = parser.getSettingEntries(config, file3, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs index 0aaa134fd85..5aa758cb9e4 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Thu Oct 08 20:38:59 EDT 2009 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 @@ -85,262 +84,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -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_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -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_selector_in_method_invocation=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 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=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 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -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_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 -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -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.format_block_comments=true -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_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=110 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -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_and_in_type_parameter=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_closing_angle_bracket_in_type_arguments=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 -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -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_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -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_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_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=110 -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_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -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.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.ui.prefs b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..fe89f28bca5 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +formatter_settings_version=12 diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java index f5b7be2071e..0f890437d03 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java @@ -47,7 +47,9 @@ import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector; import org.eclipse.cdt.utils.envvar.StorableEnvironment; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -83,10 +85,12 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { protected List parseOptions(String line) { return null; } + @Override protected AbstractOptionParser[] getOptionParsers() { return null; } + @Override protected String getCompilerCommand(String languageId) { return null; @@ -101,6 +105,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { protected void startupForLanguage(String languageId) throws CoreException { super.startupForLanguage(languageId); } + @Override protected void shutdownForLanguage() { super.shutdownForLanguage(); @@ -116,6 +121,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { super.execute(); waitForProviderToFinish(); } + protected boolean isExecuted() { return isExecuted; } @@ -128,15 +134,19 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { private int executedCount = 0; @Override - public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException { + public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) + throws CoreException { executedCount++; super.startup(cfgDescription, cwdTracker); } + @Override - public MockBuiltinSpecsDetectorEnvironmentChangeListener cloneShallow() throws CloneNotSupportedException { + public MockBuiltinSpecsDetectorEnvironmentChangeListener cloneShallow() + throws CloneNotSupportedException { MockBuiltinSpecsDetectorEnvironmentChangeListener clone = (MockBuiltinSpecsDetectorEnvironmentChangeListener) super.cloneShallow(); return clone; } + @Override public MockBuiltinSpecsDetectorEnvironmentChangeListener clone() throws CloneNotSupportedException { MockBuiltinSpecsDetectorEnvironmentChangeListener clone = (MockBuiltinSpecsDetectorEnvironmentChangeListener) super.clone(); @@ -158,17 +168,21 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { protected boolean validateEnvironment() { return false; } + @Override protected void execute() { super.execute(); sampleEnvVarValue = environmentMap.get(ENV_SAMPLE); } + @Override - public MockBuiltinSpecsDetectorEnvironmentChangeListener cloneShallow() throws CloneNotSupportedException { + public MockBuiltinSpecsDetectorEnvironmentChangeListener cloneShallow() + throws CloneNotSupportedException { MockBuiltinSpecsDetectorEnvironmentChangeListener clone = (MockBuiltinSpecsDetectorEnvironmentChangeListener) super.cloneShallow(); clone.sampleEnvVarValue = sampleEnvVarValue; return clone; } + @Override public MockBuiltinSpecsDetectorEnvironmentChangeListener clone() throws CloneNotSupportedException { MockBuiltinSpecsDetectorEnvironmentChangeListener clone = (MockBuiltinSpecsDetectorEnvironmentChangeListener) super.clone(); @@ -179,6 +193,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { protected boolean isExecuted() { return isExecuted; } + public String getSampleEnvVar() { return sampleEnvVarValue; } @@ -189,28 +204,38 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { */ private class MockConsoleBuiltinSpecsDetector extends AbstractBuiltinSpecsDetector { @SuppressWarnings("nls") - private final AbstractOptionParser[] optionParsers = { - new MacroOptionParser("#define (\\S*) *(\\S*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), - }; + private final AbstractOptionParser[] optionParsers = { new MacroOptionParser("#define (\\S*) *(\\S*)", + "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), }; + @Override - protected int runProgramForLanguage(String languageId, String command, String[] envp, URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, IProgressMonitor monitor) throws CoreException, IOException { + protected int runProgramForLanguage(String languageId, String command, String[] envp, + URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, + IProgressMonitor monitor) throws CoreException, IOException { String line = "#define MACRO VALUE"; consoleOut.write((line + '\n').getBytes()); consoleOut.flush(); return ICommandLauncher.OK; } + @Override protected IStatus runForEachLanguage(IProgressMonitor monitor) { return super.runForEachLanguage(monitor); } + @Override protected List parseOptions(final String line) { - return new ArrayList() {{ add(line); }}; + return new ArrayList() { + { + add(line); + } + }; } + @Override protected AbstractOptionParser[] getOptionParsers() { return optionParsers; } + @Override protected String getCompilerCommand(String languageId) { return null; @@ -280,7 +305,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { Map properties = new HashMap(); properties.put(ATTR_PARAMETER, CUSTOM_COMMAND_1); List entries = new ArrayList(); - ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); entries.add(entry); provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties); @@ -314,6 +340,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { public MockDetectorCloneable clone() throws CloneNotSupportedException { return (MockDetectorCloneable) super.clone(); } + @Override public MockDetectorCloneable cloneShallow() throws CloneNotSupportedException { return (MockDetectorCloneable) super.cloneShallow(); @@ -326,7 +353,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { List languages = new ArrayList(); languages.add(LANGUAGE_ID); List entries = new ArrayList(); - ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); entries.add(entry); // check clone after initialization @@ -367,7 +395,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { { MockDetectorCloneable clone = provider.clone(); boolean isConsoleEnabled = clone.isConsoleEnabled(); - clone.setConsoleEnabled( ! isConsoleEnabled ); + clone.setConsoleEnabled(!isConsoleEnabled); assertFalse(provider.equals(clone)); } @@ -384,7 +412,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { { MockDetectorCloneable clone = provider.clone(); List entries2 = new ArrayList(); - entries2.add(new CMacroEntry("MACRO2", "VALUE2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY)); + entries2.add( + new CMacroEntry("MACRO2", "VALUE2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY)); clone.setSettingEntries(null, null, null, entries2); assertFalse(provider.equals(clone)); } @@ -544,7 +573,11 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { ICConfigurationDescription cfgDescription = cfgDescriptions[0]; MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector(); - provider.setLanguageScope(new ArrayList() {{add(LANGUAGE_ID);}}); + provider.setLanguageScope(new ArrayList() { + { + add(LANGUAGE_ID); + } + }); // Run provider provider.startup(cfgDescription, null); @@ -557,8 +590,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { assertNull(noentries); // Check parsed entries - List entries = provider.getSettingEntries(cfgDescription, null, LANGUAGE_ID); - ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + List entries = provider.getSettingEntries(config, null, LANGUAGE_ID); + ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); assertEquals(expected, entries.get(0)); } @@ -568,7 +603,11 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { public void testAbstractBuiltinSpecsDetector_RunGlobal() throws Exception { // Create provider MockConsoleBuiltinSpecsDetector provider = new MockConsoleBuiltinSpecsDetector(); - provider.setLanguageScope(new ArrayList() {{add(LANGUAGE_ID);}}); + provider.setLanguageScope(new ArrayList() { + { + add(LANGUAGE_ID); + } + }); // Run provider provider.startup(null, null); @@ -579,7 +618,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Check parsed entries List entries = provider.getSettingEntries(null, null, LANGUAGE_ID); - ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + ICLanguageSettingEntry expected = new CMacroEntry("MACRO", "VALUE", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); assertEquals(expected, entries.get(0)); } @@ -595,7 +635,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Create provider MockBuiltinSpecsDetectorEnvironmentChangeListener provider = new MockBuiltinSpecsDetectorEnvironmentChangeListener(); - // register environment listener on configuration - note that provider is not included in the configuration + // register environment listener on configuration - note that provider is not included in the + // configuration provider.registerListener(cfgDescription); waitForProviderToFinish(); assertEquals(true, provider.isExecuted()); @@ -607,8 +648,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Set an environment variable to the configuration { - ICProjectDescription prjDescriptionWritable = CoreModel.getDefault().getProjectDescription(project, true); - ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable.getActiveConfiguration(); + ICProjectDescription prjDescriptionWritable = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable + .getActiveConfiguration(); // create and set sample environment variable in the configuration IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IContributedEnvironment contribEnv = envManager.getContributedEnvironment(); @@ -635,8 +678,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Set an environment variable to the configuration { - ICProjectDescription prjDescriptionWritable = CoreModel.getDefault().getProjectDescription(project, true); - ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable.getActiveConfiguration(); + ICProjectDescription prjDescriptionWritable = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable + .getActiveConfiguration(); // create and set sample environment variable in the configuration IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IContributedEnvironment contribEnv = envManager.getContributedEnvironment(); @@ -667,13 +712,16 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Assign a provider to configuration { - ICProjectDescription prjDescriptionWritable = CoreModel.getDefault().getProjectDescription(project, true); - ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable.getActiveConfiguration(); + ICProjectDescription prjDescriptionWritable = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable + .getActiveConfiguration(); // Create provider MockBuiltinSpecsDetectorEnvironmentChangeListener provider = new MockBuiltinSpecsDetectorEnvironmentChangeListener(); List providers = new ArrayList(); providers.add(provider); - ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .setLanguageSettingProviders(providers); // Write to project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable); @@ -685,8 +733,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Set environment variable to the configuration { - ICProjectDescription prjDescriptionWritable = CoreModel.getDefault().getProjectDescription(project, true); - ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable.getActiveConfiguration(); + ICProjectDescription prjDescriptionWritable = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable + .getActiveConfiguration(); IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IContributedEnvironment contribEnv = envManager.getContributedEnvironment(); @@ -695,8 +745,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { contribEnv.addVariable(var, cfgDescriptionWritable); assertEquals(var, envManager.getVariable(ENV_SAMPLE, cfgDescriptionWritable, true)); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); - MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers.get(0); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); + MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers + .get(0); // unset "isExecuted" flag provider.clear(); assertEquals(false, provider.isExecuted()); @@ -710,7 +762,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Check if the provider got executed { // check if environment variable got there - ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); + ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, + false); ICConfigurationDescription cfgDescription = prjDescription.getActiveConfiguration(); IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable var = envManager.getVariable(ENV_SAMPLE, cfgDescription, true); @@ -718,8 +771,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { assertEquals(ENV_SAMPLE_VALUE_1, var.getValue()); // check if provider got executed with new value - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); - MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers.get(0); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); + MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers + .get(0); assertEquals(true, provider.isExecuted()); assertEquals(ENV_SAMPLE_VALUE_1, provider.getSampleEnvVar()); } @@ -727,8 +782,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Repeat one more time with different value of environment variable // Set another environment variable to the configuration { - ICProjectDescription prjDescriptionWritable = CoreModel.getDefault().getProjectDescription(project, true); - ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable.getActiveConfiguration(); + ICProjectDescription prjDescriptionWritable = CoreModel.getDefault() + .getProjectDescription(project, true); + ICConfigurationDescription cfgDescriptionWritable = prjDescriptionWritable + .getActiveConfiguration(); IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IContributedEnvironment contribEnv = envManager.getContributedEnvironment(); @@ -737,8 +794,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { contribEnv.addVariable(var, cfgDescriptionWritable); assertEquals(var, envManager.getVariable(ENV_SAMPLE, cfgDescriptionWritable, true)); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); - MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers.get(0); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); + MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers + .get(0); // unset "isExecuted" flag provider.clear(); assertEquals(false, provider.isExecuted()); @@ -752,7 +811,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { // Check if the provider got executed { // check if environment variable got there - ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, false); + ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project, + false); ICConfigurationDescription cfgDescription = prjDescription.getActiveConfiguration(); IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager(); IEnvironmentVariable var = envManager.getVariable(ENV_SAMPLE, cfgDescription, true); @@ -760,8 +820,10 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { assertEquals(ENV_SAMPLE_VALUE_2, var.getValue()); // check if provider got executed with new value - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); - MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers.get(0); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); + MockBuiltinSpecsDetectorEnvironmentChangeListener provider = (MockBuiltinSpecsDetectorEnvironmentChangeListener) providers + .get(0); assertEquals(true, provider.isExecuted()); assertEquals(ENV_SAMPLE_VALUE_2, provider.getSampleEnvVar()); } @@ -843,7 +905,6 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { long lastModifiedUpdated = compiler.lastModified(); assertTrue(lastModifiedUpdated != lastModified); - // Check that an event triggers rerun after upgrade provider.handleEvent(null); waitForProviderToFinish(); @@ -940,18 +1001,30 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase { */ public void testAbstractBuiltinSpecsDetector_GroupSettings() throws Exception { // define benchmarks - final CIncludePathEntry includePath_1 = new CIncludePathEntry("/include/path_1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CIncludePathEntry includePath_2 = new CIncludePathEntry("/include/path_2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CIncludeFileEntry includeFile_1 = new CIncludeFileEntry(new Path("/include.file1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CIncludeFileEntry includeFile_2 = new CIncludeFileEntry(new Path("/include.file2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CMacroEntry macro_1 = new CMacroEntry("MACRO_1", "", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CMacroEntry macro_2 = new CMacroEntry("MACRO_2", "", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY |ICSettingEntry.UNDEFINED); - final CMacroFileEntry macroFile_1 = new CMacroFileEntry(new Path("/macro.file1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CMacroFileEntry macroFile_2 = new CMacroFileEntry(new Path("/macro.file2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CLibraryPathEntry libraryPath_1 = new CLibraryPathEntry(new Path("/lib/path_1"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CLibraryPathEntry libraryPath_2 = new CLibraryPathEntry(new Path("/lib/path_2"), ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CLibraryFileEntry libraryFile_1 = new CLibraryFileEntry("lib_1.a", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); - final CLibraryFileEntry libraryFile_2 = new CLibraryFileEntry("lib_2.a", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CIncludePathEntry includePath_1 = new CIncludePathEntry("/include/path_1", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CIncludePathEntry includePath_2 = new CIncludePathEntry("/include/path_2", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CIncludeFileEntry includeFile_1 = new CIncludeFileEntry(new Path("/include.file1"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CIncludeFileEntry includeFile_2 = new CIncludeFileEntry(new Path("/include.file2"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CMacroEntry macro_1 = new CMacroEntry("MACRO_1", "", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CMacroEntry macro_2 = new CMacroEntry("MACRO_2", "", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.UNDEFINED); + final CMacroFileEntry macroFile_1 = new CMacroFileEntry(new Path("/macro.file1"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CMacroFileEntry macroFile_2 = new CMacroFileEntry(new Path("/macro.file2"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CLibraryPathEntry libraryPath_1 = new CLibraryPathEntry(new Path("/lib/path_1"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CLibraryPathEntry libraryPath_2 = new CLibraryPathEntry(new Path("/lib/path_2"), + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CLibraryFileEntry libraryFile_1 = new CLibraryFileEntry("lib_1.a", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + final CLibraryFileEntry libraryFile_2 = new CLibraryFileEntry("lib_2.a", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); // Define mock detector adding unorganized entries MockBuiltinSpecsDetector provider = new MockBuiltinSpecsDetector() { diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java index 73b3fe9ea05..7a7b7876d7f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java @@ -42,9 +42,11 @@ import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSetting import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser; import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -78,18 +80,21 @@ public class GCCBuildCommandParserTest extends BaseTestCase { /** * Mock build command parser. */ - private class MockBuildCommandParser extends AbstractBuildCommandParser implements Cloneable { + private class MockBuildCommandParser extends AbstractBuildCommandParser implements Cloneable { public MockBuildCommandParser() { setId("GCCBuildCommandParserTest.MockBuildCommandParser"); } + @Override protected AbstractOptionParser[] getOptionParsers() { return new AbstractOptionParser[] {}; } + @Override public MockBuildCommandParser cloneShallow() throws CloneNotSupportedException { return (MockBuildCommandParser) super.cloneShallow(); } + @Override public MockBuildCommandParser clone() throws CloneNotSupportedException { return (MockBuildCommandParser) super.clone(); @@ -105,8 +110,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { protected void tearDown() throws Exception { try { Job.getJobManager().join(AbstractBuildCommandParser.JOB_FAMILY_BUILD_COMMAND_PARSER, null); - Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT, null); - Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null); + Job.getJobManager().join( + LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT, null); + Job.getJobManager().join( + LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, + null); } catch (Exception e) { // ignore } @@ -147,7 +155,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { } { // triplecheck builderCWD for different project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -170,8 +179,13 @@ public class GCCBuildCommandParserTest extends BaseTestCase { ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0]; - cfgDescription.setReferenceInfo(new HashMap() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }}); + final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions( + projectReferenced)[0]; + cfgDescription.setReferenceInfo(new HashMap() { + { + put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); + } + }); coreModel.setProjectDescription(project, projectDescription); } @@ -179,7 +193,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // doublecheck that it's set as expected ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - Map refs = cfgDescription.getReferenceInfo(); + Map refs = cfgDescription.getReferenceInfo(); assertEquals(1, refs.size()); Set referencedProjectsNames = new LinkedHashSet(refs.keySet()); assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]); @@ -187,7 +201,6 @@ public class GCCBuildCommandParserTest extends BaseTestCase { } - /** * Test getters and setters. */ @@ -213,7 +226,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { Map properties = new HashMap(); properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER); List entries = new ArrayList(); - ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); + ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", + ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); entries.add(entry); provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties); @@ -269,7 +283,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { { MockBuildCommandParser clone = parser.clone(); boolean expandRelativePaths = clone.isResolvingPaths(); - clone.setResolvingPaths( ! expandRelativePaths ); + clone.setResolvingPaths(!expandRelativePaths); assertFalse(parser.equals(clone)); } @@ -358,8 +372,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - final IFile file=ResourceHelper.createFile(project, "file.cpp"); + final IFile file = ResourceHelper.createFile(project, "file.cpp"); // create test class AbstractBuildCommandParser parser = new MockBuildCommandParser() { @@ -380,14 +396,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // sanity check that it does not return same values for all inputs - List noentries = parser.getSettingEntries(null, null, null); + List noentries = parser.getSettingEntries((IBuildConfiguration) null, null, + null); assertNull(noentries); // check populated entries ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CMacroEntry expected = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN); assertEquals(expected, entries.get(0)); } @@ -401,13 +418,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -415,10 +435,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); { CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); + CIncludePathEntry entry = (CIncludePathEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -436,23 +456,26 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file1=ResourceHelper.createFile(project, "file1.cpp"); - IFile file2=ResourceHelper.createFile(project, "file2.cpp"); - IFile file3=ResourceHelper.createFile(project, "file3.cpp"); - IFile file4=ResourceHelper.createFile(project, "file4.cpp"); - IFile file5=ResourceHelper.createFile(project, "file5.cpp"); - IFile file6=ResourceHelper.createFile(project, "file6.cpp"); - IFile file7=ResourceHelper.createFile(project, "file7.cpp"); - IFile file8=ResourceHelper.createFile(project, "file8.cpp"); - IFile file9=ResourceHelper.createFile(project, "file9.cpp"); - IFile file10=ResourceHelper.createFile(project, "file10.cpp"); - IFile file11=ResourceHelper.createFile(project, "file11.cpp"); + IFile file1 = ResourceHelper.createFile(project, "file1.cpp"); + IFile file2 = ResourceHelper.createFile(project, "file2.cpp"); + IFile file3 = ResourceHelper.createFile(project, "file3.cpp"); + IFile file4 = ResourceHelper.createFile(project, "file4.cpp"); + IFile file5 = ResourceHelper.createFile(project, "file5.cpp"); + IFile file6 = ResourceHelper.createFile(project, "file6.cpp"); + IFile file7 = ResourceHelper.createFile(project, "file7.cpp"); + IFile file8 = ResourceHelper.createFile(project, "file8.cpp"); + IFile file9 = ResourceHelper.createFile(project, "file9.cpp"); + IFile file10 = ResourceHelper.createFile(project, "file10.cpp"); + IFile file11 = ResourceHelper.createFile(project, "file11.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -471,47 +494,47 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries { - List entries = parser.getSettingEntries(cfgDescription, file1, languageId); + List entries = parser.getSettingEntries(config, file1, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file2, languageId); + List entries = parser.getSettingEntries(config, file2, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file3, languageId); + List entries = parser.getSettingEntries(config, file3, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file4, languageId); + List entries = parser.getSettingEntries(config, file4, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file5, languageId); + List entries = parser.getSettingEntries(config, file5, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file6, languageId); + List entries = parser.getSettingEntries(config, file6, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file7, languageId); + List entries = parser.getSettingEntries(config, file7, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file8, languageId); + List entries = parser.getSettingEntries(config, file8, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file9, languageId); + List entries = parser.getSettingEntries(config, file9, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file10, languageId); + List entries = parser.getSettingEntries(config, file10, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file11, languageId); + List entries = parser.getSettingEntries(config, file11, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } } @@ -525,13 +548,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -547,14 +573,13 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // single-quoted path with spaces + " -isystem'/path with spaces2'" // second single-quoted and space after -isystem - + " -isystem '/path with spaces3'" - + " file.cpp"); + + " -isystem '/path with spaces3'" + " file.cpp"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); + CIncludePathEntry entry = (CIncludePathEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -576,14 +601,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); - + // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); - + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + // parse line parser.startup(cfgDescription, null); parser.processLine("gcc" @@ -598,26 +626,25 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // single-quoted path with spaces + " -I'/path with spaces2'" // second single-quoted and space after -I - + " -I '/path with spaces3'" - + " file.cpp"); + + " -I '/path with spaces3'" + " file.cpp"); parser.shutdown(); - + // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CIncludePathEntry expected = new CIncludePathEntry("/path0", 0); - CIncludePathEntry entry = (CIncludePathEntry)entries.get(0); + CIncludePathEntry entry = (CIncludePathEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); assertEquals(expected.getFlags(), entry.getFlags()); assertEquals(expected, entry); - + assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); assertEquals(new CIncludePathEntry("/path with spaces2", 0), entries.get(3)); assertEquals(new CIncludePathEntry("/path with spaces3", 0), entries.get(4)); } - + /** * Parse Mac Frameworks. */ @@ -627,13 +654,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -643,15 +673,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // framework system + " -iframework/framework/system " // with spaces - + " -F '/Framework with spaces' " - + " file.cpp"); + + " -F '/Framework with spaces' " + " file.cpp"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CIncludePathEntry("/Framework", ICSettingEntry.FRAMEWORKS_MAC), entries.get(0)); - assertEquals(new CIncludePathEntry("/framework/system", ICSettingEntry.FRAMEWORKS_MAC), entries.get(1)); - assertEquals(new CIncludePathEntry("/Framework with spaces", ICSettingEntry.FRAMEWORKS_MAC), entries.get(2)); + assertEquals(new CIncludePathEntry("/framework/system", ICSettingEntry.FRAMEWORKS_MAC), + entries.get(1)); + assertEquals(new CIncludePathEntry("/Framework with spaces", ICSettingEntry.FRAMEWORKS_MAC), + entries.get(2)); } /** @@ -663,13 +694,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -687,9 +721,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CMacroEntry expected = new CMacroEntry("MACRO0", "", 0); - CMacroEntry entry = (CMacroEntry)entries.get(0); + CMacroEntry entry = (CMacroEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -715,13 +749,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -731,7 +768,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CMacroEntry("MACRO", null, ICSettingEntry.UNDEFINED), entries.get(0)); } @@ -744,13 +781,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -764,9 +804,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CIncludeFileEntry expected = new CIncludeFileEntry("/include.file1", 0); - CIncludeFileEntry entry = (CIncludeFileEntry)entries.get(0); + CIncludeFileEntry entry = (CIncludeFileEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -774,9 +814,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { assertEquals(expected, entry); assertEquals(new CIncludeFileEntry("/include.file with spaces", 0), entries.get(1)); - assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include.file2"), 0), entries.get(2)); - assertEquals(new CIncludeFileEntry("/${ProjName}/include.file3", ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(3)); - assertEquals(new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include-file-with-dashes"), 0), entries.get(4)); + assertEquals( + new CIncludeFileEntry(project.getLocation().removeLastSegments(2).append("include.file2"), 0), + entries.get(2)); + assertEquals(new CIncludeFileEntry("/${ProjName}/include.file3", ICSettingEntry.VALUE_WORKSPACE_PATH), + entries.get(3)); + assertEquals( + new CIncludeFileEntry( + project.getLocation().removeLastSegments(2).append("include-file-with-dashes"), 0), + entries.get(4)); } /** @@ -788,13 +834,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -806,9 +855,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CMacroFileEntry expected = new CMacroFileEntry("/macro.file", 0); - CMacroFileEntry entry = (CMacroFileEntry)entries.get(0); + CMacroFileEntry entry = (CMacroFileEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -828,13 +877,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -845,9 +897,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CLibraryPathEntry expected = new CLibraryPathEntry("/path0", 0); - CLibraryPathEntry entry = (CLibraryPathEntry)entries.get(0); + CLibraryPathEntry entry = (CLibraryPathEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); assertEquals(expected.getValue(), entry.getValue()); assertEquals(expected.getKind(), entry.getKind()); @@ -866,13 +918,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -880,7 +935,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CLibraryFileEntry expected = new CLibraryFileEntry("libdomain.a", 0); CLibraryFileEntry entry = (CLibraryFileEntry) entries.get(0); assertEquals(expected.getName(), entry.getName()); @@ -899,13 +954,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -921,12 +979,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { + " -o file.exe" + " -L/usr/lib" + " file.cpp" - + " -mtune=pentiumpro" - ); + + " -mtune=pentiumpro"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); assertEquals(new CIncludePathEntry("/path with spaces", 0), entries.get(2)); @@ -948,7 +1005,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { ICConfigurationDescription cfgDescription = cfgDescriptions[0]; // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -966,15 +1024,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -985,9 +1046,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), + entries.get(1)); } /** @@ -997,7 +1059,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; @@ -1005,7 +1067,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(null, null); @@ -1016,8 +1079,12 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(null, file, languageId).get(0)); - assertEquals(new CIncludePathEntry(file.getParent().getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), parser.getSettingEntries(null, file, languageId).get(1)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(null, file, languageId).get(0)); + assertEquals( + new CIncludePathEntry(file.getParent().getFullPath(), + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), + parser.getSettingEntries(null, file, languageId).get(1)); } /** @@ -1029,16 +1096,19 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file1=ResourceHelper.createFile(project, "file with spaces 1.cpp"); - IFile file2=ResourceHelper.createFile(project, "file with spaces 2.cpp"); - IFile file3=ResourceHelper.createFile(project, "file with spaces 3.cpp"); - IFile file4=ResourceHelper.createFile(project, "file with spaces 4.cpp"); + IFile file1 = ResourceHelper.createFile(project, "file with spaces 1.cpp"); + IFile file2 = ResourceHelper.createFile(project, "file with spaces 2.cpp"); + IFile file3 = ResourceHelper.createFile(project, "file with spaces 3.cpp"); + IFile file4 = ResourceHelper.createFile(project, "file with spaces 4.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -1050,13 +1120,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries // in single quotes - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file1, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file1, languageId).get(0)); // in double quotes - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file2, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file2, languageId).get(0)); // Unix EOL - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file3, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file3, languageId).get(0)); // Windows EOL - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file4, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file4, languageId).get(0)); } /** @@ -1066,16 +1140,19 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFolder folder1=ResourceHelper.createFolder(project, "Folder1"); - IFile file=ResourceHelper.createFile(project, "Folder1/Folder2/file.cpp"); + IFolder folder1 = ResourceHelper.createFolder(project, "Folder1"); + IFile file = ResourceHelper.createFile(project, "Folder1/Folder2/file.cpp"); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // Shift build directory, that could happen if Make Target from folder1 was run // Build directory points to /project/Folder1/ @@ -1092,9 +1169,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file, languageId).get(0)); // Information from build output should take precedence over build dir - assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), parser.getSettingEntries(cfgDescription, file, languageId).get(1)); + assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), + parser.getSettingEntries(config, file, languageId).get(1)); } /** @@ -1106,15 +1185,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file0=ResourceHelper.createFile(project, "file0.cpp"); - IFile file1=ResourceHelper.createFile(project, "file1.cpp"); - IFile file2=ResourceHelper.createFile(project, "file2.cpp"); + IFile file0 = ResourceHelper.createFile(project, "file0.cpp"); + IFile file1 = ResourceHelper.createFile(project, "file1.cpp"); + IFile file2 = ResourceHelper.createFile(project, "file2.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file0.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -1125,15 +1207,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries { - List entries = parser.getSettingEntries(cfgDescription, file0, languageId); + List entries = parser.getSettingEntries(config, file0, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file1, languageId); + List entries = parser.getSettingEntries(config, file1, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } { - List entries = parser.getSettingEntries(cfgDescription, file2, languageId); + List entries = parser.getSettingEntries(config, file2, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } } @@ -1147,48 +1229,51 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - - IFile file0=ResourceHelper.createFile(project, "file0.cpp"); - IFile file1=ResourceHelper.createFile(project, "file1.cpp"); - IFile file2=ResourceHelper.createFile(project, "file2.cpp"); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + + IFile file0 = ResourceHelper.createFile(project, "file0.cpp"); + IFile file1 = ResourceHelper.createFile(project, "file1.cpp"); + IFile file2 = ResourceHelper.createFile(project, "file2.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file0.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); - + // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); - + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + // parse line parser.startup(cfgDescription, null); parser.processLine("gcc file0.cpp -I/path0 \\"); parser.processLine(" -I/path1"); - parser.processLine("gcc file1.cpp -I/path0 \\\\"); // not a continuation, '\' is escaped! - parser.processLine(" -I/path1"); - parser.processLine("gcc file2.cpp -I/path0 \\"); // continuation at end of last line + parser.processLine("gcc file1.cpp -I/path0 \\\\"); // not a continuation, '\' is escaped! + parser.processLine(" -I/path1"); + parser.processLine("gcc file2.cpp -I/path0 \\"); // continuation at end of last line parser.shutdown(); - + // check populated entries { - List entries = parser.getSettingEntries(cfgDescription, file0, languageId); + List entries = parser.getSettingEntries(config, file0, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); assertEquals(new CIncludePathEntry("/path1", 0), entries.get(1)); } { - List entries = parser.getSettingEntries(cfgDescription, file1, languageId); + List entries = parser.getSettingEntries(config, file1, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); assertEquals(1, entries.size()); } { - List entries = parser.getSettingEntries(cfgDescription, file2, languageId); + List entries = parser.getSettingEntries(config, file2, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); } } - + /** * Test parsing of paths located on a different drive on Windows. */ public void testPathEntry_DriveLetter() throws Exception { // do not test on non-windows systems where drive letters are not supported - if (! Platform.getOS().equals(Platform.OS_WIN32)) + if (!Platform.getOS().equals(Platform.OS_WIN32)) return; // Create model project and accompanied descriptions @@ -1196,13 +1281,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResolvingPaths(true); // parse line @@ -1213,7 +1301,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CIncludePathEntry(new Path("X:\\path"), 0), entries.get(0)); } @@ -1226,15 +1314,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); - IFolder folder=ResourceHelper.createFolder(project, "Folder"); - IFolder folderComposite=ResourceHelper.createFolder(project, "Folder-Icomposite"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); + IFolder folderComposite = ResourceHelper.createFolder(project, "Folder-Icomposite"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResolvingPaths(true); // parse line @@ -1248,12 +1339,15 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); // check that relative paths are relative to CWD which is the location of the project - assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), + entries.get(0)); assertEquals(new CIncludePathEntry(project.getLocation().removeLastSegments(1), 0), entries.get(1)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(2)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folderComposite.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(3)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(2)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folderComposite.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(3)); } /** @@ -1265,15 +1359,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); @SuppressWarnings("unused") - IFolder folder=ResourceHelper.createFolder(project, "Folder"); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser with expandRelativePaths=false - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResolvingPaths(false); // parse line @@ -1286,7 +1383,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); assertEquals(new CIncludePathEntry(".", 0), entries.get(0)); assertEquals(new CIncludePathEntry("..", 0), entries.get(1)); assertEquals(new CIncludePathEntry("Folder", 0), entries.get(2)); @@ -1301,14 +1398,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); - IFolder folder=ResourceHelper.createFolder(project, "Folder"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "Folder"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResolvingPaths(true); // parse line @@ -1320,8 +1420,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); assertEquals(1, entries.size()); } @@ -1334,17 +1435,20 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder buildDir=ResourceHelper.createFolder(project, "BuildDir"); - IFolder folder=ResourceHelper.createFolder(project, "BuildDir/Folder"); - IFile file=ResourceHelper.createFile(project, "BuildDir/file.cpp"); + IFolder buildDir = ResourceHelper.createFolder(project, "BuildDir"); + IFolder folder = ResourceHelper.createFolder(project, "BuildDir/Folder"); + IFile file = ResourceHelper.createFile(project, "BuildDir/file.cpp"); @SuppressWarnings("unused") - IFile fakeFile=ResourceHelper.createFile(project, "file.cpp"); + IFile fakeFile = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // Set different working directory epm.pushDirectoryURI(buildDir.getLocationURI()); @@ -1361,12 +1465,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry( + "/${ProjName}/" + buildDir.getProjectRelativePath().removeLastSegments(1), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); assertEquals(new CIncludePathEntry(buildDir.getLocation().removeLastSegments(3), 0), entries.get(2)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(3)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().append("MissingFolder"), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(4)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(3)); + assertEquals(new CIncludePathEntry( + "/${ProjName}/" + buildDir.getProjectRelativePath().append("MissingFolder"), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(4)); } /** @@ -1378,14 +1488,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder folder=ResourceHelper.createFolder(project, "BuildDir/Folder"); - IFile file=ResourceHelper.createFile(project, "BuildDir/file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "BuildDir/Folder"); + IFile file = ResourceHelper.createFile(project, "BuildDir/file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); @@ -1397,8 +1510,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); } /** @@ -1410,14 +1524,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder buildDir=project.getFolder("Missing/Folder"); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFolder buildDir = project.getFolder("Missing/Folder"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // define working directory @@ -1434,15 +1551,21 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().removeLastSegments(1), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().append("Folder"), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(2)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry( + "/${ProjName}/" + buildDir.getProjectRelativePath().removeLastSegments(1), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + assertEquals( + new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().append("Folder"), + ICSettingEntry.VALUE_WORKSPACE_PATH), + entries.get(2)); } /** - * Test case when build command indicates impossible working directory and - * ErrorParserManager indicates non-existing working directory. + * Test case when build command indicates impossible working directory and ErrorParserManager + * indicates non-existing working directory. */ public void testPathEntry_NonExistentCWD_Filesystem() throws Exception { // Create model project and accompanied descriptions @@ -1450,13 +1573,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); URI uriBuildDir = new URI("file:/non-existing/path"); @@ -1474,7 +1600,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); IPath buildPath = new Path(uriBuildDir.getPath()).setDevice(project.getLocation().getDevice()); assertEquals(new CIncludePathEntry(buildPath, 0), entries.get(0)); assertEquals(new CIncludePathEntry(buildPath.removeLastSegments(1), 0), entries.get(1)); @@ -1490,19 +1616,22 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder buildDir=ResourceHelper.createFolder(project, "Local/BuildDir"); - IFolder folder=ResourceHelper.createFolder(project, "Local/BuildDir/Folder"); - IFolder folder2=ResourceHelper.createFolder(project, "Local/BuildDir/Folder2"); - IFile file=ResourceHelper.createFile(project, "Local/BuildDir/file.cpp"); - IFile incFile1=ResourceHelper.createFile(project, "Local/BuildDir/include.file1"); - IFile incFile2=ResourceHelper.createFile(project, "Local/BuildDir/include.file2"); + IFolder buildDir = ResourceHelper.createFolder(project, "Local/BuildDir"); + IFolder folder = ResourceHelper.createFolder(project, "Local/BuildDir/Folder"); + IFolder folder2 = ResourceHelper.createFolder(project, "Local/BuildDir/Folder2"); + IFile file = ResourceHelper.createFile(project, "Local/BuildDir/file.cpp"); + IFile incFile1 = ResourceHelper.createFile(project, "Local/BuildDir/include.file1"); + IFile incFile2 = ResourceHelper.createFile(project, "Local/BuildDir/include.file2"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // define working directory as URI pointing outside workspace @@ -1525,16 +1654,25 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder2.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(2)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder2.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(2)); assertEquals(new CIncludePathEntry("/BuildDir/MissingFolder", 0), entries.get(3)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath().append("MissingFolder2"), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(4)); - assertEquals(new CIncludeFileEntry("/${ProjName}/" + incFile1.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(5)); - assertEquals(new CIncludeFileEntry("/${ProjName}/" + incFile2.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(6)); + assertEquals(new CIncludePathEntry( + "/${ProjName}/" + buildDir.getProjectRelativePath().append("MissingFolder2"), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(4)); + assertEquals(new CIncludeFileEntry("/${ProjName}/" + incFile1.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(5)); + assertEquals(new CIncludeFileEntry("/${ProjName}/" + incFile2.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(6)); assertEquals(new CIncludeFileEntry("/BuildDir/missing.include.file", 0), entries.get(7)); - assertEquals(new CIncludeFileEntry("/${ProjName}/" + buildDir.getProjectRelativePath().append("missing.include.file2"), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(8)); + assertEquals(new CIncludeFileEntry( + "/${ProjName}/" + buildDir.getProjectRelativePath().append("missing.include.file2"), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(8)); } /** @@ -1546,20 +1684,23 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "BuildDir/file.cpp"); - IFolder mappedFolder=ResourceHelper.createFolder(project, "Mapped/Folder"); - IFolder folder=ResourceHelper.createFolder(project, "Mapped/Folder/Subfolder"); + IFile file = ResourceHelper.createFile(project, "BuildDir/file.cpp"); + IFolder mappedFolder = ResourceHelper.createFolder(project, "Mapped/Folder"); + IFolder folder = ResourceHelper.createFolder(project, "Mapped/Folder/Subfolder"); @SuppressWarnings("unused") - IFolder ambiguousFolder1=ResourceHelper.createFolder(project, "One/Ambiguous/Folder"); + IFolder ambiguousFolder1 = ResourceHelper.createFolder(project, "One/Ambiguous/Folder"); @SuppressWarnings("unused") - IFolder ambiguousFolder2=ResourceHelper.createFolder(project, "Another/Ambiguous/Folder"); + IFolder ambiguousFolder2 = ResourceHelper.createFolder(project, "Another/Ambiguous/Folder"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -1573,9 +1714,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + mappedFolder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + mappedFolder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(2)); assertEquals(new CIncludePathEntry("/Missing/Folder", 0), entries.get(3)); } @@ -1589,23 +1732,25 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // create files and folders - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); // another project - IProject anotherProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-another"); - IFolder folder=ResourceHelper.createFolder(anotherProject, "Mapped/Folder/Subfolder"); + IProject anotherProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-another"); + IFolder folder = ResourceHelper.createFolder(anotherProject, "Mapped/Folder/Subfolder"); @SuppressWarnings("unused") - IFolder ambiguousFolder1=ResourceHelper.createFolder(anotherProject, "One/Ambiguous/Folder"); + IFolder ambiguousFolder1 = ResourceHelper.createFolder(anotherProject, "One/Ambiguous/Folder"); @SuppressWarnings("unused") - IFolder ambiguousFolder2=ResourceHelper.createFolder(anotherProject, "Another/Ambiguous/Folder"); - + IFolder ambiguousFolder2 = ResourceHelper.createFolder(anotherProject, "Another/Ambiguous/Folder"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -1618,8 +1763,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry(folder.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry(folder.getFullPath(), + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(1)); assertEquals(new CIncludePathEntry("/Missing/Folder", 0), entries.get(2)); } @@ -1633,31 +1779,36 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // create main project IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); // create another project (non-referenced) - IProject anotherProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-another"); + IProject anotherProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-another"); @SuppressWarnings("unused") - IFolder folderInAnotherProject=ResourceHelper.createFolder(anotherProject, "Mapped/Folder/Subfolder"); + IFolder folderInAnotherProject = ResourceHelper.createFolder(anotherProject, + "Mapped/Folder/Subfolder"); // create referenced project - IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced"); - IFolder folderInReferencedProject=ResourceHelper.createFolder(referencedProject, "Mapped/Folder/Subfolder"); + IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-referenced"); + IFolder folderInReferencedProject = ResourceHelper.createFolder(referencedProject, + "Mapped/Folder/Subfolder"); @SuppressWarnings("unused") - IFolder ambiguousFolder1=ResourceHelper.createFolder(referencedProject, "One/Ambiguous/Folder"); + IFolder ambiguousFolder1 = ResourceHelper.createFolder(referencedProject, "One/Ambiguous/Folder"); @SuppressWarnings("unused") - IFolder ambiguousFolder2=ResourceHelper.createFolder(referencedProject, "Another/Ambiguous/Folder"); + IFolder ambiguousFolder2 = ResourceHelper.createFolder(referencedProject, "Another/Ambiguous/Folder"); setReference(project, referencedProject); // get cfgDescription and language to work with ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -1669,8 +1820,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry(folderInReferencedProject.getFullPath(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry(folderInReferencedProject.getFullPath(), + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED), entries.get(0)); assertEquals(new CIncludePathEntry("/Ambiguous/Folder", 0), entries.get(1)); } @@ -1687,9 +1839,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String languageId = LANG_CPP; - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); // create link on the filesystem IPath dir1 = ResourceHelper.createTemporaryFolder(); @@ -1698,17 +1852,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { ResourceHelper.createSymbolicLink(linkPath, dir2); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line parser.startup(cfgDescription, epm); // "../" should navigate along filesystem path, not along the link itself - parser.processLine("gcc -I"+linkPath.toString()+"/.."+" file.cpp"); + parser.processLine("gcc -I" + linkPath.toString() + "/.." + " file.cpp"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); CIncludePathEntry expected = new CIncludePathEntry(dir2.removeLastSegments(1), 0); assertEquals(expected, entries.get(0)); } @@ -1726,9 +1881,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String languageId = LANG_CPP; - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); // create link IFolder folder = ResourceHelper.createFolder(project, "folder"); @@ -1737,18 +1894,20 @@ public class GCCBuildCommandParserTest extends BaseTestCase { ResourceHelper.createSymbolicLink(linkPath, subfolder.getLocation()); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line parser.startup(cfgDescription, epm); // "../" should navigate along filesystem path, not along the link itself - parser.processLine("gcc -Ilinked/.."+" file.cpp"); + parser.processLine("gcc -Ilinked/.." + " file.cpp"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - CIncludePathEntry expected = new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH); + List entries = parser.getSettingEntries(config, file, languageId); + CIncludePathEntry expected = new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH); assertEquals(expected, entries.get(0)); } @@ -1761,24 +1920,27 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); // Create resources trying to confuse the parser @SuppressWarnings("unused") - IFile fileInProjectRoot=ResourceHelper.createFile(project, "file.cpp"); + IFile fileInProjectRoot = ResourceHelper.createFile(project, "file.cpp"); @SuppressWarnings("unused") - IFolder includeDirInProjectRoot=ResourceHelper.createFolder(project, "include"); + IFolder includeDirInProjectRoot = ResourceHelper.createFolder(project, "include"); // Create resources meant to be found - IFolder buildDir=ResourceHelper.createFolder(project, "BuildDir"); - IFile file=ResourceHelper.createFile(project, "BuildDir/file.cpp"); - IFolder includeDir=ResourceHelper.createFolder(project, "BuildDir/include"); + IFolder buildDir = ResourceHelper.createFolder(project, "BuildDir"); + IFile file = ResourceHelper.createFile(project, "BuildDir/file.cpp"); + IFolder includeDir = ResourceHelper.createFolder(project, "BuildDir/include"); // Change build dir setBuilderCWD(project, buildDir.getLocation()); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -1789,9 +1951,11 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + includeDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + includeDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); } /** @@ -1803,38 +1967,42 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); // Create resources trying to confuse the parser @SuppressWarnings("unused") - IFile fileInProjectRoot=ResourceHelper.createFile(project, "file.cpp"); + IFile fileInProjectRoot = ResourceHelper.createFile(project, "file.cpp"); @SuppressWarnings("unused") - IFolder includeDirInProjectRoot=ResourceHelper.createFolder(project, "include"); + IFolder includeDirInProjectRoot = ResourceHelper.createFolder(project, "include"); // Create resources meant to be found - IFolder buildDir=ResourceHelper.createFolder(project, "BuildDir"); - IFile file=ResourceHelper.createFile(project, "BuildDir/file.cpp"); - IFolder includeDir=ResourceHelper.createFolder(project, "BuildDir/include"); + IFolder buildDir = ResourceHelper.createFolder(project, "BuildDir"); + IFile file = ResourceHelper.createFile(project, "BuildDir/file.cpp"); + IFolder includeDir = ResourceHelper.createFolder(project, "BuildDir/include"); // Change build dir setBuilderCWD(project, buildDir.getLocation()); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); parser.processLine("gcc " + "-I. " + "-Iinclude " - + '"' + file.getLocation().toOSString() + '"' - ); + + '"' + file.getLocation().toOSString() + '"'); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry("/${ProjName}/" + includeDir.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/" + buildDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + includeDir.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(1)); } /** @@ -1867,9 +2035,14 @@ public class GCCBuildCommandParserTest extends BaseTestCase { ResourceHelper.createFile(project, "file.c"); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // restrict the parser's language scope to C++ only - parser.setLanguageScope(new ArrayList() {{add(LANG_CPP);}}); + parser.setLanguageScope(new ArrayList() { + { + add(LANG_CPP); + } + }); // parse line parser.startup(cfgDescription, null); @@ -1888,6 +2061,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String languageId = LANG_CPP; // add custom extension to C++ content type @@ -1895,12 +2070,13 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IContentType contentType = manager.findContentTypeFor("file.cpp"); contentType.addFileSpec("x++", IContentTypeSettings.FILE_EXTENSION_SPEC); - IFile file=ResourceHelper.createFile(project, "file.x++"); + IFile file = ResourceHelper.createFile(project, "file.x++"); IContentType contentTypeX = manager.findContentTypeFor("file.x++"); assertEquals(contentType, contentTypeX); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); @@ -1908,7 +2084,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file, languageId).get(0)); // cleanup contentType.removeFileSpec("x++", IContentTypeSettings.FILE_EXTENSION_SPEC); @@ -1923,13 +2100,16 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String languageId = LANG_CPP; - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -1938,7 +2118,8 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - assertEquals(new CIncludePathEntry("/path0", 0), parser.getSettingEntries(cfgDescription, file, languageId).get(0)); + assertEquals(new CIncludePathEntry("/path0", 0), + parser.getSettingEntries(config, file, languageId).get(0)); } /** @@ -1950,31 +2131,34 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFile file=ResourceHelper.createFile(project, "libs/python/src/numeric.cpp"); + IFile file = ResourceHelper.createFile(project, "libs/python/src/numeric.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); // parse line parser.startup(cfgDescription, null); - // "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DBOOST_PYTHON_STATIC_LIB -I"." -I"/Python25/Include" -c -o "bin.v2/libs/python/build/gcc-mingw-3.4.5/debug/link-static/threading-multi/numeric.o" "libs/python/src/numeric.cpp" - parser.processLine(" \"g++\"" + - " -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads" + - " -DBOOST_ALL_NO_LIB=1" + - " -DBOOST_PYTHON_SOURCE" + - " -DBOOST_PYTHON_STATIC_LIB" + - " -I\".\"" + - " -I\"/Python1025/Include\"" + - " -c -o \"bin.v2/libs/python/build/gcc-mingw-3.4.5/debug/link-static/threading-multi/numeric.o\"" + - " libs/python/src/numeric.cpp"); + // "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -DBOOST_ALL_NO_LIB=1 -DBOOST_PYTHON_SOURCE -DBOOST_PYTHON_STATIC_LIB -I"." -I"/Python25/Include" -c -o "bin.v2/libs/python/build/gcc-mingw-3.4.5/debug/link-static/threading-multi/numeric.o" "libs/python/src/numeric.cpp" + parser.processLine(" \"g++\"" + + " -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads" + + " -DBOOST_ALL_NO_LIB=1" + + " -DBOOST_PYTHON_SOURCE" + + " -DBOOST_PYTHON_STATIC_LIB" + + " -I\".\"" + " -I\"/Python1025/Include\"" + + " -c -o \"bin.v2/libs/python/build/gcc-mingw-3.4.5/debug/link-static/threading-multi/numeric.o\"" + + " libs/python/src/numeric.cpp"); parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); - assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + List entries = parser.getSettingEntries(config, file, languageId); + assertEquals(new CIncludePathEntry("/${ProjName}/", ICSettingEntry.VALUE_WORKSPACE_PATH), + entries.get(0)); // "/Python1025/Include" not expected to be there assertFalse(new java.io.File("/Python1025/Include").exists()); assertEquals(new CIncludePathEntry("/Python1025/Include", 0), entries.get(1)); @@ -1993,17 +2177,23 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // create folder structure @SuppressWarnings("unused") - IFolder buildDir=ResourceHelper.createEfsFolder(project, "BuildDir", new URI("mem:/EfsProject/BuildDir")); - IFolder folder=ResourceHelper.createEfsFolder(project, "BuildDir/Folder", new URI("mem:/EfsProject/BuildDir/Folder")); - IFile file=ResourceHelper.createEfsFile(project, "BuildDir/file.cpp", new URI("mem:/EfsProject/BuildDir/file.cpp")); + IFolder buildDir = ResourceHelper.createEfsFolder(project, "BuildDir", + new URI("mem:/EfsProject/BuildDir")); + IFolder folder = ResourceHelper.createEfsFolder(project, "BuildDir/Folder", + new URI("mem:/EfsProject/BuildDir/Folder")); + IFile file = ResourceHelper.createEfsFile(project, "BuildDir/file.cpp", + new URI("mem:/EfsProject/BuildDir/file.cpp")); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -2015,10 +2205,12 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); String device = project.getLocation().getDevice(); - assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); - assertEquals(new CIncludePathEntry(new Path("/Absolute/Folder").setDevice(device), 0), entries.get(1)); + assertEquals(new CIncludePathEntry("/${ProjName}/" + folder.getProjectRelativePath(), + ICSettingEntry.VALUE_WORKSPACE_PATH), entries.get(0)); + assertEquals(new CIncludePathEntry(new Path("/Absolute/Folder").setDevice(device), 0), + entries.get(1)); } /** @@ -2030,18 +2222,24 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // create folder structure @SuppressWarnings("unused") - IFolder buildDir=ResourceHelper.createEfsFolder(project, "BuildDir", new URI("mem:/MappedEfsProject/BuildDir")); + IFolder buildDir = ResourceHelper.createEfsFolder(project, "BuildDir", + new URI("mem:/MappedEfsProject/BuildDir")); @SuppressWarnings("unused") - IFolder folder=ResourceHelper.createEfsFolder(project, "BuildDir/Folder", new URI("mem:/MappedEfsProject/BuildDir/Folder")); - IFile file=ResourceHelper.createEfsFile(project, "BuildDir/file.cpp", new URI("mem:/MappedEfsProject/BuildDir/file.cpp")); + IFolder folder = ResourceHelper.createEfsFolder(project, "BuildDir/Folder", + new URI("mem:/MappedEfsProject/BuildDir/Folder")); + IFile file = ResourceHelper.createEfsFile(project, "BuildDir/file.cpp", + new URI("mem:/MappedEfsProject/BuildDir/file.cpp")); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); ErrorParserManager epm = new ErrorParserManager(project, null); // parse line @@ -2052,9 +2250,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check populated entries - List entries = parser.getSettingEntries(cfgDescription, file, languageId); + List entries = parser.getSettingEntries(config, file, languageId); String device = project.getLocation().getDevice(); - assertEquals(new CIncludePathEntry(new Path("/LocallyMappedTo/Folder").setDevice(device), 0), entries.get(0)); + assertEquals(new CIncludePathEntry(new Path("/LocallyMappedTo/Folder").setDevice(device), 0), + entries.get(0)); } /** @@ -2066,14 +2265,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder folder=ResourceHelper.createFolder(project, "folder"); - IFile file=ResourceHelper.createFile(project, "folder/file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "folder"); + IFile file = ResourceHelper.createFile(project, "folder/file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.FILE); // parse line @@ -2084,9 +2286,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); expected.add(new CIncludePathEntry("/path0", 0)); - assertEquals(expected, parser.getSettingEntries(cfgDescription, file, languageId)); - assertEquals(null, parser.getSettingEntries(cfgDescription, folder, languageId)); - assertEquals(null, parser.getSettingEntries(cfgDescription, project, languageId)); + assertEquals(expected, parser.getSettingEntries(config, file, languageId)); + assertEquals(null, parser.getSettingEntries(config, folder, languageId)); + assertEquals(null, parser.getSettingEntries(config, project, languageId)); } /** @@ -2098,14 +2300,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder folder=ResourceHelper.createFolder(project, "folder"); - IFile file=ResourceHelper.createFile(project, "folder/file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "folder"); + IFile file = ResourceHelper.createFile(project, "folder/file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.FOLDER); // parse line @@ -2116,9 +2321,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // check populated entries List expected = new ArrayList(); expected.add(new CIncludePathEntry("/path0", 0)); - assertEquals(null, parser.getSettingEntries(cfgDescription, file, languageId)); - assertEquals(expected, parser.getSettingEntries(cfgDescription, folder, languageId)); - assertEquals(null, parser.getSettingEntries(cfgDescription, project, languageId)); + assertEquals(null, parser.getSettingEntries(config, file, languageId)); + assertEquals(expected, parser.getSettingEntries(config, folder, languageId)); + assertEquals(null, parser.getSettingEntries(config, project, languageId)); } /** @@ -2130,14 +2335,17 @@ public class GCCBuildCommandParserTest extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - IFolder folder=ResourceHelper.createFolder(project, "folder"); - IFile file=ResourceHelper.createFile(project, "folder/file.cpp"); + IFolder folder = ResourceHelper.createFolder(project, "folder"); + IFile file = ResourceHelper.createFile(project, "folder/file.cpp"); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT); // parse line @@ -2149,9 +2357,9 @@ public class GCCBuildCommandParserTest extends BaseTestCase { List expected = new ArrayList(); expected.add(new CIncludePathEntry("/path0", 0)); - assertEquals(null, parser.getSettingEntries(cfgDescription, file, languageId)); - assertEquals(null, parser.getSettingEntries(cfgDescription, folder, languageId)); - assertEquals(expected, parser.getSettingEntries(cfgDescription, project, languageId)); + assertEquals(null, parser.getSettingEntries(config, file, languageId)); + assertEquals(null, parser.getSettingEntries(config, folder, languageId)); + assertEquals(expected, parser.getSettingEntries(config, project, languageId)); } /** @@ -2159,8 +2367,10 @@ public class GCCBuildCommandParserTest extends BaseTestCase { */ public void testEntriesProjectLevelGlobalProvider() throws Exception { // create GCCBuildCommandParser - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(GCC_BUILD_COMMAND_PARSER_EXT); - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getRawProvider(wspProvider); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(GCC_BUILD_COMMAND_PARSER_EXT); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getRawProvider(wspProvider); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT); parser.clear(); @@ -2182,15 +2392,18 @@ public class GCCBuildCommandParserTest extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT); // parse line @@ -2202,7 +2415,7 @@ public class GCCBuildCommandParserTest extends BaseTestCase { parser.shutdown(); // check entries - List entries = parser.getSettingEntries(cfgDescription, project, languageId); + List entries = parser.getSettingEntries(config, project, languageId); assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); assertEquals(new CIncludePathEntry(project.getLocation().removeLastSegments(1), 0), entries.get(1)); } @@ -2212,42 +2425,47 @@ public class GCCBuildCommandParserTest extends BaseTestCase { */ public void testFileAbsolutePath_ProjectLevel_DriveLetter() throws Exception { // do not test on non-windows systems where drive letters are not supported - if (! Platform.getOS().equals(Platform.OS_WIN32)) + if (!Platform.getOS().equals(Platform.OS_WIN32)) return; // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IFile file=ResourceHelper.createFile(project, "file.cpp"); + IFile file = ResourceHelper.createFile(project, "file.cpp"); ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file.getProjectRelativePath(), true); String languageId = ls.getLanguageId(); - + // create GCCBuildCommandParser - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(GCC_BUILD_COMMAND_PARSER_EXT, true); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT); - + // parse line parser.startup(cfgDescription, null); parser.processLine("gcc " + "-IC:/path0 " + "/absolute/path/file.cpp"); parser.shutdown(); - + // check entries - List entries = parser.getSettingEntries(cfgDescription, project, languageId); + List entries = parser.getSettingEntries(config, project, languageId); assertEquals(new CIncludePathEntry("C:/path0", 0), entries.get(0)); } - + /** * Parsing of file being compiled outside of workspace saving entries at project scope. */ public void testFileAbsolutePath_ProjectLevelGlobalProvider() throws Exception { // create GCCBuildCommandParser - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(GCC_BUILD_COMMAND_PARSER_EXT); - GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getRawProvider(wspProvider); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(GCC_BUILD_COMMAND_PARSER_EXT); + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager + .getRawProvider(wspProvider); parser.setResourceScope(AbstractBuildCommandParser.ResourceScope.PROJECT); parser.clear(); diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java index 9651d9db79f..6aa9fdbf824 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; @@ -55,9 +56,11 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { * Test that null arguments don't crash the provider. */ public void testNulls() throws Exception { - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(MBS_LANGUAGE_SETTINGS_PROVIDER_ID); assertNotNull(provider); - List entries = provider.getSettingEntries(null, null, null); + List entries = provider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(null, entries); } @@ -76,7 +79,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); { ILanguageSettingsProvider provider = providers.get(0); String id = provider.getId(); @@ -110,8 +114,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { } /** - * Test that no unnecessary storage file is created for language settings for default set - * of language settings providers. + * Test that no unnecessary storage file is created for language settings for default set of language + * settings providers. */ public void testProjectPersistence_Defaults() throws Exception { // create a new project @@ -125,8 +129,10 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getDefaultLanguageSettingsProvidersIds(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(defaultIds.length, providers.size()); for (int i = 0; i < defaultIds.length; i++) { assertEquals(providers.get(i).getId(), defaultIds[i]); @@ -140,7 +146,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { assertEquals(false, xmlStorageFile.getParent().exists()); // .settings folder // no settings file in workspace area - String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML); + String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests + .getStoreLocationInWorkspaceArea(project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML); java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation); assertEquals(false, xmlStorageFilePrjWsp.exists()); } @@ -160,8 +167,10 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(new ArrayList()); - assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders().size() == 0); + ((ILanguageSettingsProvidersKeeper) cfgDescription) + .setLanguageSettingProviders(new ArrayList()); + assertTrue(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders() + .size() == 0); } CoreModel.getDefault().setProjectDescription(project, prjDescription); @@ -171,7 +180,8 @@ public class LanguageSettingsProvidersMBSTest extends BaseTestCase { assertEquals(true, xmlStorageFile.exists()); // no settings file in workspace area - String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests.getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML); + String xmlPrjWspStorageFileLocation = LanguageSettingsPersistenceProjectTests + .getStoreLocationInWorkspaceArea(project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML); java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation); assertEquals(false, xmlStorageFilePrjWsp.exists()); diff --git a/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs index 30f1cf1e4db..deae7a7dfbb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs +++ b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Thu Apr 29 13:15:20 EDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 @@ -81,262 +80,6 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -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_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -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_selector_in_method_invocation=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 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=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 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -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_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 -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -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.format_block_comments=true -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_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=110 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -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_and_in_type_parameter=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_closing_angle_bracket_in_type_arguments=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 -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -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_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -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_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_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=110 -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_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -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.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.ui.prefs b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..fe89f28bca5 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +formatter_settings_version=12 diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java index 828b7a0ad7f..6086a01adb0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java @@ -31,6 +31,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; @@ -41,10 +42,17 @@ import org.eclipse.core.variables.VariablesPlugin; /** * Implementation of language settings provider for CDT Managed Build System. */ -public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsBroadcastingProvider { +public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase + implements ILanguageSettingsBroadcastingProvider { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (cfgDescription == null || rc == null) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config == null || rc == null) { + return null; + } + + ICConfigurationDescription cfgDescription = config.getAdapter(ICConfigurationDescription.class); + if (cfgDescription == null) { return null; } @@ -56,7 +64,7 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase if (ls != null) { languageSettings = new ICLanguageSetting[] { ls }; } else { - return getSettingEntries(cfgDescription, rc.getParent(), languageId); + return getSettingEntries(config, rc.getParent(), languageId); } } else { ICResourceDescription rcDescription = cfgDescription.getResourceDescription(projectPath, false); @@ -72,9 +80,10 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase String id = langSetting.getLanguageId(); if (id == languageId || (id != null && id.equals(languageId))) { int kindsBits = langSetting.getSupportedEntryKinds(); - for (int kind=1; kind <= kindsBits; kind <<= 1) { + for (int kind = 1; kind <= kindsBits; kind <<= 1) { if ((kindsBits & kind) != 0) { - List additions = langSetting.getSettingEntriesList(kind); + List additions = langSetting + .getSettingEntriesList(kind); for (ICLanguageSettingEntry entry : additions) { if (entry instanceof ICPathEntry) { // have to use getName() rather than getLocation() and not use IPath operations to avoid collapsing ".." @@ -83,17 +92,26 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase // We need to add project-rooted entry for relative path as MBS counts it this way in some UI // The relative entry below also should be added for indexer to resolve from source file locations - ICdtVariableManager varManager = CCorePlugin.getDefault().getCdtVariableManager(); + ICdtVariableManager varManager = CCorePlugin.getDefault() + .getCdtVariableManager(); try { // Substitute build/environment variables - String location = varManager.resolveValue(pathStr, "", null, cfgDescription); //$NON-NLS-1$ + String location = varManager.resolveValue(pathStr, "", null, //$NON-NLS-1$ + cfgDescription); if (!new Path(location).isAbsolute()) { - IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); - String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$ + IStringVariableManager mngr = VariablesPlugin.getDefault() + .getStringVariableManager(); + String projectRootedPath = mngr + .generateVariableExpression("workspace_loc", //$NON-NLS-1$ + rc.getProject().getName()) + + Path.SEPARATOR + pathStr; // clear "RESOLVED" flag - int flags = entry.getFlags() & ~(ICSettingEntry.RESOLVED | ICSettingEntry.VALUE_WORKSPACE_PATH); - ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, flags); - if (! list.contains(projectRootedEntry)) { + int flags = entry.getFlags() & ~(ICSettingEntry.RESOLVED + | ICSettingEntry.VALUE_WORKSPACE_PATH); + ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil + .createEntry(kind, projectRootedPath, + projectRootedPath, null, flags); + if (!list.contains(projectRootedEntry)) { list.add(projectRootedEntry); } } @@ -101,10 +119,10 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase // Swallow exceptions but also log them ManagedBuilderCorePlugin.log(e); } - + } } - if (! list.contains(entry)) { + if (!list.contains(entry)) { list.add(entry); } } @@ -126,11 +144,11 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase case ICSettingBase.SETTING_PROJECT: case ICSettingBase.SETTING_CONFIGURATION: case ICSettingBase.SETTING_FOLDER: - ICFolderDescription foDes = (ICFolderDescription)rcDescription; + ICFolderDescription foDes = (ICFolderDescription) rcDescription; array = foDes.getLanguageSettings(); break; case ICSettingBase.SETTING_FILE: - ICFileDescription fiDes = (ICFileDescription)rcDescription; + ICFileDescription fiDes = (ICFileDescription) rcDescription; ICLanguageSetting ls = fiDes.getLanguageSetting(); if (ls != null) { array = new ICLanguageSetting[] { ls }; @@ -149,10 +167,12 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase public boolean isEmpty() { return false; } + @Override public LanguageSettingsStorage clone() throws CloneNotSupportedException { return this; } + @Override public boolean equals(Object obj) { // Note that this always triggers change event even if nothing changed in MBS diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuildCommandParser.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuildCommandParser.java index daa9a5a80be..1583d71d57c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuildCommandParser.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuildCommandParser.java @@ -23,17 +23,21 @@ import org.eclipse.cdt.core.errorparsers.RegexErrorPattern; import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; /** - * Abstract class for providers parsing compiler option from build command when present in build output. + * Abstract class for providers parsing compiler option from build command when present in build + * output. *

- * EXPERIMENTAL. This class interface is not stable yet as - * it is not currently (CDT 8.1, Juno) clear how it may need to be used in future. - * There is no guarantee that this API will work or that it will remain the same. - * Please do not use this API without consulting with the CDT team. + * EXPERIMENTAL. This class interface is not stable yet as it is not currently (CDT + * 8.1, Juno) clear how it may need to be used in future. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without consulting with the CDT + * team. *

+ * * @noextend This class is not intended to be subclassed by clients. * * @since 8.1 @@ -47,12 +51,11 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting private static final String VALUE_FOLDER_SCOPE = "per-folder"; //$NON-NLS-1$ private static final String VALUE_PROJECT_SCOPE = "per-project"; //$NON-NLS-1$ - private static final String LEADING_PATH_PATTERN = "\\S+[/\\\\]"; //$NON-NLS-1$ /** - * "foo" - * Using look-ahead and look-behind to resolve ambiguity with "\" {@link #QUOTE_BSLASH_QUOTE} + * "foo" Using look-ahead and look-behind to resolve ambiguity with "\" + * {@link #QUOTE_BSLASH_QUOTE} */ private static final String QUOTE = "(\"(?!\\\\).*?(?- {@code AbstractBuildCommandParser.ResourceScope.FILE} - apply entries to the file being parsed. - *
- {@code AbstractBuildCommandParser.ResourceScope.FOLDER} - apply entries to the enclosing folder. - *
- {@code AbstractBuildCommandParser.ResourceScope.PROJECT} - apply entries to the project level. + * @return resource scope of the entries, i.e. level in resource hierarchy where language + * settings entries will be applied by the provider. Resource scope can be one of the + * following:
+ * - {@code AbstractBuildCommandParser.ResourceScope.FILE} - apply entries to the file + * being parsed.
+ * - {@code AbstractBuildCommandParser.ResourceScope.FOLDER} - apply entries to the + * enclosing folder.
+ * - {@code AbstractBuildCommandParser.ResourceScope.PROJECT} - apply entries to the + * project level. */ public ResourceScope getResourceScope() { if (resourceScope == null) { @@ -141,13 +150,17 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting } /** - * Set resource scope of the entries, i.e. level in resource hierarchy where language settings entries - * will be applied by the provider. + * Set resource scope of the entries, i.e. level in resource hierarchy where language settings + * entries will be applied by the provider. * - * @param rcScope - resource scope can be one of the following: - *
- {@code AbstractBuildCommandParser.ResourceScope.FILE} - apply entries to the file being parsed. - *
- {@code AbstractBuildCommandParser.ResourceScope.FOLDER} - apply entries to the enclosing folder. - *
- {@code AbstractBuildCommandParser.ResourceScope.PROJECT} - apply entries to the project level. + * @param rcScope + * - resource scope can be one of the following:
+ * - {@code AbstractBuildCommandParser.ResourceScope.FILE} - apply entries to the + * file being parsed.
+ * - {@code AbstractBuildCommandParser.ResourceScope.FOLDER} - apply entries to the + * enclosing folder.
+ * - {@code AbstractBuildCommandParser.ResourceScope.PROJECT} - apply entries to the + * project level. */ public void setResourceScope(ResourceScope rcScope) { resourceScope = rcScope; @@ -187,11 +200,13 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting } - setSettingEntries(currentCfgDescription, rc, currentLanguageId, entries); + IBuildConfiguration currentConfig = Adapters.adapt(currentCfgDescription, IBuildConfiguration.class); + setSettingEntries(currentConfig, rc, currentLanguageId, entries); } /** - * Adjust count for file group taking into consideration extra groups added by {@link #getCompilerPatternExtended()}. + * Adjust count for file group taking into consideration extra groups added by + * {@link #getCompilerPatternExtended()}. */ private int adjustFileGroup() { return countGroups(getCompilerPatternExtended()) + FILE_GROUP; @@ -202,10 +217,9 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting */ private String makePattern(String template) { @SuppressWarnings("nls") - String pattern = template - .replace("${COMPILER_PATTERN}", getCompilerPatternExtended()) - .replace("${EXTENSIONS_PATTERN}", getPatternFileExtensions()) - .replace("${COMPILER_GROUPS+1}", new Integer(countGroups(getCompilerPatternExtended()) + 1).toString()); + String pattern = template.replace("${COMPILER_PATTERN}", getCompilerPatternExtended()) + .replace("${EXTENSIONS_PATTERN}", getPatternFileExtensions()).replace("${COMPILER_GROUPS+1}", + new Integer(countGroups(getCompilerPatternExtended()) + 1).toString()); return pattern; } @@ -237,7 +251,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting Matcher optionMatcher = OPTIONS_PATTERN.matcher(line); while (optionMatcher.find()) { String option = optionMatcher.group(OPTION_GROUP); - if (option!=null) { + if (option != null) { options.add(option); } } @@ -263,29 +277,29 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting processLine(partialLine); partialLine = null; } - + serializeLanguageSettingsInBackground(); super.shutdown(); } - + @Override public boolean processLine(String line) { line = handleLineContinuation(line); return super.processLine(line); } - + /** * Handle line continuations ('\' at the end of a line, indicating that the next line is a * continuation of this one). */ private String handleLineContinuation(String line) { - if (line == null) + if (line == null) return null; - // If the character preceding the '\' is also '\', it's not a line continuation - + // If the character preceding the '\' is also '\', it's not a line continuation - // the first '\' escapes the second. - if (line.length() > 0 && line.charAt(line.length() - 1) == '\\' && - (line.length() == 1 || line.charAt(line.length() - 2) != '\\')) { + if (line.length() > 0 && line.charAt(line.length() - 1) == '\\' + && (line.length() == 1 || line.charAt(line.length() - 2) != '\\')) { // Line ends in line continuation - save it for later. String fragment = line.substring(0, line.length() - 1); if (partialLine == null) { @@ -293,7 +307,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting } else { partialLine += fragment; } - return null; // line will not be processed now + return null; // line will not be processed now } else if (partialLine != null) { // Line doesn't end in continuation but previous lines did - use their contents. line = partialLine + line; @@ -303,14 +317,18 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting } /** - * Trivial Error Parser which allows highlighting of output lines matching the patterns - * of this parser. Intended for better troubleshooting experience. - * Implementers are supposed to add the error parser via extension point {@code org.eclipse.cdt.core.ErrorParser}. + * Trivial Error Parser which allows highlighting of output lines matching the patterns of this + * parser. Intended for better troubleshooting experience. Implementers are supposed to add the + * error parser via extension point {@code org.eclipse.cdt.core.ErrorParser}. */ - protected static abstract class AbstractBuildCommandPatternHighlighter extends RegexErrorParser implements IErrorParser2 { + protected static abstract class AbstractBuildCommandPatternHighlighter extends RegexErrorParser + implements IErrorParser2 { /** * Constructor. - * @param parserId - build command parser ID specified in the extension {@code org.eclipse.cdt.core.LanguageSettingsProvider}. + * + * @param parserId + * - build command parser ID specified in the extension + * {@code org.eclipse.cdt.core.LanguageSettingsProvider}. */ public AbstractBuildCommandPatternHighlighter(String parserId) { init(parserId); @@ -318,16 +336,20 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting /** * Initialize the error parser. - * @param parserId - language settings provider (the build command parser) ID. + * + * @param parserId + * - language settings provider (the build command parser) ID. */ protected void init(String parserId) { - AbstractBuildCommandParser buildCommandParser = (AbstractBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(parserId, false); + AbstractBuildCommandParser buildCommandParser = (AbstractBuildCommandParser) LanguageSettingsManager + .getExtensionProviderCopy(parserId, false); if (buildCommandParser != null) { for (String template : COMPILER_COMMAND_PATTERN_TEMPLATES) { String pattern = buildCommandParser.makePattern(template); - String fileExpr = "$"+buildCommandParser.adjustFileGroup(); //$NON-NLS-1$ + String fileExpr = "$" + buildCommandParser.adjustFileGroup(); //$NON-NLS-1$ String descExpr = "$0"; //$NON-NLS-1$ - addPattern(new RegexErrorPattern(pattern, fileExpr, null, descExpr, null, IMarkerGenerator.SEVERITY_WARNING, true)); + addPattern(new RegexErrorPattern(pattern, fileExpr, null, descExpr, null, + IMarkerGenerator.SEVERITY_WARNING, true)); } } } @@ -338,5 +360,4 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting } } - } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java index d27247f9db3..6a43df4e987 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java @@ -55,11 +55,13 @@ import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.PathUtil; import org.eclipse.cdt.utils.envvar.IEnvironmentChangeEvent; import org.eclipse.cdt.utils.envvar.IEnvironmentChangeListener; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -77,14 +79,14 @@ import org.eclipse.core.runtime.jobs.Job; import org.w3c.dom.Element; /** - * Abstract parser capable to execute compiler command printing built-in compiler - * specs and parse built-in language settings out of it. + * Abstract parser capable to execute compiler command printing built-in compiler specs and parse built-in + * language settings out of it. *

- * EXPERIMENTAL. This class interface is not stable yet as - * it is not currently (CDT 8.1, Juno) clear how it may need to be used in future. - * There is no guarantee that this API will work or that it will remain the same. - * Please do not use this API without consulting with the CDT team. + * EXPERIMENTAL. This class interface is not stable yet as it is not currently (CDT 8.1, + * Juno) clear how it may need to be used in future. There is no guarantee that this API will work or that it + * will remain the same. Please do not use this API without consulting with the CDT team. *

+ * * @noextend This class is not intended to be subclassed by clients. * * @since 8.1 @@ -159,12 +161,15 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti final String providerName = getName(); final String providerId = getId(); // Add markers in a job to avoid deadlocks - Job markerJob = new Job(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.AddScannerDiscoveryMarkers")) { //$NON-NLS-1$ + Job markerJob = new Job(ManagedMakeMessages + .getResourceString("AbstractBuiltinSpecsDetector.AddScannerDiscoveryMarkers")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { // Avoid duplicates as different languages can generate identical errors try { - IMarker[] markers = problemMarkerInfo.file.findMarkers(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); + IMarker[] markers = problemMarkerInfo.file.findMarkers( + SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER, false, + IResource.DEPTH_ZERO); for (IMarker marker : markers) { int sev = ((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue(); if (sev == problemMarkerInfo.severity) { @@ -175,24 +180,31 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } } } catch (CoreException e) { - return new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error checking markers.", e); //$NON-NLS-1$ + return new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Error checking markers.", e); //$NON-NLS-1$ } try { - IMarker marker = problemMarkerInfo.file.createMarker(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER); + IMarker marker = problemMarkerInfo.file + .createMarker(SDMarkerGenerator.SCANNER_DISCOVERY_PROBLEM_MARKER); marker.setAttribute(IMarker.MESSAGE, problemMarkerInfo.description); marker.setAttribute(IMarker.SEVERITY, problemMarkerInfo.severity); marker.setAttribute(SDMarkerGenerator.ATTR_PROVIDER, providerId); if (problemMarkerInfo.file instanceof IWorkspaceRoot) { - String msgPreferences = ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationPreferences", providerName); //$NON-NLS-1$ + String msgPreferences = ManagedMakeMessages.getFormattedString( + "AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationPreferences", //$NON-NLS-1$ + providerName); marker.setAttribute(IMarker.LOCATION, msgPreferences); } else { - String msgProperties = ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationProperties", providerName); //$NON-NLS-1$ + String msgProperties = ManagedMakeMessages.getFormattedString( + "AbstractBuiltinSpecsDetector.ScannerDiscoveryMarkerLocationProperties", //$NON-NLS-1$ + providerName); marker.setAttribute(IMarker.LOCATION, msgProperties); } } catch (CoreException e) { - return new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error adding markers.", e); //$NON-NLS-1$ + return new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Error adding markers.", e); //$NON-NLS-1$ } return Status.OK_STATUS; @@ -206,19 +218,22 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Delete markers previously set by this provider for the resource. * - * @param rc - resource to check markers. + * @param rc + * - resource to check markers. */ public void deleteMarkers(IResource rc) { String providerId = getId(); try { - IMarker[] markers = rc.findMarkers(SCANNER_DISCOVERY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); + IMarker[] markers = rc.findMarkers(SCANNER_DISCOVERY_PROBLEM_MARKER, false, + IResource.DEPTH_ZERO); for (IMarker marker : markers) { if (providerId.equals(marker.getAttribute(ATTR_PROVIDER))) { marker.delete(); } } } catch (CoreException e) { - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error deleting markers.", e)); //$NON-NLS-1$ + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Error deleting markers.", e)); //$NON-NLS-1$ } } @@ -229,13 +244,16 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti */ private class ConsoleParserAdapter implements ICBuildOutputParser { @Override - public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException { + public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) + throws CoreException { AbstractBuiltinSpecsDetector.this.cwdTracker = cwdTracker; } + @Override public boolean processLine(String line) { return AbstractBuiltinSpecsDetector.this.processLine(line); } + @Override public void shutdown() { AbstractBuiltinSpecsDetector.this.cwdTracker = null; @@ -243,11 +261,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * Compiler command without arguments. This value is used to replace macro ${COMMAND}. - * In particular, this method is implemented in {@link ToolchainBuiltinSpecsDetector} - * which retrieves the command from tool-chain. + * Compiler command without arguments. This value is used to replace macro ${COMMAND}. In particular, this + * method is implemented in {@link ToolchainBuiltinSpecsDetector} which retrieves the command from + * tool-chain. * - * @param languageId - language ID. + * @param languageId + * - language ID. * @return compiler command without arguments, i.e. compiler program. */ protected abstract String getCompilerCommand(String languageId); @@ -255,13 +274,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * The command to run. Some macros could be specified in there: *
    - * ${COMMAND} - compiler command without arguments (compiler program). - * Normally would come from the tool-chain.
    + * ${COMMAND} - compiler command without arguments (compiler program). Normally would come from the + * tool-chain.
    * ${INPUTS} - path to spec file which will be placed in workspace area.
    * ${EXT} - file extension calculated from language ID. *
- * The parameter could be taken from the extension - * in {@code plugin.xml} or from property file. + * The parameter could be taken from the extension in {@code plugin.xml} or from property file. * * @return the command to run or empty string if command is not defined. */ @@ -271,7 +289,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Set custom command for the provider. See {@link #getCommand()}. - * @param command - value of custom command to set. + * + * @param command + * - value of custom command to set. */ public void setCommand(String command) { setProperty(ATTR_PARAMETER, command); @@ -287,19 +307,22 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Enable or disable console output for this provider. * - * @param enable - {@code true} to enable console output or {@code false} to disable. + * @param enable + * - {@code true} to enable console output or {@code false} to disable. */ public void setConsoleEnabled(boolean enable) { isConsoleEnabled = enable; } /** - * Expand macros specified in the compiler command. See {@link #getCommand()} for - * the recognized list of macros. + * Expand macros specified in the compiler command. See {@link #getCommand()} for the recognized list of + * macros. * - * @param languageId - language ID. + * @param languageId + * - language ID. * @return - resolved command to run. - * @throws CoreException if something goes wrong. + * @throws CoreException + * if something goes wrong. */ protected String resolveCommand(String languageId) throws CoreException { String cmd = getCommand(); @@ -388,7 +411,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } @Override - public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException { + public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) + throws CoreException { super.startup(cfgDescription, cwdTracker); mappedRootURI = null; @@ -414,14 +438,14 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti List languageIds = getLanguageScope(); if (languageIds == null) { languageIds = new ArrayList(1); - // "null" language indicates that the provider provides for any language + // "null" language indicates that the provider provides for any language languageIds.add(null); } for (String languageId : languageIds) { try { String command = resolveCommand(languageId); if (command != null) { - envHashNew = 31*envHashNew + command.hashCode(); + envHashNew = 31 * envHashNew + command.hashCode(); } String[] cmdArray = CommandLineUtil.argumentsToArray(command); @@ -433,14 +457,15 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti if (location != null) { java.io.File file = new java.io.File(location.toString()); try { - // handles symbolic links as java.io.File.getCanonicalPath() resolves symlinks on UNIX + // handles symbolic links as java.io.File.getCanonicalPath() resolves symlinks on + // UNIX file = file.getCanonicalFile(); } catch (IOException e) { ManagedBuilderCorePlugin.log(e); } long lastModified = file.lastModified(); - envHashNew = 31*envHashNew + location.hashCode(); - envHashNew = 31*envHashNew + lastModified; + envHashNew = 31 * envHashNew + location.hashCode(); + envHashNew = 31 * envHashNew + lastModified; } } } catch (CoreException e) { @@ -451,12 +476,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * This method does 2 related things: - *
- * 1. Validate environment, i.e. check that environment for running the command has not changed. - * If environment changed {@link #execute()} will rerun the command even if flag {@link #isExecuted} - * suggests that it was run already. - *
+ * This method does 2 related things:
+ * 1. Validate environment, i.e. check that environment for running the command has not changed. If + * environment changed {@link #execute()} will rerun the command even if flag {@link #isExecuted} suggests + * that it was run already.
* 2. The relevant environment is cached here so the new one is validated against it at the next call. * {@link #validateEnvironment()} will be called right before running the job to execute the command. * @@ -473,8 +496,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * Execute provider's command which is expected to print built-in compiler options (specs) to build output. - * The parser will parse output and generate language settings for corresponding resources. + * Execute provider's command which is expected to print built-in compiler options (specs) to build + * output. The parser will parse output and generate language settings for corresponding resources. */ protected void execute() { environmentMap = createEnvironmentMap(currentCfgDescription); @@ -482,7 +505,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti return; } - WorkspaceJob job = new WorkspaceJob(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$ + WorkspaceJob job = new WorkspaceJob(ManagedMakeMessages + .getResourceString("AbstractBuiltinSpecsDetector.DiscoverBuiltInSettingsJobName")) { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { isExecuted = false; @@ -496,7 +520,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti status = runForEachLanguage(monitor); } catch (CoreException e) { ManagedBuilderCorePlugin.log(e); - status = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e); //$NON-NLS-1$ + status = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, + "Error running Builtin Specs Detector", e); //$NON-NLS-1$ } finally { isExecuted = true; shutdown(); @@ -504,6 +529,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti return status; } + @Override public boolean belongsTo(Object family) { return family == JOB_FAMILY_BUILTIN_SPECS_DETECTOR; @@ -527,12 +553,14 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Run built-in specs command for each language. * - * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)} - * has not been called yet. + * @param monitor + * - progress monitor in the initial state where + * {@link IProgressMonitor#beginTask(String, int)} has not been called yet. * @return status of operation. */ protected IStatus runForEachLanguage(IProgressMonitor monitor) { - MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, "Problem running CDT Scanner Discovery provider " + getId(), null); //$NON-NLS-1$ + MultiStatus status = new MultiStatus(ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.OK, + "Problem running CDT Scanner Discovery provider " + getId(), null); //$NON-NLS-1$ if (monitor == null) { monitor = new NullProgressMonitor(); @@ -543,32 +571,44 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti List languageIds = getLanguageScope(); if (languageIds != null) { - monitor.beginTask(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.ScannerDiscoveryTaskTitle"), //$NON-NLS-1$ - TICKS_REMOVE_MARKERS + languageIds.size()*TICKS_RUN_FOR_ONE_LANGUAGE + TICKS_SERIALIZATION); + monitor.beginTask( + ManagedMakeMessages + .getResourceString("AbstractBuiltinSpecsDetector.ScannerDiscoveryTaskTitle"), //$NON-NLS-1$ + TICKS_REMOVE_MARKERS + languageIds.size() * TICKS_RUN_FOR_ONE_LANGUAGE + + TICKS_SERIALIZATION); - IResource markersResource = currentProject != null ? currentProject : ResourcesPlugin.getWorkspace().getRoot(); + IResource markersResource = currentProject != null ? currentProject + : ResourcesPlugin.getWorkspace().getRoot(); - monitor.subTask(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ClearingMarkers", markersResource.getFullPath().toString())); //$NON-NLS-1$ + monitor.subTask( + ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.ClearingMarkers", //$NON-NLS-1$ + markersResource.getFullPath().toString())); markerGenerator.deleteMarkers(markersResource); if (monitor.isCanceled()) throw new OperationCanceledException(); monitor.worked(TICKS_REMOVE_MARKERS); + IBuildConfiguration currentConfig = Adapters.adapt(currentCfgDescription, + IBuildConfiguration.class); + for (String languageId : languageIds) { - List oldEntries = getSettingEntries(currentCfgDescription, null, languageId); + List oldEntries = getSettingEntries(currentConfig, null, + languageId); try { startupForLanguage(languageId); runForLanguage(new SubProgressMonitor(monitor, TICKS_RUN_FOR_ONE_LANGUAGE)); } catch (Exception e) { - IStatus s = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e); //$NON-NLS-1$ + IStatus s = new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + IStatus.ERROR, "Error running Builtin Specs Detector", e); //$NON-NLS-1$ ManagedBuilderCorePlugin.log(s); status.merge(s); } finally { shutdownForLanguage(); } if (!isChanged) { - List newEntries = getSettingEntries(currentCfgDescription, null, languageId); + List newEntries = getSettingEntries(currentConfig, null, + languageId); isChanged = newEntries != oldEntries; } @@ -577,7 +617,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } } - monitor.subTask(ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.SerializingResults")); //$NON-NLS-1$ + monitor.subTask( + ManagedMakeMessages.getResourceString("AbstractBuiltinSpecsDetector.SerializingResults")); //$NON-NLS-1$ if (isChanged) { // avoids resource and settings change notifications IStatus s = serializeLanguageSettings(currentCfgDescription); status.merge(s); @@ -587,7 +628,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } catch (OperationCanceledException e) { // user chose to cancel operation, do not threaten them with red error signs } catch (Exception e) { - status.merge(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error running Builtin Specs Detector", e)); //$NON-NLS-1$ + status.merge(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, IStatus.ERROR, + "Error running Builtin Specs Detector", e)); //$NON-NLS-1$ ManagedBuilderCorePlugin.log(status); } finally { monitor.done(); @@ -599,8 +641,10 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Initialize provider before running for a language. * - * @param languageId - language ID. - * @throws CoreException if something goes wrong. + * @param languageId + * - language ID. + * @throws CoreException + * if something goes wrong. */ protected void startupForLanguage(String languageId) throws CoreException { currentLanguageId = languageId; @@ -618,12 +662,14 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti protected void shutdownForLanguage() { if (detectedSettingEntries != null && detectedSettingEntries.size() > 0) { collected = detectedSettingEntries.size(); - setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, detectedSettingEntries); + IBuildConfiguration currentConfig = Adapters.adapt(currentCfgDescription, + IBuildConfiguration.class); + setSettingEntries(currentConfig, currentResource, currentLanguageId, detectedSettingEntries); } detectedSettingEntries = null; currentCommandResolved = null; - if (specFile!=null && !preserveSpecFile) { + if (specFile != null && !preserveSpecFile) { specFile.delete(); specFile = null; } @@ -634,8 +680,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Run built-in specs command for one language. * - * @param monitor - progress monitor in the initial state where {@link IProgressMonitor#beginTask(String, int)} - * has not been called yet. + * @param monitor + * - progress monitor in the initial state where + * {@link IProgressMonitor#beginTask(String, int)} has not been called yet. */ private void runForLanguage(IProgressMonitor monitor) throws CoreException { buildRunnerHelper = new BuildRunnerHelper(currentProject); @@ -644,7 +691,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti monitor = new NullProgressMonitor(); } try { - monitor.beginTask(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName()), //$NON-NLS-1$ + monitor.beginTask( + ManagedMakeMessages.getFormattedString( + "AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName()), //$NON-NLS-1$ TICKS_EXECUTE_COMMAND + TICKS_OUTPUT_PARSING); IConsole console; @@ -652,7 +701,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti console = startProviderConsole(); } else { // that looks in extension points registry and won't find the id, this console is not shown - console = CCorePlugin.getDefault().getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ + console = CCorePlugin.getDefault() + .getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ } console.start(currentProject); @@ -665,7 +715,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti if (cmdArray != null && cmdArray.length > 0) { program = new Path(cmdArray[0]); if (cmdArray.length > 1) { - args = new String[cmdArray.length-1]; + args = new String[cmdArray.length - 1]; System.arraycopy(cmdArray, 1, args, 0, args.length); } } @@ -673,27 +723,32 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti String[] envp = toEnvp(environmentMap); // Using GMAKE_ERROR_PARSER_ID as it can handle generated error messages - ErrorParserManager epm = new ErrorParserManager(currentProject, buildDirURI, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); + ErrorParserManager epm = new ErrorParserManager(currentProject, buildDirURI, markerGenerator, + new String[] { GMAKE_ERROR_PARSER_ID }); ConsoleParserAdapter consoleParser = new ConsoleParserAdapter(); consoleParser.startup(currentCfgDescription, epm); List parsers = new ArrayList(); parsers.add(consoleParser); buildRunnerHelper.setLaunchParameters(launcher, program, args, buildDirURI, envp); - buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, TICKS_OUTPUT_PARSING)); + buildRunnerHelper.prepareStreams(epm, parsers, console, + new SubProgressMonitor(monitor, TICKS_OUTPUT_PARSING)); - buildRunnerHelper.greeting(ManagedMakeMessages.getFormattedString("AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName())); //$NON-NLS-1$ + buildRunnerHelper.greeting(ManagedMakeMessages + .getFormattedString("AbstractBuiltinSpecsDetector.RunningScannerDiscovery", getName())); //$NON-NLS-1$ OutputStream outStream = buildRunnerHelper.getOutputStream(); OutputStream errStream = buildRunnerHelper.getErrorStream(); - runProgramForLanguage(currentLanguageId, currentCommandResolved, envp, buildDirURI, outStream, errStream, - new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + runProgramForLanguage(currentLanguageId, currentCommandResolved, envp, buildDirURI, outStream, + errStream, new SubProgressMonitor(monitor, TICKS_EXECUTE_COMMAND, + SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); buildRunnerHelper.close(); buildRunnerHelper.goodbye(); } catch (Exception e) { - ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Error running Builtin Specs Detector" , e))); //$NON-NLS-1$ + ManagedBuilderCorePlugin.log(new CoreException(new Status(IStatus.ERROR, + ManagedBuilderCorePlugin.PLUGIN_ID, "Error running Builtin Specs Detector", e))); //$NON-NLS-1$ } finally { try { buildRunnerHelper.close(); @@ -705,8 +760,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * Returns list of environment variables to be used during execution of provider's command. - * Implementers are expected to add their variables to the end of the list. + * Returns list of environment variables to be used during execution of provider's command. Implementers + * are expected to add their variables to the end of the list. * * @return list of environment variables. * @since 8.2 @@ -715,7 +770,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti if (envMngr == null) { envMngr = CCorePlugin.getDefault().getBuildEnvironmentManager(); } - List vars = new ArrayList(Arrays.asList(envMngr.getVariables(currentCfgDescription, true))); + List vars = new ArrayList( + Arrays.asList(envMngr.getVariables(currentCfgDescription, true))); // On POSIX (Linux, UNIX) systems reset language variables to default (English) // with UTF-8 encoding since GNU compilers can handle only UTF-8 characters. @@ -749,13 +805,15 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti */ private String[] toEnvp(Map environmentMap) { Set envp = new HashSet(); - for (Entry var: environmentMap.entrySet()) { + for (Entry var : environmentMap.entrySet()) { envp.add(var.getKey() + '=' + var.getValue()); } return envp.toArray(new String[envp.size()]); } - protected int runProgramForLanguage(String languageId, String command, String[] envp, URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, IProgressMonitor monitor) throws CoreException, IOException { + protected int runProgramForLanguage(String languageId, String command, String[] envp, + URI workingDirectoryURI, OutputStream consoleOut, OutputStream consoleErr, + IProgressMonitor monitor) throws CoreException, IOException { return buildRunnerHelper.build(monitor); } @@ -774,6 +832,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti /** * Create and start the provider console. + * * @return CDT console. */ private IConsole startProviderConsole() { @@ -788,32 +847,39 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } ILanguage ld = LanguageManager.getInstance().getLanguage(currentLanguageId); if (ld != null) { - String consoleId = ManagedBuilderCorePlugin.PLUGIN_ID + '.' + getId() + '.' + currentLanguageId; + String consoleId = ManagedBuilderCorePlugin.PLUGIN_ID + '.' + getId() + '.' + + currentLanguageId; String consoleName = getName() + ", " + ld.getName(); //$NON-NLS-1$ - URL defaultIcon = Platform.getBundle(CDT_MANAGEDBUILDER_UI_PLUGIN_ID).getEntry(DEFAULT_CONSOLE_ICON); + URL defaultIcon = Platform.getBundle(CDT_MANAGEDBUILDER_UI_PLUGIN_ID) + .getEntry(DEFAULT_CONSOLE_ICON); if (defaultIcon == null) { @SuppressWarnings("nls") - String msg = "Unable to find icon " + DEFAULT_CONSOLE_ICON + " in plugin " + CDT_MANAGEDBUILDER_UI_PLUGIN_ID; - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg)); + String msg = "Unable to find icon " + DEFAULT_CONSOLE_ICON + " in plugin " + + CDT_MANAGEDBUILDER_UI_PLUGIN_ID; + ManagedBuilderCorePlugin + .log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg)); } - console = CCorePlugin.getDefault().getConsole(extConsoleId, consoleId, consoleName, defaultIcon); + console = CCorePlugin.getDefault().getConsole(extConsoleId, consoleId, consoleName, + defaultIcon); } } if (console == null) { // that looks in extension points registry and won't find the id, this console is not shown - console = CCorePlugin.getDefault().getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ + console = CCorePlugin.getDefault() + .getConsole(ManagedBuilderCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ } return console; } /** - * Get path to spec file which normally would be placed in workspace area. - * This value is used to replace macro ${INPUTS}. + * Get path to spec file which normally would be placed in workspace area. This value is used to replace + * macro ${INPUTS}. * - * @param languageId - language ID. + * @param languageId + * - language ID. * @return full path to the specs file. */ protected String getSpecFile(String languageId) { @@ -843,11 +909,12 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } /** - * Determine file extension by language id. This implementation retrieves first extension - * from the list as there could be multiple extensions associated with the given language. - * This value is used to replace macro ${EXT}. + * Determine file extension by language id. This implementation retrieves first extension from the list as + * there could be multiple extensions associated with the given language. This value is used to replace + * macro ${EXT}. * - * @param languageId - given language ID. + * @param languageId + * - given language ID. * @return file extension associated with the language or {@code null} if not found. */ protected String getSpecFileExtension(String languageId) { @@ -864,16 +931,18 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti } if (ext == null) { - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Unable to find file extension for language " + languageId)); //$NON-NLS-1$ + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Unable to find file extension for language " + languageId)); //$NON-NLS-1$ } return ext; } /** - * Determine additional options to pass to scanner discovery command. - * These options are intended to come from the tool-chain. + * Determine additional options to pass to scanner discovery command. These options are intended to come + * from the tool-chain. * - * @param languageId - language ID. + * @param languageId + * - language ID. * @return additional options to pass to scanner discovery command. * * @since 8.3 @@ -907,7 +976,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti try { envPathHash = Long.parseLong(envPathHashStr); } catch (Exception e) { - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, "Wrong integer format [" + envPathHashStr + "]", e)); //$NON-NLS-1$ //$NON-NLS-2$ + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + "Wrong integer format [" + envPathHashStr + "]", e)); //$NON-NLS-1$ //$NON-NLS-2$ } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java index bcc6e87e59b..22c12ae6199 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractLanguageSettingsOutputScanner.java @@ -42,12 +42,14 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; @@ -61,19 +63,22 @@ import org.w3c.dom.Element; /** * Abstract class for language settings providers capable to parse build output. *

- * EXPERIMENTAL. This class interface is not stable yet as - * it is not currently (CDT 8.1, Juno) clear how it may need to be used in future. - * There is no guarantee that this API will work or that it will remain the same. - * Please do not use this API without consulting with the CDT team. + * EXPERIMENTAL. This class interface is not stable yet as it is not currently (CDT + * 8.1, Juno) clear how it may need to be used in future. There is no guarantee that this API will + * work or that it will remain the same. Please do not use this API without consulting with the CDT + * team. *

+ * * @noextend This class is not intended to be subclassed by clients. * * @since 8.1 */ -public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSettingsSerializableProvider implements ICBuildOutputParser { +public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSettingsSerializableProvider + implements ICBuildOutputParser { protected static final String ATTR_KEEP_RELATIVE_PATHS = "keep-relative-paths"; //$NON-NLS-1$ // evaluates to "/${ProjName)/" - private static final String PROJ_NAME_PREFIX = '/' + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/'; + private static final String PROJ_NAME_PREFIX = '/' + + CdtVariableResolver.createVariableReference(CdtVariableResolver.VAR_PROJ_NAME) + '/'; protected ICConfigurationDescription currentCfgDescription = null; protected IWorkingDirectoryTracker cwdTracker = null; @@ -89,26 +94,32 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett private static final EFSExtensionProvider efsProviderDefault = new EFSExtensionProvider() { final EFSExtensionManager efsManager = EFSExtensionManager.getDefault(); + @Override public String getPathFromURI(URI locationURI) { return efsManager.getPathFromURI(locationURI); } + @Override public URI getLinkedURI(URI locationURI) { return efsManager.getLinkedURI(locationURI); } + @Override public URI createNewURIFromPath(URI locationOnSameFilesystem, String path) { return efsManager.createNewURIFromPath(locationOnSameFilesystem, path); } + @Override public String getMappedPath(URI locationURI) { return efsManager.getMappedPath(locationURI); } + @Override public boolean isVirtual(URI locationURI) { return efsManager.isVirtual(locationURI); } + @Override public URI append(URI baseURI, String extension) { return efsManager.append(baseURI, extension); @@ -116,9 +127,9 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett }; /** - * Abstract class defining common functionality for option parsers. - * The purpose of this parser is to parse a portion of string representing - * a single option and create a language settings entry out of it. + * Abstract class defining common functionality for option parsers. The purpose of this parser + * is to parse a portion of string representing a single option and create a language settings + * entry out of it. * * See {@link GCCBuildCommandParser} for an example how to define the parsers. */ @@ -136,13 +147,19 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Constructor. * - * @param kind - kind of language settings entries being parsed by the parser. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param valueExpression - capturing group expression defining value of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * @param kind + * - kind of language settings entries being parsed by the parser. + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param valueExpression + * - capturing group expression defining value of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ - public AbstractOptionParser(int kind, String pattern, String nameExpression, String valueExpression, int extraFlag) { + public AbstractOptionParser(int kind, String pattern, String nameExpression, String valueExpression, + int extraFlag) { this.kind = kind; this.patternStr = pattern; this.nameExpression = nameExpression; @@ -153,11 +170,16 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Create language settings entry of appropriate kind and considering extra-flag passed in constructor. + * Create language settings entry of appropriate kind and considering extra-flag passed in + * constructor. * - * @param name - name of language settings entry. - * @param value - value of language settings entry. - * @param flag - flag to set. Note that the flag will be amended with the extra-flag defined in constructor. + * @param name + * - name of language settings entry. + * @param value + * - value of language settings entry. + * @param flag + * - flag to set. Note that the flag will be amended with the extra-flag defined + * in constructor. * @return new language settings entry. */ public ICLanguageSettingEntry createEntry(String name, String value, int flag) { @@ -192,12 +214,13 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Test for a match and parse a portion of input string representing a single option - * to retrieve name and value. + * Test for a match and parse a portion of input string representing a single option to + * retrieve name and value. * - * @param optionString - an option to test and parse, possibly with an argument. - * @return {@code true} if the option is a match to parser's regular expression - * or {@code false} otherwise. + * @param optionString + * - an option to test and parse, possibly with an argument. + * @return {@code true} if the option is a match to parser's regular expression or + * {@code false} otherwise. */ public boolean parseOption(String optionString) { // get rid of extra text at the end (for example file name could be confused for an argument) @@ -221,6 +244,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett public IncludePathOptionParser(String pattern, String nameExpression) { super(ICLanguageSettingEntry.INCLUDE_PATH, pattern, nameExpression, nameExpression, 0); } + public IncludePathOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.INCLUDE_PATH, pattern, nameExpression, nameExpression, extraFlag); } @@ -232,17 +256,25 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected static class IncludeFileOptionParser extends AbstractOptionParser { /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. */ public IncludeFileOptionParser(String pattern, String nameExpression) { super(ICLanguageSettingEntry.INCLUDE_FILE, pattern, nameExpression, nameExpression, 0); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ public IncludeFileOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.INCLUDE_FILE, pattern, nameExpression, nameExpression, extraFlag); @@ -255,28 +287,44 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected static class MacroOptionParser extends AbstractOptionParser { /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param valueExpression - capturing group expression defining value of an entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param valueExpression + * - capturing group expression defining value of an entry. */ public MacroOptionParser(String pattern, String nameExpression, String valueExpression) { super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, valueExpression, 0); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param valueExpression - capturing group expression defining value of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param valueExpression + * - capturing group expression defining value of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ - public MacroOptionParser(String pattern, String nameExpression, String valueExpression, int extraFlag) { + public MacroOptionParser(String pattern, String nameExpression, String valueExpression, + int extraFlag) { super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, valueExpression, extraFlag); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ public MacroOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.MACRO, pattern, nameExpression, null, extraFlag); @@ -289,17 +337,25 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected static class MacroFileOptionParser extends AbstractOptionParser { /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. */ public MacroFileOptionParser(String pattern, String nameExpression) { super(ICLanguageSettingEntry.MACRO_FILE, pattern, nameExpression, nameExpression, 0); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ public MacroFileOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.MACRO_FILE, pattern, nameExpression, nameExpression, extraFlag); @@ -312,17 +368,25 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected static class LibraryPathOptionParser extends AbstractOptionParser { /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. */ public LibraryPathOptionParser(String pattern, String nameExpression) { super(ICLanguageSettingEntry.LIBRARY_PATH, pattern, nameExpression, nameExpression, 0); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ public LibraryPathOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.LIBRARY_PATH, pattern, nameExpression, nameExpression, extraFlag); @@ -335,17 +399,25 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett protected static class LibraryFileOptionParser extends AbstractOptionParser { /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. */ public LibraryFileOptionParser(String pattern, String nameExpression) { super(ICLanguageSettingEntry.LIBRARY_FILE, pattern, nameExpression, nameExpression, 0); } + /** * Constructor. - * @param pattern - regular expression pattern being parsed by the parser. - * @param nameExpression - capturing group expression defining name of an entry. - * @param extraFlag - extra-flag to add while creating language settings entry. + * + * @param pattern + * - regular expression pattern being parsed by the parser. + * @param nameExpression + * - capturing group expression defining name of an entry. + * @param extraFlag + * - extra-flag to add while creating language settings entry. */ public LibraryFileOptionParser(String pattern, String nameExpression, int extraFlag) { super(ICLanguageSettingEntry.LIBRARY_FILE, pattern, nameExpression, nameExpression, extraFlag); @@ -353,60 +425,63 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Parse the line returning the resource name as appears in the output. - * This is the resource where {@link ICLanguageSettingEntry} list is being added. + * Parse the line returning the resource name as appears in the output. This is the resource + * where {@link ICLanguageSettingEntry} list is being added. * - * @param line - one input line from the output stripped from end of line characters. - * @return the resource name as appears in the output or {@code null}. - * Note that {@code null} can have different semantics and can mean "no resource found" - * or "applicable to any resource". By default "no resource found" is used in this - * abstract class but extenders can handle otherwise. + * @param line + * - one input line from the output stripped from end of line characters. + * @return the resource name as appears in the output or {@code null}. Note that {@code null} + * can have different semantics and can mean "no resource found" or "applicable to any + * resource". By default "no resource found" is used in this abstract class but + * extenders can handle otherwise. */ protected abstract String parseResourceName(String line); /** - * Parse the line returning the list of substrings to be treated each as input to - * the option parsers. It is assumed that each substring presents one - * {@link ICLanguageSettingEntry} (for example compiler options {@code -I/path} or - * {@code -DMACRO=1}). + * Parse the line returning the list of substrings to be treated each as input to the option + * parsers. It is assumed that each substring presents one {@link ICLanguageSettingEntry} (for + * example compiler options {@code -I/path} or {@code -DMACRO=1}). * - * @param line - one input line from the output stripped from end of line characters. + * @param line + * - one input line from the output stripped from end of line characters. * @return list of substrings representing language settings entries. */ protected abstract List parseOptions(String line); /** * @return array of option parsers defining how to parse a string to - * {@link ICLanguageSettingEntry}. - * See {@link AbstractOptionParser} and its specific extenders. + * {@link ICLanguageSettingEntry}. See {@link AbstractOptionParser} and its specific + * extenders. */ protected abstract AbstractOptionParser[] getOptionParsers(); /** - * @return {@code true} when the provider tries to resolve relative or remote paths - * to the existing paths in the workspace or local file-system using certain heuristics. + * @return {@code true} when the provider tries to resolve relative or remote paths to the + * existing paths in the workspace or local file-system using certain heuristics. */ public boolean isResolvingPaths() { return isResolvingPaths; } /** - * Enable or disable resolving relative or remote paths to the existing paths - * in the workspace or local file-system. + * Enable or disable resolving relative or remote paths to the existing paths in the workspace + * or local file-system. * - * @param resolvePaths - set {@code true} to enable or {@code false} to disable - * resolving paths. When this parameter is set to {@code false} the paths will - * be kept as they appear in the build output. + * @param resolvePaths + * - set {@code true} to enable or {@code false} to disable resolving paths. When + * this parameter is set to {@code false} the paths will be kept as they appear in + * the build output. */ public void setResolvingPaths(boolean resolvePaths) { this.isResolvingPaths = resolvePaths; } - @Override - public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) throws CoreException { + public void startup(ICConfigurationDescription cfgDescription, IWorkingDirectoryTracker cwdTracker) + throws CoreException { this.currentCfgDescription = cfgDescription; - this.currentProject = cfgDescription != null ? cfgDescription.getProjectDescription().getProject() : null; + this.currentProject = cfgDescription != null ? cfgDescription.getProjectDescription().getProject() + : null; this.cwdTracker = cwdTracker; this.efsProvider = getEFSProvider(); } @@ -432,18 +507,18 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * URI of directory where the build is happening. This URI could point to a remote file-system - * for remote builds. Most often it is the same file-system as for currentResource but - * it can be different file-system (and different URI schema). + * URI of directory where the build is happening. This URI could point to a remote + * file-system for remote builds. Most often it is the same file-system as for + * currentResource but it can be different file-system (and different URI schema). */ URI buildDirURI = null; /** - * Where source tree starts if mapped. This kind of mapping is useful for example in cases when - * the absolute path to the source file on the remote system is simulated inside a project in the - * workspace. - * This URI is rooted on the same file-system where currentResource resides. In general this file-system - * (or even URI schema) does not have to match that of buildDirURI. + * Where source tree starts if mapped. This kind of mapping is useful for example in cases + * when the absolute path to the source file on the remote system is simulated inside a + * project in the workspace. This URI is rooted on the same file-system where + * currentResource resides. In general this file-system (or even URI schema) does not have + * to match that of buildDirURI. */ URI mappedRootURI = null; @@ -462,7 +537,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett try { if (optionParser.parseOption(option)) { ICLanguageSettingEntry entry = null; - if (isResolvingPaths && (optionParser.isForFile() || optionParser.isForFolder())) { + if (isResolvingPaths + && (optionParser.isForFile() || optionParser.isForFolder())) { URI baseURI = mappedRootURI; if (buildDirURI != null && !new Path(optionParser.parsedName).isAbsolute()) { if (mappedRootURI != null) { @@ -471,9 +547,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett baseURI = buildDirURI; } } - entry = createResolvedPathEntry(optionParser, optionParser.parsedName, 0, baseURI); + entry = createResolvedPathEntry(optionParser, optionParser.parsedName, 0, + baseURI); } else { - entry = optionParser.createEntry(optionParser.parsedName, optionParser.parsedValue, 0); + entry = optionParser.createEntry(optionParser.parsedName, + optionParser.parsedValue, 0); } if (entry != null && !entries.contains(entry)) { @@ -483,8 +561,10 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } } catch (Throwable e) { @SuppressWarnings("nls") - String msg = "Exception trying to parse option [" + option + "], class " + getClass().getSimpleName(); - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e)); + String msg = "Exception trying to parse option [" + option + "], class " + + getClass().getSimpleName(); + ManagedBuilderCorePlugin + .log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e)); } } } @@ -498,13 +578,14 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * In case when absolute path is mapped to the source tree in a project - * this function will try to figure mapping and return "mapped root", - * i.e URI where the root path would be mapped. The mapped root will be - * used to prepend to other "absolute" paths where appropriate. + * In case when absolute path is mapped to the source tree in a project this function will try + * to figure mapping and return "mapped root", i.e URI where the root path would be mapped. The + * mapped root will be used to prepend to other "absolute" paths where appropriate. * - * @param resource - a resource referred by parsed path - * @param parsedResourceName - path as appears in the output + * @param resource + * - a resource referred by parsed path + * @param parsedResourceName + * - path as appears in the output * @return mapped path as URI */ protected URI getMappedRootURI(IResource resource, String parsedResourceName) { @@ -542,7 +623,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett * Determine current build directory considering currentResource (resource being compiled), * parsedResourceName and mappedRootURI. * - * @param mappedRootURI - root of the source tree when mapped to remote file-system. + * @param mappedRootURI + * - root of the source tree when mapped to remote file-system. * @return {@link URI} of current build directory */ protected URI getBuildDirURI(URI mappedRootURI) { @@ -550,7 +632,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett // try to deduce build directory from full path of currentResource and partial path of parsedResourceName URI cwdURI = null; - if (currentResource != null && parsedResourceName != null && !new Path(parsedResourceName).isAbsolute()) { + if (currentResource != null && parsedResourceName != null + && !new Path(parsedResourceName).isAbsolute()) { cwdURI = findBaseLocationURI(currentResource.getLocationURI(), parsedResourceName); } String cwdPath = cwdURI != null ? efsProvider.getPathFromURI(cwdURI) : null; @@ -603,13 +686,15 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Sets language settings entries for current configuration description, current resource - * and current language ID. + * Sets language settings entries for current configuration description, current resource and + * current language ID. * - * @param entries - language settings entries to set. + * @param entries + * - language settings entries to set. */ protected void setSettingEntries(List entries) { - setSettingEntries(currentCfgDescription, currentResource, currentLanguageId, entries); + IBuildConfiguration currentConfig = Adapters.adapt(currentCfgDescription, IBuildConfiguration.class); + setSettingEntries(currentConfig, currentResource, currentLanguageId, entries); } /** @@ -638,7 +723,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Determine if the language is in scope of the provider. * - * @param languageId - language ID. + * @param languageId + * - language ID. * @return {@code true} if the language is in scope, {@code false } otherwise. */ protected boolean isLanguageInScope(String languageId) { @@ -647,10 +733,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Find file resource in the workspace for a given URI with a preference for the resource - * to reside in the given project. + * Find file resource in the workspace for a given URI with a preference for the resource to + * reside in the given project. */ - private static IResource findFileForLocationURI(URI uri, IProject preferredProject, boolean checkExistence) { + private static IResource findFileForLocationURI(URI uri, IProject preferredProject, + boolean checkExistence) { IResource sourceFile = null; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource[] resources = root.findFilesForLocationURI(uri); @@ -669,10 +756,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Return a resource in workspace corresponding the given folder {@link URI} preferable residing in - * the provided project. + * Return a resource in workspace corresponding the given folder {@link URI} preferable residing + * in the provided project. */ - private static IResource findContainerForLocationURI(URI uri, IProject preferredProject, boolean checkExistence) { + private static IResource findContainerForLocationURI(URI uri, IProject preferredProject, + boolean checkExistence) { IResource resource = null; IResource[] resources = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(uri); for (IResource rc : resources) { @@ -707,7 +795,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett // try to find absolute path in the workspace if (sourceFile == null && new Path(parsedResourceName).isAbsolute()) { URI uri = org.eclipse.core.filesystem.URIUtil.toURI(parsedResourceName); - sourceFile = findFileForLocationURI(uri, currentProject, /*checkExistence*/ true); + sourceFile = findFileForLocationURI(uri, currentProject, /* checkExistence */ true); } // try last known current working directory from build output @@ -715,7 +803,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett URI cwdURI = cwdTracker.getWorkingDirectoryURI(); if (cwdURI != null) { URI uri = efsProvider.append(cwdURI, parsedResourceName); - sourceFile = findFileForLocationURI(uri, currentProject, /*checkExistence*/ true); + sourceFile = findFileForLocationURI(uri, currentProject, /* checkExistence */ true); } } @@ -730,13 +818,14 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } catch (Exception e) { @SuppressWarnings("nls") String msg = "Exception trying to resolve value [" + strBuilderCWD + "]"; - ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e)); + ManagedBuilderCorePlugin + .log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, msg, e)); } builderCWD = new Path(strBuilderCWD); IPath path = builderCWD.append(parsedResourceName); URI uri = org.eclipse.core.filesystem.URIUtil.toURI(path); - sourceFile = findFileForLocationURI(uri, currentProject, /*checkExistence*/ true); + sourceFile = findFileForLocationURI(uri, currentProject, /* checkExistence */ true); } } @@ -749,9 +838,9 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Find base location of the file, i.e. location of the directory which - * results from removing trailing relativeFileName from fileURI or - * {@code null} if fileURI doesn't represent relativeFileName. + * Find base location of the file, i.e. location of the directory which results from removing + * trailing relativeFileName from fileURI or {@code null} if fileURI doesn't represent + * relativeFileName. */ private static URI findBaseLocationURI(URI fileURI, String relativeFileName) { URI cwdURI = null; @@ -780,8 +869,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } try { - cwdURI = new URI(fileURI.getScheme(), fileURI.getUserInfo(), fileURI.getHost(), - fileURI.getPort(), path + '/', fileURI.getQuery(), fileURI.getFragment()); + cwdURI = new URI(fileURI.getScheme(), fileURI.getUserInfo(), fileURI.getHost(), fileURI.getPort(), + path + '/', fileURI.getQuery(), fileURI.getFragment()); } catch (URISyntaxException e) { // It should be valid URI here or something is really wrong ManagedBuilderCorePlugin.log(e); @@ -791,10 +880,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * The manipulations here are done to resolve problems such as "../" navigation for symbolic links where - * "link/.." cannot be collapsed as it must follow the real file-system path. {@link java.io.File#getCanonicalPath()} - * deals with that correctly but {@link Path} or {@link URI} try to normalize the path which would be incorrect here. - * Another issue being resolved here is fixing drive letters in URI syntax. + * The manipulations here are done to resolve problems such as "../" navigation for symbolic + * links where "link/.." cannot be collapsed as it must follow the real file-system path. + * {@link java.io.File#getCanonicalPath()} deals with that correctly but {@link Path} or + * {@link URI} try to normalize the path which would be incorrect here. Another issue being + * resolved here is fixing drive letters in URI syntax. */ private static URI resolvePathFromBaseLocation(String pathStr0, IPath baseLocation) { String pathStr = pathStr0; @@ -851,8 +941,10 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Determine URI on the local file-system considering possible mapping. * - * @param pathStr - path to the resource, can be absolute or relative - * @param baseURI - base {@link URI} where path to the resource is rooted + * @param pathStr + * - path to the resource, can be absolute or relative + * @param baseURI + * - base {@link URI} where path to the resource is rooted * @return {@link URI} of the resource */ private URI determineMappedURI(String pathStr, URI baseURI) { @@ -869,7 +961,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett uri = resolvePathFromBaseLocation(pathStr, baseLocation); } else { // location on a remote file-system - IPath path = new Path(pathStr); // use canonicalized path here, in particular replace all '\' with '/' for Windows paths + IPath path = new Path(pathStr); // use canonicalized path here, in particular replace all '\' with + // '/' for Windows paths URI remoteUri = efsProvider.append(baseURI, path.toString()); if (remoteUri != null) { String localPath = efsProvider.getMappedPath(remoteUri); @@ -915,7 +1008,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett private IResource findBestFitInWorkspace(String parsedName) { Set referencedProjectsNames = new LinkedHashSet(); if (currentCfgDescription != null) { - Map refs = currentCfgDescription.getReferenceInfo(); + Map refs = currentCfgDescription.getReferenceInfo(); referencedProjectsNames.addAll(refs.keySet()); } @@ -964,7 +1057,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett if (projects.length > 0) { IResource rc = null; for (IProject prj : projects) { - if (!prj.equals(currentProject) && !referencedProjectsNames.contains(prj.getName()) && prj.isOpen()) { + if (!prj.equals(currentProject) && !referencedProjectsNames.contains(prj.getName()) + && prj.isOpen()) { List result = findPathInFolder(path, prj); int size = result.size(); if (size == 1 && rc == null) { @@ -986,7 +1080,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Get location on the local file-system considering possible mapping by EFS provider. See {@link EFSExtensionManager}. + * Get location on the local file-system considering possible mapping by EFS provider. See + * {@link EFSExtensionManager}. */ private IPath getFilesystemLocation(URI uri) { if (uri == null) @@ -1013,14 +1108,17 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Resolve and create language settings path entry. */ - private ICLanguageSettingEntry createResolvedPathEntry(AbstractOptionParser optionParser, String parsedPath, int flag, URI baseURI) { + private ICLanguageSettingEntry createResolvedPathEntry(AbstractOptionParser optionParser, + String parsedPath, int flag, URI baseURI) { URI uri = determineMappedURI(parsedPath, baseURI); boolean isRelative = !new Path(parsedPath).isAbsolute(); // is mapped something that is not a project root - boolean isRemapped = baseURI != null && currentProject != null && !baseURI.equals(currentProject.getLocationURI()); + boolean isRemapped = baseURI != null && currentProject != null + && !baseURI.equals(currentProject.getLocationURI()); boolean presentAsRelative = isRelative || isRemapped; - ICLanguageSettingEntry entry = resolvePathEntryInWorkspace(optionParser, uri, flag, presentAsRelative); + ICLanguageSettingEntry entry = resolvePathEntryInWorkspace(optionParser, uri, flag, + presentAsRelative); if (entry != null) { return entry; } @@ -1044,10 +1142,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Create a language settings entry for a given resource. - * This will represent relative path using CDT variable ${ProjName}. + * Create a language settings entry for a given resource. This will represent relative path + * using CDT variable ${ProjName}. */ - private ICLanguageSettingEntry createPathEntry(AbstractOptionParser optionParser, IResource rc, boolean isRelative, int flag) { + private ICLanguageSettingEntry createPathEntry(AbstractOptionParser optionParser, IResource rc, + boolean isRelative, int flag) { String path; if (isRelative && rc.getProject().equals(currentProject)) { path = PROJ_NAME_PREFIX + rc.getFullPath().removeFirstSegments(1); @@ -1062,13 +1161,14 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Find an existing resource in the workspace and create a language settings entry for it. */ - private ICLanguageSettingEntry resolvePathEntryInWorkspace(AbstractOptionParser optionParser, URI uri, int flag, boolean isRelative) { + private ICLanguageSettingEntry resolvePathEntryInWorkspace(AbstractOptionParser optionParser, URI uri, + int flag, boolean isRelative) { if (uri != null && uri.isAbsolute()) { IResource rc = null; if (optionParser.isForFolder()) { - rc = findContainerForLocationURI(uri, currentProject, /*checkExistence*/ true); + rc = findContainerForLocationURI(uri, currentProject, /* checkExistence */ true); } else if (optionParser.isForFile()) { - rc = findFileForLocationURI(uri, currentProject, /*checkExistence*/ true); + rc = findFileForLocationURI(uri, currentProject, /* checkExistence */ true); } if (rc != null) { return createPathEntry(optionParser, rc, isRelative, flag); @@ -1080,7 +1180,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett /** * Find a resource on the file-system and create a language settings entry for it. */ - private ICLanguageSettingEntry resolvePathEntryInFilesystem(AbstractOptionParser optionParser, URI uri, int flag) { + private ICLanguageSettingEntry resolvePathEntryInFilesystem(AbstractOptionParser optionParser, URI uri, + int flag) { IPath location = getFilesystemLocation(uri); if (location != null) { String loc = location.toString(); @@ -1092,9 +1193,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Find a best fit for the resource in the workspace and create a language settings entry for it. + * Find a best fit for the resource in the workspace and create a language settings entry for + * it. */ - private ICLanguageSettingEntry resolvePathEntryInWorkspaceAsBestFit(AbstractOptionParser optionParser, String parsedPath, int flag, boolean isRelative) { + private ICLanguageSettingEntry resolvePathEntryInWorkspaceAsBestFit(AbstractOptionParser optionParser, + String parsedPath, int flag, boolean isRelative) { IResource rc = findBestFitInWorkspace(parsedPath); if (rc != null) { return createPathEntry(optionParser, rc, isRelative, flag); @@ -1103,15 +1206,17 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Try to map a resource in the workspace even if it does not exist and create a language settings entry for it. + * Try to map a resource in the workspace even if it does not exist and create a language + * settings entry for it. */ - private ICLanguageSettingEntry resolvePathEntryInWorkspaceToNonexistingResource(AbstractOptionParser optionParser, URI uri, int flag, boolean isRelative) { + private ICLanguageSettingEntry resolvePathEntryInWorkspaceToNonexistingResource( + AbstractOptionParser optionParser, URI uri, int flag, boolean isRelative) { if (uri != null && uri.isAbsolute()) { IResource rc = null; if (optionParser.isForFolder()) { - rc = findContainerForLocationURI(uri, currentProject, /*checkExistence*/ false); + rc = findContainerForLocationURI(uri, currentProject, /* checkExistence */ false); } else if (optionParser.isForFile()) { - rc = findFileForLocationURI(uri, currentProject, /*checkExistence*/ false); + rc = findFileForLocationURI(uri, currentProject, /* checkExistence */ false); } if (rc != null) { return createPathEntry(optionParser, rc, isRelative, flag); @@ -1121,9 +1226,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Try to map a resource on the file-system even if it does not exist and create a language settings entry for it. + * Try to map a resource on the file-system even if it does not exist and create a language + * settings entry for it. */ - private ICLanguageSettingEntry resolvePathEntryInFilesystemToNonExistingResource(AbstractOptionParser optionParser, URI uri, int flag) { + private ICLanguageSettingEntry resolvePathEntryInFilesystemToNonExistingResource( + AbstractOptionParser optionParser, URI uri, int flag) { IPath location = getFilesystemLocation(uri); if (location != null) { return optionParser.createEntry(location.toString(), location.toString(), flag); @@ -1132,10 +1239,11 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Count how many groups are present in regular expression. - * The implementation is simplistic but should be sufficient for the cause. + * Count how many groups are present in regular expression. The implementation is simplistic but + * should be sufficient for the cause. * - * @param str - regular expression to count the groups. + * @param str + * - regular expression to count the groups. * @return number of the groups (groups are enclosed in round brackets) present. */ protected static int countGroups(String str) { @@ -1164,8 +1272,8 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett } /** - * Construct regular expression to find any file extension for C or C++. - * Returns expression shaped in form of "((cpp)|(c++)|(c))". + * Construct regular expression to find any file extension for C or C++. Returns expression + * shaped in form of "((cpp)|(c++)|(c))". * * @return regular expression for searching C/C++ file extensions. */ @@ -1184,14 +1292,14 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett return pattern; } - + /** * This {@link EFSExtensionProvider} is capable to translate EFS paths to and from local * file-system. Added mostly for Cygwin translations. * - * This usage of {@link EFSExtensionProvider} is somewhat a misnomer. This provider is not - * an "extension" provider but rather a wrapper on {@link EFSExtensionManager} which in fact - * will use genuine {@link EFSExtensionProvider}s defined as extensions. + * This usage of {@link EFSExtensionProvider} is somewhat a misnomer. This provider is not an + * "extension" provider but rather a wrapper on {@link EFSExtensionManager} which in fact will + * use genuine {@link EFSExtensionProvider}s defined as extensions. * * @since 8.2 */ @@ -1202,7 +1310,7 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett @Override public Element serializeAttributes(Element parentElement) { Element elementProvider = super.serializeAttributes(parentElement); - elementProvider.setAttribute(ATTR_KEEP_RELATIVE_PATHS, Boolean.toString( ! isResolvingPaths )); + elementProvider.setAttribute(ATTR_KEEP_RELATIVE_PATHS, Boolean.toString(!isResolvingPaths)); return elementProvider; } @@ -1210,9 +1318,10 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett public void loadAttributes(Element providerNode) { super.loadAttributes(providerNode); - String expandRelativePathsValue = XmlUtil.determineAttributeValue(providerNode, ATTR_KEEP_RELATIVE_PATHS); - if (expandRelativePathsValue!=null) - isResolvingPaths = ! Boolean.parseBoolean(expandRelativePathsValue); + String expandRelativePathsValue = XmlUtil.determineAttributeValue(providerNode, + ATTR_KEEP_RELATIVE_PATHS); + if (expandRelativePathsValue != null) + isResolvingPaths = !Boolean.parseBoolean(expandRelativePathsValue); } @Override diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs index b8de6b0c2da..89b984d869b 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -59,288 +59,4 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 -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.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 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -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_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -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_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=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 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -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_package=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 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -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_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 -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -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.format_block_comments=true -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_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -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_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -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_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_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -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_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_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -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_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -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.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs index 8ddf01004c1..6a961f809e1 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ eclipse.preferences.version=1 -formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile formatter_settings_version=12 internal.default.compliance=user diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java index d11ccfbeb9e..b9992523213 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsListenersTests.java @@ -15,8 +15,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CMacroEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; @@ -26,12 +24,16 @@ import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.jobs.Job; +import junit.framework.TestSuite; + /** * Test cases to cover {@link ILanguageSettingsChangeListener} capabilities. */ @@ -45,7 +47,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase { private static final String PROVIDER_CUSTOM_GLOBAL = "test.provider.custom.global.id"; private static final String PROVIDER_CUSTOM_GLOBAL_NAME = "test.provider.custom.global.name"; - private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value",0); + private static final CMacroEntry SAMPLE_LSE = new CMacroEntry("MACRO", "value", 0); /** * Mock {@link ILanguageSettingsChangeListener}. @@ -53,27 +55,34 @@ public class LanguageSettingsListenersTests extends BaseTestCase { private class MockLanguageSettingsChangeListener implements ILanguageSettingsChangeListener { private int count = 0; private ILanguageSettingsChangeEvent lastEvent = null; + @Override public void handleEvent(ILanguageSettingsChangeEvent event) { count++; lastEvent = event; } + public int getCount() { return count; } + public void resetCount() { count = 0; lastEvent = null; } + public ILanguageSettingsChangeEvent getLastEvent() { return lastEvent; } } + private MockLanguageSettingsChangeListener mockLseListener = new MockLanguageSettingsChangeListener(); /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsListenersTests(String name) { super(name); @@ -90,8 +99,10 @@ public class LanguageSettingsListenersTests extends BaseTestCase { LanguageSettingsManager.unregisterLanguageSettingsChangeListener(mockLseListener); LanguageSettingsManager.setWorkspaceProviders(null); try { - Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT, null); - Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null); + Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT, + null); + Job.getJobManager() + .join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null); } catch (Exception e) { // ignore } @@ -108,7 +119,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -119,7 +131,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { */ public void testListenerRegisterer_CheckExtensionProvider() throws Exception { // check if extension provider exists - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider); assertNotNull(rawProvider); // global listeners providers get registered only lazily @@ -136,7 +149,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -148,7 +162,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -179,14 +194,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { public void testListenerRegisterer_TwoOwnedByCfgs() throws Exception { // create project IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { - "org.eclipse.cdt.core.tests.configuration.id.1", - "org.eclipse.cdt.core.tests.configuration.id.2", - }); + "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", }); ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true); { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(2, cfgDescriptions.length); @@ -201,7 +215,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { @@ -210,7 +225,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } @@ -246,7 +262,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -254,11 +271,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -289,16 +308,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase { public void testListenerRegisterer_TwoGlobal() throws Exception { // create project IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { - "org.eclipse.cdt.core.tests.configuration.id.1", - "org.eclipse.cdt.core.tests.configuration.id.2", - }); + "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", }); ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true); { // retrieve global provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(2, cfgDescriptions.length); @@ -312,7 +331,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { @@ -320,7 +340,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } // write to project description @@ -350,16 +371,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase { public void testListenerRegisterer_TwoGlobalMinusOne() throws Exception { // create project IProject project = ResourceHelper.createCDTProject(this.getName(), null, new String[] { - "org.eclipse.cdt.core.tests.configuration.id.1", - "org.eclipse.cdt.core.tests.configuration.id.2", - }); + "org.eclipse.cdt.core.tests.configuration.id.1", "org.eclipse.cdt.core.tests.configuration.id.2", }); ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true); { // retrieve workspace provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(2, cfgDescriptions.length); @@ -373,7 +394,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } { @@ -381,7 +403,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription2).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription2) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); } // write to project description @@ -390,9 +413,11 @@ public class LanguageSettingsListenersTests extends BaseTestCase { } { // retrieve workspace provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(2, cfgDescriptions.length); @@ -405,7 +430,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // remove global provider from configuration 1 List providers = new ArrayList(); ((ILanguageSettingsProvidersKeeper) cfgDescription1).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); } // write to project description @@ -428,7 +454,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project_1, true); { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_1, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project_1, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -436,11 +463,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -453,7 +482,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project_2, true); { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project_2, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project_2, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -461,11 +491,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // add global provider - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_REGISTERER_PROVIDER_ID); List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -491,7 +523,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { */ public void testListenerRegisterer_GlobalProviderNotInUse() throws Exception { // create project - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); // the global custom provider has not been added yet ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider); @@ -501,15 +534,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List workspaceProvidersOriginal = LanguageSettingsManager.getWorkspaceProviders(); { // add global provider which is not engaged - ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, PROVIDER_CUSTOM_GLOBAL_NAME); - List providers = new ArrayList(workspaceProvidersOriginal); + ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, + PROVIDER_CUSTOM_GLOBAL_NAME); + List providers = new ArrayList( + workspaceProvidersOriginal); providers.add(provider); LanguageSettingsManager.setWorkspaceProviders(providers); assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL)); } { // remove global provider and restore original list - List providers = new ArrayList(workspaceProvidersOriginal); + List providers = new ArrayList( + workspaceProvidersOriginal); LanguageSettingsManager.setWorkspaceProviders(providers); assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL)); } @@ -520,7 +556,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { */ public void testListenerRegisterer_GlobalProviderAddRemoveOutsideTheProject() throws Exception { // create project - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(PROVIDER_CUSTOM_GLOBAL); // the global custom provider has not been added yet ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(workspaceProvider); @@ -533,7 +570,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ScannerDiscoveryLegacySupport.setLanguageSettingsProvidersFunctionalityEnabled(project, true); { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -544,7 +582,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(workspaceProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -555,7 +594,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { { // add global provider - ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, PROVIDER_CUSTOM_GLOBAL_NAME); + ILanguageSettingsProvider provider = new MockListenerRegisterer(PROVIDER_CUSTOM_GLOBAL, + PROVIDER_CUSTOM_GLOBAL_NAME); List providers = new ArrayList(); providers.add(provider); LanguageSettingsManager.setWorkspaceProviders(providers); @@ -563,14 +603,16 @@ public class LanguageSettingsListenersTests extends BaseTestCase { } { // remove global provider - List providers = new ArrayList(workspaceProvidersOriginal); + List providers = new ArrayList( + workspaceProvidersOriginal); LanguageSettingsManager.setWorkspaceProviders(providers); assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL)); } { // wait until serializing has finished - Job.getJobManager().join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null); + Job.getJobManager() + .join(LanguageSettingsProvidersSerializer.JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE, null); // close project project.close(null); assertEquals(0, MockListenerRegisterer.getCount(PROVIDER_CUSTOM_GLOBAL)); @@ -578,7 +620,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { } /** - * Test events triggered when empty provider added and the resulting list of entries does not change. + * Test events triggered when empty provider added and the resulting list of entries does not + * change. */ public void testNotification_cfgProvider_AddEmptyProvider() throws Exception { // create project @@ -587,7 +630,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // First clear default providers { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -597,7 +641,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // clear providers List providers = new ArrayList(); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -612,7 +657,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Add empty provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -620,11 +666,13 @@ public class LanguageSettingsListenersTests extends BaseTestCase { assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // create a provider and add to cfgDescription - ILanguageSettingsProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + ILanguageSettingsProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -646,7 +694,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // First clear default providers { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -656,7 +705,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // clear providers List providers = new ArrayList(); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -671,23 +721,28 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Add non-empty provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; String cfgDescriptionId = cfgDescription.getId(); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // create a provider and add entries - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, project, null, entries); + mockProvider.setSettingEntries(config, project, null, entries); List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -715,7 +770,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add the mock provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -726,7 +782,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1)); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -741,23 +798,27 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Change the provider's entries { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String cfgDescriptionId = cfgDescription.getId(); // Add entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); - mockProvider.setSettingEntries(cfgDescription, project, null, entries); + mockProvider.setSettingEntries(config, project, null, entries); assertEquals(0, mockLseListener.getCount()); assertEquals(null, mockLseListener.getLastEvent()); @@ -785,7 +846,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add the mock provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -796,7 +858,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List providers = new ArrayList(); providers.add(new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1)); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -811,26 +874,31 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Change the provider's entries concurrently // get project descriptions - ICProjectDescription prjDescription_1 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription_1 = CProjectDescriptionManager.getInstance().getProjectDescription(project, + false); assertNotNull(prjDescription_1); - ICProjectDescription prjDescription_2 = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription_2 = CProjectDescriptionManager.getInstance().getProjectDescription(project, + false); assertNotNull(prjDescription_2); { ICConfigurationDescription[] cfgDescriptions = prjDescription_1.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String cfgDescriptionId = cfgDescription.getId(); // Add entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); - mockProvider.setSettingEntries(cfgDescription, project, null, entries); + mockProvider.setSettingEntries(config, project, null, entries); // reset count mockLseListener.resetCount(); @@ -854,15 +922,18 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); String cfgDescriptionId = cfgDescription.getId(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // Add same entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); assertTrue(providers.get(0) instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); - mockProvider.setSettingEntries(cfgDescription, project, null, entries); + mockProvider.setSettingEntries(config, project, null, entries); // reset count mockLseListener.resetCount(); @@ -888,7 +959,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // First clear default providers { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -898,7 +970,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // clear providers List providers = new ArrayList(); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -913,26 +986,31 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Add empty global provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); // clear it ((MockLanguageSettingsEditableProvider) rawProvider).clear(); - assertEquals(null, wspProvider.getSettingEntries(cfgDescription, project, null)); + assertEquals(null, wspProvider.getSettingEntries(config, project, null)); // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -954,7 +1032,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // First clear default providers { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -964,7 +1043,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // clear providers List providers = new ArrayList(); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, storedProviders.size()); // write to project description @@ -979,17 +1059,21 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Add non-empty provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); String cfgDescriptionId = cfgDescription.getId(); // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); @@ -997,13 +1081,14 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add entries List entries = new ArrayList(); entries.add(SAMPLE_LSE); - ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(cfgDescription, project, null, entries); - assertEquals(SAMPLE_LSE, wspProvider.getSettingEntries(cfgDescription, project, null).get(0)); + ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(config, project, null, entries); + assertEquals(SAMPLE_LSE, wspProvider.getSettingEntries(config, project, null).get(0)); // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1034,26 +1119,31 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Add empty global provider { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); // clear it ((MockLanguageSettingsEditableProvider) rawProvider).clear(); - assertEquals(null, wspProvider.getSettingEntries(cfgDescription, project, null)); + assertEquals(null, wspProvider.getSettingEntries(config, project, null)); // add the provider to cfgDescription List providers = new ArrayList(); providers.add(wspProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1063,7 +1153,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Change the provider's entries { // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); @@ -1072,7 +1163,7 @@ public class LanguageSettingsListenersTests extends BaseTestCase { List entries = new ArrayList(); entries.add(SAMPLE_LSE); ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(null, project, null, entries); - assertEquals(SAMPLE_LSE, wspProvider.getSettingEntries(null, project, null).get(0)); + assertEquals(SAMPLE_LSE, wspProvider.getSettingEntries((IBuildConfiguration) null, project, null).get(0)); // reset count mockLseListener.resetCount(); @@ -1083,7 +1174,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { LanguageSettingsManager.serializeLanguageSettingsWorkspace(); // get cfgDescriptionId - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1103,7 +1195,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Clear the provider's entries { // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); @@ -1119,7 +1212,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { LanguageSettingsManager.serializeLanguageSettingsWorkspace(); // get cfgDescriptionId - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1138,40 +1232,44 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // Change the provider's entries back to original state from extension point { - - ILanguageSettingsProvider extensionProviderCopy = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true); - List extEntries = extensionProviderCopy.getSettingEntries(null, null, null); - + + ILanguageSettingsProvider extensionProviderCopy = LanguageSettingsManager + .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true); + List extEntries = extensionProviderCopy + .getSettingEntries((IBuildConfiguration) null, null, null); + // retrieve a global provider - ILanguageSettingsProvider wspProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider wspProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); assertNotNull(wspProvider); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(wspProvider); assertTrue(rawProvider instanceof MockLanguageSettingsEditableProvider); // reset the provider to match extension ((MockLanguageSettingsEditableProvider) rawProvider).setSettingEntries(null, null, null, extEntries); assertTrue(LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true)); - + // reset count mockLseListener.resetCount(); assertEquals(0, mockLseListener.getCount()); assertEquals(null, mockLseListener.getLastEvent()); - + // Serialize settings LanguageSettingsManager.serializeLanguageSettingsWorkspace(); - + // get cfgDescriptionId - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; String cfgDescriptionId = cfgDescription.getId(); - + // inspect event assertEquals(1, mockLseListener.getCount()); ILanguageSettingsChangeEvent event = mockLseListener.getLastEvent(); assertNotNull(event); - + assertEquals(project.getName(), event.getProjectName()); assertEquals(1, event.getConfigurationDescriptionIds().length); assertEquals(cfgDescriptionId, event.getConfigurationDescriptionIds()[0]); @@ -1189,7 +1287,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // create a mock provider and add to cfgDescription { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1198,10 +1297,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add mock provider to cfgDescription List providers = new ArrayList(); - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1219,19 +1320,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription; { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, project, null, entries); + mockProvider.setSettingEntries(config, project, null, entries); mockProvider.serializeLanguageSettings(cfgDescription); } @@ -1260,7 +1365,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // create a mock provider and add to cfgDescription { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1269,10 +1375,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add mock provider to cfgDescription List providers = new ArrayList(); - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1290,19 +1398,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription; { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, null, null, entries); + mockProvider.setSettingEntries(config, null, null, entries); mockProvider.serializeLanguageSettings(cfgDescription); } @@ -1332,7 +1444,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // create a mock provider and add to cfgDescription { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1341,10 +1454,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add mock provider to cfgDescription List providers = new ArrayList(); - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1362,19 +1477,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription; { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, folder, null, entries); + mockProvider.setSettingEntries(config, folder, null, entries); mockProvider.serializeLanguageSettings(cfgDescription); } @@ -1404,7 +1523,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // create a mock provider and add to cfgDescription { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1413,10 +1533,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add mock provider to cfgDescription List providers = new ArrayList(); - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1434,19 +1556,23 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription; { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, file, null, entries); + mockProvider.setSettingEntries(config, file, null, entries); mockProvider.serializeLanguageSettings(cfgDescription); } @@ -1479,7 +1605,8 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // create a mock provider and add to cfgDescription { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -1488,10 +1615,12 @@ public class LanguageSettingsListenersTests extends BaseTestCase { // add mock provider to cfgDescription List providers = new ArrayList(); - MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + MockLanguageSettingsEditableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1509,21 +1638,25 @@ public class LanguageSettingsListenersTests extends BaseTestCase { ICConfigurationDescription cfgDescription; { // get project descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescription); ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); assertEquals(1, cfgDescriptions.length); cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper)cfgDescription).getLanguageSettingProviders(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); MockLanguageSettingsEditableProvider mockProvider = (MockLanguageSettingsEditableProvider) providers.get(0); List entries = new ArrayList(); entries.add(SAMPLE_LSE); - mockProvider.setSettingEntries(cfgDescription, folder, null, entries); - mockProvider.setSettingEntries(cfgDescription, file1, null, entries); - mockProvider.setSettingEntries(cfgDescription, file2, null, entries); + mockProvider.setSettingEntries(config, folder, null, entries); + mockProvider.setSettingEntries(config, file1, null, entries); + mockProvider.setSettingEntries(config, file2, null, entries); mockProvider.serializeLanguageSettings(cfgDescription); } @@ -1544,4 +1677,3 @@ public class LanguageSettingsListenersTests extends BaseTestCase { } } } - diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java index 26b828581c5..73b39c51c01 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java @@ -14,8 +14,6 @@ package org.eclipse.cdt.core.language.settings.providers; import java.util.ArrayList; import java.util.List; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.AbstractExecutableExtensionBase; import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; @@ -31,12 +29,18 @@ import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSetting import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; +import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +import junit.framework.TestSuite; /** * Test cases testing {@link LanguageSettingsManager} utility methods. @@ -62,48 +66,85 @@ public class LanguageSettingsManagerTests extends BaseTestCase { /** * Mock configuration description. */ - class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { + class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription + implements ILanguageSettingsProvidersKeeper { List providers = new ArrayList(); String[] defaultProvidersIds = null; + public MockConfigurationDescription(String id) { super(id); } + @Override public void setLanguageSettingProviders(List providers) { this.providers = new ArrayList(providers); } + @Override public List getLanguageSettingProviders() { return providers; } + @Override public void setDefaultLanguageSettingsProvidersIds(String[] ids) { defaultProvidersIds = ids; } + @Override public String[] getDefaultLanguageSettingsProvidersIds() { return defaultProvidersIds; } } + private class MockBuildConfiguration implements IBuildConfiguration { + private final MockConfigurationDescription cfgDesc; + + public MockBuildConfiguration(MockConfigurationDescription cfgDesc) { + this.cfgDesc = cfgDesc; + } + + @Override + public T getAdapter(Class adapter) { + if (adapter.isInstance(cfgDesc)) { + return (T) cfgDesc; + } + return null; + } + + @Override + public IProject getProject() { + return null; + } + + @Override + public String getName() { + return cfgDesc.getId(); + } + } + /** * Mock language sttings provider. */ private class MockProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider { private List entries; + public MockProvider(String id, String name, List entries) { super(id, name); this.entries = entries; } + @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { return entries; } } /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsManagerTests(String name) { super(name); @@ -113,6 +154,18 @@ public class LanguageSettingsManagerTests extends BaseTestCase { @Override protected void setUp() throws Exception { super.setUp(); + Platform.getAdapterManager().registerAdapters(new IAdapterFactory() { + @Override + public T getAdapter(Object adaptableObject, Class adapterType) { + MockConfigurationDescription cfgDesc = (MockConfigurationDescription) adaptableObject; + return (T) new MockBuildConfiguration(cfgDesc); + } + + @Override + public Class[] getAdapterList() { + return new Class[] { IBuildConfiguration.class }; + } + }, MockConfigurationDescription.class); } @Override @@ -131,7 +184,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -174,7 +228,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; @@ -202,6 +257,9 @@ public class LanguageSettingsManagerTests extends BaseTestCase { public void testRudeProviders() throws Exception { // mock configuration description MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); + // set impolite provider returning null by getSettingEntries() ILanguageSettingsProvider providerNull = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null); { @@ -212,25 +270,25 @@ public class LanguageSettingsManagerTests extends BaseTestCase { // use provider returning null, no exception should be recorded { - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(providerNull, cfgDescription, FILE_0, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerNull, + config, FILE_0, LANG_ID); assertNotNull(actual); assertEquals(0, actual.size()); } { - List actual = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0); + List actual = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, 0); assertNotNull(actual); assertEquals(0, actual.size()); } // set impolite provider returning null in getSettingEntries() array ILanguageSettingsProvider providerNull_2 = new MockProvider(PROVIDER_2, PROVIDER_NAME_2, - new ArrayList() { - { // init via static initializer - add(null); - } - }); + new ArrayList() { + { // init via static initializer + add(null); + } + }); { List providers = new ArrayList(); providers.add(providerNull); @@ -240,13 +298,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase { // use provider returning null as item in array { List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(providerNull_2, cfgDescription, FILE_0, LANG_ID); + .getSettingEntriesUpResourceTree(providerNull_2, config, FILE_0, LANG_ID); assertNotNull(actual); assertEquals(1, actual.size()); } { - List actual = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, 0); + List actual = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, 0); assertNotNull(actual); assertEquals(0, actual.size()); } @@ -257,7 +315,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { ILanguageSettingsProvider providerNPE = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { throw new NullPointerException("Can you handle me?"); } }; @@ -277,16 +336,20 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testProvider_Basic() throws Exception { final MockConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration modelConfig = Adapters.adapt(modelCfgDescription, IBuildConfiguration.class); + assertNotNull(modelConfig); final List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); List providers = new ArrayList(); - // define provider returning entries when configuration id matches and null otherwise - ILanguageSettingsProvider providerYes = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { + // define provider returning entries when configuration id matches and + // null otherwise + ILanguageSettingsProvider providerYes = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (cfgDescription.getId().equals(modelCfgDescription.getId())) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config.getName().equals(modelCfgDescription.getId())) { return entries; } return null; @@ -294,11 +357,13 @@ public class LanguageSettingsManagerTests extends BaseTestCase { }; providers.add(providerYes); - // define provider returning entries when configuration id does NOT match and null otherwise - ILanguageSettingsProvider providerNo = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) { + // define provider returning entries when configuration id does NOT + // match and null otherwise + ILanguageSettingsProvider providerNo = new MockProvider(PROVIDER_1, PROVIDER_NAME_1, null) { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (cfgDescription!= null && !cfgDescription.getId().equals(modelCfgDescription.getId())) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config != null && !config.getName().equals(modelCfgDescription.getId())) { return entries; } return null; @@ -310,16 +375,16 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve the entries with provider returning the given list - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(providerYes, modelCfgDescription, FILE_0, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerYes, + modelConfig, FILE_0, LANG_ID); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } { // retrieve the entries with provider returning empty list - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(providerNo, modelCfgDescription, FILE_0, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(providerNo, + modelConfig, FILE_0, LANG_ID); assertEquals(0, actual.size()); } } @@ -329,6 +394,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testProvider_Regular() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // create couple of providers List entries1 = new ArrayList(); @@ -349,28 +416,28 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve the entries for provider-1 - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(provider1, cfgDescription, FILE_0, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider1, + config, FILE_0, LANG_ID); assertNotSame(entries1, actual); ICLanguageSettingEntry[] entriesArray = entries1.toArray(new ICLanguageSettingEntry[0]); ICLanguageSettingEntry[] actualArray = actual.toArray(new ICLanguageSettingEntry[0]); - for (int i=0;i entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); List providers = new ArrayList(); - ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (rc!=null && rc.equals(parentFolder)) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (rc != null && rc.equals(parentFolder)) { return entries; } - if (rc!=null && rc.equals(emptySettingsPath)) { + if (rc != null && rc.equals(emptySettingsPath)) { return new ArrayList(0); } return null; @@ -417,25 +488,26 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve entries for a derived resource (in a subfolder) IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource"); - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, + configWritable, derived, LANG_ID); // taken from parent folder - assertEquals(entries.get(0),actual.get(0)); + assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } { // retrieve entries for not related resource - IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource")); - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, notRelated, LANG_ID); + IFile notRelated = ResourcesPlugin.getWorkspace().getRoot() + .getFile(new Path("/AnotherFolder/Subfolder/resource")); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, + configWritable, notRelated, LANG_ID); assertEquals(0, actual.size()); } { // test distinction between no settings and empty settings - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, emptySettingsPath, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, + configWritable, emptySettingsPath, LANG_ID); // NOT taken from parent folder assertEquals(0, actual.size()); } @@ -448,11 +520,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertTrue(cfgDescriptionWritable instanceof CConfigurationDescription); + IBuildConfiguration configWritable = Adapters.adapt(cfgDescriptionWritable, IBuildConfiguration.class); + assertNotNull(configWritable); final IFolder parentFolder = ResourceHelper.createFolder(project, "/ParentFolder/"); assertNotNull(parentFolder); @@ -463,10 +538,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase { final List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); List providers = new ArrayList(); - ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { + ILanguageSettingsProvider provider = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, null) { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (cfgDescription==null && rc==null) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config == null && rc == null) { return entries; } return null; @@ -479,10 +555,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve entries for a resource IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource"); - List actual = LanguageSettingsManager - .getSettingEntriesUpResourceTree(provider, cfgDescriptionWritable, derived, LANG_ID); + List actual = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, + configWritable, derived, LANG_ID); // default entries given - assertEquals(entries.get(0),actual.get(0)); + assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } } @@ -492,13 +568,15 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_Regular() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // contribute the entries List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); - entries.add(new CMacroEntry("MACRO0", "value0",0)); + entries.add(new CMacroEntry("MACRO0", "value0", 0)); entries.add(new CIncludePathEntry("path1", 0)); - entries.add(new CMacroEntry("MACRO1", "value1",0)); + entries.add(new CMacroEntry("MACRO1", "value1", 0)); entries.add(new CIncludePathEntry("path2", 0)); ILanguageSettingsProvider provider0 = new MockProvider(PROVIDER_0, PROVIDER_NAME_0, entries); @@ -507,17 +585,17 @@ public class LanguageSettingsManagerTests extends BaseTestCase { cfgDescription.setLanguageSettingProviders(providers); // retrieve entries by kind - List includes = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); - assertEquals(new CIncludePathEntry("path0", 0),includes.get(0)); - assertEquals(new CIncludePathEntry("path1", 0),includes.get(1)); - assertEquals(new CIncludePathEntry("path2", 0),includes.get(2)); + List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + assertEquals(new CIncludePathEntry("path0", 0), includes.get(0)); + assertEquals(new CIncludePathEntry("path1", 0), includes.get(1)); + assertEquals(new CIncludePathEntry("path2", 0), includes.get(2)); assertEquals(3, includes.size()); - List macros = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.MACRO); - assertEquals(new CMacroEntry("MACRO0", "value0",0), macros.get(0)); - assertEquals(new CMacroEntry("MACRO1", "value1",0), macros.get(1)); + List macros = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.MACRO); + assertEquals(new CMacroEntry("MACRO0", "value0", 0), macros.get(0)); + assertEquals(new CMacroEntry("MACRO1", "value1", 0), macros.get(1)); assertEquals(2, macros.size()); } @@ -526,6 +604,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_ConflictingEntries() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // contribute the entries List entries = new ArrayList(); @@ -539,9 +619,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase { cfgDescription.setLanguageSettingProviders(providers); // retrieve entries by kind, only first entry should be returned - List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); assertEquals(1, includes.size()); - assertEquals(entries.get(0),includes.get(0)); + assertEquals(entries.get(0), includes.get(0)); } /** @@ -549,6 +630,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_Undefined() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // contribute the entries List entries = new ArrayList(); @@ -561,8 +644,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { cfgDescription.setLanguageSettingProviders(providers); // retrieve entries by kind, no entries should be returned - List includes = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); assertEquals(0, includes.size()); } @@ -571,6 +654,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_LocalAndSystem() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // contribute the entries List entries = new ArrayList(); @@ -587,7 +672,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve local entries List includes = LanguageSettingsProvidersSerializer - .getLocalSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + .getLocalSettingEntriesByKind(config, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); assertEquals(localIncludeEntry, includes.get(0)); assertEquals(1, includes.size()); } @@ -595,15 +680,15 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // retrieve system entries List includes = LanguageSettingsProvidersSerializer - .getSystemSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + .getSystemSettingEntriesByKind(config, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); assertEquals(systemIncludeEntry, includes.get(0)); assertEquals(1, includes.size()); } { // retrieve both local and system - List includes = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); assertEquals(entries.get(0), includes.get(0)); assertEquals(entries.get(1), includes.get(1)); assertEquals(2, includes.size()); @@ -615,6 +700,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_ConflictingProviders() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // contribute the entries List providers = new ArrayList(); @@ -639,15 +726,15 @@ public class LanguageSettingsManagerTests extends BaseTestCase { cfgDescription.setLanguageSettingProviders(providers); // retrieve entries by kind - List includes = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); + List includes = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH); // path0 is taken from higher priority provider - assertEquals(entriesHigh.get(0),includes.get(0)); + assertEquals(entriesHigh.get(0), includes.get(0)); // path1 disablement by lower priority provider is ignored - assertEquals(entriesHigh.get(1),includes.get(1)); + assertEquals(entriesHigh.get(1), includes.get(1)); // path2 is removed because of DISABLED flag of high priority provider // path3 gets there from low priority provider - assertEquals(entriesLow.get(3),includes.get(2)); + assertEquals(entriesLow.get(3), includes.get(2)); assertEquals(3, includes.size()); } @@ -656,13 +743,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testEntriesByKind_CompositeKind() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); // contribute the entries List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); - entries.add(new CMacroEntry("MACRO0", "value0",0)); + entries.add(new CMacroEntry("MACRO0", "value0", 0)); entries.add(new CIncludePathEntry("path1", 0)); - entries.add(new CMacroEntry("MACRO1", "value1",0)); + entries.add(new CMacroEntry("MACRO1", "value1", 0)); entries.add(new CIncludePathEntry("path2", 0)); entries.add(new CIncludeFileEntry("include-path-file", 0)); @@ -673,12 +761,12 @@ public class LanguageSettingsManagerTests extends BaseTestCase { cfgDescription.setLanguageSettingProviders(providers); // retrieve entries by kind - List result = LanguageSettingsProvidersSerializer - .getSettingEntriesByKind(cfgDescription, FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO); + List result = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, + FILE_0, LANG_ID, ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO); assertEquals(new CIncludePathEntry("path0", 0), result.get(0)); - assertEquals(new CMacroEntry("MACRO0", "value0",0), result.get(1)); + assertEquals(new CMacroEntry("MACRO0", "value0", 0), result.get(1)); assertEquals(new CIncludePathEntry("path1", 0), result.get(2)); - assertEquals(new CMacroEntry("MACRO1", "value1",0), result.get(3)); + assertEquals(new CMacroEntry("MACRO1", "value1", 0), result.get(3)); assertEquals(new CIncludePathEntry("path2", 0), result.get(4)); assertEquals(5, result.size()); } @@ -690,19 +778,22 @@ public class LanguageSettingsManagerTests extends BaseTestCase { // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertTrue(cfgDescription instanceof CConfigurationDescription); // Select a sample workspace provider for the test - ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider workspaceProvider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); assertNotNull(workspaceProvider); { // ensure no test provider is set yet but default providers - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(0).getId()); assertEquals(ReferencedProjectsLanguageSettingsProvider.ID, providers.get(1).getId()); assertEquals(ScannerDiscoveryLegacySupport.MBS_LANGUAGE_SETTINGS_PROVIDER_ID, providers.get(2).getId()); @@ -716,7 +807,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { } { // check that test provider got there - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(workspaceProvider, providers.get(0)); } @@ -730,12 +822,14 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // check that test provider got loaded - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); ICConfigurationDescription[] loadedCfgDescriptions = prjDescription.getConfigurations(); ICConfigurationDescription loadedCfgDescription = loadedCfgDescriptions[0]; assertTrue(cfgDescription instanceof CConfigurationDescription); - List loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription).getLanguageSettingProviders(); + List loadedProviders = ((ILanguageSettingsProvidersKeeper) loadedCfgDescription) + .getLanguageSettingProviders(); assertTrue(LanguageSettingsManager.isWorkspaceProvider(loadedProviders.get(0))); } @@ -746,7 +840,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testWorkspaceProvider_Basic() throws Exception { // get workspace provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId()); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_NAME, provider.getName()); @@ -760,9 +855,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // make sure entries are the same - List entries = provider.getSettingEntries(null, null, null); + List entries = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(1, entries.size()); // defined in the extension - List rawEntries = rawProvider.getSettingEntries(null, null, null); + List rawEntries = rawProvider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries, rawEntries); } @@ -771,10 +867,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase { List newEntries = new ArrayList(); newEntries.add(new CIncludePathEntry("path0", 0)); newEntries.add(new CIncludePathEntry("path1", 0)); - ((LanguageSettingsSerializableProvider)rawProvider).setSettingEntries(null, null, null, newEntries); + ((LanguageSettingsSerializableProvider) rawProvider).setSettingEntries(null, null, null, newEntries); // check that the workspace provider gets them too - List newRawEntries = rawProvider.getSettingEntries(null, null, null); + List newRawEntries = rawProvider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(newEntries, newRawEntries); assertEquals(2, newEntries.size()); } @@ -784,8 +881,10 @@ public class LanguageSettingsManagerTests extends BaseTestCase { * Test workspace providers equality. */ public void testWorkspaceProvider_Equals() throws Exception { - ILanguageSettingsProvider providerA = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - ILanguageSettingsProvider providerB = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider providerA = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider providerB = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); assertEquals(providerA, providerB); } @@ -794,10 +893,11 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testWorkspaceProvider_ReplaceRawProvider() throws Exception { // get sample workspace provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); { // check on its entries (1 predefined entry via extension point) - List entries = provider.getSettingEntries(null, null, null); + List entries = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(1, entries.size()); // defined in the extension } @@ -810,7 +910,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // replace raw provider List providers = new ArrayList(); - LanguageSettingsSerializableProvider newRawProvider = new LanguageSettingsSerializableProvider(EXTENSION_EDITABLE_PROVIDER_ID, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider newRawProvider = new LanguageSettingsSerializableProvider( + EXTENSION_EDITABLE_PROVIDER_ID, PROVIDER_NAME_0); newRawProvider.setSettingEntries(null, null, null, newEntries); providers.add(newRawProvider); LanguageSettingsManager.setWorkspaceProviders(providers); @@ -818,7 +919,7 @@ public class LanguageSettingsManagerTests extends BaseTestCase { { // check that provider provides the new entries - List entries = provider.getSettingEntries(null, null, null); + List entries = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(newEntries.size(), entries.size()); assertEquals(newEntries, entries); } @@ -829,7 +930,8 @@ public class LanguageSettingsManagerTests extends BaseTestCase { */ public void testWorkspaceProvider_ReplaceWithWorkspaceProvider() throws Exception { // get sample workspace provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertNotSame(provider, rawProvider); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java index e7e840cebdf..f87407add8d 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java @@ -15,8 +15,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; @@ -29,13 +27,17 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.IPath; import org.w3c.dom.Document; import org.w3c.dom.Element; +import junit.framework.TestSuite; + /** * Test cases testing LanguageSettingsProvider functionality related to persistence. */ @@ -69,22 +71,28 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Mock configuration description. */ - class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription implements ILanguageSettingsProvidersKeeper { + class MockConfigurationDescription extends CModelMock.DummyCConfigurationDescription + implements ILanguageSettingsProvidersKeeper { List providers; + public MockConfigurationDescription(String id) { super(id); } + @Override public void setLanguageSettingProviders(List providers) { this.providers = new ArrayList(providers); } + @Override public List getLanguageSettingProviders() { return providers; } + @Override public void setDefaultLanguageSettingsProvidersIds(String[] ids) { } + @Override public String[] getDefaultLanguageSettingsProvidersIds() { return null; @@ -96,17 +104,21 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { */ class MockProjectDescription extends CModelMock.DummyCProjectDescription { ICConfigurationDescription[] cfgDescriptions; + public MockProjectDescription(ICConfigurationDescription[] cfgDescriptions) { this.cfgDescriptions = cfgDescriptions; } + public MockProjectDescription(ICConfigurationDescription cfgDescription) { this.cfgDescriptions = new ICConfigurationDescription[] { cfgDescription }; } + @Override public ICConfigurationDescription[] getConfigurations() { return cfgDescriptions; } + @Override public ICConfigurationDescription getConfigurationById(String id) { for (ICConfigurationDescription cfgDescription : cfgDescriptions) { @@ -119,7 +131,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsPersistenceProjectTests(String name) { super(name); @@ -146,7 +160,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -157,7 +172,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { */ private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) { // project description - ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription projectDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(projectDescription); assertEquals(1, projectDescription.getConfigurations().length); // configuration description @@ -197,7 +213,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); @@ -205,11 +222,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); - List originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List originalProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); int originalSize = originalProviders.size(); // create new provider list - LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_0, + PROVIDER_NAME_0); List providers = new ArrayList(originalProviders); providers.add(mockProvider); assertTrue(originalSize != providers.size()); @@ -228,7 +247,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // get read-only description - ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescriptionReadOnly); ICConfigurationDescription cfgDescriptionReadOnly = prjDescriptionReadOnly.getDefaultSettingConfiguration(); assertNotNull(cfgDescriptionReadOnly); @@ -245,7 +265,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // try to write to it default providers ids try { - ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); + ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly) + .setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); fail("WriteAccessException was expected but it was not throw."); } catch (WriteAccessException e) { // exception is expected @@ -257,80 +278,95 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration configWritable = Adapters.adapt(cfgDescriptionWritable, IBuildConfiguration.class); // create a provider and write to cfgDescription - LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider mockProvider = new MockLanguageSettingsEditableProvider(PROVIDER_1, + PROVIDER_NAME_1); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true); - mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries); + mockProvider.setSettingEntries(configWritable, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to cfgDescription default providers ids - ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); + ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .setDefaultLanguageSettingsProvidersIds(new String[] { PROVIDER_0 }); // apply new project description to the project model CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable); } { // get read-only project descriptions - ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription prjDescriptionReadOnly = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); assertNotNull(prjDescriptionReadOnly); ICConfigurationDescription[] cfgDescriptions = prjDescriptionReadOnly.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionReadOnly = cfgDescriptions[0]; assertNotNull(cfgDescriptionReadOnly); assertTrue(cfgDescriptionReadOnly instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration configReadOnly = Adapters.adapt(cfgDescriptionReadOnly, IBuildConfiguration.class); + assertNotNull(configReadOnly); // double-check providers - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); assertEquals(PROVIDER_1, loadedProvider.getId()); assertEquals(PROVIDER_NAME_1, loadedProvider.getName()); // double-check provider's setting entries - List actual = loadedProvider.getSettingEntries(cfgDescriptionReadOnly, null, null); + List actual = loadedProvider.getSettingEntries(configReadOnly, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); // double-check default providers ids - String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly).getDefaultLanguageSettingsProvidersIds(); + String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionReadOnly) + .getDefaultLanguageSettingsProvidersIds(); assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds)); } { // get writable project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration configWritable = Adapters.adapt(cfgDescriptionWritable, IBuildConfiguration.class); + assertNotNull(configWritable); // check providers - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof MockLanguageSettingsEditableProvider); assertEquals(PROVIDER_1, loadedProvider.getId()); assertEquals(PROVIDER_NAME_1, loadedProvider.getName()); // check provider's setting entries - List actual = loadedProvider.getSettingEntries(cfgDescriptionWritable, null, null); + List actual = loadedProvider.getSettingEntries(configWritable, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); // check default providers ids - String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getDefaultLanguageSettingsProvidersIds(); + String[] actualDefaultProvidersIds = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getDefaultLanguageSettingsProvidersIds(); assertTrue(Arrays.equals(new String[] { PROVIDER_0 }, actualDefaultProvidersIds)); } } @@ -344,8 +380,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // get the raw extension provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - LanguageSettingsSerializableProvider extProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + LanguageSettingsSerializableProvider extProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager + .getRawProvider(provider); assertNotNull(extProvider); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, extProvider.getId()); @@ -364,17 +402,19 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // doublecheck it's clean - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - List actual = provider.getSettingEntries(null, null, null); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertNull(actual); } { // re-load and check language settings of the provider LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace(); - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId()); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -388,14 +428,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY); { // test initial state of the extension provider - ILanguageSettingsProvider extProvider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true); + ILanguageSettingsProvider extProvider = LanguageSettingsManager + .getExtensionProviderCopy(EXTENSION_SERIALIZABLE_PROVIDER_ID, true); assertNull(extProvider); } { // get the workspace provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); // check that entries match that of extension provider - assertEquals(extensionEntries, provider.getSettingEntries(null, null, null)); + assertEquals(extensionEntries, provider.getSettingEntries((IBuildConfiguration) null, null, null)); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true)); @@ -407,9 +449,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace(); // ensure the workspace provider still matches extension - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, provider.getId()); - assertEquals(extensionEntries, provider.getSettingEntries(null, null, null)); + assertEquals(extensionEntries, provider.getSettingEntries((IBuildConfiguration) null, null, null)); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true)); @@ -417,7 +460,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertTrue(rawProvider instanceof LanguageSettingsSerializableProvider); List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); - ((LanguageSettingsSerializableProvider)rawProvider).setSettingEntries(null, null, null, entries); + ((LanguageSettingsSerializableProvider) rawProvider).setSettingEntries(null, null, null, entries); // check that the extension provider is not affected assertTrue(!LanguageSettingsManager.isEqualExtensionProvider(rawProvider, true)); @@ -430,8 +473,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { public void testWorkspacePersistence_GlobalProvider() throws Exception { { // get the raw extension provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager + .getRawProvider(provider); assertNotNull(rawProvider); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, rawProvider.getId()); @@ -442,14 +487,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // save workspace provider (as opposed to raw provider) List providers = new ArrayList(); - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); providers.add(provider); LanguageSettingsManager.setWorkspaceProviders(providers); } { // check that it has not cleared - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager + .getRawProvider(provider); assertEquals(CUSTOM_PARAMETER, rawProvider.getProperty(ATTR_PARAMETER)); } } @@ -460,7 +508,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception { { // get the raw extension provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); // confirm its type and name assertTrue(rawProvider instanceof LanguageSettingsBaseProvider); @@ -469,7 +518,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // replace extension provider - ILanguageSettingsProvider provider = new MockLanguageSettingsSerializableProvider(EXTENSION_BASE_PROVIDER_ID, PROVIDER_NAME_0); + ILanguageSettingsProvider provider = new MockLanguageSettingsSerializableProvider( + EXTENSION_BASE_PROVIDER_ID, PROVIDER_NAME_0); List providers = new ArrayList(); providers.add(provider); // note that this will also serialize workspace providers @@ -477,7 +527,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // doublecheck it's in the list - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(rawProvider instanceof MockLanguageSettingsSerializableProvider); assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId()); @@ -488,7 +539,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // re-load to check serialization LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace(); - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(rawProvider instanceof MockLanguageSettingsSerializableProvider); assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId()); @@ -501,7 +553,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // doublecheck original one is in the list - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(rawProvider instanceof LanguageSettingsBaseProvider); assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId()); @@ -511,7 +564,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // re-load to check serialization LanguageSettingsProvidersSerializer.loadLanguageSettingsWorkspace(); - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(provider); assertTrue(rawProvider instanceof LanguageSettingsBaseProvider); assertEquals(EXTENSION_BASE_PROVIDER_ID, rawProvider.getId()); @@ -530,14 +584,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, true); @@ -549,12 +605,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); assertTrue(XmlUtil.toString(doc).contains(PROVIDER_0)); } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -564,13 +622,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -587,13 +646,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - ILanguageSettingsProvider provider = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, false); assertTrue(provider instanceof MockLanguageSettingsEditableProvider); MockLanguageSettingsEditableProvider serializableProvider = (MockLanguageSettingsEditableProvider) provider; serializableProvider.setSettingEntries(null, null, null, entries); @@ -607,13 +668,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); assertTrue(XmlUtil.toString(doc).contains(EXTENSION_EDITABLE_PROVIDER_ID)); assertTrue(XmlUtil.toString(doc).contains(MockLanguageSettingsEditableProvider.class.getName())); } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -623,20 +686,22 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof MockLanguageSettingsEditableProvider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } } /** - * Test serialization of providers to project storage where the project has multiple configurations. + * Test serialization of providers to project storage where the project has multiple + * configurations. */ public void testProjectPersistence_TwoConfigurationsDOM() throws Exception { Element rootElement = null; @@ -648,11 +713,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // create a project description with 2 configuration descriptions - MockProjectDescription mockPrjDescription = new MockProjectDescription( - new MockConfigurationDescription[] { - new MockConfigurationDescription(CFG_ID), - new MockConfigurationDescription(CFG_ID_2), - }); + MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription[] { + new MockConfigurationDescription(CFG_ID), new MockConfigurationDescription(CFG_ID_2), }); { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); assertNotNull(cfgDescriptions); @@ -664,7 +726,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); assertEquals(CFG_ID, cfgDescription1.getId()); - LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, true); provider1.setSettingEntries(null, null, null, entries); ArrayList providers = new ArrayList(); @@ -678,7 +741,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); assertEquals(CFG_ID_2, cfgDescription2.getId()); - LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, true); provider2.setSettingEntries(null, null, null, entries2); ArrayList providers = new ArrayList(); @@ -697,13 +761,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription1 = cfgDescriptions[0]; assertNotNull(cfgDescription1); assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertNotNull(provider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -713,12 +779,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription2); assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertNotNull(provider); - List actual2 = provider.getSettingEntries(null, null, null); + List actual2 = provider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries2.get(0), actual2.get(0)); assertEquals(entries2.size(), actual2.size()); } @@ -728,15 +796,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); } { // re-create a project description and re-load language settings for each configuration - MockProjectDescription mockPrjDescription = new MockProjectDescription( - new MockConfigurationDescription[] { - new MockConfigurationDescription(CFG_ID), - new MockConfigurationDescription(CFG_ID_2), - }); + MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription[] { + new MockConfigurationDescription(CFG_ID), new MockConfigurationDescription(CFG_ID_2), }); // load LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); @@ -749,12 +815,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription1); assertTrue(cfgDescription1 instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription1) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertNotNull(provider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -763,13 +831,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription2 = cfgDescriptions[1]; assertNotNull(cfgDescription2); assertTrue(cfgDescription2 instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription2) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertNotNull(provider); - List actual2 = provider.getSettingEntries(null, null, null); + List actual2 = provider.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries2.get(0), actual2.get(0)); assertEquals(entries2.size(), actual2.size()); } @@ -787,14 +857,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - LanguageSettingsSerializableProvider serializableProvider = new MockLanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider serializableProvider = new MockLanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, true); @@ -806,11 +878,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -820,13 +894,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof MockLanguageSettingsSerializableProvider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -838,12 +913,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception { Element rootElement = null; - // provider of other type (not LanguageSettingsSerializableProvider) defined as an extension - ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + // provider of other type (not LanguageSettingsSerializableProvider) + // defined as an extension + ILanguageSettingsProvider providerExt = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); { // create cfg description - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); @@ -858,11 +936,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); } { // re-load - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -872,8 +952,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - // and check the newly loaded provider which should be workspace provider - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + // and check the newly loaded provider which should be workspace + // provider + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -894,29 +976,32 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(providerExt); { // create cfg description - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // populate with provider overriding the extension (must be SerializableLanguageSettingsProvider or a class from another extension) - MockLanguageSettingsSerializableProvider providerOverride = new MockLanguageSettingsSerializableProvider(idExt, PROVIDER_NAME_0); + MockLanguageSettingsSerializableProvider providerOverride = new MockLanguageSettingsSerializableProvider( + idExt, PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(providerOverride, true); List providers = new ArrayList(); providers.add(providerOverride); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); - // prepare DOM storage Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); } { // re-load - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -927,7 +1012,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); // check the newly loaded provider - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -938,7 +1024,6 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } } - /** * Test serialization flavors in one storage. */ @@ -954,7 +1039,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ILanguageSettingsProvider providerExt; { // Define providers a bunch - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); { ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; @@ -966,11 +1052,13 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // 2. Providers defined in a configuration // 2.1 - LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider mockProvider1 = new LanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider1, true); mockProvider1.setSettingEntries(null, null, null, entries_31); // 2.2 - LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2); + LanguageSettingsSerializableProvider mockProvider2 = new MockLanguageSettingsSerializableProvider( + PROVIDER_2, PROVIDER_NAME_2); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider2, true); mockProvider2.setSettingEntries(null, null, null, entries_32); @@ -985,12 +1073,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); rootElement = XmlUtil.appendElement(doc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(rootElement, null, + mockPrjDescription); XmlUtil.toString(doc); } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(rootElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -1000,7 +1090,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); // 1. Provider reference to extension from plugin.xml ILanguageSettingsProvider provider0 = providers.get(0); @@ -1011,7 +1102,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { ILanguageSettingsProvider provider1 = providers.get(1); assertTrue(provider1 instanceof LanguageSettingsSerializableProvider); - List actual = provider1.getSettingEntries(null, null, null); + List actual = provider1.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries_31.get(0), actual.get(0)); assertEquals(entries_31.size(), actual.size()); } @@ -1019,7 +1111,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { ILanguageSettingsProvider provider2 = providers.get(2); assertTrue(provider2 instanceof MockLanguageSettingsSerializableProvider); - List actual = provider2.getSettingEntries(null, null, null); + List actual = provider2.getSettingEntries((IBuildConfiguration) null, null, + null); assertEquals(entries_32.get(0), actual.get(0)); assertEquals(entries_32.size(), actual.size()); } @@ -1040,22 +1133,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration configWritable = Adapters.adapt(cfgDescriptionWritable, IBuildConfiguration.class); + assertNotNull(configWritable); // create a provider - LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, + PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, true); - mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries); + mockProvider.setSettingEntries(configWritable, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description @@ -1066,15 +1164,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); assertEquals(PROVIDER_0, provider.getId()); assertEquals(PROVIDER_NAME_0, provider.getName()); - List actual = provider.getSettingEntries(cfgDescription, null, null); + List actual = provider.getSettingEntries(config, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -1082,7 +1183,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // Move storage out of the way String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFileLocation); - xmlPrjOutOfTheWay = xmlStorageFileLocation+".out-of-the-way"; + xmlPrjOutOfTheWay = xmlStorageFileLocation + ".out-of-the-way"; java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFile.renameTo(xmlFileOut); assertFalse(xmlFile.exists()); @@ -1090,23 +1191,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // Should not pollute workspace area with file with no meaningful data - String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML); + String xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea( + project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML); java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation); assertFalse(xmlStorageFileWsp.exists()); } { // clear configuration - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); - ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList()); + ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .setLanguageSettingProviders(new ArrayList()); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -1115,7 +1220,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -1130,24 +1236,25 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); // Move storage back String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFileLocation); xmlFile.delete(); - assertFalse("File "+xmlFile+ " still exist", xmlFile.exists()); + assertFalse("File " + xmlFile + " still exist", xmlFile.exists()); java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFileOut.renameTo(xmlFile); - assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists()); - assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists()); + assertTrue("File " + xmlFile + " does not exist", xmlFile.exists()); + assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists()); // Wait out in case indexer thread hijacks refreshLocal(), see bug 415970 waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project)); // Refresh storage in workspace xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null); - assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists()); + assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists()); // and close project.close(null); @@ -1161,15 +1268,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider); assertEquals(PROVIDER_0, loadedProvider.getId()); assertEquals(PROVIDER_NAME_0, loadedProvider.getName()); - List actual = loadedProvider.getSettingEntries(cfgDescription, null, null); + List actual = loadedProvider.getSettingEntries(config, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -1187,14 +1297,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider serializableProvider = new LanguageSettingsSerializableProvider( + PROVIDER_0, PROVIDER_NAME_0); serializableProvider.setSettingEntries(null, null, null, entries); // do not store entries inside project LanguageSettingsManager.setStoringEntriesInProjectArea(serializableProvider, false); @@ -1209,12 +1321,15 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document wspDoc = XmlUtil.newDocument(); wspStorageElement = XmlUtil.appendElement(wspDoc, ELEM_TEST); // serialize language settings to the DOM - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(prjStorageElement, wspStorageElement, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(prjStorageElement, wspStorageElement, + mockPrjDescription); } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); - LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(prjStorageElement, wspStorageElement, mockPrjDescription); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); + LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(prjStorageElement, wspStorageElement, + mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); assertNotNull(cfgDescriptions); @@ -1223,13 +1338,14 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); - List actual = provider.getSettingEntries(null, null, null); + List actual = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -1238,7 +1354,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { /** * TODO: refactor with ErrorParserManager * - * @param store - name of the store + * @param store + * - name of the store * @return location of the store in the plug-in state area */ public static String getStoreLocationInWorkspaceArea(String store) { @@ -1261,29 +1378,35 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // get project descriptions - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); assertNotNull(prjDescriptionWritable); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration configWritable = Adapters.adapt(cfgDescriptionWritable, IBuildConfiguration.class); + assertNotNull(configWritable); // create a provider - LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, PROVIDER_NAME_0); + LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_0, + PROVIDER_NAME_0); LanguageSettingsManager.setStoringEntriesInProjectArea(mockProvider, false); - mockProvider.setSettingEntries(cfgDescriptionWritable, null, null, entries); + mockProvider.setSettingEntries(configWritable, null, null, entries); List providers = new ArrayList(); providers.add(mockProvider); ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(providers); - List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List storedProviders = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(1, storedProviders.size()); // write to project description CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable); xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); assertTrue(xmlStorageFilePrj.exists()); - xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML); + xmlStorageFileWspLocation = getStoreLocationInWorkspaceArea( + project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML); java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation); assertTrue(xmlStorageFileWsp.exists()); } @@ -1291,15 +1414,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); assertTrue(provider instanceof LanguageSettingsSerializableProvider); assertEquals(PROVIDER_0, provider.getId()); assertEquals(PROVIDER_NAME_0, provider.getName()); - List actual = provider.getSettingEntries(cfgDescription, null, null); + List actual = provider.getSettingEntries(config, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -1308,7 +1434,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // project storage String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation); - xmlPrjOutOfTheWay = xmlStorageFilePrjLocation+".out-of-the-way"; + xmlPrjOutOfTheWay = xmlStorageFilePrjLocation + ".out-of-the-way"; java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFile.renameTo(xmlFileOut); assertFalse(xmlFile.exists()); @@ -1317,7 +1443,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // workspace storage java.io.File xmlStorageFileWsp = new java.io.File(xmlStorageFileWspLocation); assertTrue(xmlStorageFileWsp.exists()); - xmlWspOutOfTheWay = xmlStorageFileWspLocation+".out-of-the-way"; + xmlWspOutOfTheWay = xmlStorageFileWspLocation + ".out-of-the-way"; java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay); boolean result = xmlStorageFileWsp.renameTo(xmlWspFileOut); assertTrue(result); @@ -1327,16 +1453,19 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { { // clear configuration - ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance().getProjectDescription(project, true); + ICProjectDescription prjDescriptionWritable = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, true); ICConfigurationDescription[] cfgDescriptions = prjDescriptionWritable.getConfigurations(); assertEquals(1, cfgDescriptions.length); ICConfigurationDescription cfgDescriptionWritable = cfgDescriptions[0]; assertNotNull(cfgDescriptionWritable); assertTrue(cfgDescriptionWritable instanceof ILanguageSettingsProvidersKeeper); - ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).setLanguageSettingProviders(new ArrayList()); + ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .setLanguageSettingProviders(new ArrayList()); CProjectDescriptionManager.getInstance().setProjectDescription(project, prjDescriptionWritable); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescriptionWritable) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -1345,7 +1474,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); } { @@ -1353,14 +1483,16 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { project.close(null); } { - // open to double-check the data is not kept in some other kind of cache + // open to double-check the data is not kept in some other kind of + // cache project.open(null); // check that list of providers is empty ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(0, providers.size()); // Move project storage back @@ -1368,17 +1500,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString(); java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation); xmlFile.delete(); - assertFalse("File "+xmlFile+ " still exist", xmlFile.exists()); + assertFalse("File " + xmlFile + " still exist", xmlFile.exists()); java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay); xmlFileOut.renameTo(xmlFile); - assertTrue("File "+xmlFile+ " does not exist", xmlFile.exists()); - assertFalse("File "+xmlFileOut+ " still exist", xmlFileOut.exists()); + assertTrue("File " + xmlFile + " does not exist", xmlFile.exists()); + assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists()); - // Wait out in case indexer thread hijacks refreshLocal(), see bug 415970 + // Wait out in case indexer thread hijacks refreshLocal(), see bug + // 415970 waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project)); // Refresh storage in workspace xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null); - assertTrue("File "+xmlStorageFilePrj+ " does not exist", xmlStorageFilePrj.exists()); + assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists()); // and close project.close(null); @@ -1388,11 +1521,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { // Move workspace storage back java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation); xmlWspFile.delete(); - assertFalse("File "+xmlWspFile+ " still exist", xmlWspFile.exists()); + assertFalse("File " + xmlWspFile + " still exist", xmlWspFile.exists()); java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay); xmlWspFileOut.renameTo(xmlWspFile); - assertTrue("File "+xmlWspFile+ " does not exist", xmlWspFile.exists()); - assertFalse("File "+xmlWspFileOut+ " still exist", xmlWspFileOut.exists()); + assertTrue("File " + xmlWspFile + " does not exist", xmlWspFile.exists()); + assertFalse("File " + xmlWspFileOut + " still exist", xmlWspFileOut.exists()); } { @@ -1403,15 +1536,18 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { ICConfigurationDescription cfgDescription = getFirstConfigurationDescription(project); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertEquals(1, providers.size()); ILanguageSettingsProvider loadedProvider = providers.get(0); assertTrue(loadedProvider instanceof LanguageSettingsSerializableProvider); assertEquals(PROVIDER_0, loadedProvider.getId()); assertEquals(PROVIDER_NAME_0, loadedProvider.getName()); - List actual = loadedProvider.getSettingEntries(cfgDescription, null, null); + List actual = loadedProvider.getSettingEntries(config, null, null); assertEquals(entries.get(0), actual.get(0)); assertEquals(entries.size(), actual.size()); } @@ -1424,25 +1560,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST); - ILanguageSettingsProvider providerExt = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); + ILanguageSettingsProvider providerExt = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_BASE_PROVIDER_ID); assertNotNull(providerExt); { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - ArrayList providers = new ArrayList(); providers.add(providerExt); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, + mockPrjDescription); String xml = XmlUtil.toString(doc); assertTrue(xml.contains(ELEM_PROVIDER_REFERENCE)); @@ -1452,7 +1590,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -1462,7 +1601,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -1477,25 +1617,27 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { Document doc = XmlUtil.newDocument(); Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST); - ILanguageSettingsProvider providerExt = LanguageSettingsManager.getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true); + ILanguageSettingsProvider providerExt = LanguageSettingsManager + .getExtensionProviderCopy(EXTENSION_EDITABLE_PROVIDER_ID, true); assertNotNull(providerExt); { // create a provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - ArrayList providers = new ArrayList(); providers.add(providerExt); ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); // prepare DOM storage - LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, mockPrjDescription); + LanguageSettingsProvidersSerializer.serializeLanguageSettingsInternal(storageElement, null, + mockPrjDescription); String xml = XmlUtil.toString(doc); assertTrue(xml.contains(ELEM_PROVIDER)); @@ -1505,7 +1647,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // re-load and check language settings of the newly loaded provider - MockProjectDescription mockPrjDescription = new MockProjectDescription(new MockConfigurationDescription(CFG_ID)); + MockProjectDescription mockPrjDescription = new MockProjectDescription( + new MockConfigurationDescription(CFG_ID)); LanguageSettingsProvidersSerializer.loadLanguageSettingsInternal(storageElement, null, mockPrjDescription); ICConfigurationDescription[] cfgDescriptions = mockPrjDescription.getConfigurations(); @@ -1515,7 +1658,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertNotNull(providers); assertEquals(1, providers.size()); ILanguageSettingsProvider provider = providers.get(0); @@ -1531,7 +1675,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML); assertFalse(xmlStorageFilePrj.exists()); - String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea(project.getName()+'.'+LANGUAGE_SETTINGS_WORKSPACE_XML); + String xmlPrjWspStorageFileLocation = getStoreLocationInWorkspaceArea( + project.getName() + '.' + LANGUAGE_SETTINGS_WORKSPACE_XML); java.io.File xmlStorageFilePrjWsp = new java.io.File(xmlPrjWspStorageFileLocation); assertFalse(xmlStorageFilePrjWsp.exists()); } @@ -1545,8 +1690,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", 0)); { // get extension provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); - LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_EDITABLE_PROVIDER_ID); + LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager + .getRawProvider(provider); assertNotNull(rawProvider); assertEquals(EXTENSION_EDITABLE_PROVIDER_ID, rawProvider.getId()); @@ -1555,8 +1702,10 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase { } { // get another extension provider - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); - LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager.getRawProvider(provider); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); + LanguageSettingsSerializableProvider rawProvider = (LanguageSettingsSerializableProvider) LanguageSettingsManager + .getRawProvider(provider); assertNotNull(rawProvider); assertEquals(EXTENSION_SERIALIZABLE_PROVIDER_ID, rawProvider.getId()); // modify it and add it to the list diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java index 7613f726fdb..65e09e84c61 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java @@ -18,8 +18,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; @@ -31,16 +29,22 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; +import junit.framework.TestSuite; + /** * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality */ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase { /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsProviderReferencedProjectsTests(String name) { super(name); @@ -67,7 +71,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -103,8 +108,13 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions(projectReferenced)[0]; - cfgDescription.setReferenceInfo(new HashMap() {{ put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); }}); + final ICConfigurationDescription cfgDescriptionReferenced = getConfigurationDescriptions( + projectReferenced)[0]; + cfgDescription.setReferenceInfo(new HashMap() { + { + put(projectReferenced.getName(), cfgDescriptionReferenced.getId()); + } + }); coreModel.setProjectDescription(project, projectDescription); } @@ -112,7 +122,7 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas // doublecheck that it's set as expected ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; - Map refs = cfgDescription.getReferenceInfo(); + Map refs = cfgDescription.getReferenceInfo(); assertEquals(1, refs.size()); Set referencedProjectsNames = new LinkedHashSet(refs.keySet()); assertEquals(projectReferenced.getName(), referencedProjectsNames.toArray()[0]); @@ -124,9 +134,10 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas * Test that null arguments don't crash the provider. */ public void testNulls() throws Exception { - ILanguageSettingsProvider provider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + ILanguageSettingsProvider provider = LanguageSettingsManager + .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); assertNotNull(provider); - List entries = provider.getSettingEntries(null, null, null); + List entries = provider.getSettingEntries((IBuildConfiguration) null, null, null); assertEquals(null, entries); } @@ -137,34 +148,41 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas // Create model project and accompanied descriptions String projectName = getName(); IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); - IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-non-referenced"); - IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName+"-referenced"); + IProject nonReferencedProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-non-referenced"); + IProject referencedProject = ResourceHelper.createCDTProjectWithConfig(projectName + "-referenced"); setReference(project, referencedProject); // get cfgDescription ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); { // double-check that provider for referenced projects is set in the configuration - ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager + .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); assertNotNull(refProjectsProvider); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); assertTrue(providers.contains(refProjectsProvider)); } // Check that no setting entries are set initially { - List entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + List entries = LanguageSettingsManager.getSettingEntriesByKind(config, project, + null, ICSettingEntry.ALL); assertEquals(0, entries.size()); } // Add an entry into a non-referenced project - CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", ICSettingEntry.EXPORTED); + CIncludePathEntry nonRefEntry = CDataUtil.createCIncludePathEntry("non-referenced-exported", + ICSettingEntry.EXPORTED); { ICConfigurationDescription[] nonRefCfgDescriptions = getConfigurationDescriptions(nonReferencedProject); ICConfigurationDescription nonRefCfgDescription = nonRefCfgDescriptions[0]; - List providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription).getLanguageSettingProviders(); + List providersNonRef = ((ILanguageSettingsProvidersKeeper) nonRefCfgDescription) + .getLanguageSettingProviders(); // get user provider which is the first one ILanguageSettingsProvider userProviderNonRef = providersNonRef.get(0); assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderNonRef.getId()); @@ -176,7 +194,8 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas } // Confirm that that does not add entries to the main project { - List entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + List entries = LanguageSettingsManager.getSettingEntriesByKind(config, project, + null, ICSettingEntry.ALL); assertEquals(0, entries.size()); } @@ -185,7 +204,10 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas { ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(referencedProject); ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; - List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + IBuildConfiguration refConfig = Adapters.adapt(refCfgDescription, IBuildConfiguration.class); + assertNotNull(refConfig); + List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription) + .getLanguageSettingProviders(); // get user provider which is the first one ILanguageSettingsProvider userProviderRef = providersRef.get(0); assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); @@ -196,12 +218,15 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas entries.add(refEntry); entries.add(refEntryNotExported); ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries); - List entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, project, null, ICSettingEntry.ALL); + List entriesActual = LanguageSettingsManager.getSettingEntriesByKind(refConfig, + project, null, ICSettingEntry.ALL); assertEquals(entries, entriesActual); } - // Check that the new entries from referenced project made it to the main project + // Check that the new entries from referenced project made it to the + // main project { - List entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescription, project, null, ICSettingEntry.ALL); + List entries = LanguageSettingsManager.getSettingEntriesByKind(config, project, + null, ICSettingEntry.ALL); assertEquals(CDataUtil.createCIncludePathEntry(refEntry.getName(), 0), entries.get(0)); assertEquals(1, entries.size()); } @@ -222,30 +247,41 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas // get cfgDescriptions to work with ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA); ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0]; + IBuildConfiguration configA = Adapters.adapt(cfgDescriptionA, IBuildConfiguration.class); + assertNotNull(configA); ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB); ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0]; + IBuildConfiguration configB = Adapters.adapt(cfgDescriptionB, IBuildConfiguration.class); + assertNotNull(configB); // double-check that provider for referenced projects is set in the configurations - ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager.getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); + ILanguageSettingsProvider refProjectsProvider = LanguageSettingsManager + .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); assertNotNull(refProjectsProvider); - List providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA).getLanguageSettingProviders(); + List providersA = ((ILanguageSettingsProvidersKeeper) cfgDescriptionA) + .getLanguageSettingProviders(); assertTrue(providersA.contains(refProjectsProvider)); - List providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB).getLanguageSettingProviders(); + List providersB = ((ILanguageSettingsProvidersKeeper) cfgDescriptionB) + .getLanguageSettingProviders(); assertTrue(providersB.contains(refProjectsProvider)); // Check that no setting entries are set initially - List entriesA = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL); + List entriesA = LanguageSettingsManager.getSettingEntriesByKind(configA, projectA, + null, ICSettingEntry.ALL); assertEquals(0, entriesA.size()); - List entriesB = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectB, null, ICSettingEntry.ALL); + List entriesB = LanguageSettingsManager.getSettingEntriesByKind(configB, projectB, + null, ICSettingEntry.ALL); assertEquals(0, entriesB.size()); } - CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", ICSettingEntry.EXPORTED); + CIncludePathEntry entryExportedA = CDataUtil.createCIncludePathEntry("referenced-exported-A", + ICSettingEntry.EXPORTED); CIncludePathEntry entryNotExportedA = CDataUtil.createCIncludePathEntry("referenced-not-exported-A", 0); // Add entries into a project A { ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectA); ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; - List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription) + .getLanguageSettingProviders(); // get user provider which is the first one ILanguageSettingsProvider userProviderRef = providersRef.get(0); assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); @@ -257,13 +293,15 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas ((LanguageSettingsGenericProvider) userProviderRef).setSettingEntries(null, null, null, entries); } - CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", ICSettingEntry.EXPORTED); + CIncludePathEntry entryExportedB = CDataUtil.createCIncludePathEntry("referenced-exported-B", + ICSettingEntry.EXPORTED); CIncludePathEntry entryNotExportedB = CDataUtil.createCIncludePathEntry("referenced-not-exported-B", 0); // Add entries into a project B { ICConfigurationDescription[] refCfgDescriptions = getConfigurationDescriptions(projectB); ICConfigurationDescription refCfgDescription = refCfgDescriptions[0]; - List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription).getLanguageSettingProviders(); + List providersRef = ((ILanguageSettingsProvidersKeeper) refCfgDescription) + .getLanguageSettingProviders(); // get user provider which is the first one ILanguageSettingsProvider userProviderRef = providersRef.get(0); assertEquals(ScannerDiscoveryLegacySupport.USER_LANGUAGE_SETTINGS_PROVIDER_ID, userProviderRef.getId()); @@ -279,7 +317,10 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas { ICConfigurationDescription[] cfgDescriptionsA = getConfigurationDescriptions(projectA); ICConfigurationDescription cfgDescriptionA = cfgDescriptionsA[0]; - List entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionA, projectA, null, ICSettingEntry.ALL); + IBuildConfiguration configA = Adapters.adapt(cfgDescriptionA, IBuildConfiguration.class); + assertNotNull(configA); + List entries = LanguageSettingsManager.getSettingEntriesByKind(configA, projectA, + null, ICSettingEntry.ALL); assertEquals(entryExportedA, entries.get(0)); assertEquals(entryNotExportedA, entries.get(1)); assertEquals(CDataUtil.createCIncludePathEntry(entryExportedB.getName(), 0), entries.get(2)); @@ -289,7 +330,9 @@ public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCas { ICConfigurationDescription[] cfgDescriptionsB = getConfigurationDescriptions(projectB); ICConfigurationDescription cfgDescriptionB = cfgDescriptionsB[0]; - List entries = LanguageSettingsManager.getSettingEntriesByKind(cfgDescriptionB, projectB, null, ICSettingEntry.ALL); + IBuildConfiguration configB = Adapters.adapt(cfgDescriptionB, IBuildConfiguration.class); + List entries = LanguageSettingsManager.getSettingEntriesByKind(configB, projectB, + null, ICSettingEntry.ALL); assertEquals(entryExportedB, entries.get(0)); assertEquals(entryNotExportedB, entries.get(1)); assertEquals(CDataUtil.createCIncludePathEntry(entryExportedA.getName(), 0), entries.get(2)); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java index 72ee4c50cfe..9716246886d 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java @@ -15,8 +15,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.parser.ExtendedScannerInfo; @@ -34,15 +32,19 @@ import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import junit.framework.TestSuite; + /** * Test cases testing LanguageSettingsProvider functionality */ @@ -65,14 +67,17 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { } @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { return entries; } } /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsScannerInfoProviderTests(String name) { super(name); @@ -99,7 +104,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -124,7 +130,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { } { // triplecheck builderCWD for different project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, READ_ONLY); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -153,7 +160,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { { // Handle prjDescription==null IProject project = FAKE_FILE.getProject(); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, READ_ONLY); assertNull(prjDescription); LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); @@ -171,7 +179,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); IFile file = ResourceHelper.createFile(project, "file"); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, READ_ONLY); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -199,7 +208,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { IFile file = ResourceHelper.createFile(project, "file.c"); // confirm that language==null - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, READ_ONLY); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + READ_ONLY); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -221,7 +231,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { public void testRegular() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -242,7 +253,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { CIncludePathEntry includePathEntry = new CIncludePathEntry(includeFolder, 0); CIncludePathEntry includeLocalPathEntry = new CIncludePathEntry(includeLocalFolder, ICSettingEntry.LOCAL); // #include "..." - CMacroEntry macroEntry = new CMacroEntry("MACRO", "value",0); + CMacroEntry macroEntry = new CMacroEntry("MACRO", "value", 0); CIncludeFileEntry includeFileEntry = new CIncludeFileEntry(includeFile, 0); CMacroFileEntry macroFileEntry = new CMacroFileEntry(macroFile, 0); @@ -293,7 +304,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { public void testLocal() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -347,7 +359,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { public void testFramework() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -390,7 +403,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { public void testDuplicate() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -440,7 +454,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { public void testWorkspacePath() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -467,9 +482,12 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // contribute the entries CIncludePathEntry incWorkspaceEntry_1 = new CIncludePathEntry(incWorkspace_1, 0); - CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); - CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); - CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, ICSettingEntry.VALUE_WORKSPACE_PATH); + CIncludePathEntry incWorkspaceEntry_2 = new CIncludePathEntry(incWorkspacePath_2, + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); + CIncludePathEntry incWorkspaceEntry_3 = new CIncludePathEntry(incWorkspaceRelativePath_3, + ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); + CIncludePathEntry incWorkspaceEntry_4 = new CIncludePathEntry(incWorkspacePathNoResolved_4, + ICSettingEntry.VALUE_WORKSPACE_PATH); CIncludePathEntry incFilesystemEntry = new CIncludePathEntry(incFilesystem, 0); List entries = new ArrayList(); @@ -511,12 +529,13 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // change drive on build working directory String buildCwdDevice = project.getLocation().getDevice(); -// // Test manually with a device which is different from project location device (path should exist) -// IPath buildCWD = new Path("D:/build/path"); -// String buildCwdDevice = buildCWD.getDevice(); + // Test manually with a device which is different from project location device (path should exist) + // IPath buildCWD = new Path("D:/build/path"); + // String buildCwdDevice = buildCWD.getDevice(); // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -560,15 +579,17 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(prjName); String relativePath = "include"; IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir"); - IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/"+relativePath); - IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/"+prjName); + IFolder relativeFolder = ResourceHelper.createFolder(project, "buildDir/" + relativePath); + IFolder relativeFolderProjName = ResourceHelper.createFolder(project, "buildDir/" + prjName); String markedResolved = "-MarkedResolved"; - IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, "buildDir/" + prjName+markedResolved); - IPath buildCWD=buildFolder.getLocation(); + IFolder relativeFolderProjNameResolved = ResourceHelper.createFolder(project, + "buildDir/" + prjName + markedResolved); + IPath buildCWD = buildFolder.getLocation(); setBuilderCWD(project, buildCWD); // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -580,7 +601,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // contribute the entries CIncludePathEntry incRelativeEntry = new CIncludePathEntry(new Path(relativePath), 0); CIncludePathEntry incProjNameEntry = new CIncludePathEntry(new Path("${ProjName}"), 0); - CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry(new Path("${ProjName}"+markedResolved), ICSettingEntry.RESOLVED); + CIncludePathEntry incProjNameMarkedResolvedEntry = new CIncludePathEntry( + new Path("${ProjName}" + markedResolved), ICSettingEntry.RESOLVED); List entries = new ArrayList(); entries.add(incRelativeEntry); entries.add(incProjNameEntry); @@ -609,7 +631,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { assertEquals(new Path(prjName), new Path(actualIncludePaths[3])); // if marked RESOLVED only that path stays - assertEquals(new Path("${ProjName}"+markedResolved), new Path(actualIncludePaths[4])); + assertEquals(new Path("${ProjName}" + markedResolved), new Path(actualIncludePaths[4])); assertEquals(5, actualIncludePaths.length); } @@ -622,7 +644,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); // set build CWD IFolder buildFolder = ResourceHelper.createFolder(project, "buildDir"); - IPath buildCWD=buildFolder.getLocation(); + IPath buildCWD = buildFolder.getLocation(); setBuilderCWD(project, buildCWD); // define a few variations of paths @@ -634,11 +656,12 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { String relativePath_dotdot_slash = "../"; String relativePath_dotdot_slash_path = "../include"; IFolder relativeFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include"); - String locationPath_dotdot_path = buildCWD.toString()+"/../include2"; + String locationPath_dotdot_path = buildCWD.toString() + "/../include2"; IFolder incFolder_dotdot_slash_path = ResourceHelper.createFolder(project, "include2"); // "/ProjPath/buildDir/../include2" // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -649,13 +672,17 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // contribute the entries CIncludePathEntry incRelativeEntry_dot = new CIncludePathEntry(new Path(relativePath_dot), 0); - CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), 0); + CIncludePathEntry incRelativeEntry_dot_slash_path = new CIncludePathEntry(new Path(relativePath_dot_slash_path), + 0); CIncludePathEntry incRelativeEntry_dotdot = new CIncludePathEntry(new Path(relativePath_dotdot), 0); - CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry(new Path(relativePath_dotdot_slash_path), 0); + CIncludePathEntry incRelativeEntry_dotdot_slash_path = new CIncludePathEntry( + new Path(relativePath_dotdot_slash_path), 0); CIncludePathEntry incEntry_dotdot_path = new CIncludePathEntry(locationPath_dotdot_path, 0); // use LOCAL flag not to clash with plain dot entries - CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), ICSettingEntry.LOCAL); - CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), ICSettingEntry.LOCAL); + CIncludePathEntry incRelativeEntry_dotdot_slash = new CIncludePathEntry(new Path(relativePath_dotdot_slash), + ICSettingEntry.LOCAL); + CIncludePathEntry incRelativeEntry_dot_slash = new CIncludePathEntry(new Path(relativePath_dot_slash), + ICSettingEntry.LOCAL); List entries = new ArrayList(); entries.add(incRelativeEntry_dot); @@ -721,7 +748,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { String envPathStr = "${ProjDirPath}/Folder"; // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -768,7 +796,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { } @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { if (this.rc.equals(rc)) return entries; return null; @@ -777,11 +806,14 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); assertTrue(cfgDescription instanceof ILanguageSettingsProvidersKeeper); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + assertNotNull(config); // sample file IFolder parentFolder = ResourceHelper.createFolder(project, "ParentFolder"); @@ -796,8 +828,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { // add provider for parent folder ILanguageSettingsProvider provider = new MockProviderForResource(parentFolder, entries); - assertNull(provider.getSettingEntries(cfgDescription, file, null)); - assertEquals(includePathEntry, provider.getSettingEntries(cfgDescription, parentFolder, null).get(0)); + assertNull(provider.getSettingEntries(config, file, null)); + assertEquals(includePathEntry, provider.getSettingEntries(config, parentFolder, null).get(0)); List providers = new ArrayList(); providers.add(provider); @@ -825,7 +857,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { String envPathStr = "${ProjDirPath}/Folder"; // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); @@ -871,7 +904,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { List languageIds = new ArrayList(); for (ICLanguageSetting ls : langSettings) { String langId = ls.getLanguageId(); - if (langId!=null && !languageIds.contains(langId)) { + if (langId != null && !languageIds.contains(langId)) { languageIds.add(langId); } } @@ -882,7 +915,7 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { * Test composition of 2 languages. */ public void testResourceLanguages() throws Exception { - class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider { + class MockProviderLang extends LanguageSettingsBaseProvider implements ILanguageSettingsProvider { private final String langId; private final List entries; @@ -893,8 +926,9 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { } @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - if (langId==null || langId.equals(languageId)) + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (langId == null || langId.equals(languageId)) return entries; return new ArrayList(); } @@ -909,7 +943,8 @@ public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { IFolder incFolderC = ResourceHelper.createFolder(project, "includeC"); // get project/configuration descriptions - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, WRITEABLE); + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, + WRITEABLE); assertNotNull(prjDescription); ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); assertNotNull(cfgDescription); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java index 48bad5d2b88..59674cf7b43 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java @@ -14,8 +14,6 @@ package org.eclipse.cdt.core.language.settings.providers; import java.util.ArrayList; import java.util.List; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.settings.model.CIncludeFileEntry; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; import org.eclipse.cdt.core.settings.model.CLibraryFileEntry; @@ -29,15 +27,21 @@ import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.ResourceHelper; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.XmlUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; +import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.w3c.dom.Document; import org.w3c.dom.Element; +import junit.framework.TestSuite; + /** * Test cases testing serialization of LanguageSettingsProviders. */ @@ -67,7 +71,9 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { /** * Constructor. - * @param name - name of the test. + * + * @param name + * - name of the test. */ public LanguageSettingsSerializableProviderTests(String name) { super(name); @@ -77,6 +83,18 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { @Override protected void setUp() throws Exception { super.setUp(); + Platform.getAdapterManager().registerAdapters(new IAdapterFactory() { + @Override + public T getAdapter(Object adaptableObject, Class adapterType) { + CModelMock.DummyCConfigurationDescription cfgDesc = (CModelMock.DummyCConfigurationDescription) adaptableObject; + return (T) new CModelMock.DummyBuildConfiguration(cfgDesc); + } + + @Override + public Class[] getAdapterList() { + return new Class[] { IBuildConfiguration.class }; + } + }, CModelMock.DummyCConfigurationDescription.class); } @Override @@ -94,7 +112,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { /** * main function of the class. * - * @param args - arguments + * @param args + * - arguments */ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); @@ -111,7 +130,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { languages.add(LANG_ID); // create a provider - LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider mockProvider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); // test isEmpty() assertTrue(mockProvider.isEmpty()); @@ -144,7 +164,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { */ public void testProvider_SetStoringEntriesInProjectArea() throws Exception { // create a provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true); @@ -160,7 +181,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create customized provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true); provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); @@ -191,12 +213,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER)); assertNotNull(provider.getLanguageScope()); - assertTrue(provider.getLanguageScope().size()>0); + assertTrue(provider.getLanguageScope().size() > 0); assertEquals(LANG_ID, provider.getLanguageScope().get(0)); List entries = provider.getSettingEntries(null, null, null); assertNotNull(entries); - assertTrue(entries.size()>0); + assertTrue(entries.size() > 0); assertEquals(new CIncludePathEntry("path0", 1), entries.get(0)); } } @@ -208,7 +230,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create customized provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true); provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); @@ -241,7 +264,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER)); assertNotNull(provider.getLanguageScope()); - assertTrue(provider.getLanguageScope().size()>0); + assertTrue(provider.getLanguageScope().size() > 0); assertEquals(LANG_ID, provider.getLanguageScope().get(0)); // no entries should be loaded List entries = provider.getSettingEntries(null, null, null); @@ -256,7 +279,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element rootElement; { // create customized provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true); provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); @@ -284,20 +308,21 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { } { // re-load and check language settings of the newly loaded provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_2, PROVIDER_NAME_2); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_2, + PROVIDER_NAME_2); provider.loadEntries(rootElement); assertEquals(PROVIDER_2, provider.getId()); assertEquals(PROVIDER_NAME_2, provider.getName()); // no attributes should be loaded assertFalse(PROVIDER_1.equals(provider.getId())); assertFalse(PROVIDER_NAME_1.equals(provider.getName())); - assertFalse(true==LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); + assertFalse(true == LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); assertFalse(VALUE_PARAMETER.equals(provider.getProperty(ATTR_PARAMETER))); assertNull(provider.getLanguageScope()); // entries should be loaded List entries = provider.getSettingEntries(null, null, null); assertNotNull(entries); - assertTrue(entries.size()>0); + assertTrue(entries.size() > 0); assertEquals(new CIncludePathEntry("path0", 1), entries.get(0)); } } @@ -309,7 +334,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create null provider - LanguageSettingsSerializableProvider providerNull = new LanguageSettingsSerializableProvider(PROVIDER_NULL, PROVIDER_NAME_NULL); + LanguageSettingsSerializableProvider providerNull = new LanguageSettingsSerializableProvider(PROVIDER_NULL, + PROVIDER_NAME_NULL); assertNull(providerNull.getSettingEntries(null, null, null)); // set and get null entries providerNull.setSettingEntries(null, null, null, null); @@ -337,7 +363,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create provider with custom parameter - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); assertEquals(VALUE_PARAMETER, provider.getProperty(ATTR_PARAMETER)); @@ -361,7 +388,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create provider storing entries in project area - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); LanguageSettingsManager.setStoringEntriesInProjectArea(provider, true); assertEquals(true, LanguageSettingsManager.isStoringEntriesInProjectArea(provider)); @@ -371,7 +399,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { elementProvider = provider.serialize(rootElement); String xmlString = XmlUtil.toString(doc); assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT)); - assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT+"=\"true\"")); + assertTrue(xmlString.contains(ATTR_STORE_ENTRIES_WITH_PROJECT + "=\"true\"")); } { // re-load and check storing mode of the newly loaded provider @@ -391,7 +419,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create provider with custom language scope - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setLanguageScope(expectedLanguageIds); List actualIds = provider.getLanguageScope(); assertEquals(LANG_ID, actualIds.get(0)); @@ -431,7 +460,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element elementProvider; { // create provider with no scope by default - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); // set entries for the whole language scope (now langId=null) provider.setSettingEntries(null, null, null, entries); { @@ -511,7 +541,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, MOCK_RC, LANG_ID, entries); Document doc = XmlUtil.newDocument(); @@ -536,13 +567,16 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { */ public void testNullLanguageDOM() throws Exception { // provider/configuration/language/resource/settingEntry + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); Element elementProvider; List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); - provider.setSettingEntries(MOCK_CFG, MOCK_RC, null, entries); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); + provider.setSettingEntries(config, MOCK_RC, null, entries); Document doc = XmlUtil.newDocument(); Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST); @@ -556,12 +590,11 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { // re-load and check language settings of the newly loaded provider LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(elementProvider); assertEquals(PROVIDER_1, provider.getId()); - List actual = provider.getSettingEntries(MOCK_CFG, MOCK_RC, null); + List actual = provider.getSettingEntries(config, MOCK_RC, null); assertEquals(entries.get(0), actual.get(0)); } } - /** * Test serialization of entries when language scope is null. */ @@ -572,11 +605,15 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List entriesLanguage = new ArrayList(); entriesLanguage.add(new CIncludePathEntry("path", 0)); + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); + Element elementProvider; { // create a provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); assertEquals(null, provider.getLanguageScope()); // add null language @@ -596,7 +633,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { } // add non-null language - provider.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, entriesLanguage); + provider.setSettingEntries(config, MOCK_RC, LANG_ID, entriesLanguage); assertNull(provider.getLanguageScope()); { // getter by null language @@ -644,12 +681,15 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { public void testNullResourceDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); - provider.setSettingEntries(MOCK_CFG, null, LANG_ID, entries); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); + provider.setSettingEntries(config, null, LANG_ID, entries); Document doc = XmlUtil.newDocument(); Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST); @@ -663,7 +703,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { // re-load and check language settings of the newly loaded provider LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(elementProvider); assertEquals(PROVIDER_1, provider.getId()); - List actual = provider.getSettingEntries(MOCK_CFG, null, LANG_ID); + List actual = provider.getSettingEntries(config, null, LANG_ID); assertEquals(entries.get(0), actual.get(0)); } } @@ -678,7 +718,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, MOCK_RC, null, entries); Document doc = XmlUtil.newDocument(); @@ -709,7 +750,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, LANG_ID, entries); Document doc = XmlUtil.newDocument(); @@ -736,12 +778,15 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { public void testNullLanguageResourceDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 0)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); - provider.setSettingEntries(MOCK_CFG, null, null, entries); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); + provider.setSettingEntries(config, null, null, entries); Document doc = XmlUtil.newDocument(); Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST); @@ -756,7 +801,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { // re-load and check language settings of the newly loaded provider LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(elementProvider); assertEquals(PROVIDER_1, provider.getId()); - List actual = provider.getSettingEntries(MOCK_CFG, null, null); + List actual = provider.getSettingEntries(config, null, null); assertEquals(entries.get(0), actual.get(0)); } } @@ -772,7 +817,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", flag)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -804,7 +850,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludePathEntry("path0", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -820,7 +867,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CIncludePathEntry); - CIncludePathEntry includePathEntry = (CIncludePathEntry)entry; + CIncludePathEntry includePathEntry = (CIncludePathEntry) entry; assertEquals(entries.get(0).getName(), includePathEntry.getName()); assertEquals(entries.get(0).getValue(), includePathEntry.getValue()); assertEquals(entries.get(0).getKind(), includePathEntry.getKind()); @@ -838,7 +885,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CIncludeFileEntry("a-path", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -853,7 +901,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List actual = provider.getSettingEntries(null, null, null); ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CIncludeFileEntry); - CIncludeFileEntry includeFileEntry = (CIncludeFileEntry)entry; + CIncludeFileEntry includeFileEntry = (CIncludeFileEntry) entry; assertEquals(entries.get(0).getName(), includeFileEntry.getName()); assertEquals(entries.get(0).getValue(), includeFileEntry.getValue()); assertEquals(entries.get(0).getKind(), includeFileEntry.getKind()); @@ -868,10 +916,11 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { public void testCMacroEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList(); - entries.add(new CMacroEntry("MACRO0", "value0",1)); + entries.add(new CMacroEntry("MACRO0", "value0", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -886,7 +935,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List actual = provider.getSettingEntries(null, null, null); ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CMacroEntry); - CMacroEntry macroEntry = (CMacroEntry)entry; + CMacroEntry macroEntry = (CMacroEntry) entry; assertEquals(entries.get(0).getName(), macroEntry.getName()); assertEquals(entries.get(0).getValue(), macroEntry.getValue()); assertEquals(entries.get(0).getKind(), macroEntry.getKind()); @@ -904,7 +953,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CMacroFileEntry("a-path", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -919,7 +969,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List actual = provider.getSettingEntries(null, null, null); ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CMacroFileEntry); - CMacroFileEntry macroFileEntry = (CMacroFileEntry)entry; + CMacroFileEntry macroFileEntry = (CMacroFileEntry) entry; assertEquals(entries.get(0).getName(), macroFileEntry.getName()); assertEquals(entries.get(0).getValue(), macroFileEntry.getValue()); assertEquals(entries.get(0).getKind(), macroFileEntry.getKind()); @@ -937,7 +987,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CLibraryPathEntry("a-path", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -952,7 +1003,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List actual = provider.getSettingEntries(null, null, null); ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CLibraryPathEntry); - CLibraryPathEntry libraryPathEntry = (CLibraryPathEntry)entry; + CLibraryPathEntry libraryPathEntry = (CLibraryPathEntry) entry; assertEquals(entries.get(0).getName(), libraryPathEntry.getName()); assertEquals(entries.get(0).getValue(), libraryPathEntry.getValue()); assertEquals(entries.get(0).getKind(), libraryPathEntry.getKind()); @@ -970,7 +1021,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { entries.add(new CLibraryFileEntry("a-path", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -985,7 +1037,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List actual = provider.getSettingEntries(null, null, null); ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CLibraryFileEntry); - CLibraryFileEntry libraryFileEntry = (CLibraryFileEntry)entry; + CLibraryFileEntry libraryFileEntry = (CLibraryFileEntry) entry; assertEquals(entries.get(0).getName(), libraryFileEntry.getName()); assertEquals(entries.get(0).getValue(), libraryFileEntry.getValue()); assertEquals(entries.get(0).getKind(), libraryFileEntry.getKind()); @@ -1002,10 +1054,11 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", 1)); entries.add(new CIncludePathEntry("path1", 1)); - entries.add(new CMacroEntry("MACRO0", "value0",1)); + entries.add(new CMacroEntry("MACRO0", "value0", 1)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -1033,17 +1086,17 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { List entries = new ArrayList(); entries.add(new CIncludePathEntry("path0", ICSettingEntry.BUILTIN - | ICSettingEntry.READONLY - | ICSettingEntry.LOCAL - | ICSettingEntry.VALUE_WORKSPACE_PATH - | ICSettingEntry.RESOLVED - | ICSettingEntry.UNDEFINED - | ICSettingEntry.FRAMEWORKS_MAC - | ICSettingEntry.EXPORTED - )); + | ICSettingEntry.READONLY + | ICSettingEntry.LOCAL + | ICSettingEntry.VALUE_WORKSPACE_PATH + | ICSettingEntry.RESOLVED + | ICSettingEntry.UNDEFINED + | ICSettingEntry.FRAMEWORKS_MAC + | ICSettingEntry.EXPORTED)); { // create a provider and serialize its settings - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, entries); Document doc = XmlUtil.newDocument(); @@ -1059,7 +1112,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { ICLanguageSettingEntry entry = actual.get(0); assertTrue(entry instanceof CIncludePathEntry); - CIncludePathEntry includePathEntry = (CIncludePathEntry)entry; + CIncludePathEntry includePathEntry = (CIncludePathEntry) entry; assertEquals(entries.get(0).getName(), includePathEntry.getName()); assertEquals(entries.get(0).getValue(), includePathEntry.getValue()); assertEquals(entries.get(0).getKind(), includePathEntry.getKind()); @@ -1093,7 +1146,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { } { // re-load and check language settings of the newly loaded provider - LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider); + LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider( + elementProvider); List actual = loadedProvider.getSettingEntries(null, null, null); assertEquals(entries.get(0), actual.get(0)); @@ -1128,11 +1182,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST); elementProvider = mockProvider.serialize(rootElement); String xml = XmlUtil.toString(elementProvider.getOwnerDocument()); -// fail(xml); // for debugging + // fail(xml); // for debugging } { // re-load and check language settings of the newly loaded provider - LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider); + LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider( + elementProvider); List actual = loadedProvider.getSettingEntries(null, null, LANG_ID_1); assertEquals(entries.get(0), actual.get(0)); @@ -1175,11 +1230,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { Element rootElement = XmlUtil.appendElement(doc, ELEM_TEST); elementProvider = mockProvider.serialize(rootElement); String xml = XmlUtil.toString(elementProvider.getOwnerDocument()); -// fail(xml); // for debugging + // fail(xml); // for debugging } { // re-load and check language settings of the newly loaded provider - LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider(elementProvider); + LanguageSettingsSerializableProvider loadedProvider = new LanguageSettingsSerializableProvider( + elementProvider); List actual = loadedProvider.getSettingEntries(null, rc1, null); assertEquals(entries.get(0), actual.get(0)); @@ -1205,7 +1261,8 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { assertNotNull(emptySettingsPath); // Create provider - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); // store the entries in parent folder List entries = new ArrayList(); @@ -1216,7 +1273,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { { // retrieve entries for a parent folder itself List actual = provider.getSettingEntries(null, parentFolder, LANG_ID); - assertEquals(entries,actual); + assertEquals(entries, actual); assertEquals(entries.size(), actual.size()); } @@ -1225,14 +1282,15 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { IFile derived = ResourceHelper.createFile(project, "/ParentFolder/Subfolder/resource"); List actual = provider.getSettingEntries(null, derived, LANG_ID); // NOT taken from parent folder - assertEquals(null,actual); + assertEquals(null, actual); } { // retrieve entries for not related resource - IFile notRelated = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/AnotherFolder/Subfolder/resource")); + IFile notRelated = ResourcesPlugin.getWorkspace().getRoot() + .getFile(new Path("/AnotherFolder/Subfolder/resource")); List actual = provider.getSettingEntries(null, notRelated, LANG_ID); - assertEquals(null,actual); + assertEquals(null, actual); } { @@ -1247,9 +1305,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { * Test equals() and hashCode(). */ public void testEquals() throws Exception { + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); + // create sample entries List sampleEntries_1 = new ArrayList(); - sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1)); + sampleEntries_1.add(new CMacroEntry("MACRO0", "value0", 1)); sampleEntries_1.add(new CIncludePathEntry("path0", 1)); sampleEntries_1.add(new CIncludePathEntry("path1", 1)); @@ -1261,46 +1322,48 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { sampleLanguages.add(LANG_ID); // create a model provider - LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider1.setLanguageScope(sampleLanguages); provider1.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider1)); LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, true); - provider1.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1); + provider1.setSettingEntries(config, MOCK_RC, LANG_ID, sampleEntries_1); provider1.setSettingEntries(null, null, LANG_ID, sampleEntries_2); // create another provider with the same data - LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); { provider2.setLanguageScope(sampleLanguages); provider2.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, true); - provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1); + provider2.setSettingEntries(config, MOCK_RC, LANG_ID, sampleEntries_1); provider2.setSettingEntries(null, null, LANG_ID, sampleEntries_2); // All set now, so they should be equal - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // start with provider with the same data - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); // replace languages List sampleLanguages2 = new ArrayList(); sampleLanguages2.add(LANG_ID_1); provider2.setLanguageScope(sampleLanguages2); - assertFalse(provider1.hashCode()==provider2.hashCode()); + assertFalse(provider1.hashCode() == provider2.hashCode()); assertFalse(provider1.equals(provider2)); // restore provider provider2.setLanguageScope(sampleLanguages); - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // start with provider with the same data - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); // replace property provider2.setProperty(ATTR_PARAMETER, "changed-parameter"); @@ -1308,12 +1371,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { assertFalse(provider1.equals(provider2)); // restore provider provider2.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // start with provider with the same data - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); // replace property LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, false); @@ -1321,45 +1384,47 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { assertFalse(provider1.equals(provider2)); // restore provider LanguageSettingsManager.setStoringEntriesInProjectArea(provider2, true); - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // start with provider with the same data - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); // replace entries List changedEntries = new ArrayList(); - changedEntries.add(new CMacroEntry("MACROX", "valueX",1)); - provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, changedEntries); - assertFalse(provider1.hashCode()==provider2.hashCode()); + changedEntries.add(new CMacroEntry("MACROX", "valueX", 1)); + provider2.setSettingEntries(config, MOCK_RC, LANG_ID, changedEntries); + assertFalse(provider1.hashCode() == provider2.hashCode()); assertFalse(provider1.equals(provider2)); // restore provider - provider2.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1); - assertTrue(provider1.hashCode()==provider2.hashCode()); + provider2.setSettingEntries(config, MOCK_RC, LANG_ID, sampleEntries_1); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // start with provider with the same data - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); // replace default entries List changedEntries = new ArrayList(); changedEntries.add(new CIncludePathEntry("pathX", 1)); provider2.setSettingEntries(null, null, LANG_ID, changedEntries); - assertFalse(provider1.hashCode()==provider2.hashCode()); + assertFalse(provider1.hashCode() == provider2.hashCode()); assertFalse(provider1.equals(provider2)); // restore provider provider2.setSettingEntries(null, null, LANG_ID, sampleEntries_2); - assertTrue(provider1.hashCode()==provider2.hashCode()); + assertTrue(provider1.hashCode() == provider2.hashCode()); assertTrue(provider1.equals(provider2)); } { // check that subclasses are not equal - LanguageSettingsSerializableProvider providerSub1 = new LanguageSettingsSerializableProvider() {}; - LanguageSettingsSerializableProvider providerSub2 = new LanguageSettingsSerializableProvider() {}; - assertFalse(providerSub1.hashCode()==providerSub2.hashCode()); + LanguageSettingsSerializableProvider providerSub1 = new LanguageSettingsSerializableProvider() { + }; + LanguageSettingsSerializableProvider providerSub2 = new LanguageSettingsSerializableProvider() { + }; + assertFalse(providerSub1.hashCode() == providerSub2.hashCode()); assertFalse(providerSub1.equals(providerSub2)); } } @@ -1369,8 +1434,10 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { */ public void testEquals_DefaultProperties() throws Exception { // create model providers - LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); - LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider2 = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); // equality for setProperty(String, String) { @@ -1415,11 +1482,14 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { * Test cloning of provider. */ public void testClone() throws Exception { + IBuildConfiguration config = Adapters.adapt(MOCK_CFG, IBuildConfiguration.class); + assertNotNull(config); + // define sample data List sampleEntries_1 = new ArrayList(); sampleEntries_1.add(new CIncludePathEntry("path0", 1)); sampleEntries_1.add(new CIncludePathEntry("path1", 1)); - sampleEntries_1.add(new CMacroEntry("MACRO0", "value0",1)); + sampleEntries_1.add(new CMacroEntry("MACRO0", "value0", 1)); List sampleEntries_2 = new ArrayList(); sampleEntries_2.add(new CIncludePathEntry("path0", 1)); @@ -1432,6 +1502,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { public MockSerializableProvider(String id, String name) { super(id, name); } + @Override public MockSerializableProvider clone() throws CloneNotSupportedException { return (MockSerializableProvider) super.clone(); @@ -1443,28 +1514,31 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { provider1.setProperty(ATTR_PARAMETER, VALUE_PARAMETER); assertEquals(false, LanguageSettingsManager.isStoringEntriesInProjectArea(provider1)); LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, true); - provider1.setSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID, sampleEntries_1); + provider1.setSettingEntries(config, MOCK_RC, LANG_ID, sampleEntries_1); provider1.setSettingEntries(null, null, LANG_ID, sampleEntries_2); // clone provider MockSerializableProvider providerClone = provider1.clone(); assertNotSame(provider1, providerClone); assertTrue(provider1.equals(providerClone)); - assertTrue(provider1.getClass()==providerClone.getClass()); + assertTrue(provider1.getClass() == providerClone.getClass()); assertEquals(provider1.getProperty(ATTR_PARAMETER), providerClone.getProperty(ATTR_PARAMETER)); // ensure we did not clone reference provider1.setProperty(ATTR_PARAMETER, ""); assertFalse(provider1.getProperty(ATTR_PARAMETER).equals(providerClone.getProperty(ATTR_PARAMETER))); - assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); + assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), + LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); // ensure we did not clone reference - LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, !LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); - assertFalse(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1) == LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); + LanguageSettingsManager.setStoringEntriesInProjectArea(provider1, + !LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); + assertFalse(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1) == LanguageSettingsManager + .isStoringEntriesInProjectArea(providerClone)); assertEquals(provider1.getLanguageScope().get(0), providerClone.getLanguageScope().get(0)); - List actual1 = providerClone.getSettingEntries(MOCK_CFG, MOCK_RC, LANG_ID); + List actual1 = providerClone.getSettingEntries(config, MOCK_RC, LANG_ID); assertNotSame(sampleEntries_1, actual1); assertEquals(sampleEntries_1.get(0), actual1.get(0)); assertEquals(sampleEntries_1.get(1), actual1.get(1)); @@ -1490,6 +1564,7 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { public MockSerializableProvider(String id, String name) { super(id, name); } + @Override public MockSerializableProvider cloneShallow() throws CloneNotSupportedException { return (MockSerializableProvider) super.cloneShallow(); @@ -1510,9 +1585,10 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { MockSerializableProvider providerClone = provider1.cloneShallow(); assertNotSame(provider1, providerClone); assertFalse(provider1.equals(providerClone)); - assertTrue(provider1.getClass()==providerClone.getClass()); + assertTrue(provider1.getClass() == providerClone.getClass()); assertEquals(provider1.getProperty(ATTR_PARAMETER), providerClone.getProperty(ATTR_PARAMETER)); - assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); + assertEquals(LanguageSettingsManager.isStoringEntriesInProjectArea(provider1), + LanguageSettingsManager.isStoringEntriesInProjectArea(providerClone)); assertEquals(provider1.getLanguageScope().get(0), providerClone.getLanguageScope().get(0)); List actual = providerClone.getSettingEntries(null, null, null); @@ -1553,11 +1629,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { unsortedEntries.add(libraryPathEntry2); // create a provider and set the entries - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, unsortedEntries); // retrieve and check that language settings got sorted properly - int i=0; + int i = 0; List actual = provider.getSettingEntries(null, null, null); assertEquals(includePathEntry1, actual.get(i++)); assertEquals(includePathEntry2, actual.get(i++)); @@ -1611,11 +1688,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { unsortedEntries.add(libraryPathEntry2); // create a provider and set the entries - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, unsortedEntries); // retrieve and check that language settings got sorted properly - int i=0; + int i = 0; List actual = provider.getSettingEntries(null, null, null); assertEquals(includePathEntry1, actual.get(i++)); assertEquals(includePathEntry2, actual.get(i++)); @@ -1654,11 +1732,12 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { unsortedEntries.add(macroEntry2C); // create a provider and set the entries - LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, PROVIDER_NAME_1); + LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, + PROVIDER_NAME_1); provider.setSettingEntries(null, null, null, unsortedEntries); // retrieve and check that language settings got sorted properly - int i=0; + int i = 0; List actual = provider.getSettingEntries(null, null, null); assertEquals(macroEntry1, actual.get(i++)); assertEquals(macroEntry2A, actual.get(i++)); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java index ca1dd40b390..925f4f294eb 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/MockLanguageSettingsProvider.java @@ -14,8 +14,8 @@ package org.eclipse.cdt.core.language.settings.providers; import java.util.List; import org.eclipse.cdt.core.AbstractExecutableExtensionBase; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; /** @@ -23,7 +23,7 @@ import org.eclipse.core.resources.IResource; */ public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, String languageId) { return null; } } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java index a6c0a5d2551..75e7a346a5c 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/CModelMock.java @@ -32,6 +32,7 @@ import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -42,8 +43,8 @@ import org.eclipse.core.runtime.QualifiedName; */ public class CModelMock { /** - * Dummy implementation of ICProjectDescription for testing. - * Feel free to override the methods you are interested to mock. + * Dummy implementation of ICProjectDescription for testing. Feel free to + * override the methods you are interested to mock. */ public static class DummyCProjectDescription implements ICProjectDescription { @@ -88,8 +89,7 @@ public class CModelMock { } @Override - public ICStorageElement getStorage(String id, boolean create) - throws CoreException { + public ICStorageElement getStorage(String id, boolean create) throws CoreException { return null; } @@ -136,20 +136,17 @@ public class CModelMock { } @Override - public void setActiveConfiguration(ICConfigurationDescription cfg) - throws WriteAccessException { + public void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { } @Override - public ICConfigurationDescription createConfiguration(String id, - String name, ICConfigurationDescription base) + public ICConfigurationDescription createConfiguration(String id, String name, ICConfigurationDescription base) throws CoreException, WriteAccessException { return null; } @Override - public ICConfigurationDescription createConfiguration( - String buildSystemId, CConfigurationData data) + public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException, WriteAccessException { return null; } @@ -165,13 +162,11 @@ public class CModelMock { } @Override - public void removeConfiguration(String name) - throws WriteAccessException { + public void removeConfiguration(String name) throws WriteAccessException { } @Override - public void removeConfiguration(ICConfigurationDescription cfg) - throws WriteAccessException { + public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { } @Override @@ -200,8 +195,7 @@ public class CModelMock { } @Override - public void setDefaultSettingConfiguration( - ICConfigurationDescription cfg) { + public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) { } @Override @@ -216,8 +210,8 @@ public class CModelMock { } /** - * Dummy implementation of ICConfigurationDescription for testing. - * Feel free to override the methods you are interested to mock. + * Dummy implementation of ICConfigurationDescription for testing. Feel free + * to override the methods you are interested to mock. */ public static class DummyCConfigurationDescription implements ICConfigurationDescription { private String id; @@ -267,8 +261,7 @@ public class CModelMock { } @Override - public ICStorageElement getStorage(String id, boolean create) - throws CoreException { + public ICStorageElement getStorage(String id, boolean create) throws CoreException { return null; } @@ -326,27 +319,23 @@ public class CModelMock { } @Override - public ICResourceDescription getResourceDescription(IPath path, - boolean exactPath) { + public ICResourceDescription getResourceDescription(IPath path, boolean exactPath) { return null; } @Override - public void removeResourceDescription(ICResourceDescription des) + public void removeResourceDescription(ICResourceDescription des) throws CoreException, WriteAccessException { + } + + @Override + public ICFileDescription createFileDescription(IPath path, ICResourceDescription base) throws CoreException, WriteAccessException { - } - - @Override - public ICFileDescription createFileDescription(IPath path, - ICResourceDescription base) throws CoreException, - WriteAccessException { return null; } @Override - public ICFolderDescription createFolderDescription(IPath path, - ICFolderDescription base) throws CoreException, - WriteAccessException { + public ICFolderDescription createFolderDescription(IPath path, ICFolderDescription base) + throws CoreException, WriteAccessException { return null; } @@ -407,9 +396,8 @@ public class CModelMock { } @Override - public ICExternalSetting createExternalSetting(String[] languageIDs, - String[] contentTypeIds, String[] extensions, - ICSettingEntry[] entries) throws WriteAccessException { + public ICExternalSetting createExternalSetting(String[] languageIDs, String[] contentTypeIds, + String[] extensions, ICSettingEntry[] entries) throws WriteAccessException { return null; } @@ -489,6 +477,37 @@ public class CModelMock { public CConfigurationStatus getConfigurationStatus() { return null; } + } + + public static class DummyBuildConfiguration implements IBuildConfiguration { + private final DummyCConfigurationDescription desc; + + public DummyBuildConfiguration(DummyCConfigurationDescription desc) { + this.desc = desc; + } + + @Override + public T getAdapter(Class adapter) { + if (adapter.isInstance(desc)) { + return (T) desc; + } + return null; + } + + @Override + public IProject getProject() { + ICProjectDescription projDesc = desc.getProjectDescription(); + if (projDesc != null) { + return projDesc.getProject(); + } else { + return null; + } + } + + @Override + public String getName() { + return desc.getName(); + } } } diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs index 62448898674..7e765d82911 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs @@ -78,287 +78,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -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 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -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_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -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_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=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 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -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_package=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 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -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_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 -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -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.format_block_comments=true -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_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -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_and_in_type_parameter=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_closing_angle_bracket_in_type_arguments=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 -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -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_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_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -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_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_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=110 -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_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -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.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs index 59ca621b2ed..6a961f809e1 100644 --- a/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.ui.prefs @@ -1,4 +1,3 @@ eclipse.preferences.version=1 -formatter_profile=_CDT formatter_settings_version=12 internal.default.compliance=user diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsBroadcastingProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsBroadcastingProvider.java index 42e46c71e8b..6081b024f46 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsBroadcastingProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsBroadcastingProvider.java @@ -10,32 +10,21 @@ *******************************************************************************/ package org.eclipse.cdt.core.language.settings.providers; -import java.util.List; - -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; -import org.eclipse.core.resources.IResource; - /** - * This interface is to be implemented by providers which want to broadcast the changes in their setting entries - * with {@link ILanguageSettingsChangeEvent}. + * This interface is to be implemented by providers which want to broadcast the changes in their + * setting entries with {@link ILanguageSettingsChangeEvent}. * * @since 5.4 */ public interface ILanguageSettingsBroadcastingProvider extends ILanguageSettingsProvider { - @Override - public String getId(); - @Override - public String getName(); - @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId); /** - * Return a copy of internal storage. This should be a deep copy/clone of the storage. - * It is used to calculate the delta and being kept in the last state object of configuration + * Return a copy of internal storage. This should be a deep copy/clone of the storage. It is + * used to calculate the delta and being kept in the last state object of configuration * description to compare to a new state later. * * @return a copy of internal storage. */ public LanguageSettingsStorage copyStorage(); + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsEditableProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsEditableProvider.java index df78d584fa2..e0f553e315a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsEditableProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsEditableProvider.java @@ -14,42 +14,67 @@ import java.util.List; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; /** * This interface is used in UI to identify classes allowing user to modify settings externally - * contrary to some subclasses of {@link LanguageSettingsSerializableProvider} managing - * their settings themselves and not providing such option to the user. + * contrary to some subclasses of {@link LanguageSettingsSerializableProvider} managing their + * settings themselves and not providing such option to the user. * * @since 5.4 */ public interface ILanguageSettingsEditableProvider extends ILanguageSettingsBroadcastingProvider, Cloneable { - @Override - public String getId(); - @Override - public String getName(); - @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId); /** * Sets language settings entries for the provider. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. If {@code null} the entries are - * considered to be being defined as default entries for resources. - * @param languageId - language id. If {@code null}, then entries are considered - * to be defined as default entries for languages. - * @param entries - language settings entries to set. + * @param config + * configuration. + * @param rc + * resource such as file or folder. If {@code null} the entries are considered to be + * being defined as default entries for resources. + * @param languageId + * language id. If {@code null}, then entries are considered to be defined as default + * entries for languages. + * @param entries + * language settings entries to set. + * @since 6.0 */ - public void setSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId, - List entries); + default public void setSettingEntries(IBuildConfiguration config, IResource rc, String languageId, + List entries) { + // Call the old method by default + setSettingEntries(config.getAdapter(ICConfigurationDescription.class), rc, languageId, entries); + } /** - * Shallow clone of the provider. "Shallow" is defined here as the exact copy except that - * the copy will have zero language settings entries. + * Sets language settings entries for the provider. + * + * @param cfgDescription + * configuration description. + * @param rc + * resource such as file or folder. If {@code null} the entries are considered to be + * being defined as default entries for resources. + * @param languageId + * language id. If {@code null}, then entries are considered to be defined as default + * entries for languages. + * @param entries + * language settings entries to set. + * @deprecated use {@link #getSettingEntries(IBuildConfiguration, IResource, String)} + */ + @Deprecated + default public void setSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId, + List entries) { + // Do nothing by default + } + + /** + * Shallow clone of the provider. "Shallow" is defined here as the exact copy except that the + * copy will have zero language settings entries. * * @return shallow copy of the provider. - * @throws CloneNotSupportedException in case {@link #clone()} throws the exception. + * @throws CloneNotSupportedException + * in case {@link #clone()} throws the exception. */ public ILanguageSettingsEditableProvider cloneShallow() throws CloneNotSupportedException; @@ -57,4 +82,5 @@ public interface ILanguageSettingsEditableProvider extends ILanguageSettingsBroa * @see Object#clone() */ public ILanguageSettingsEditableProvider clone() throws CloneNotSupportedException; + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvider.java index 3a147be9019..0c0e4e26270 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/ILanguageSettingsProvider.java @@ -17,35 +17,36 @@ import org.eclipse.cdt.core.model.LanguageManager; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; /** - * Base interface to provide list of {@link ICLanguageSettingEntry}. - * This interface is used to deliver additions to compiler options such as - * include paths (-I) or preprocessor defines (-D) and others (see - * {@link ICSettingEntry#INCLUDE_PATH} and other kinds). - *

+ * Base interface to provide list of {@link ICLanguageSettingEntry}. This interface is used to + * deliver additions to compiler options such as include paths (-I) or preprocessor defines (-D) and + * others (see {@link ICSettingEntry#INCLUDE_PATH} and other kinds).
+ *
* To define a provider like that use extension point - * {@code org.eclipse.cdt.core.LanguageSettingsProvider} and implement this - * interface. The recommended way of implementing is to extend - * {@link LanguageSettingsSerializableProvider} and implement {@link ILanguageSettingsEditableProvider}. - * That will give the ability to persist and edit/clean entries by user in UI. - * The clone methods defined by {@link ILanguageSettingsEditableProvider} should be - * chained as done for example by {@link LanguageSettingsGenericProvider}. - *

- * CDT provides a few general use implementations in the core such as {@link LanguageSettingsBaseProvider} - * or {@link LanguageSettingsSerializableProvider} or {@link LanguageSettingsGenericProvider} - * which could be used out of the box or built upon. There are also abstract classes in build - * plugins {@code AbstractBuildCommandParser} and {@code AbstractBuiltinSpecsDetector} which - * serve as a base for output parsers and built-in compiler language settings detectors. - * See also extension point schema description LanguageSettingsProvider.exsd. + * {@code org.eclipse.cdt.core.LanguageSettingsProvider} and implement this interface. The + * recommended way of implementing is to extend {@link LanguageSettingsSerializableProvider} and + * implement {@link ILanguageSettingsEditableProvider}. That will give the ability to persist and + * edit/clean entries by user in UI. The clone methods defined by + * {@link ILanguageSettingsEditableProvider} should be chained as done for example by + * {@link LanguageSettingsGenericProvider}.
+ *
+ * CDT provides a few general use implementations in the core such as + * {@link LanguageSettingsBaseProvider} or {@link LanguageSettingsSerializableProvider} or + * {@link LanguageSettingsGenericProvider} which could be used out of the box or built upon. There + * are also abstract classes in build plugins {@code AbstractBuildCommandParser} and + * {@code AbstractBuiltinSpecsDetector} which serve as a base for output parsers and built-in + * compiler language settings detectors. See also extension point schema description + * LanguageSettingsProvider.exsd. * * @since 5.4 */ public interface ILanguageSettingsProvider { /** - * Id is used to keep track of the providers internally. Use unique id - * to represent the provider. + * Id is used to keep track of the providers internally. Use unique id to represent the + * provider. * * @return Id of the provider. */ @@ -59,28 +60,72 @@ public interface ILanguageSettingsProvider { public String getName(); /** - * Returns the list of setting entries for the given configuration description, - * resource and language. - *

- * Note to implementers - this method should not be used to do any long running - * operations such as extensive calculations or reading files. If you need to do - * so, the recommended way is to do the calculations outside of - * this function call - in advance and on appropriate event. For example, Build - * Output Parser prepares the list and stores it in internal cache while parsing output. - * {@link #getSettingEntries(ICConfigurationDescription, IResource, String)} will - * return cached entries when asked. You can also implement {@link ICListenerAgent} - * interface to get registered and listen to arbitrary events. + * Returns the list of setting entries for the given configuration description, resource and + * language.
+ *
+ * Note to implementers - this method should not be used to do any long running operations such + * as extensive calculations or reading files. If you need to do so, the recommended way is to + * do the calculations outside of this function call - in advance and on appropriate event. For + * example, Build Output Parser prepares the list and stores it in internal cache while parsing + * output. {@link #getSettingEntries(IBuildConfiguration, IResource, String)} will return cached + * entries when asked. You can also implement {@link ICListenerAgent} interface to get + * registered and listen to arbitrary events. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * If {@code null}, the default entries for all resources are returned. - * @param languageId - language id. - * If {@code null}, the default entries for all languages are returned. - * (see {@link LanguageManager#getLanguageForFile(org.eclipse.core.resources.IFile, ICConfigurationDescription)}). + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. If {@code null}, the default entries for all + * resources are returned. + * @param languageId + * - language id. If {@code null}, the default entries for all languages are + * returned. (see + * {@link LanguageManager#getLanguageForFile(org.eclipse.core.resources.IFile, ICConfigurationDescription)} + * ). * - * @return the list of setting entries or {@code null} if no settings defined. - * The list needs to be a pooled list created by {@link LanguageSettingsStorage#getPooledList(List)} - * to save memory and avoid deep equality comparisons. + * @return the list of setting entries or {@code null} if no settings defined. The list needs to + * be a pooled list created by {@link LanguageSettingsStorage#getPooledList(List)} to + * save memory and avoid deep equality comparisons. + * @since 6.0 */ - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId); + default public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + // call the old one by default + return getSettingEntries(config.getAdapter(ICConfigurationDescription.class), rc, languageId); + } + + /** + * Returns the list of setting entries for the given configuration description, resource and + * language.
+ *
+ * Note to implementers - this method should not be used to do any long running operations such + * as extensive calculations or reading files. If you need to do so, the recommended way is to + * do the calculations outside of this function call - in advance and on appropriate event. For + * example, Build Output Parser prepares the list and stores it in internal cache while parsing + * output. {@link #getSettingEntries(IBuildConfiguration, IResource, String)} will return cached + * entries when asked. You can also implement {@link ICListenerAgent} interface to get + * registered and listen to arbitrary events. + * + * @param cfgDescription + * - configuration description. + * @param rc + * - resource such as file or folder. If {@code null}, the default entries for all + * resources are returned. + * @param languageId + * - language id. If {@code null}, the default entries for all languages are + * returned. (see + * {@link LanguageManager#getLanguageForFile(org.eclipse.core.resources.IFile, ICConfigurationDescription)} + * ). + * + * @return the list of setting entries or {@code null} if no settings defined. The list needs to + * be a pooled list created by {@link LanguageSettingsStorage#getPooledList(List)} to + * save memory and avoid deep equality comparisons. + * @deprecated use {@link #getSettingEntries(IBuildConfiguration, IResource, String)} + */ + @Deprecated + default public List getSettingEntries(ICConfigurationDescription cfgDescription, + IResource rc, String languageId) { + // return null by default + return null; + } + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsBaseProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsBaseProvider.java index 686a0225917..d867ce2997b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsBaseProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsBaseProvider.java @@ -23,19 +23,24 @@ import org.eclipse.cdt.core.AbstractExecutableExtensionBase; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; /** - * {@code LanguageSettingsBaseProvider} is a basic implementation of {@link ILanguageSettingsProvider} - * for the extensions defined by {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. + * {@code LanguageSettingsBaseProvider} is a basic implementation of + * {@link ILanguageSettingsProvider} for the extensions defined by + * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. * - * This implementation supports "static" list of entries for languages specified in - * the extension point. + * This implementation supports "static" list of entries for languages specified in the extension + * point. * * @since 5.4 */ -public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBase implements ILanguageSettingsProvider { - /** Language scope, i.e. list of languages the entries will be provided for. */ +public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBase + implements ILanguageSettingsProvider { + /** + * Language scope, i.e. list of languages the entries will be provided for. + */ protected List languageScope = null; /** Provider-specific properties */ @@ -54,8 +59,10 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas /** * Constructor. Creates an "empty" non-configured provider. * - * @param id - id of the provider. - * @param name - name of the provider to be presented to a user. + * @param id + * - id of the provider. + * @param name + * - name of the provider to be presented to a user. */ public LanguageSettingsBaseProvider(String id, String name) { super(id, name); @@ -64,85 +71,97 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas /** * Constructor. * - * @param id - id of the provider. - * @param name - name of the provider to be presented to a user. - * @param languages - list of languages the {@code entries} provided for. - * {@code languages} can be {@code null}, in this case the {@code entries} - * are provided for any language. - * @param entries - the list of language settings entries this provider provides. - * If {@code null} is passed, the provider creates an empty list. + * @param id + * - id of the provider. + * @param name + * - name of the provider to be presented to a user. + * @param languages + * - list of languages the {@code entries} provided for. {@code languages} can be + * {@code null}, in this case the {@code entries} are provided for any language. + * @param entries + * - the list of language settings entries this provider provides. If {@code null} is + * passed, the provider creates an empty list. */ public LanguageSettingsBaseProvider(String id, String name, List languages, List entries) { super(id, name); - this.languageScope = languages!=null ? new ArrayList(languages) : null; + this.languageScope = languages != null ? new ArrayList(languages) : null; this.entries = getPooledList(entries); } /** * Constructor. * - * @param id - id of the provider. - * @param name - name of the provider to be presented to a user. - * @param languages - list of languages the {@code entries} provided for. - * {@code languages} can be {@code null}, in this case the {@code entries} - * are provided for any language. - * @param entries - the list of language settings entries this provider provides. - * If {@code null} is passed, the provider creates an empty list. - * @param properties - custom properties as the means to customize providers. + * @param id + * - id of the provider. + * @param name + * - name of the provider to be presented to a user. + * @param languages + * - list of languages the {@code entries} provided for. {@code languages} can be + * {@code null}, in this case the {@code entries} are provided for any language. + * @param entries + * - the list of language settings entries this provider provides. If {@code null} is + * passed, the provider creates an empty list. + * @param properties + * - custom properties as the means to customize providers. */ public LanguageSettingsBaseProvider(String id, String name, List languages, List entries, Map properties) { super(id, name); - this.languageScope = languages!=null ? new ArrayList(languages) : null; + this.languageScope = languages != null ? new ArrayList(languages) : null; this.entries = getPooledList(entries); if (properties != null) this.properties = new HashMap(properties); } /** - * A method to configure the provider. The initialization of provider from - * the extension point is done in 2 steps. First, the class is created as - * an executable extension using the default provider. Then this method is - * used to configure the provider. - *

+ * A method to configure the provider. The initialization of provider from the extension point + * is done in 2 steps. First, the class is created as an executable extension using the default + * provider. Then this method is used to configure the provider.
+ *
* It is not allowed to reconfigure the provider. * - * @param id - id of the provider. - * @param name - name of the provider to be presented to a user. - * @param languages - list of languages the {@code entries} provided for. - * {@code languages} can be {@code null}, in this case the {@code entries} - * are provided for any language. - * @param entries - the list of language settings entries this provider provides. - * If {@code null} is passed, the provider creates an empty list. - * @param properties - custom properties as the means to customize providers. + * @param id + * - id of the provider. + * @param name + * - name of the provider to be presented to a user. + * @param languages + * - list of languages the {@code entries} provided for. {@code languages} can be + * {@code null}, in this case the {@code entries} are provided for any language. + * @param entries + * - the list of language settings entries this provider provides. If {@code null} is + * passed, the provider creates an empty list. + * @param properties + * - custom properties as the means to customize providers. * - * @throws UnsupportedOperationException if an attempt to reconfigure provider is made. + * @throws UnsupportedOperationException + * if an attempt to reconfigure provider is made. */ public void configureProvider(String id, String name, List languages, List entries, Map properties) { - if (this.entries!=null || !this.properties.isEmpty()) - throw new UnsupportedOperationException(SettingsModelMessages.getString("LanguageSettingsBaseProvider.CanBeConfiguredOnlyOnce")); //$NON-NLS-1$ + if (this.entries != null || !this.properties.isEmpty()) + throw new UnsupportedOperationException( + SettingsModelMessages.getString("LanguageSettingsBaseProvider.CanBeConfiguredOnlyOnce")); //$NON-NLS-1$ setId(id); setName(name); - this.languageScope = languages!=null ? new ArrayList(languages) : null; + this.languageScope = languages != null ? new ArrayList(languages) : null; this.entries = getPooledList(entries); if (properties != null) this.properties = new HashMap(properties); } /** - * {@code LanguageSettingsBaseProvider} keeps the list of key-value pairs - * so extenders of this class can customize the provider. The properties - * of {@code LanguageSettingsBaseProvider} come from the extension in plugin.xml - * although the extenders can provide their own method. - *

- * Please note that empty string value is treated as "default" value and - * the same as {@code null} and the same as missing property, which allows - * {@link #equals(Object)} evaluate the property as equal while comparing providers. + * {@code LanguageSettingsBaseProvider} keeps the list of key-value pairs so extenders of this + * class can customize the provider. The properties of {@code LanguageSettingsBaseProvider} come + * from the extension in plugin.xml although the extenders can provide their own method.
+ *
+ * Please note that empty string value is treated as "default" value and the same as + * {@code null} and the same as missing property, which allows {@link #equals(Object)} evaluate + * the property as equal while comparing providers. * - * @param key - property to check the value. + * @param key + * - property to check the value. * @return value of the property. If the property is missing returns empty string. */ public String getProperty(String key) { @@ -155,11 +174,13 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas /** * Convenience method to get boolean property. + * * @see #getProperty(String) * - * @param key - property to check the value. - * @return boolean value of the property. If the property is missing or cannot be - * interpreted as boolean returns {@code false}. + * @param key + * - property to check the value. + * @return boolean value of the property. If the property is missing or cannot be interpreted as + * boolean returns {@code false}. */ public boolean getPropertyBool(String key) { return Boolean.parseBoolean(properties.get(key)); @@ -175,33 +196,46 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas /** * {@inheritDoc} * - * @param languageId - language id. If {@code null}, then entries defined for - * the language scope are returned. See {@link #getLanguageScope()} + * @param languageId + * - language id. If {@code null}, then entries defined for the language scope are + * returned. See {@link #getLanguageScope()} * - * @return unmodifiable list of setting entries or {@code null} if no settings defined. - * the list is internally pooled and guaranteed to be the same object for equal - * lists. + * @return unmodifiable list of setting entries or {@code null} if no settings defined. the list + * is internally pooled and guaranteed to be the same object for equal lists. + * @since 6.0 */ @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, - IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, String languageId) { + // For backwards compatibility + if (config != null) { + ICConfigurationDescription cfgDesc = config.getAdapter(ICConfigurationDescription.class); + if (cfgDesc != null) { + List entriesOld = getSettingEntries(cfgDesc, rc, languageId); + if (entriesOld != null) { + return entriesOld; + } + } + } + if (languageScope == null) { return entries; } + for (String lang : languageScope) { if (lang.equals(languageId)) { return entries; } } + return null; } /** - * @return the unmodifiable list of languages this provider provides for. - * If {@code null}, the provider provides for any language. + * @return the unmodifiable list of languages this provider provides for. If {@code null}, the + * provider provides for any language. */ public List getLanguageScope() { - if (languageScope==null) + if (languageScope == null) return null; return Collections.unmodifiableList(languageScope); } @@ -267,7 +301,8 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas } else if (other.properties == null) { return false; } else { - // The trouble to ensure default properties are equal to missing ones. + // The trouble to ensure default properties are equal to missing + // ones. Set keys = new HashSet(properties.keySet()); keys.addAll(other.properties.keySet()); for (String key : keys) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java index 194518d400a..2e27a35e13b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManager.java @@ -28,78 +28,90 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; /** - * A collection of utility methods to manage language settings providers. - * See {@link ILanguageSettingsProvider}. + * A collection of utility methods to manage language settings providers. See + * {@link ILanguageSettingsProvider}. * * @since 5.4 */ public class LanguageSettingsManager { /** - * Returns the list of setting entries of a certain kind (such as include paths) - * for the given configuration description, resource and language. This is a - * combined list for all providers taking into account settings of parent folder - * if settings for the given resource are not defined. For include paths both - * local (#include "...") and system (#include <...>) entries are returned. + * Returns the list of setting entries of a certain kind (such as include paths) for the given + * configuration description, resource and language. This is a combined list for all providers + * taking into account settings of parent folder if settings for the given resource are not + * defined. For include paths both local (#include "...") and system (#include <...>) entries + * are returned. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. - * @param kind - kind of language settings entries, such as - * {@link ICSettingEntry#INCLUDE_PATH} etc. This is a binary flag - * and it is possible to specify composite kind. - * Use {@link ICSettingEntry#ALL} to get all kinds. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. + * @param kind + * - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} + * etc. This is a binary flag and it is possible to specify composite kind. Use + * {@link ICSettingEntry#ALL} to get all kinds. * * @return the list of setting entries. * - * @since 5.5 + * @since 6.0 */ - public static List getSettingEntriesByKind(ICConfigurationDescription cfgDescription, IResource rc, String languageId, int kind) { - return LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, languageId, kind); + public static List getSettingEntriesByKind(IBuildConfiguration config, + IResource rc, String languageId, int kind) { + return LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, rc, languageId, kind); } /** - * Returns the list of setting entries of the given provider - * for the given configuration description, resource and language. - * This method reaches to the parent folder of the resource recursively - * if the resource does not define the entries for the given provider. + * Returns the list of setting entries of the given provider for the given configuration + * description, resource and language. This method reaches to the parent folder of the resource + * recursively if the resource does not define the entries for the given provider. * - * @param provider - language settings provider. - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. + * @param provider + * - language settings provider. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. * - * @return the list of setting entries. Never returns {@code null} - * although individual providers return {@code null} if no settings defined. + * @return the list of setting entries. Never returns {@code null} although individual providers + * return {@code null} if no settings defined. + * @since 6.0 */ - public static List getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - return LanguageSettingsProvidersSerializer.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, languageId); + public static List getSettingEntriesUpResourceTree( + ILanguageSettingsProvider provider, IBuildConfiguration config, IResource rc, String languageId) { + return LanguageSettingsProvidersSerializer.getSettingEntriesUpResourceTree(provider, config, rc, + languageId); } /** - * Get Language Settings Provider from the list of workspace providers, - * see {@link #getWorkspaceProviders()}. + * Get Language Settings Provider from the list of workspace providers, see + * {@link #getWorkspaceProviders()}. * - * @param id - id of provider to find. - * @return the workspace provider. If workspace provider is not defined - * a new instance is created and returned. + * @param id + * - id of provider to find. + * @return the workspace provider. If workspace provider is not defined a new instance is + * created and returned. */ public static ILanguageSettingsProvider getWorkspaceProvider(String id) { return LanguageSettingsProvidersSerializer.getWorkspaceProvider(id); } /** - * Get Language Settings Providers defined in the workspace. That includes - * user-defined providers and after that providers defined as extensions via - * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. - * Note that this returns wrappers around workspace provider so underlying - * provider could be replaced internally without need to change configuration. - * See also {@link #getRawProvider(ILanguageSettingsProvider)}. + * Get Language Settings Providers defined in the workspace. That includes user-defined + * providers and after that providers defined as extensions via + * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. Note that this returns + * wrappers around workspace provider so underlying provider could be replaced internally + * without need to change configuration. See also + * {@link #getRawProvider(ILanguageSettingsProvider)}. * * @return list of workspace providers. */ @@ -108,12 +120,12 @@ public class LanguageSettingsManager { } /** - * Checks if the provider is a workspace level provider. - * This method is intended to check providers retrieved from a configuration. - * Raw providers from {@link #getRawProvider(ILanguageSettingsProvider)} - * are not considered as workspace providers. + * Checks if the provider is a workspace level provider. This method is intended to check + * providers retrieved from a configuration. Raw providers from + * {@link #getRawProvider(ILanguageSettingsProvider)} are not considered as workspace providers. * - * @param provider - provider to check. + * @param provider + * - provider to check. * @return {@code true} if the given provider is workspace provider, {@code false} otherwise. */ public static boolean isWorkspaceProvider(ILanguageSettingsProvider provider) { @@ -123,11 +135,14 @@ public class LanguageSettingsManager { /** * Helper method to get to real underlying provider collecting entries as opposed to wrapper * which is normally used for workspace provider. + * * @see LanguageSettingsProvidersSerializer#isWorkspaceProvider(ILanguageSettingsProvider) * - * @param provider - the provider to get raw provider for. Can be either workspace provider - * or regular one. - * @return raw underlying provider for workspace provider or provider itself if no wrapper is used. + * @param provider + * - the provider to get raw provider for. Can be either workspace provider or + * regular one. + * @return raw underlying provider for workspace provider or provider itself if no wrapper is + * used. */ public static ILanguageSettingsProvider getRawProvider(ILanguageSettingsProvider provider) { if (isWorkspaceProvider(provider)) { @@ -136,38 +151,42 @@ public class LanguageSettingsManager { return provider; } - /** * Set and store in workspace area user defined providers. * - * @param providers - array of user defined workspace providers. - * Note that those providers will shadow extension providers with the same ID. - * All not shadowed extension providers will be added to the list to be present - * as workspace providers. {@code null} is equivalent to passing an empty array - * and so will reset workspace providers to match extension providers. - * @throws CoreException in case of problems (such as problems with persistence). + * @param providers + * - array of user defined workspace providers. Note that those providers will shadow + * extension providers with the same ID. All not shadowed extension providers will be + * added to the list to be present as workspace providers. {@code null} is equivalent + * to passing an empty array and so will reset workspace providers to match extension + * providers. + * @throws CoreException + * in case of problems (such as problems with persistence). */ public static void setWorkspaceProviders(List providers) throws CoreException { LanguageSettingsProvidersSerializer.setWorkspaceProviders(providers); } /** - * Copy language settings provider. It is different from clone() methods in that - * it does not throw {@code CloneNotSupportedException} but returns {@code null} - * instead. + * Copy language settings provider. It is different from clone() methods in that it does not + * throw {@code CloneNotSupportedException} but returns {@code null} instead. * - * @param provider - language settings provider to copy. - * @param deep - {@code true} to request deep copy including copying settings entries - * or {@code false} to return shallow copy with no settings entries. + * @param provider + * - language settings provider to copy. + * @param deep + * - {@code true} to request deep copy including copying settings entries or + * {@code false} to return shallow copy with no settings entries. * * @return a copy of the provider or null if copying is not possible. */ - public static ILanguageSettingsEditableProvider getProviderCopy(ILanguageSettingsEditableProvider provider, boolean deep) { + public static ILanguageSettingsEditableProvider getProviderCopy( + ILanguageSettingsEditableProvider provider, boolean deep) { return LanguageSettingsExtensionManager.getProviderCopy(provider, deep); } /** * Returns list of provider id-s contributed by all extensions. + * * @return the provider id-s. */ public static Set getExtensionProviderIds() { @@ -176,14 +195,17 @@ public class LanguageSettingsManager { /** * Get language settings provider defined via extension point - * {@code org.eclipse.cdt.core.LanguageSettingsProvider}. - * A new copy of the extension provider is returned. + * {@code org.eclipse.cdt.core.LanguageSettingsProvider}. A new copy of the extension provider + * is returned. * - * @param id - ID of the extension provider. - * @param deep - {@code true} to request deep copy including copying settings entries - * or {@code false} to return shallow copy with no settings entries. - * @return the copy of the extension provider if possible (i.e. for {@link ILanguageSettingsEditableProvider}) - * or {@code null} if provider is not copyable. + * @param id + * - ID of the extension provider. + * @param deep + * - {@code true} to request deep copy including copying settings entries or + * {@code false} to return shallow copy with no settings entries. + * @return the copy of the extension provider if possible (i.e. for + * {@link ILanguageSettingsEditableProvider}) or {@code null} if provider is not + * copyable. */ public static ILanguageSettingsProvider getExtensionProviderCopy(String id, boolean deep) { return LanguageSettingsExtensionManager.getExtensionProviderCopy(id, deep); @@ -193,9 +215,11 @@ public class LanguageSettingsManager { * Test if the provider is equal to the one defined via extension point * {@code org.eclipse.cdt.core.LanguageSettingsProvider}. * - * @param provider - the provider to test. - * @param deep - {@code true} to check for deep equality testing also settings entries - * or {@code false} to test shallow copy with no settings entries. + * @param provider + * - the provider to test. + * @param deep + * - {@code true} to check for deep equality testing also settings entries or + * {@code false} to test shallow copy with no settings entries. * @return - {@code true} if the provider matches the extension or {@code false} otherwise. */ public static boolean isEqualExtensionProvider(ILanguageSettingsProvider provider, boolean deep) { @@ -203,24 +227,24 @@ public class LanguageSettingsManager { } /** - * Find language IDs for the resource represented by resource description. - * Under the hood build component is inquired and the language IDs would - * commonly come from the input type(s). + * Find language IDs for the resource represented by resource description. Under the hood build + * component is inquired and the language IDs would commonly come from the input type(s). * - * @param rcDescription - resource description - * @return list of language IDs for the resource. The list can contain {@code null} ID. - * Never returns {@code null} but empty list if no languages can be found. + * @param rcDescription + * - resource description + * @return list of language IDs for the resource. The list can contain {@code null} ID. Never + * returns {@code null} but empty list if no languages can be found. * */ public static List getLanguages(ICResourceDescription rcDescription) { ICLanguageSetting[] languageSettings = null; if (rcDescription instanceof ICFileDescription) { - ICLanguageSetting languageSetting = ((ICFileDescription)rcDescription).getLanguageSetting(); + ICLanguageSetting languageSetting = ((ICFileDescription) rcDescription).getLanguageSetting(); if (languageSetting != null) { - languageSettings = new ICLanguageSetting[] {languageSetting}; + languageSettings = new ICLanguageSetting[] { languageSetting }; } } else if (rcDescription instanceof ICFolderDescription) { - languageSettings = ((ICFolderDescription)rcDescription).getLanguageSettings(); + languageSettings = ((ICFolderDescription) rcDescription).getLanguageSettings(); } List languageIds = new ArrayList(); @@ -228,7 +252,7 @@ public class LanguageSettingsManager { for (ICLanguageSetting languageSetting : languageSettings) { if (languageSetting != null) { String languageId = languageSetting.getLanguageId(); - if (! languageIds.contains(languageId)) { + if (!languageIds.contains(languageId)) { languageIds.add(languageId); } } @@ -239,14 +263,14 @@ public class LanguageSettingsManager { } /** - * Find language IDs for the resource in given build configuration. - * Under the hood build component is inquired and the language IDs would - * commonly come from the input type(s). + * Find language IDs for the resource in given build configuration. Under the hood build + * component is inquired and the language IDs would commonly come from the input type(s). * - * @param resource - the resource to find languages for. + * @param resource + * - the resource to find languages for. * @param cfgDescription - * @return list of language IDs for the resource. - * Never returns {@code null} but empty list if no languages can be found. + * @return list of language IDs for the resource. Never returns {@code null} but empty list if + * no languages can be found. */ public static List getLanguages(IResource resource, ICConfigurationDescription cfgDescription) { List languageIds = new ArrayList(); @@ -263,7 +287,8 @@ public class LanguageSettingsManager { if (langId == null) { // Try getting language from content types try { - ILanguage lang = LanguageManager.getInstance().getLanguageForFile((IFile) resource, cfgDescription); + ILanguage lang = LanguageManager.getInstance().getLanguageForFile((IFile) resource, + cfgDescription); if (lang != null) { langId = lang.getId(); } @@ -288,7 +313,8 @@ public class LanguageSettingsManager { /** * Adds a listener that will be notified of changes in language settings. * - * @param listener the listener to add + * @param listener + * the listener to add */ public static void registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener) { LanguageSettingsProvidersSerializer.registerLanguageSettingsChangeListener(listener); @@ -297,33 +323,35 @@ public class LanguageSettingsManager { /** * Removes a language settings change listener. * - * @param listener the listener to remove. + * @param listener + * the listener to remove. */ public static void unregisterLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener) { LanguageSettingsProvidersSerializer.unregisterLanguageSettingsChangeListener(listener); } /** - * Tells if the provider is meant to be shared between projects in workspace - * or belong to a specific configuration. This attribute is defined in - * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. - *
Note that only {@link ILanguageSettingsEditableProvider} can be owned by - * a configuration. + * Tells if the provider is meant to be shared between projects in workspace or belong to a + * specific configuration. This attribute is defined in + * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point.
+ * Note that only {@link ILanguageSettingsEditableProvider} can be owned by a configuration. * - * @param id - ID of the provider to inquire. - * @return {@code true} if the provider is designed to be shared, - * {@code false} if configuration-owned. + * @param id + * - ID of the provider to inquire. + * @return {@code true} if the provider is designed to be shared, {@code false} if + * configuration-owned. */ public static boolean isPreferShared(String id) { return LanguageSettingsExtensionManager.isPreferShared(id); } /** - * Tells if language settings entries of the provider are persisted with the project - * (under .settings/ folder) or in workspace area. Persistence in the project area lets - * the entries migrate with the project. + * Tells if language settings entries of the provider are persisted with the project (under + * .settings/ folder) or in workspace area. Persistence in the project area lets the entries + * migrate with the project. * - * @param provider - provider to check the persistence mode. + * @param provider + * - provider to check the persistence mode. * @return {@code true} if LSE persisted with the project or {@code false} if in the workspace. */ public static boolean isStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider) { @@ -333,19 +361,23 @@ public class LanguageSettingsManager { /** * Define where language settings are persisted for the provider. * - * @param provider - provider to set the persistence mode. - * @param storeEntriesWithProject - {@code true} if with the project, - * {@code false} if in workspace area. + * @param provider + * - provider to set the persistence mode. + * @param storeEntriesWithProject + * - {@code true} if with the project, {@code false} if in workspace area. */ - public static void setStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, boolean storeEntriesWithProject) { + public static void setStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, + boolean storeEntriesWithProject) { LanguageSettingsProvidersSerializer.setStoringEntriesInProjectArea(provider, storeEntriesWithProject); } /** * Save language settings providers of a project to persistent storage. * - * @param prjDescription - project description of the project. - * @throws CoreException if something goes wrong. + * @param prjDescription + * - project description of the project. + * @throws CoreException + * if something goes wrong. */ public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException { LanguageSettingsProvidersSerializer.serializeLanguageSettings(prjDescription); @@ -354,7 +386,8 @@ public class LanguageSettingsManager { /** * Save language settings providers of the workspace (global providers) to persistent storage. * - * @throws CoreException if something goes wrong. + * @throws CoreException + * if something goes wrong. */ public static void serializeLanguageSettingsWorkspace() throws CoreException { LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace(); @@ -363,15 +396,16 @@ public class LanguageSettingsManager { /** * Save language settings providers of a project to persistent storage in a background job. * - * @param prjDescription - project description of the project. + * @param prjDescription + * - project description of the project. */ public static void serializeLanguageSettingsInBackground(ICProjectDescription prjDescription) { LanguageSettingsProvidersSerializer.serializeLanguageSettingsInBackground(prjDescription); } /** - * Save language settings providers of the workspace (global providers) to persistent storage - * in a background job. + * Save language settings providers of the workspace (global providers) to persistent storage in + * a background job. */ public static void serializeLanguageSettingsWorkspaceInBackground() { LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspaceInBackground(); @@ -380,11 +414,13 @@ public class LanguageSettingsManager { /** * Create a list of providers with intention to assign to a configuration description. * - * The list will contain global providers for ones where attribute "prefer-non-shared" is {@code true} - * and a new copy for those where attribute "prefer-non-shared" is {@code false}. Attribute "prefer-non-shared" - * is defined in extension point {@code org.eclipse.cdt.core.LanguageSettingsProvider}. + * The list will contain global providers for ones where attribute "prefer-non-shared" is + * {@code true} and a new copy for those where attribute "prefer-non-shared" is {@code false}. + * Attribute "prefer-non-shared" is defined in extension point + * {@code org.eclipse.cdt.core.LanguageSettingsProvider}. * - * @param ids - list of providers id which cannot be {@code null}. + * @param ids + * - list of providers id which cannot be {@code null}. * @return a list of language settings providers with given ids. * * @since 5.5 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java index 839f80e4c60..77acb4dbecf 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProvider.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSetting import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsSerializableStorage; import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -34,19 +35,21 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * This class is the base class for language settings providers able to serialize - * into XML storage. - * Although this class has setter methods, by design its instances are not editable in UI - * nor instances can be assigned to a configuration (cannot be global or non-shared). - * Implement {@link ILanguageSettingsEditableProvider} interface for that. There is a generic - * implementation of this interface available to be used, see {@link LanguageSettingsGenericProvider}. + * This class is the base class for language settings providers able to + * serialize into XML storage. Although this class has setter methods, by design + * its instances are not editable in UI nor instances can be assigned to a + * configuration (cannot be global or non-shared). Implement + * {@link ILanguageSettingsEditableProvider} interface for that. There is a + * generic implementation of this interface available to be used, see + * {@link LanguageSettingsGenericProvider}. * * For more on the suggested way of extending this class see the description of * {@link ILanguageSettingsProvider}. * * @since 5.4 */ -public class LanguageSettingsSerializableProvider extends LanguageSettingsBaseProvider implements ILanguageSettingsBroadcastingProvider { +public class LanguageSettingsSerializableProvider extends LanguageSettingsBaseProvider + implements ILanguageSettingsBroadcastingProvider { protected static final String ATTR_ID = LanguageSettingsProvidersSerializer.ATTR_ID; protected static final String ATTR_NAME = LanguageSettingsProvidersSerializer.ATTR_NAME; protected static final String ATTR_CLASS = LanguageSettingsProvidersSerializer.ATTR_CLASS; @@ -56,8 +59,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr private LanguageSettingsSerializableStorage fStorage = new LanguageSettingsSerializableStorage(); /** - * Default constructor. This constructor has to be always followed with setting id and name of the provider. - * This constructor is necessary to instantiate the class via the extension point in plugin.xml. + * Default constructor. This constructor has to be always followed with + * setting id and name of the provider. This constructor is necessary to + * instantiate the class via the extension point in plugin.xml. */ public LanguageSettingsSerializableProvider() { super(); @@ -66,8 +70,10 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * Constructor. * - * @param id - id of the provider. - * @param name - name of the provider. Note that this name shows up in UI. + * @param id + * - id of the provider. + * @param name + * - name of the provider. Note that this name shows up in UI. */ public LanguageSettingsSerializableProvider(String id, String name) { super(id, name); @@ -84,21 +90,24 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } @Override - public void configureProvider(String id, String name, List languages, List entries, Map properties) { + public void configureProvider(String id, String name, List languages, + List entries, Map properties) { // do not pass entries to super, keep them in local storage super.configureProvider(id, name, languages, null, properties); fStorage.clear(); - if (entries!=null) { - // note that these entries are intended to be retrieved by LanguageSettingsManager.getSettingEntriesUpResourceTree() + if (entries != null) { + // note that these entries are intended to be retrieved by + // LanguageSettingsManager.getSettingEntriesUpResourceTree() // when the whole resource hierarchy has been traversed up setSettingEntries(null, null, null, entries); } } /** - * @return {@code true} if the provider does not keep any settings yet or {@code false} if there are some. + * @return {@code true} if the provider does not keep any settings yet or + * {@code false} if there are some. */ public boolean isEmpty() { return fStorage.isEmpty(); @@ -107,8 +116,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * Sets the language scope of the provider. * - * @param languages - the list of languages this provider provides for. - * If {@code null}, the provider provides for any language. + * @param languages + * - the list of languages this provider provides for. If + * {@code null}, the provider provides for any language. * * @see #getLanguageScope() */ @@ -121,46 +131,57 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } /** - * Clears all the entries for all configurations, all resources and all languages. + * Clears all the entries for all configurations, all resources and all + * languages. */ public void clear() { fStorage.clear(); } /** - * Sets language settings entries for the provider. - * Note that the entries are not persisted at that point. Use this method to set - * the entries for all resources one by one and after all done persist in one shot - * using {@link #serializeLanguageSettings(ICConfigurationDescription)}. - * See for example {@code AbstractBuildCommandParser} and {@code AbstractBuiltinSpecsDetector} - * in build plugins. + * Sets language settings entries for the provider. Note that the entries + * are not persisted at that point. Use this method to set the entries for + * all resources one by one and after all done persist in one shot using + * {@link #serializeLanguageSettings(ICConfigurationDescription)}. See for + * example {@code AbstractBuildCommandParser} and + * {@code AbstractBuiltinSpecsDetector} in build plugins. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. If {@code null} the entries are - * considered to be being defined as default entries for resources. - * @param languageId - language id. If {@code null}, then entries are considered - * to be defined for the language scope. See {@link #getLanguageScope()} - * @param entries - language settings entries to set. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. If {@code null} the entries + * are considered to be being defined as default entries for + * resources. + * @param languageId + * - language id. If {@code null}, then entries are considered to + * be defined for the language scope. See + * {@link #getLanguageScope()} + * @param entries + * - language settings entries to set. + * @since 6.0 */ - public void setSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId, + public void setSettingEntries(IBuildConfiguration config, IResource rc, String languageId, List entries) { - String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null; + String rcProjectPath = rc != null ? rc.getProjectRelativePath().toString() : null; fStorage.setSettingEntries(rcProjectPath, languageId, entries); } /** - * {@inheritDoc} + * {@inheritDoc}
+ * Note that this list is unmodifiable. To modify the list copy it, + * change and use + * {@link #setSettingEntries(IBuildConfiguration, IResource, String, List)} + * .
*
- * Note that this list is unmodifiable. To modify the list copy it, change and use - * {@link #setSettingEntries(ICConfigurationDescription, IResource, String, List)}. - *

- * Note also that you can compare these lists with simple equality operator ==, - * as the lists themselves are backed by WeakHashSet> where - * identical copies (deep comparison is used) are replaced with the same one instance. + * Note also that you can compare these lists with simple equality + * operator ==, as the lists themselves are backed by + * WeakHashSet> where identical copies (deep + * comparison is used) are replaced with the same one instance. */ @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - String rcProjectPath = rc!=null ? rc.getProjectRelativePath().toString() : null; + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + String rcProjectPath = rc != null ? rc.getProjectRelativePath().toString() : null; List entries = fStorage.getSettingEntries(rcProjectPath, languageId); if (entries == null) { if (languageId != null && (languageScope == null || languageScope.contains(languageId))) { @@ -172,25 +193,22 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } /** - * Serialize the provider under parent XML element. - * This is convenience method not intended to be overridden on purpose. - * Override {@link #serializeAttributes(Element)} or + * Serialize the provider under parent XML element. This is convenience + * method not intended to be overridden on purpose. Override + * {@link #serializeAttributes(Element)} or * {@link #serializeEntries(Element)} instead. * - * @param parentElement - element where to serialize. + * @param parentElement + * - element where to serialize. * @return - newly created "provider" element. That element will already be - * attached to the parent element. + * attached to the parent element. */ final public Element serialize(Element parentElement) { /* - - - - - - - - + * + * + * */ Element elementProvider = serializeAttributes(parentElement); serializeEntries(elementProvider); @@ -199,14 +217,17 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * Serialize the provider attributes under parent XML element. That is - * equivalent to serializing everything (including language scope) except entries. + * equivalent to serializing everything (including language scope) except + * entries. * - * @param parentElement - element where to serialize. + * @param parentElement + * - element where to serialize. * @return - newly created "provider" element. That element will already be - * attached to the parent element. + * attached to the parent element. */ public Element serializeAttributes(Element parentElement) { - // Keeps pairs: key, value. See JavaDoc XmlUtil.appendElement(Node, String, String[]). + // Keeps pairs: key, value. See JavaDoc XmlUtil.appendElement(Node, + // String, String[]). List attributes = new ArrayList(); attributes.add(ATTR_ID); @@ -220,11 +241,12 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr attributes.add(entry.getValue()); } - Element elementProvider = XmlUtil.appendElement(parentElement, ELEM_PROVIDER, attributes.toArray(new String[0])); + Element elementProvider = XmlUtil.appendElement(parentElement, ELEM_PROVIDER, + attributes.toArray(new String[0])); - if (languageScope!=null) { + if (languageScope != null) { for (String langId : languageScope) { - XmlUtil.appendElement(elementProvider, ELEM_LANGUAGE_SCOPE, new String[] {ATTR_ID, langId}); + XmlUtil.appendElement(elementProvider, ELEM_LANGUAGE_SCOPE, new String[] { ATTR_ID, langId }); } } return elementProvider; @@ -232,21 +254,24 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * Serialize the provider entries under parent XML element. - * @param elementProvider - element where to serialize the entries. + * + * @param elementProvider + * - element where to serialize the entries. */ public void serializeEntries(Element elementProvider) { fStorage.serializeEntries(elementProvider); } /** - * Convenience method to persist language settings entries for the project or - * workspace as often-used operation. - * Note that configuration description is passed as an argument but the - * current implementation saves all configurations. + * Convenience method to persist language settings entries for the project + * or workspace as often-used operation. Note that configuration description + * is passed as an argument but the current implementation saves all + * configurations. * - * @param cfgDescription - configuration description. - * If not {@code null}, all providers of the project are serialized. - * If {@code null}, global workspace providers are serialized. + * @param cfgDescription + * - configuration description. If not {@code null}, all + * providers of the project are serialized. If {@code null}, + * global workspace providers are serialized. * * @return - status of operation. */ @@ -259,26 +284,29 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr LanguageSettingsManager.serializeLanguageSettingsWorkspace(); } } catch (CoreException e) { - status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error serializing language settings", e); //$NON-NLS-1$ + status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, + "Error serializing language settings", e); //$NON-NLS-1$ CCorePlugin.log(status); } return status; } /** - * Convenience method to persist language settings entries in background for the project or - * workspace as often-used operation. - * Note that configuration description is passed as an argument but the - * current implementation saves all configurations. + * Convenience method to persist language settings entries in background for + * the project or workspace as often-used operation. Note that configuration + * description is passed as an argument but the current implementation saves + * all configurations. * - * @param cfgDescription - configuration description. - * If not {@code null}, all providers of the project are serialized. - * If {@code null}, global workspace providers are serialized. + * @param cfgDescription + * - configuration description. If not {@code null}, all + * providers of the project are serialized. If {@code null}, + * global workspace providers are serialized. */ public void serializeLanguageSettingsInBackground(ICConfigurationDescription cfgDescription) { if (cfgDescription != null) { if (isLanguageSettingsProviderStoreChanged(cfgDescription)) { - LanguageSettingsManager.serializeLanguageSettingsInBackground(cfgDescription.getProjectDescription()); + LanguageSettingsManager + .serializeLanguageSettingsInBackground(cfgDescription.getProjectDescription()); } } else { LanguageSettingsManager.serializeLanguageSettingsWorkspaceInBackground(); @@ -286,12 +314,13 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } /** - * Compare provider store with cached persistent store used to calculate delta. + * Compare provider store with cached persistent store used to calculate + * delta. */ private boolean isLanguageSettingsProviderStoreChanged(ICConfigurationDescription cfgDescription) { if (cfgDescription instanceof IInternalCCfgInfo) { try { - CConfigurationSpecSettings ss = ((IInternalCCfgInfo)cfgDescription).getSpecSettings(); + CConfigurationSpecSettings ss = ((IInternalCCfgInfo) cfgDescription).getSpecSettings(); if (ss != null) { return ss.isLanguageSettingsProviderStoreChanged(this); } @@ -305,19 +334,20 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } /** - * Load provider from XML provider element. - * This is convenience method not intended to be overridden on purpose. - * Override {@link #loadAttributes(Element)} or - * {@link #loadEntries(Element)} instead. + * Load provider from XML provider element. This is convenience method not + * intended to be overridden on purpose. Override + * {@link #loadAttributes(Element)} or {@link #loadEntries(Element)} + * instead. * - * @param providerNode - XML element "provider" to load provider from. + * @param providerNode + * - XML element "provider" to load provider from. */ final public void load(Element providerNode) { fStorage.clear(); languageScope = null; // provider/configuration/language/resource/entry - if (providerNode!=null) { + if (providerNode != null) { loadAttributes(providerNode); loadEntries(providerNode); } @@ -327,7 +357,7 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr * Determine and set language scope from given XML node. */ private void loadLanguageScopeElement(Node parentNode) { - if (languageScope==null) { + if (languageScope == null) { languageScope = new ArrayList(); } String id = XmlUtil.determineAttributeValue(parentNode, ATTR_ID); @@ -337,7 +367,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * Load attributes from XML provider element. - * @param providerNode - XML element "provider" to load attributes from. + * + * @param providerNode + * - XML element "provider" to load attributes from. */ public void loadAttributes(Element providerNode) { String providerId = XmlUtil.determineAttributeValue(providerNode, ATTR_ID); @@ -345,9 +377,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr properties.clear(); NamedNodeMap attrs = providerNode.getAttributes(); - for (int i=0; i
- * A note of caution - do not use default values for a provider which are different - * from empty or {@code null} value. When providers are checked for equality - * (during internal operations in core) the missing properties are evaluated as - * empty ones. + * Set a custom property of the provider.
+ *
+ * A note of caution - do not use default values for a provider which are + * different from empty or {@code null} value. When providers are checked + * for equality (during internal operations in core) the missing properties + * are evaluated as empty ones. * * @see LanguageSettingsBaseProvider#getProperty(String) * - * @param key - name of the property. - * @param value - value of the property. - * If value is {@code null} the property is removed from the list. + * @param key + * - name of the property. + * @param value + * - value of the property. If value is {@code null} the property + * is removed from the list. */ public void setProperty(String key, String value) { properties.put(key, value); } /** - * Set a custom boolean property of the provider. - *
Please, note that default value is always {@code false}. + * Set a custom boolean property of the provider.
+ * Please, note that default value is always {@code false}. + * * @see LanguageSettingsBaseProvider#getProperty(String) * - * @param key - name of the property. - * @param value - {@code boolean} value of the property. + * @param key + * - name of the property. + * @param value + * - {@code boolean} value of the property. */ public void setPropertyBool(String key, boolean value) { properties.put(key, Boolean.toString(value)); @@ -412,11 +451,12 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr /** * See {@link #cloneShallow()}. This method is extracted to avoid expressing - * {@link #clone()} via {@link #cloneShallow()}. Do not inline to "optimize"! + * {@link #clone()} via {@link #cloneShallow()}. Do not inline to + * "optimize"! */ private LanguageSettingsSerializableProvider cloneShallowInternal() throws CloneNotSupportedException { - LanguageSettingsSerializableProvider clone = (LanguageSettingsSerializableProvider)super.clone(); - if (languageScope!=null) + LanguageSettingsSerializableProvider clone = (LanguageSettingsSerializableProvider) super.clone(); + if (languageScope != null) clone.languageScope = new ArrayList(languageScope); clone.properties = new HashMap(properties); @@ -425,11 +465,12 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr } /** - * Shallow clone of the provider. "Shallow" is defined here as the exact copy except that - * the copy will have zero language settings entries. + * Shallow clone of the provider. "Shallow" is defined here as the exact + * copy except that the copy will have zero language settings entries. * * @return shallow copy of the provider. - * @throws CloneNotSupportedException in case {@link #clone()} throws the exception. + * @throws CloneNotSupportedException + * in case {@link #clone()} throws the exception. */ protected LanguageSettingsSerializableProvider cloneShallow() throws CloneNotSupportedException { return cloneShallowInternal(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 2938c2a6539..5f9afa6cc4c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -47,6 +47,7 @@ import org.eclipse.cdt.internal.core.model.SourceEntry; import org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.util.MementoTokenizer; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -55,6 +56,7 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -90,6 +92,7 @@ public class CoreModel { /** * Creates a translation from a location URI. Returns null if not found. + * * @since 5.0 */ public ITranslationUnit createTranslationUnitFrom(ICProject cproject, URI locationURI) { @@ -98,10 +101,11 @@ public class CoreModel { /** * Returns the C model element corresponding to the given handle identifier - * generated by {@code ICElement.getHandleIdentifier()}, or - * {@code null} if unable to create the associated element. + * generated by {@code ICElement.getHandleIdentifier()}, or {@code null} if + * unable to create the associated element. * - * @param handleIdentifier the given handle identifier + * @param handleIdentifier + * the given handle identifier * @return the C element corresponding to the handle identifier * * @since 5.0 @@ -149,7 +153,8 @@ public class CoreModel { /** * Returns the C model. * - * @param root the given root + * @param root + * the given root * @return the C model, or {@code null} if the root is null */ public static ICModel create(IWorkspaceRoot root) { @@ -172,7 +177,7 @@ public class CoreModel { public boolean isSharedLib(IFile file) { ICElement celement = create(file); if (celement instanceof IBinary) { - return ((IBinary)celement).isSharedLib(); + return ((IBinary) celement).isSharedLib(); } return false; } @@ -183,7 +188,7 @@ public class CoreModel { public boolean isObject(IFile file) { ICElement celement = create(file); if (celement instanceof IBinary) { - return ((IBinary)celement).isObject(); + return ((IBinary) celement).isObject(); } return false; } @@ -194,7 +199,7 @@ public class CoreModel { public boolean isExecutable(IFile file) { ICElement celement = create(file); if (celement instanceof IBinary) { - return ((IBinary)celement).isExecutable(); + return ((IBinary) celement).isExecutable(); } return false; } @@ -212,7 +217,7 @@ public class CoreModel { */ public boolean isArchive(IFile file) { ICElement celement = create(file); - return(celement instanceof IArchive); + return (celement instanceof IArchive); } /** @@ -230,6 +235,7 @@ public class CoreModel { /** * Returns an array of the register contentTypes. + * * @return String[] ids */ public static String[] getRegistedContentTypeIds() { @@ -244,11 +250,11 @@ public class CoreModel { if (contentType != null) { String id = contentType.getId(); return CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) - || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id) - || CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) - || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) - || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) - || LanguageManager.getInstance().isContributedContentType(id); + || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id) + || CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) + || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) + || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) + || LanguageManager.getInstance().isContributedContentType(id); } return false; } @@ -260,8 +266,8 @@ public class CoreModel { IContentType contentType = CCorePlugin.getContentType(project, name); if (contentType != null) { String id = contentType.getId(); - if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) || - CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) { + if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) + || CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) { return true; } } @@ -281,9 +287,9 @@ public class CoreModel { } return CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) - || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) - || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) - || LanguageManager.getInstance().isContributedContentType(id); + || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id) + || CCorePlugin.CONTENT_TYPE_ASMSOURCE.equals(id) + || LanguageManager.getInstance().isContributedContentType(id); } return false; } @@ -359,15 +365,16 @@ public class CoreModel { } /** - * Return the registered content type id, for example: - *
    - *
  • CONTENT_TYPE_CHEADER - *
  • CONTENT_TYPE_CXXHEADER - *
  • CONTENT_TYPE_CSOURCE - *
  • CONTENT_TYPE_CXXSOURCE - *
  • CONTENT_TYPE_ASMSOURCE - *
- * or null is return if no id match the list + * Return the registered content type id, for example: + *
    + *
  • CONTENT_TYPE_CHEADER + *
  • CONTENT_TYPE_CXXHEADER + *
  • CONTENT_TYPE_CSOURCE + *
  • CONTENT_TYPE_CXXSOURCE + *
  • CONTENT_TYPE_ASMSOURCE + *
+ * or null is return if no id match the list + * * @return the know id or null */ public static String getRegistedContentTypeId(IProject project, String name) { @@ -404,14 +411,14 @@ public class CoreModel { * Creates and returns a new non-exported entry of kind {@code CDT_PROJECT} * for the project identified by the given absolute path. *

- * A project entry is used to denote a prerequisite project. The - * exported IPathEntry[] entries of the project will be contributed. + * A project entry is used to denote a prerequisite project. The exported + * IPathEntry[] entries of the project will be contributed. *

* The prerequisite project is referred to using an absolute path relative * to the workspace root. *

- * The resulting entry is not exported to dependent projects. This method - * is equivalent to {@code newProjectEntry(path, false)}. + * The resulting entry is not exported to dependent projects. This method is + * equivalent to {@code newProjectEntry(path, false)}. *

* * @param projectPath @@ -425,8 +432,8 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_PROJECT} for - * the project identified by the given workspace-relative path. + * Creates and returns a new entry of kind {@code CDT_PROJECT} for the + * project identified by the given workspace-relative path. *

* A project entry is used to denote a prerequisite project. All the * IPathEntries of the project will be contributed as a whole. The @@ -435,7 +442,8 @@ public class CoreModel { *

* * @param projectPath - * the absolute workspace-relative path of the prerequisite project + * the absolute workspace-relative path of the prerequisite + * project * @param isExported * indicates whether this entry is contributed to dependent * projects @@ -446,16 +454,17 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_CONTAINER} for - * the given path. The path of the container will be used during resolution - * so as to map this container entry to a set of other entries the - * container is acting for. + * Creates and returns a new entry of kind {@code CDT_CONTAINER} for the + * given path. The path of the container will be used during resolution so + * as to map this container entry to a set of other entries the container is + * acting for. *

- * The resulting entry is not exported to dependent projects. This method - * is equivalent to {@code newContainerEntry(path, false)}. + * The resulting entry is not exported to dependent projects. This method is + * equivalent to {@code newContainerEntry(path, false)}. *

* - * @param id the id of the container + * @param id + * the id of the container * @return a new container entry * */ @@ -464,13 +473,13 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_CONTAINER} for - * the given path. The path of the container will be used during resolution - * so as to map this container entry to a set of other entries the - * container is acting for. + * Creates and returns a new entry of kind {@code CDT_CONTAINER} for the + * given path. The path of the container will be used during resolution so + * as to map this container entry to a set of other entries the container is + * acting for. *

- * The resulting entry is not exported to dependent projects. This method - * is equivalent to {@code newContainerEntry(path,false)}. + * The resulting entry is not exported to dependent projects. This method is + * equivalent to {@code newContainerEntry(path,false)}. *

*/ public static IContainerEntry newContainerEntry(IPath id, boolean isExported) { @@ -478,8 +487,8 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_LIBRARY} - * for the archive or folder identified by the given absolute path. + * Creates and returns a new entry of kind {@code CDT_LIBRARY} for the + * archive or folder identified by the given absolute path. * * @param resourcePath * the affected project-relative resource path @@ -494,10 +503,9 @@ public class CoreModel { return new LibraryEntry(resourcePath, null, baseRef, libraryPath, null, null, null, false); } - /** - * Creates and returns a new entry of kind {@code CDT_LIBRARY} - * for the archive or folder identified by the given absolute path. + * Creates and returns a new entry of kind {@code CDT_LIBRARY} for the + * archive or folder identified by the given absolute path. * * Note that this operation does not attempt to validate or access the * resources at the given paths. @@ -510,26 +518,28 @@ public class CoreModel { * @param libraryPath * the path of the library * @param sourceAttachmentPath - * the project-relative path of the corresponding source archive or - * folder, or {@code null} if none. + * the project-relative path of the corresponding source archive + * or folder, or {@code null} if none. * @param sourceAttachmentRootPath * the location of the root within the source archive or folder * or {@code null}. * @param sourceAttachmentPrefixMapping * prefix mapping or {@code null}. * @param isExported - * whether the entry is exported + * whether the entry is exported * @return a new library entry * */ - public static ILibraryEntry newLibraryEntry(IPath resourcePath, IPath basePath, IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, - IPath sourceAttachmentPrefixMapping, boolean isExported) { - return new LibraryEntry(resourcePath, basePath, null, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); + public static ILibraryEntry newLibraryEntry(IPath resourcePath, IPath basePath, IPath libraryPath, + IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping, + boolean isExported) { + return new LibraryEntry(resourcePath, basePath, null, libraryPath, sourceAttachmentPath, + sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); } /** - * Creates and returns a new entry of kind {@code CDT_OUTPUT} for - * the project's output folder + * Creates and returns a new entry of kind {@code CDT_OUTPUT} for the + * project's output folder *

* * @param outputPath @@ -542,8 +552,7 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_OUPUT} for - * the project + * Creates and returns a new entry of kind {@code CDT_OUPUT} for the project * * @param outputPath * the project-relative path of a folder @@ -557,21 +566,21 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_SOURCE} for - * the project's source folder identified by the given absolute + * Creates and returns a new entry of kind {@code CDT_SOURCE} for the + * project's source folder identified by the given absolute * workspace-relative path. *

* The source folder is referred to using an absolute path relative to the - * workspace root, e.g. {@code /Project/src}. A project's source - * folders are located with that project. That is, a source entry - * specifying the path {@code /P1/src} is only usable for project - * {@code P1}. + * workspace root, e.g. {@code /Project/src}. A project's source folders are + * located with that project. That is, a source entry specifying the path + * {@code /P1/src} is only usable for project {@code P1}. *

* Note that all sources/binaries inside a project are contributed as a - * whole through a project entry (see {@code newProjectEntry}). - * Particular source entries cannot be selectively exported. + * whole through a project entry (see {@code newProjectEntry}). Particular + * source entries cannot be selectively exported. * - * @param sourcePath the project-relative path of a source folder + * @param sourcePath + * the project-relative path of a source folder * @return a new source entry with not exclusion patterns * */ @@ -580,17 +589,17 @@ public class CoreModel { } /** - * Creates and returns a new entry of kind {@code CDT_SOURCE} for - * the project's source folder identified by the given absolute + * Creates and returns a new entry of kind {@code CDT_SOURCE} for the + * project's source folder identified by the given absolute * workspace-relative path but excluding all source files with paths * matching any of the given patterns. This specifies that all package - * fragments within the root will have children of type {@code ICompilationUnit}. + * fragments within the root will have children of type + * {@code ICompilationUnit}. *

* The source folder is referred to using an absolute path relative to the - * workspace root, e.g. {@code /Project/src}. A project's source - * folders are located with that project. That is, a source entry - * specifying the path {@code /P1/src} is only usable for project - * {@code P1}. + * workspace root, e.g. {@code /Project/src}. A project's source folders are + * located with that project. That is, a source entry specifying the path + * {@code /P1/src} is only usable for project {@code P1}. * * @param sourcePath * the absolute project-relative path of a source folder @@ -628,11 +637,14 @@ public class CoreModel { * @param includePath * the absolute path of the include * @param isSystemInclude - * whether this include path should be consider a system include path + * whether this include path should be consider a system include + * path * @return IIncludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude) { - return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, APathEntry.NO_EXCLUSION_PATTERNS); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, + boolean isSystemInclude) { + return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, + APathEntry.NO_EXCLUSION_PATTERNS); } /** @@ -651,8 +663,10 @@ public class CoreModel { * exclusion patterns in the resource if a container * @return IIincludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns) { - return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, exclusionPatterns, false); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, + boolean isSystemInclude, IPath[] exclusionPatterns) { + return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, exclusionPatterns, + false); } /** @@ -665,17 +679,18 @@ public class CoreModel { * @param includePath * the path of the include * @param isSystemInclude - * wheter this include path should be consider the system - * include path + * wheter this include path should be consider the system include + * path * @param exclusionPatterns * exclusion patterns in the resource if a container * @param isExported * if the entry ix exported to reference projects * @return IIincludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, - IPath[] exclusionPatterns, boolean isExported) { - return new IncludeEntry(resourcePath, basePath, null, includePath, isSystemInclude, exclusionPatterns, isExported); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, + boolean isSystemInclude, IPath[] exclusionPatterns, boolean isExported) { + return new IncludeEntry(resourcePath, basePath, null, includePath, isSystemInclude, exclusionPatterns, + isExported); } /** @@ -715,9 +730,10 @@ public class CoreModel { * if the entry ix exported to reference projects * @return IIincludeEntry */ - public static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath, IPath baseRef, IPath basePath, IPath includeFilePath, - IPath[] exclusionPatterns, boolean isExported) { - return new IncludeFileEntry(resourcePath, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); + public static IIncludeFileEntry newIncludeFileEntry(IPath resourcePath, IPath baseRef, IPath basePath, + IPath includeFilePath, IPath[] exclusionPatterns, boolean isExported) { + return new IncludeFileEntry(resourcePath, basePath, baseRef, includeFilePath, exclusionPatterns, + isExported); } /** @@ -747,7 +763,8 @@ public class CoreModel { * @param exclusionPatterns * exclusion patterns in the resource if a container */ - public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns) { + public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, + IPath[] exclusionPatterns) { return newMacroEntry(resourcePath, macroName, macroValue, exclusionPatterns, false); } @@ -763,7 +780,8 @@ public class CoreModel { * @param exclusionPatterns * exclusion patterns in the resource if a container */ - public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported) { + public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, + IPath[] exclusionPatterns, boolean isExported) { return new MacroEntry(resourcePath, null, macroName, macroValue, exclusionPatterns, isExported); } @@ -773,12 +791,13 @@ public class CoreModel { * @param resourcePath * the affected workspace-relative resource path * @param baseRef - * the base reference path + * the base reference path * @param macroName * the name of the macro */ public static IMacroEntry newMacroRefEntry(IPath resourcePath, IPath baseRef, String macroName) { - return new MacroEntry(resourcePath, baseRef, macroName, null, APathEntry.NO_EXCLUSION_PATTERNS, false); + return new MacroEntry(resourcePath, baseRef, macroName, null, APathEntry.NO_EXCLUSION_PATTERNS, + false); } /** @@ -800,28 +819,29 @@ public class CoreModel { * @param exclusionPatterns * exclusion patterns in the resource if a container */ - public static IMacroFileEntry newMacroFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath macroFilePath, IPath[] exclusionPatterns, boolean isExported) { - return new MacroFileEntry(resourcePath, basePath, baseRef, macroFilePath, exclusionPatterns, isExported); + public static IMacroFileEntry newMacroFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, + IPath macroFilePath, IPath[] exclusionPatterns, boolean isExported) { + return new MacroFileEntry(resourcePath, basePath, baseRef, macroFilePath, exclusionPatterns, + isExported); } - /** * Answers the project specific value for a given container. In case this - * container path could not be resolved, then will answer {@code null}. - * Both the container path and the project context are supposed to be - * non-null. + * container path could not be resolved, then will answer {@code null}. Both + * the container path and the project context are supposed to be non-null. *

* The containerPath is a formed by a first ID segment followed with extra * segments, which can be used as additional hints for resolution. If no * container was ever recorded for this container path onto this project - * (using {@code setPathEntryContainer}, then a {@code PathEntryContainerInitializer} - * will be activated if any was registered for this container ID onto the - * extension point "org.eclipse.cdt.core.PathEntryContainerInitializer". + * (using {@code setPathEntryContainer}, then a + * {@code PathEntryContainerInitializer} will be activated if any was + * registered for this container ID onto the extension point + * "org.eclipse.cdt.core.PathEntryContainerInitializer". *

* PathEntry container values are persisted locally to the workspace, but * are not preserved from a session to another. It is thus highly - * recommended to register a {@code PathEntryContainerInitializer} - * for each referenced container (through the extension point + * recommended to register a {@code PathEntryContainerInitializer} for each + * referenced container (through the extension point * "org.eclipse.cdt.core.PathEntryContainerInitializer"). *

* @@ -829,26 +849,28 @@ public class CoreModel { * the name of the container, which needs to be resolved * @param project * a specific project in which the container is being resolved - * @return the corresponding container or {@code null} if unable to - * find one. + * @return the corresponding container or {@code null} if unable to find + * one. * * @exception CModelException - * if an exception occurred while resolving the container, - * or if the resolved container contains illegal entries + * if an exception occurred while resolving the container, or + * if the resolved container contains illegal entries * (contains CDT_CONTAINER entries or null entries). * * @see PathEntryContainerInitializer * @see IPathEntryContainer - * @see #setPathEntryContainer(ICProject[], IPathEntryContainer, IProgressMonitor) + * @see #setPathEntryContainer(ICProject[], IPathEntryContainer, + * IProgressMonitor) */ - public static IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project) throws CModelException { + public static IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project) + throws CModelException { return pathEntryManager.getPathEntryContainer(containerPath, project); } /** - * Bind a container reference path to some actual containers ({@code IPathEntryContainer}). - * This API must be invoked whenever changes in container need to be - * reflected onto the CModel. + * Bind a container reference path to some actual containers + * ({@code IPathEntryContainer}). This API must be invoked whenever changes + * in container need to be reflected onto the CModel. *

* In reaction to changing container values, the CModel will be updated to * reflect the new state of the updated container. @@ -857,19 +879,19 @@ public class CoreModel { *

* PathEntry container values are persisted locally to the workspace, but * are not preserved from a session to another. It is thus highly - * recommended to register a {@code PathEntryContainerInitializer} - * for each referenced container (through the extension point + * recommended to register a {@code PathEntryContainerInitializer} for each + * referenced container (through the extension point * "org.eclipse.cdt.core.PathEntryContainerInitializer"). *

- * Note: setting a container to {@code null} will cause it to be - * lazily resolved again whenever its value is required. In particular, - * this will cause a registered initializer to be invoked again. + * Note: setting a container to {@code null} will cause it to be lazily + * resolved again whenever its value is required. In particular, this will + * cause a registered initializer to be invoked again. *

* - * @param affectedProjects - - * the set of projects for which this container is being bound - * @param container - - * the container for the affected projects + * @param affectedProjects + * - the set of projects for which this container is being bound + * @param container + * - the container for the affected projects * @param monitor * a monitor to report progress * @throws CModelException @@ -877,31 +899,35 @@ public class CoreModel { * @see #getPathEntryContainer(IPath, ICProject) * @see IPathEntryContainer */ - public static void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, IProgressMonitor monitor) - throws CModelException { + public static void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, + IProgressMonitor monitor) throws CModelException { pathEntryManager.setPathEntryContainer(affectedProjects, container, monitor); } /** - * Helper method use by a path entry container implementing {@code IPathEntryContainerExtension} - * It notify the model of changes. - * Note: the paths in the {@code PathEntryContainerChanged[]} array must be on - * source that the container was set too. If not the changes will be silently ignore. + * Helper method use by a path entry container implementing + * {@code IPathEntryContainerExtension} It notify the model of changes. + * Note: the paths in the {@code PathEntryContainerChanged[]} array must be + * on source that the container was set too. If not the changes will be + * silently ignore. * * @param container - * @param changes array of changes. - * @param monitor progress monitor + * @param changes + * array of changes. + * @param monitor + * progress monitor */ - public static void pathEntryContainerUpdates(IPathEntryContainerExtension container, PathEntryContainerChanged[] changes, IProgressMonitor monitor) { + public static void pathEntryContainerUpdates(IPathEntryContainerExtension container, + PathEntryContainerChanged[] changes, IProgressMonitor monitor) { pathEntryManager.pathEntryContainerUpdates(container, changes, monitor); } /** * Sets the pathentries of this project using a list of entries. *

- * Setting the pathentries to {@code null} specifies a default - * classpath (the project root). Setting the pathentry to an empty array - * specifies an empty pathentry. + * Setting the pathentries to {@code null} specifies a default classpath + * (the project root). Setting the pathentry to an empty array specifies an + * empty pathentry. *

* * @param newEntries @@ -911,7 +937,8 @@ public class CoreModel { * @exception CModelException * if the entries could not be set. Reasons include: */ - public static void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { + public static void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, + IProgressMonitor monitor) throws CModelException { pathEntryManager.setRawPathEntries(cproject, newEntries, monitor); } @@ -949,8 +976,9 @@ public class CoreModel { } /** - * This method returns the include entries associated with a translation unit - * if the path does not refer to a valid translation unit an empty array is return. + * This method returns the include entries associated with a translation + * unit if the path does not refer to a valid translation unit an empty + * array is return. *

* The resulting resolved entries are accurate for the given point in time. * If the project's raw entries are later modified they can become out of @@ -966,8 +994,9 @@ public class CoreModel { } /** - * This method returns the include file entries associated with a translation unit - * if the path does not refer to a valid translation unit an empty array is return. + * This method returns the include file entries associated with a + * translation unit if the path does not refer to a valid translation unit + * an empty array is return. *

* The resulting resolved entries are accurate for the given point in time. * If the project's raw entries are later modified they can become out of @@ -984,7 +1013,8 @@ public class CoreModel { /** * This method returns the macro entries associated with a translation unit - * if the path does not refer to a valid translation unit an empty array is return. + * if the path does not refer to a valid translation unit an empty array is + * return. *

* The resulting resolved entries are accurate for the given point in time. * If the project's raw entries are later modified they can become out of @@ -1000,8 +1030,9 @@ public class CoreModel { } /** - * This method returns the macro file entries associated with a translation unit - * if the path does not refer to a valid translation unit an empty array is return. + * This method returns the macro file entries associated with a translation + * unit if the path does not refer to a valid translation unit an empty + * array is return. *

* The resulting resolved entries are accurate for the given point in time. * If the project's raw entries are later modified they can become out of @@ -1018,16 +1049,16 @@ public class CoreModel { /** * Helper method finding the pathentry container initializer registered for - * a given container ID or {@code null} if none was found while - * iterating over the contributions to extension point to the extension - * point "org.eclipse.cdt.core.PathEntryContainerInitializer". + * a given container ID or {@code null} if none was found while iterating + * over the contributions to extension point to the extension point + * "org.eclipse.cdt.core.PathEntryContainerInitializer". *

* A containerID is the first segment of any container path, used to * identify the registered container initializer. *

* - * @param containerID - - * a containerID identifying a registered initializer + * @param containerID + * - a containerID identifying a registered initializer * @return ClasspathContainerInitializer - the registered classpath * container initializer or {@code null} if none was found. */ @@ -1037,6 +1068,7 @@ public class CoreModel { /** * Returns the IPathEntryStore of the project. + * * @throws CoreException */ public static IPathEntryStore getPathEntryStore(IProject project) throws CoreException { @@ -1056,60 +1088,71 @@ public class CoreModel { /** * Validate a given path entries for a project, using the following rules: *

    - *
  • Entries cannot collide with each other; that is, all entry paths must be unique. - *
  • The output entry location path can be empty, if not they must be located inside - * the project. - *
  • Source entry location can be null, if not they must be located inside the project, - *
  • A project entry cannot refer to itself directly (that is, a project cannot - * prerequisite itself). - *
  • Source entries or output locations cannot coincide or be nested in each other, except - * for the following scenarios listed below: - *
      - *
    • A source folder can coincide with its own output location, in which case this - * output can then contain library archives. However, a specific output location - * cannot coincide with any library or a distinct source folder than the one - * referring to it.
    • - *
    • A source/library folder can be nested in any source folder as long as - * the nested folder is excluded from the enclosing one.
    • - *
    • An output location can be nested in a source folder, if the source folder - * coincides with the project itself, or if the output location is excluded from - * the source folder.
    • - *
    + *
  • Entries cannot collide with each other; that is, all entry paths must + * be unique. + *
  • The output entry location path can be empty, if not they must be + * located inside the project. + *
  • Source entry location can be null, if not they must be located inside + * the project, + *
  • A project entry cannot refer to itself directly (that is, a project + * cannot prerequisite itself). + *
  • Source entries or output locations cannot coincide or be nested in + * each other, except for the following scenarios listed below: + *
      + *
    • A source folder can coincide with its own output location, in which + * case this output can then contain library archives. However, a specific + * output location cannot coincide with any library or a distinct source + * folder than the one referring to it.
    • + *
    • A source/library folder can be nested in any source folder as long as + * the nested folder is excluded from the enclosing one.
    • + *
    • An output location can be nested in a source folder, if the source + * folder coincides with the project itself, or if the output location is + * excluded from the source folder.
    • + *
    *
* - * Note that the entries are not validated automatically. Only bound variables or containers - * are considered in the checking process (this allows to perform a consistency check on - * an entry which has references to yet non existing projects, folders, ...). - *

- * This validation is intended to anticipate issues prior to assigning it to a project. - * In particular, it will automatically be performed during the setting operation - * (if validation fails, the classpath setting will not complete) and during - * {@link #getResolvedPathEntries}. + * Note that the entries are not validated automatically. Only bound + * variables or containers are considered in the checking process (this + * allows to perform a consistency check on an entry which has references to + * yet non existing projects, folders, ...). + *

+ * This validation is intended to anticipate issues prior to assigning it to + * a project. In particular, it will automatically be performed during the + * setting operation (if validation fails, the classpath setting will not + * complete) and during {@link #getResolvedPathEntries}. * - * @param cProject the given C project - * @return a status object with code {@code IStatus.OK} if - * the entries location are compatible, otherwise a status - * object indicating what is wrong with them + * @param cProject + * the given C project + * @return a status object with code {@code IStatus.OK} if the entries + * location are compatible, otherwise a status object indicating + * what is wrong with them */ public static ICModelStatus validatePathEntries(ICProject cProject, IPathEntry[] entries) { return pathEntryManager.validatePathEntry(cProject, entries); } /** - * Returns a C model status describing the problem related to this entry if any, - * a status object with code {@code IStatus.OK} if the entry is fine (that is, if the - * given entry denotes a valid element). + * Returns a C model status describing the problem related to this entry if + * any, a status object with code {@code IStatus.OK} if the entry is fine + * (that is, if the given entry denotes a valid element). * - * @param cProject the given C project - * @param entry the given entry - * @param checkSourceAttachment a flag to determine if source attachment should be checked - * @param recurseInContainers flag indicating whether validation should be applied to container - * entries recursively - * @return a c model status describing the problem related to this entry if any, a status object - * with code {@code IStatus.OK} if the entry is fine + * @param cProject + * the given C project + * @param entry + * the given entry + * @param checkSourceAttachment + * a flag to determine if source attachment should be checked + * @param recurseInContainers + * flag indicating whether validation should be applied to + * container entries recursively + * @return a c model status describing the problem related to this entry if + * any, a status object with code {@code IStatus.OK} if the entry is + * fine */ - public static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers){ - return pathEntryManager.validatePathEntry(cProject, entry, checkSourceAttachment, recurseInContainers); + public static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, + boolean checkSourceAttachment, boolean recurseInContainers) { + return pathEntryManager.validatePathEntry(cProject, entry, checkSourceAttachment, + recurseInContainers); } /** @@ -1127,8 +1170,8 @@ public class CoreModel { } /** - * Removes the given element changed listener. Has no affect if an - * identical listener is not registered. + * Removes the given element changed listener. Has no affect if an identical + * listener is not registered. * * @param listener * the listener @@ -1154,76 +1197,83 @@ public class CoreModel { /** * Runs the given action as an atomic C model operation. *

- * After running a method that modifies C elements, - * registered listeners receive after-the-fact notification of - * what just transpired, in the form of a element changed event. - * This method allows clients to call a number of - * methods that modify C elements and only have element - * changed event notifications reported at the end of the entire - * batch. + * After running a method that modifies C elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form + * of a element changed event. This method allows clients to call a number + * of methods that modify C elements and only have element changed event + * notifications reported at the end of the entire batch. *

- * If this method is called outside the dynamic scope of another such - * call, this method runs the action and then reports a single - * element changed event describing the net effect of all changes - * done to C elements by the action. + * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed + * event describing the net effect of all changes done to C elements by the + * action. *

- * If this method is called in the dynamic scope of another such - * call, this method simply runs the action. + * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. *

* - * @param action the action to perform - * @param monitor a progress monitor, or {@code null} if progress - * reporting and cancellation are not desired - * @exception CoreException if the operation failed. + * @param action + * the action to perform + * @param monitor + * a progress monitor, or {@code null} if progress reporting and + * cancellation are not desired + * @exception CoreException + * if the operation failed. * @since 2.1 */ public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException { run(action, ResourcesPlugin.getWorkspace().getRoot(), monitor); } + /** * Runs the given action as an atomic C model operation. *

- * After running a method that modifies C elements, - * registered listeners receive after-the-fact notification of - * what just transpired, in the form of a element changed event. - * This method allows clients to call a number of - * methods that modify C elements and only have element - * changed event notifications reported at the end of the entire - * batch. + * After running a method that modifies C elements, registered listeners + * receive after-the-fact notification of what just transpired, in the form + * of a element changed event. This method allows clients to call a number + * of methods that modify C elements and only have element changed event + * notifications reported at the end of the entire batch. *

- * If this method is called outside the dynamic scope of another such - * call, this method runs the action and then reports a single - * element changed event describing the net effect of all changes - * done to C elements by the action. + * If this method is called outside the dynamic scope of another such call, + * this method runs the action and then reports a single element changed + * event describing the net effect of all changes done to C elements by the + * action. *

- * If this method is called in the dynamic scope of another such - * call, this method simply runs the action. + * If this method is called in the dynamic scope of another such call, this + * method simply runs the action. *

- * The supplied scheduling rule is used to determine whether this operation can be - * run simultaneously with workspace changes in other threads. See + * The supplied scheduling rule is used to determine whether this operation + * can be run simultaneously with workspace changes in other threads. See * {@link IWorkspace#run} for more details. * - * @param action the action to perform - * @param rule the scheduling rule to use when running this operation, or - * {@code null} if there are no scheduling restrictions for this operation. - * @param monitor a progress monitor, or {@code null} if progress - * reporting and cancellation are not desired - * @exception CoreException if the operation failed. + * @param action + * the action to perform + * @param rule + * the scheduling rule to use when running this operation, or + * {@code null} if there are no scheduling restrictions for this + * operation. + * @param monitor + * a progress monitor, or {@code null} if progress reporting and + * cancellation are not desired + * @exception CoreException + * if the operation failed. * @since 3.0 */ - public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException { + public static void run(IWorkspaceRunnable action, ISchedulingRule rule, IProgressMonitor monitor) + throws CoreException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace.isTreeLocked()) { new BatchOperation(action).run(monitor); } else { - // Use IWorkspace.run(...) to ensure that a build will be done in autobuild mode. + // Use IWorkspace.run(...) to ensure that a build will be done in + // autobuild mode. workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor); } } /** - * The method returns whether scanner information for a resource is empty or not. - * If {@code null} is supplied the method returns {@code true}. + * The method returns whether scanner information for a resource is empty or + * not. If {@code null} is supplied the method returns {@code true}. * * @param resource * @since 3.0 @@ -1235,32 +1285,40 @@ public class CoreModel { IProject project = resource.getProject(); CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance(); ICProjectDescription des = mngr.getProjectDescription(project, false); - if (des != null){ + if (des != null) { ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration(); - if (indexCfg != null){ + if (indexCfg != null) { if (!mngr.isNewStyleCfg(indexCfg)) { return oldIsScannerInformationEmpty(resource); } - if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) && - indexCfg instanceof ILanguageSettingsProvidersKeeper) { - List languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg); - for (String langId : languageIds) { - List entries = LanguageSettingsManager.getSettingEntriesByKind(indexCfg, resource, langId, - ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO | ICSettingEntry.INCLUDE_FILE | ICSettingEntry.MACRO_FILE); - if (!(entries == null || entries.isEmpty())) { - return false; + if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project) + && indexCfg instanceof ILanguageSettingsProvidersKeeper) { + IBuildConfiguration config = Adapters.adapt(indexCfg, IBuildConfiguration.class); + if (config != null) { + List languageIds = LanguageSettingsManager.getLanguages(resource, indexCfg); + for (String langId : languageIds) { + List entries = LanguageSettingsManager + .getSettingEntriesByKind(config, resource, langId, + ICSettingEntry.INCLUDE_PATH | ICSettingEntry.MACRO + | ICSettingEntry.INCLUDE_FILE + | ICSettingEntry.MACRO_FILE); + if (!(entries == null || entries.isEmpty())) { + return false; + } } } return true; } else { - ICLanguageSetting lSetting = indexCfg.getLanguageSettingForFile(resource.getProjectRelativePath(), false); - if (lSetting != null && lSetting instanceof CLanguageSettingCache){ - if (!((CLanguageSettingCache)lSetting).containsDiscoveredScannerInfo()) + ICLanguageSetting lSetting = indexCfg + .getLanguageSettingForFile(resource.getProjectRelativePath(), false); + if (lSetting != null && lSetting instanceof CLanguageSettingCache) { + if (!((CLanguageSettingCache) lSetting).containsDiscoveredScannerInfo()) lSetting = null; } - if (lSetting != null){ - ICLanguageSettingEntry[] entries = lSetting.getSettingEntries(ICSettingEntry.INCLUDE_PATH); + if (lSetting != null) { + ICLanguageSettingEntry[] entries = lSetting + .getSettingEntries(ICSettingEntry.INCLUDE_PATH); if (entries.length != 0) return false; @@ -1283,8 +1341,8 @@ public class CoreModel { } private static boolean oldIsScannerInformationEmpty(IResource resource) { - final int PATH_ENTRY_MASK = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | - IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE; + final int PATH_ENTRY_MASK = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO + | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE; boolean rc = true; IPath resPath = resource.getFullPath(); IProject project = resource.getProject(); @@ -1296,8 +1354,8 @@ public class CoreModel { for (IPathEntry pe : resolvedPE) { // first check all containers if (pe.getEntryKind() == IPathEntry.CDT_CONTAINER) { - IPathEntryContainer peContainer = CoreModel.getPathEntryContainer( - pe.getPath(), cProject); + IPathEntryContainer peContainer = CoreModel.getPathEntryContainer(pe.getPath(), + cProject); if (peContainer != null) { if (peContainer instanceof IPathEntryContainerExtension) { IPathEntryContainerExtension contExt = (IPathEntryContainerExtension) peContainer; @@ -1305,8 +1363,7 @@ public class CoreModel { rc = false; break; } - } - else if (peContainer.getPathEntries().length > 0) { + } else if (peContainer.getPathEntries().length > 0) { rc = false; break; } @@ -1328,55 +1385,72 @@ public class CoreModel { } /** - * this method is a full equivalent to {@code createProjectDescription(project, loadIfExists, false)}. + * this method is a full equivalent to + * {@code createProjectDescription(project, loadIfExists, false)}. * * @see #createProjectDescription(IProject, boolean, boolean) */ - public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{ + public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) + throws CoreException { return descriptionManager.createProjectDescription(project, loadIfExists); } /** * the method creates and returns a writable project description * - * @param project project for which the project description is requested - * @param loadIfExists if true the method first tries to load and return the project description - * from the settings file (.cproject) - * if false, the stored settings are ignored and the new (empty) project description is created - * @param creating if true the created project description will be contain the true "isCdtProjectCreating" state. - * NOTE: in case the project already contains the project description AND its "isCdtProjectCreating" is false - * the resulting description will be created with the false "isCdtProjectCreating" state + * @param project + * project for which the project description is requested + * @param loadIfExists + * if true the method first tries to load and return the project + * description from the settings file (.cproject) if false, the + * stored settings are ignored and the new (empty) project + * description is created + * @param creating + * if true the created project description will be contain the + * true "isCdtProjectCreating" state. NOTE: in case the project + * already contains the project description AND its + * "isCdtProjectCreating" is false the resulting description will + * be created with the false "isCdtProjectCreating" state * - * NOTE: changes made to the returned project description will not be applied until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * NOTE: changes made to the returned project description will + * not be applied until the + * {@link #setProjectDescription(IProject, ICProjectDescription)} + * is called * @return {@link ICProjectDescription} * @throws CoreException */ - public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, boolean creating) throws CoreException{ + public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, + boolean creating) throws CoreException { return descriptionManager.createProjectDescription(project, loadIfExists, creating); } /** - * returns the project description associated with this project or null if the project does not contain the - * CDT data associated with it. + * returns the project description associated with this project or null if + * the project does not contain the CDT data associated with it. * - * this is a convenience method fully equivalent to getProjectDescription(project, true) - * see {@link #getProjectDescription(IProject, boolean)} for more detail + * this is a convenience method fully equivalent to + * getProjectDescription(project, true) see + * {@link #getProjectDescription(IProject, boolean)} for more detail + * * @param project - * @return a writable copy of the ICProjectDescription or null if the project does not contain the - * CDT data associated with it. - * Note: changes to the project description will not be reflected/used by the core - * until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * @return a writable copy of the ICProjectDescription or null if the + * project does not contain the CDT data associated with it. Note: + * changes to the project description will not be reflected/used by + * the core until the + * {@link #setProjectDescription(IProject, ICProjectDescription)} is + * called * * @see #getProjectDescription(IProject, boolean) */ - public ICProjectDescription getProjectDescription(IProject project){ + public ICProjectDescription getProjectDescription(IProject project) { return descriptionManager.getProjectDescription(project); } /** - * this method is called to save/apply the project description - * the method should be called to apply changes made to the project description - * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)} + * this method is called to save/apply the project description the method + * should be called to apply changes made to the project description + * returned by the {@link #getProjectDescription(IProject, boolean)} or + * {@link #createProjectDescription(IProject, boolean)} * * @param project * @param des @@ -1389,79 +1463,89 @@ public class CoreModel { descriptionManager.setProjectDescription(project, des); } - public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException { + public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, + IProgressMonitor monitor) throws CoreException { descriptionManager.setProjectDescription(project, des, force, monitor); } /** - * returns the project description associated with this project or null if the project does not contain the - * CDT data associated with it. + * returns the project description associated with this project or null if + * the project does not contain the CDT data associated with it. * - * @param project project for which the description is requested - * @param write if true, the writable description copy is returned. - * If false the cached read-only description is returned. + * @param project + * project for which the description is requested + * @param write + * if true, the writable description copy is returned. If false + * the cached read-only description is returned. * - * CDT core maintains the cached project description settings. If only read access is needed to description, - * then the read-only project description should be obtained. - * This description always operates with cached data and thus it is better to use it for performance reasons - * All set* calls to the read-only description result in the {@link WriteAccessException} + * CDT core maintains the cached project description settings. If + * only read access is needed to description, then the read-only + * project description should be obtained. This description + * always operates with cached data and thus it is better to use + * it for performance reasons All set* calls to the read-only + * description result in the {@link WriteAccessException} * - * When the writable description is requested, the description copy is created. - * Changes to this description will not be reflected/used by the core and Build System untill the - * {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * When the writable description is requested, the description + * copy is created. Changes to this description will not be + * reflected/used by the core and Build System untill the + * {@link #setProjectDescription(IProject, ICProjectDescription)} + * is called * - * Each getProjectDescription(project, true) returns a new copy of the project description + * Each getProjectDescription(project, true) returns a new copy + * of the project description * - * The writable description uses the cached data untill the first set call - * after that the description communicates directly to the Build System - * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension - * This ensures the Core<->Build System settings integrity + * The writable description uses the cached data untill the first + * set call after that the description communicates directly to + * the Build System i.e. the implementer of the + * org.eclipse.cdt.core.CConfigurationDataProvider extension This + * ensures the Core<->Build System settings integrity * - * @return {@link ICProjectDescription} or null if the project does not contain the - * CDT data associated with it. + * @return {@link ICProjectDescription} or null if the project does not + * contain the CDT data associated with it. */ - public ICProjectDescription getProjectDescription(IProject project, boolean write){ + public ICProjectDescription getProjectDescription(IProject project, boolean write) { return descriptionManager.getProjectDescription(project, write); } /** - * Forces the cached data of the specified projects to be re-calculated. - * If the {@code projects} argument is {@code null}, all projects - * within the workspace are updated. + * Forces the cached data of the specified projects to be re-calculated. If + * the {@code projects} argument is {@code null}, all projects within the + * workspace are updated. * * @param projects * @param monitor * @throws CoreException */ - public void updateProjectDescriptions(IProject projects[], IProgressMonitor monitor) throws CoreException{ + public void updateProjectDescriptions(IProject projects[], IProgressMonitor monitor) + throws CoreException { descriptionManager.updateProjectDescriptions(projects, monitor); } /** - * Answers whether the given project is a new-style project, - * i.e. CConfigurationDataProvider-driven. + * Answers whether the given project is a new-style project, i.e. + * CConfigurationDataProvider-driven. */ - public boolean isNewStyleProject(IProject project){ + public boolean isNewStyleProject(IProject project) { return descriptionManager.isNewStyleProject(project); } /** - * Answers whether the given project is a new-style project, - * i.e. CConfigurationDataProvider-driven + * Answers whether the given project is a new-style project, i.e. + * CConfigurationDataProvider-driven */ - public boolean isNewStyleProject(ICProjectDescription des){ + public boolean isNewStyleProject(ICProjectDescription des) { return descriptionManager.isNewStyleProject(des); } - public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ + public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes) { descriptionManager.addCProjectDescriptionListener(listener, eventTypes); } - public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ + public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener) { descriptionManager.removeCProjectDescriptionListener(listener); } - public ICProjectDescriptionManager getProjectDescriptionManager(){ + public ICProjectDescriptionManager getProjectDescriptionManager() { return descriptionManager; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java index 42cfc33cc3e..29d0a3ed8dd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/PathEntryTranslator.java @@ -71,12 +71,14 @@ import org.eclipse.cdt.internal.core.model.PathEntry; import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; @@ -103,7 +105,7 @@ public class PathEntryTranslator { static String ATTRIBUTE_PREFIXMAPPING = "prefixmapping"; //$NON-NLS-1$ static String ATTRIBUTE_EXCLUDING = "excluding"; //$NON-NLS-1$ static String ATTRIBUTE_INCLUDE = "include"; //$NON-NLS-1$ - static String ATTRIBUTE_INCLUDE_FILE= "include-file"; //$NON-NLS-1$ + static String ATTRIBUTE_INCLUDE_FILE = "include-file"; //$NON-NLS-1$ static String ATTRIBUTE_LIBRARY = "library"; //$NON-NLS-1$ static String ATTRIBUTE_SYSTEM = "system"; //$NON-NLS-1$ static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ @@ -126,20 +128,21 @@ public class PathEntryTranslator { ICdtVariableManager fMngr = CCorePlugin.getDefault().getCdtVariableManager(); public VarSubstitutor(ICConfigurationDescription cfgDescription) { - super(new DefaultVariableContextInfo(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, cfgDescription), "", " "); //$NON-NLS-1$ //$NON-NLS-2$ + super(new DefaultVariableContextInfo(ICoreVariableContextInfo.CONTEXT_CONFIGURATION, + cfgDescription), "", " "); //$NON-NLS-1$ //$NON-NLS-2$ fCfg = cfgDescription; } @Override - protected ResolvedMacro resolveMacro(ICdtVariable macro) - throws CdtVariableException { + protected ResolvedMacro resolveMacro(ICdtVariable macro) throws CdtVariableException { if (!CdtVarPathEntryVariableManager.isPathEntryVariable(macro, fCfg, fMngr)) return super.resolveMacro(macro); - return new ResolvedMacro(macro.getName(), CdtVariableResolver.createVariableReference(macro.getName())); + return new ResolvedMacro(macro.getName(), + CdtVariableResolver.createVariableReference(macro.getName())); } } - public static final class ReferenceSettingsInfo{ + public static final class ReferenceSettingsInfo { private IPath[] fRefProjPaths; private ICExternalSetting[] fExtSettings; @@ -197,18 +200,18 @@ public class PathEntryTranslator { private static final int STORAGE_SIZE = 9; - private static final int ENTRY_KINDS[] = new int[]{ - IPathEntry.CDT_LIBRARY, - IPathEntry.CDT_PROJECT, - IPathEntry.CDT_SOURCE, - IPathEntry.CDT_INCLUDE, - IPathEntry.CDT_CONTAINER, - IPathEntry.CDT_MACRO, - IPathEntry.CDT_OUTPUT, - IPathEntry.CDT_INCLUDE_FILE, - IPathEntry.CDT_MACRO_FILE, + private static final int ENTRY_KINDS[] = new int[] { + IPathEntry.CDT_LIBRARY, + IPathEntry.CDT_PROJECT, + IPathEntry.CDT_SOURCE, + IPathEntry.CDT_INCLUDE, + IPathEntry.CDT_CONTAINER, + IPathEntry.CDT_MACRO, + IPathEntry.CDT_OUTPUT, + IPathEntry.CDT_INCLUDE_FILE, + IPathEntry.CDT_MACRO_FILE, }; -// private static final int INEXISTENT_INDEX = -1; + // private static final int INEXISTENT_INDEX = -1; @SuppressWarnings("unchecked") private Map[] fEntryStorage = new Map[STORAGE_SIZE]; @@ -293,7 +296,6 @@ public class PathEntryTranslator { } return new ICLanguageSettingEntry[0]; - } } @@ -316,48 +318,47 @@ public class PathEntryTranslator { int kind = entry.fEntry.getEntryKind(); switch (kind) { - case IPathEntry.CDT_LIBRARY:{ - if (path != null) { - ILibraryEntry libEntry = (ILibraryEntry)entry.fEntry; - return (ICLanguageSettingEntry) CDataUtil.createEntry(ICSettingEntry.LIBRARY_FILE, name, null, null, flags, - libEntry.getSourceAttachmentPath(), - libEntry.getSourceAttachmentRootPath(), - libEntry.getSourceAttachmentPrefixMapping()); - } - break; + case IPathEntry.CDT_LIBRARY: { + if (path != null) { + ILibraryEntry libEntry = (ILibraryEntry) entry.fEntry; + return (ICLanguageSettingEntry) CDataUtil.createEntry(ICSettingEntry.LIBRARY_FILE, name, null, + null, flags, libEntry.getSourceAttachmentPath(), + libEntry.getSourceAttachmentRootPath(), libEntry.getSourceAttachmentPrefixMapping()); } -// case IPathEntry.CDT_PROJECT: -// return ICLanguageSettingEntry; -// case IPathEntry.CDT_SOURCE: -// return INDEX_CDT_SOURCE; - case IPathEntry.CDT_INCLUDE:{ - if (path != null) { - return CDataUtil.createCIncludePathEntry(name, flags); - } - break; + break; + } + // case IPathEntry.CDT_PROJECT: + // return ICLanguageSettingEntry; + // case IPathEntry.CDT_SOURCE: + // return INDEX_CDT_SOURCE; + case IPathEntry.CDT_INCLUDE: { + if (path != null) { + return CDataUtil.createCIncludePathEntry(name, flags); } -// case IPathEntry.CDT_CONTAINER: -// return INDEX_CDT_CONTAINER; - case IPathEntry.CDT_MACRO: - if (name.length() != 0) { - String value = pathEntryValue.getValue(); - return CDataUtil.createCMacroEntry(name, value, flags); - } - break; -// case IPathEntry.CDT_OUTPUT: -// return INDEX_CDT_OUTPUT; - case IPathEntry.CDT_INCLUDE_FILE:{ - if (path != null) { - return CDataUtil.createCIncludeFileEntry(name, flags); - } - break; + break; + } + // case IPathEntry.CDT_CONTAINER: + // return INDEX_CDT_CONTAINER; + case IPathEntry.CDT_MACRO: + if (name.length() != 0) { + String value = pathEntryValue.getValue(); + return CDataUtil.createCMacroEntry(name, value, flags); } - case IPathEntry.CDT_MACRO_FILE:{ - if (path != null) { - return CDataUtil.createCMacroFileEntry(name, flags); - } - break; + break; + // case IPathEntry.CDT_OUTPUT: + // return INDEX_CDT_OUTPUT; + case IPathEntry.CDT_INCLUDE_FILE: { + if (path != null) { + return CDataUtil.createCIncludeFileEntry(name, flags); } + break; + } + case IPathEntry.CDT_MACRO_FILE: { + if (path != null) { + return CDataUtil.createCMacroFileEntry(name, flags); + } + break; + } } return null; } @@ -417,35 +418,35 @@ public class PathEntryTranslator { boolean calcPath = false; switch (peKind) { case IPathEntry.CDT_MACRO: - IMacroEntry me = (IMacroEntry)entry; + IMacroEntry me = (IMacroEntry) entry; fName = me.getMacroName(); fValue = me.getMacroValue(); break; case IPathEntry.CDT_LIBRARY: isFile = true; calcPath = true; - ILibraryEntry le = (ILibraryEntry)entry; + ILibraryEntry le = (ILibraryEntry) entry; basePath = le.getBasePath(); valuePath = le.getLibraryPath(); break; case IPathEntry.CDT_INCLUDE: isFile = false; calcPath = true; - IIncludeEntry ie = (IIncludeEntry)entry; + IIncludeEntry ie = (IIncludeEntry) entry; basePath = ie.getBasePath(); valuePath = ie.getIncludePath(); break; case IPathEntry.CDT_INCLUDE_FILE: isFile = true; calcPath = true; - IIncludeFileEntry ife = (IIncludeFileEntry)entry; + IIncludeFileEntry ife = (IIncludeFileEntry) entry; basePath = ife.getBasePath(); valuePath = ife.getIncludeFilePath(); break; case IPathEntry.CDT_MACRO_FILE: isFile = true; calcPath = true; - IMacroFileEntry mfe = (IMacroFileEntry)entry; + IMacroFileEntry mfe = (IMacroFileEntry) entry; basePath = mfe.getBasePath(); valuePath = mfe.getMacroFilePath(); break; @@ -466,7 +467,8 @@ public class PathEntryTranslator { basePath = mngr.resolvePath(basePath); valuePath = mngr.resolvePath(valuePath); - fName = unresolvedBase.isEmpty() ? unresolvedValue.toString() : unresolvedBase.append(unresolvedValue).toString(); + fName = unresolvedBase.isEmpty() ? unresolvedValue.toString() + : unresolvedBase.append(unresolvedValue).toString(); fValue = fName; if (!basePath.isEmpty()) { @@ -488,11 +490,12 @@ public class PathEntryTranslator { ResourceInfo rcInfo = fResolvedEntry.getResourceInfo(); if (rcInfo.fExists) { if (rcInfo.fRc.getType() == IResource.FILE) { - rcInfo = findResourceInfo(fRoot, rcInfo.fRc.getFullPath().removeLastSegments(1), true); + rcInfo = findResourceInfo(fRoot, + rcInfo.fRc.getFullPath().removeLastSegments(1), true); } IPath location = rcInfo.fRc.getLocation(); if (location != null && rcInfo.fRc.getType() != IResource.FILE) { - rcInfo = findResourceInfo((IContainer)rcInfo.fRc, valuePath, !isFile); + rcInfo = findResourceInfo((IContainer) rcInfo.fRc, valuePath, !isFile); fResourceInfo = rcInfo; break; } @@ -554,7 +557,7 @@ public class PathEntryTranslator { } else { List list = new ArrayList(); for (IPath path : paths) { - list.addAll(Arrays.asList(processFilter((IContainer)rcInfo.fRc, path))); + list.addAll(Arrays.asList(processFilter((IContainer) rcInfo.fRc, path))); } fFilterInfos = new ResourceInfo[list.size()]; list.toArray(fFilterInfos); @@ -562,7 +565,8 @@ public class PathEntryTranslator { } else { fFilterInfos = new ResourceInfo[paths.length]; for (int i = 0; i < paths.length; i++) { - fFilterInfos[i] = processInexistingResourceFilter((IContainer)rcInfo.fRc, paths[i]); + fFilterInfos[i] = processInexistingResourceFilter((IContainer) rcInfo.fRc, + paths[i]); } } } @@ -579,7 +583,7 @@ public class PathEntryTranslator { ResourceInfo rcInfo = new ResourceInfo(f, false); addRcInfoToMap(rcInfo); - addResolvedFilterToMap(container.getFullPath(), new ResourceInfo[]{rcInfo}, true); + addResolvedFilterToMap(container.getFullPath(), new ResourceInfo[] { rcInfo }, true); return rcInfo; } @@ -594,7 +598,6 @@ public class PathEntryTranslator { return fResolvedValue; } - } private static class PathEntryComposer { @@ -604,7 +607,10 @@ public class PathEntryTranslator { private boolean fIsExported; private IProject fProject; - PathEntryComposer(IPath path, IProject project/*, ICConfigurationDescription cfgDescription*/) { + PathEntryComposer(IPath path, + IProject project/* + * , ICConfigurationDescription cfgDescription + */) { fPath = toProjectPath(path); fProject = project; } @@ -616,7 +622,10 @@ public class PathEntryTranslator { return path.makeAbsolute(); } - PathEntryComposer(ICExclusionPatternPathEntry entry, IProject project/*, ICConfigurationDescription cfgDescription*/) { + PathEntryComposer(ICExclusionPatternPathEntry entry, + IProject project/* + * , ICConfigurationDescription cfgDescription + */) { fPath = new Path(entry.getValue()); fLangEntry = entry; fProject = project; @@ -627,7 +636,10 @@ public class PathEntryTranslator { } } - PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, IProject project/*, ICConfigurationDescription cfgDescription*/) { + PathEntryComposer(IPath path, ICLanguageSettingEntry entry, boolean exported, + IProject project/* + * , ICConfigurationDescription cfgDescription + */) { fPath = path; fLangEntry = entry; fIsExported = exported; @@ -656,10 +668,12 @@ public class PathEntryTranslator { } private IPath[][] getEntryPath(ICSettingEntry entry, ICConfigurationDescription cfgDescription) { - return valueToEntryPath(entry.getName(), (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0, cfgDescription); + return valueToEntryPath(entry.getName(), + (entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0, cfgDescription); } - private IPath[][] valueToEntryPath(String value, boolean isWsp, ICConfigurationDescription cfgDescription) { + private IPath[][] valueToEntryPath(String value, boolean isWsp, + ICConfigurationDescription cfgDescription) { String[] pathVarValues = resolveKeepingPathEntryFars(value, cfgDescription); IPath result[][] = new IPath[2][pathVarValues.length]; for (int i = 0; i < pathVarValues.length; i++) { @@ -677,8 +691,10 @@ public class PathEntryTranslator { if (pathVarPath.segmentCount() != 0) { String resolvedProjName = projName; String varProjName = pathVarPath.segment(0); - IPath resolvedProjPath = CCorePlugin.getDefault().getPathEntryVariableManager().resolvePath(new Path(varProjName)); - if (resolvedProjPath.segmentCount() == 1 && resolvedProjName.equals(resolvedProjPath.segment(0))) { + IPath resolvedProjPath = CCorePlugin.getDefault() + .getPathEntryVariableManager().resolvePath(new Path(varProjName)); + if (resolvedProjPath.segmentCount() == 1 + && resolvedProjName.equals(resolvedProjPath.segment(0))) { projName = varProjName; valuePath = pathVarPath.removeFirstSegments(1).makeRelative(); } @@ -708,45 +724,50 @@ public class PathEntryTranslator { IPathEntry[] result = new IPathEntry[0]; if (fLangEntry != null) { switch (fLangEntry.getKind()) { - case ICSettingEntry.INCLUDE_FILE:{ - IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); - result = new IPathEntry[paths[0].length]; - for (int i = 0; i < result.length; i++) - result[i] = CoreModel.newIncludeFileEntry(path, null, paths[0][i], paths[1][i], getExclusionPatterns(), fIsExported); - return result; - } - case ICSettingEntry.INCLUDE_PATH:{ - IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); - ICIncludePathEntry ipe = (ICIncludePathEntry)fLangEntry; + case ICSettingEntry.INCLUDE_FILE: { + IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); + result = new IPathEntry[paths[0].length]; + for (int i = 0; i < result.length; i++) + result[i] = CoreModel.newIncludeFileEntry(path, null, paths[0][i], paths[1][i], + getExclusionPatterns(), fIsExported); + return result; + } + case ICSettingEntry.INCLUDE_PATH: { + IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); + ICIncludePathEntry ipe = (ICIncludePathEntry) fLangEntry; - result = new IPathEntry[paths[0].length]; - for (int i = 0; i < result.length; i++) - result[i] = CoreModel.newIncludeEntry(path, paths[0][i], paths[1][i], !ipe.isLocal(), getExclusionPatterns(), fIsExported); - return result; - } + result = new IPathEntry[paths[0].length]; + for (int i = 0; i < result.length; i++) + result[i] = CoreModel.newIncludeEntry(path, paths[0][i], paths[1][i], !ipe.isLocal(), + getExclusionPatterns(), fIsExported); + return result; + } case ICSettingEntry.MACRO: result = new IPathEntry[1]; - result[0] = CoreModel.newMacroEntry(path, fLangEntry.getName(), fLangEntry.getValue(), getExclusionPatterns(), fIsExported); + result[0] = CoreModel.newMacroEntry(path, fLangEntry.getName(), fLangEntry.getValue(), + getExclusionPatterns(), fIsExported); return result; - case ICSettingEntry.MACRO_FILE:{ - IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); - result = new IPathEntry[paths[0].length]; - for (int i = 0; i < result.length; i++) - result[i] = CoreModel.newMacroFileEntry(path, paths[0][i], null, paths[1][i], getExclusionPatterns(), fIsExported); - return result; - } + case ICSettingEntry.MACRO_FILE: { + IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); + result = new IPathEntry[paths[0].length]; + for (int i = 0; i < result.length; i++) + result[i] = CoreModel.newMacroFileEntry(path, paths[0][i], null, paths[1][i], + getExclusionPatterns(), fIsExported); + return result; + } case ICSettingEntry.LIBRARY_PATH: case ICSettingEntry.LIBRARY_FILE: // Bug 100844 don't contribute library files back to the CModel as a library files, as supplied by the build system, // aren't currently resolved return null; -// case ICSettingEntry.LIBRARY_FILE:{ -// IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); -// result = new IPathEntry[paths[0].length]; -// for (int i = 0; i < result.length; i++) -// result[i] = CoreModel.newLibraryEntry(path, paths[0][i], paths[1][i], null, null, null, fIsExported); -// return result; -// } + //case ICSettingEntry.LIBRARY_FILE: { + // IPath paths[][] = getEntryPath(fLangEntry, cfgDescription); + // result = new IPathEntry[paths[0].length]; + // for (int i = 0; i < result.length; i++) + // result[i] = CoreModel.newLibraryEntry(path, paths[0][i], + // paths[1][i], null, null, null, fIsExported); + // return result; + //} case ICSettingEntry.OUTPUT_PATH: result = new IPathEntry[1]; result[0] = CoreModel.newOutputEntry(fPath, getExclusionPatterns()); @@ -769,21 +790,23 @@ public class PathEntryTranslator { private static String resolveAll(String value, ICConfigurationDescription cfgDescription) { try { - return CCorePlugin.getDefault().getCdtVariableManager().resolveValue(value, "", " ", cfgDescription); //$NON-NLS-1$ //$NON-NLS-2$ + return CCorePlugin.getDefault().getCdtVariableManager().resolveValue(value, "", " ", //$NON-NLS-1$ //$NON-NLS-2$ + cfgDescription); } catch (CdtVariableException e) { CCorePlugin.log(e); } return value; } - private static String[] resolveKeepingPathEntryFars(String value, ICConfigurationDescription cfgDescription) { + private static String[] resolveKeepingPathEntryFars(String value, + ICConfigurationDescription cfgDescription) { String[] result = new String[] { value }; // default value; try { VarSubstitutor substitutor = new VarSubstitutor(cfgDescription); result = CdtVariableResolver.resolveToStringList(value, substitutor); if (result == null || result.length == 0) - result = new String[] { CdtVariableResolver.resolveToString(value, substitutor) }; + result = new String[] { CdtVariableResolver.resolveToString(value, substitutor) }; } catch (CdtVariableException e) { CCorePlugin.log(e); } @@ -793,11 +816,14 @@ public class PathEntryTranslator { public static class PathEntryCollector { private PathSettingsContainer fStorage; private KindBasedStore> fStore; - private KindBasedStore> fNameKeyMapStore; //utility map, does not contain all entries, only those added explicitly + private KindBasedStore> fNameKeyMapStore; // utility map, does not contain all entries, only those added explicitly private LinkedHashMap fRefProjMap; private IProject fProject; - private PathEntryCollector(IProject project/*, ICConfigurationDescription cfgDescription*/) { + private PathEntryCollector( + IProject project/* + * , ICConfigurationDescription cfgDescription + */) { fStorage = PathSettingsContainer.createRootContainer(); fStorage.setValue(this); fStore = new KindBasedStore>(false); @@ -805,7 +831,11 @@ public class PathEntryTranslator { fProject = project; } - private PathEntryCollector(PathSettingsContainer container, KindBasedStore> store, IProject project/*, ICConfigurationDescription cfgDescription*/) { + private PathEntryCollector(PathSettingsContainer container, + KindBasedStore> store, + IProject project/* + * , ICConfigurationDescription cfgDescription + */) { fStorage = container; fStore = store; fNameKeyMapStore = new KindBasedStore>(false); @@ -821,22 +851,22 @@ public class PathEntryTranslator { PathEntryComposer old = nameKeyMap.get(nameKey); if (old != null) { entry = CDataUtil.addRemoveExclusionsToEntry(entry, - ((ICExclusionPatternPathEntry)old.fLangEntry).getExclusionPatterns(), - true); + ((ICExclusionPatternPathEntry) old.fLangEntry).getExclusionPatterns(), true); } - PathEntryComposer newComposer = new PathEntryComposer(entry, fProject/*, fCfg*/); + PathEntryComposer newComposer = new PathEntryComposer(entry, fProject/* , fCfg */); map.put(entry, newComposer); nameKeyMap.put(nameKey, newComposer); } } - public void setRefProjects(IPath []paths) { + public void setRefProjects(IPath[] paths) { if (paths == null || paths.length == 0) { fRefProjMap = null; } else { fRefProjMap = new LinkedHashMap(); for (IPath path : paths) { - PathEntryComposer cs = new PathEntryComposer(path, fProject/*, fCfg*/); + PathEntryComposer cs = new PathEntryComposer(path, + fProject/* , fCfg */); IPath composerPath = cs.getPath(); fRefProjMap.put(composerPath, cs); } @@ -847,7 +877,8 @@ public class PathEntryTranslator { if (path.segmentCount() == 0) return this; - PathEntryCollector cr = (PathEntryCollector)fStorage.getChildContainer(path, false, false).getValue(); + PathEntryCollector cr = (PathEntryCollector) fStorage.getChildContainer(path, false, false) + .getValue(); if (cr != this) { IPath basePath = cr.getPath(); path = path.removeFirstSegments(basePath.segmentCount()); @@ -856,18 +887,21 @@ public class PathEntryTranslator { PathSettingsContainer newContainer = fStorage.getChildContainer(path, true, true); @SuppressWarnings("unchecked") - KindBasedStore> cloneStore = - (KindBasedStore>)fStore.clone(); - IKindBasedInfo> info[] = cloneStore.getContents(); + KindBasedStore> cloneStore = (KindBasedStore>) fStore + .clone(); + IKindBasedInfo> info[] = cloneStore + .getContents(); for (IKindBasedInfo> kindInfo : info) { LinkedHashMap map = kindInfo.getInfo(); if (map != null) { @SuppressWarnings("unchecked") - LinkedHashMap clone = (LinkedHashMap)map.clone(); + LinkedHashMap clone = (LinkedHashMap) map + .clone(); kindInfo.setInfo(clone); } } - PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, fProject/*, fCfg*/); + PathEntryCollector newCr = new PathEntryCollector(newContainer, cloneStore, + fProject/* , fCfg */); newContainer.setValue(newCr); return newCr; } @@ -876,16 +910,17 @@ public class PathEntryTranslator { return fStorage.getPath(); } - public void setEntries(int kind, ICLanguageSettingEntry entries[], Set exportedEntries) { + public void setEntries(int kind, ICLanguageSettingEntry entries[], + Set exportedEntries) { IPath path = getPath(); HashSet parentSet = getEntriesSetCopy(kind); @SuppressWarnings("unchecked") - HashSet removedParentSet = (HashSet)parentSet.clone(); - HashSet addedThisSet = new HashSet(Arrays.asList(entries)); + HashSet removedParentSet = (HashSet) parentSet.clone(); + HashSet addedThisSet = new HashSet( + Arrays.asList(entries)); removedParentSet.removeAll(addedThisSet); addedThisSet.removeAll(parentSet); - if (removedParentSet.size() != 0) { PathEntryCollector parent = getParent(); IPath parentPath = parent.getPath(); @@ -914,7 +949,8 @@ public class PathEntryTranslator { continue; ICLanguageSettingEntry entry = entries[i]; - map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), fProject/*, fCfg*/)); + map.put(entry, new PathEntryComposer(fullPath, entry, exportedEntries.contains(entry), + fProject/* , fCfg */)); } } } @@ -928,7 +964,8 @@ public class PathEntryTranslator { return map; } - private LinkedHashMap getEntriesNameKeyMap(int kind, boolean create) { + private LinkedHashMap getEntriesNameKeyMap(int kind, + boolean create) { LinkedHashMap map = fNameKeyMapStore.get(kind); if (map == null && create) { map = new LinkedHashMap(); @@ -952,7 +989,7 @@ public class PathEntryTranslator { if (fStorage.isRoot()) return null; PathSettingsContainer cr = fStorage.getParentContainer(); - return (PathEntryCollector)cr.getValue(); + return (PathEntryCollector) cr.getValue(); } private HashSet getEntriesSetCopy(int kind) { @@ -970,7 +1007,7 @@ public class PathEntryTranslator { @Override public boolean visit(PathSettingsContainer container) { - PathEntryCollector clr = (PathEntryCollector)container.getValue(); + PathEntryCollector clr = (PathEntryCollector) container.getValue(); clr.getLocalCollectedEntries(kind, list, set); return true; } @@ -980,7 +1017,8 @@ public class PathEntryTranslator { return list; } - private void getLocalCollectedEntries(int kind, List list, Set addedEntries) { + private void getLocalCollectedEntries(int kind, List list, + Set addedEntries) { Map map = getEntriesMap(kind, false); if (map == null) return; @@ -992,7 +1030,8 @@ public class PathEntryTranslator { } } - public List getEntries(int peKind, List list, int flags, ICConfigurationDescription cfgDescription) { + public List getEntries(int peKind, List list, int flags, + ICConfigurationDescription cfgDescription) { Set set = new LinkedHashSet(); int sKind = peKindToSettingKind(peKind); @@ -1046,8 +1085,8 @@ public class PathEntryTranslator { private static boolean checkFilter(PathEntryComposer cs, ICSettingEntry entry, int flags) { boolean builtIn = isBuiltIn(entry); -// if (builtIn && cs.getPath().segmentCount() > 1) -// return false; + // if (builtIn && cs.getPath().segmentCount() > 1) + // return false; if ((flags & INCLUDE_BUILT_INS) != 0 && builtIn) return true; if ((flags & INCLUDE_USER) != 0 && !builtIn) @@ -1056,10 +1095,11 @@ public class PathEntryTranslator { } private static boolean isBuiltIn(ICSettingEntry entry) { - return entry != null && (entry.isBuiltIn() || entry.isReadOnly()); + return entry != null && (entry.isBuiltIn() || entry.isReadOnly()); } - public List getEntries(List list, int flags, ICConfigurationDescription cfgDescription) { + public List getEntries(List list, int flags, + ICConfigurationDescription cfgDescription) { if (list == null) list = new ArrayList(); int peKinds[] = PathEntryKyndStore.getSupportedKinds(); @@ -1071,7 +1111,7 @@ public class PathEntryTranslator { } public IPathEntry[] getEntries(int flags, ICConfigurationDescription cfgDescription) { - List list = getEntries(null, flags,cfgDescription); + List list = getEntries(null, flags, cfgDescription); IPathEntry[] entries = list.toArray(new IPathEntry[list.size()]); return entries; } @@ -1085,7 +1125,6 @@ public class PathEntryTranslator { return null; } - private static boolean areEntriesReadOnly(PathEntryResolveInfoElement el) { switch (el.getRawEntry().getEntryKind()) { case IPathEntry.CDT_LIBRARY: @@ -1096,13 +1135,12 @@ public class PathEntryTranslator { case IPathEntry.CDT_SOURCE: case IPathEntry.CDT_OUTPUT: return false; -// case IPathEntry.CDT_PROJECT: -// case IPathEntry.CDT_CONTAINER: + // case IPathEntry.CDT_PROJECT: + // case IPathEntry.CDT_CONTAINER: } return true; } - private IPath getEntryFullPath(IPathEntry entry) { IPath path = entry.getPath(); if (path == null) @@ -1120,7 +1158,7 @@ public class PathEntryTranslator { case IPathEntry.CDT_MACRO: case IPathEntry.CDT_OUTPUT: case IPathEntry.CDT_SOURCE: - return ((APathEntry)entry).getExclusionPatterns(); + return ((APathEntry) entry).getExclusionPatterns(); } return new IPath[0]; } @@ -1130,7 +1168,7 @@ public class PathEntryTranslator { fCfgData = cfgData; fRcDataHolder = createRcDataHolder(cfgData); fTranslatedFilters = PathSettingsContainer.createRootContainer(); - fTranslatedFilters.setValue(new ResourceInfo[]{new ResourceInfo(fRoot, true)}); + fTranslatedFilters.setValue(new ResourceInfo[] { new ResourceInfo(fRoot, true) }); } private static PathSettingsContainer createRcDataHolder(CConfigurationData cfgData) { @@ -1146,7 +1184,7 @@ public class PathEntryTranslator { IResource rc = rcInfo.fRc; IPath projPath = rc.getProjectRelativePath(); PathSettingsContainer child = cr.getChildContainer(projPath, true, true); - RcDesInfo rcDes = (RcDesInfo)child.getValue(); + RcDesInfo rcDes = (RcDesInfo) child.getValue(); if (rcDes == null) { rcDes = new RcDesInfo(rcInfo); child.setValue(rcDes); @@ -1205,7 +1243,7 @@ public class PathEntryTranslator { propagateValues(cr, new ArrayList(0)); - //applying settings + // applying settings applyOutputEntries(outEntries, op); applySourceEntries(srcEntries, op); applyLangSettings(cr, op); @@ -1219,7 +1257,8 @@ public class PathEntryTranslator { ICExternalSetting extSettings[]; if (exportSettingsList.size() != 0) { extSettings = new ICExternalSetting[1]; - List list = new ArrayList(exportSettingsList.size()); + List list = new ArrayList( + exportSettingsList.size()); for (int i = 0; i < exportSettingsList.size(); i++) { ResolvedEntry re = exportSettingsList.get(i); ICLanguageSettingEntry le = createLangEntry(re); @@ -1238,7 +1277,7 @@ public class PathEntryTranslator { private static ICSourceEntry[] toCSourceEntries(List list) { ICSourceEntry[] entries = new ICSourceEntry[list.size()]; for (int i = 0; i < entries.length; i++) { - entries[i] = toCSourceEntry((ISourceEntry)list.get(i), true); + entries[i] = toCSourceEntry((ISourceEntry) list.get(i), true); } return entries; } @@ -1246,18 +1285,16 @@ public class PathEntryTranslator { private static ICOutputEntry[] toCOutputEntries(List list) { ICOutputEntry[] entries = new ICOutputEntry[list.size()]; for (int i = 0; i < entries.length; i++) { - entries[i] = toCOutputEntry((IOutputEntry)list.get(i), true); + entries[i] = toCOutputEntry((IOutputEntry) list.get(i), true); } return entries; } - private static ICSourceEntry toCSourceEntry(ISourceEntry entry, boolean makeProjRelative) { IPath path = entry.getPath(); if (makeProjRelative && path.isAbsolute()) path = path.removeFirstSegments(1); - return new CSourceEntry(path, - entry.getExclusionPatterns(), + return new CSourceEntry(path, entry.getExclusionPatterns(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); } @@ -1265,12 +1302,12 @@ public class PathEntryTranslator { IPath path = entry.getPath(); if (makeProjRelative && path.isAbsolute()) path = path.removeFirstSegments(1); - return new COutputEntry(path, - entry.getExclusionPatterns(), + return new COutputEntry(path, entry.getExclusionPatterns(), ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED); } - private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, ICSettingEntry[] newUsrEntries) { + private static ICSettingEntry[] replaceUserEntries(ICSettingEntry[] oldEntries, + ICSettingEntry[] newUsrEntries) { Set set = new LinkedHashSet(); Class componentType = null; @@ -1293,7 +1330,7 @@ public class PathEntryTranslator { } if (componentType != null) { - ICSettingEntry[] result = (ICSettingEntry[])Array.newInstance(componentType, set.size()); + ICSettingEntry[] result = (ICSettingEntry[]) Array.newInstance(componentType, set.size()); set.toArray(result); return result; } @@ -1302,9 +1339,9 @@ public class PathEntryTranslator { private void applySourceEntries(ICSourceEntry entries[], int op) { ICSourceEntry[] oldEntries = fCfgData.getSourceEntries(); - oldEntries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, oldEntries, true); - entries = (ICSourceEntry[])CDataUtil.makeRelative(fProject, entries, true); - entries = (ICSourceEntry[])replaceUserEntries(oldEntries, entries); + oldEntries = (ICSourceEntry[]) CDataUtil.makeRelative(fProject, oldEntries, true); + entries = (ICSourceEntry[]) CDataUtil.makeRelative(fProject, entries, true); + entries = (ICSourceEntry[]) replaceUserEntries(oldEntries, entries); switch (op) { case OP_ADD: @@ -1342,9 +1379,9 @@ public class PathEntryTranslator { } ICOutputEntry[] oldEntries = bData.getOutputDirectories(); - oldEntries = (ICOutputEntry[])CDataUtil.makeRelative(fProject, oldEntries, true); - entries = (ICOutputEntry[])CDataUtil.makeRelative(fProject, entries, true); - entries = (ICOutputEntry[])replaceUserEntries(oldEntries, entries); + oldEntries = (ICOutputEntry[]) CDataUtil.makeRelative(fProject, oldEntries, true); + entries = (ICOutputEntry[]) CDataUtil.makeRelative(fProject, entries, true); + entries = (ICOutputEntry[]) replaceUserEntries(oldEntries, entries); switch (op) { case OP_ADD: @@ -1377,7 +1414,7 @@ public class PathEntryTranslator { private void applyLangSettings(PathSettingsContainer cr, int op) { PathSettingsContainer crs[] = cr.getChildren(true); for (PathSettingsContainer cur : crs) { - RcDesInfo desInfo = (RcDesInfo)cur.getValue(); + RcDesInfo desInfo = (RcDesInfo) cur.getValue(); try { CResourceData rcData = getResourceData(cur.getPath(), true, true); applyEntries(rcData, desInfo, op); @@ -1402,15 +1439,16 @@ public class PathEntryTranslator { PathSettingsContainer crs[] = fRcDataHolder.getChildren(true); List list = new ArrayList(crs.length); for (PathSettingsContainer cur : crs) { - list.add((CResourceData)cur.getValue()); + list.add((CResourceData) cur.getValue()); } return list.toArray(new CResourceData[list.size()]); } - private CResourceData getResourceData(IPath path, boolean create, boolean exactPath) throws CoreException{ + private CResourceData getResourceData(IPath path, boolean create, boolean exactPath) + throws CoreException { PathSettingsContainer rcDataH = fRcDataHolder.getChildContainer(path, false, exactPath); if (rcDataH != null) { - return (CResourceData)rcDataH.getValue(); + return (CResourceData) rcDataH.getValue(); } else if (create) { ResourceInfo rcInfo = findResourceInfo(fProject, path, true); CResourceData base = getResourceData(path, false, false); @@ -1418,11 +1456,12 @@ public class PathEntryTranslator { CResourceData newRcData; if (rcInfo.fRc.getType() == IResource.FILE) { if (base.getType() == ICSettingBase.SETTING_FILE) { - newRcData = fCfgData.createFileData(path, (CFileData)base); + newRcData = fCfgData.createFileData(path, (CFileData) base); } else { - CFolderData folderData = (CFolderData)base; + CFolderData folderData = (CFolderData) base; CLanguageData lDatas[] = folderData.getLanguageDatas(); - CLanguageData baseLData = CDataUtil.findLanguagDataForFile(rcInfo.fRc.getFullPath().lastSegment(), fProject, lDatas); + CLanguageData baseLData = CDataUtil + .findLanguagDataForFile(rcInfo.fRc.getFullPath().lastSegment(), fProject, lDatas); newRcData = fCfgData.createFileData(path, folderData, baseLData); } } else { @@ -1430,7 +1469,7 @@ public class PathEntryTranslator { base = getResourceData(base.getPath().removeLastSegments(1), false, false); } - newRcData = fCfgData.createFolderData(path, (CFolderData)base); + newRcData = fCfgData.createFolderData(path, (CFolderData) base); } fRcDataHolder.getChildContainer(path, true, true).setValue(newRcData); @@ -1440,9 +1479,9 @@ public class PathEntryTranslator { } private void applyEntries(CResourceData rcData, RcDesInfo info, int op) { - CLanguageData lDatas[] = rcData.getType() == ICSettingBase.SETTING_FILE ? - new CLanguageData[] { ((CFileData)rcData).getLanguageData() } : - ((CFolderData) rcData).getLanguageDatas(); + CLanguageData lDatas[] = rcData.getType() == ICSettingBase.SETTING_FILE + ? new CLanguageData[] { ((CFileData) rcData).getLanguageData() } + : ((CFolderData) rcData).getLanguageDatas(); for (CLanguageData lData : lDatas) { if (lData == null) @@ -1452,7 +1491,6 @@ public class PathEntryTranslator { } } - private void applyEntries(CLanguageData lData, RcDesInfo info, int op) { int kinds[] = KindBasedStore.getLanguageEntryKinds(); int supported = lData.getSupportedEntryKinds(); @@ -1462,7 +1500,7 @@ public class PathEntryTranslator { ICLanguageSettingEntry opEntries[] = info.getEntries(kind); ICLanguageSettingEntry oldEntries[] = lData.getEntries(kind); - opEntries = (ICLanguageSettingEntry[])replaceUserEntries(oldEntries, opEntries); + opEntries = (ICLanguageSettingEntry[]) replaceUserEntries(oldEntries, opEntries); if (op == OP_REPLACE) oldEntries = null; @@ -1472,13 +1510,14 @@ public class PathEntryTranslator { } private ICLanguageSettingEntry[] composeNewEntries(ICLanguageSettingEntry oldEntries[], - ICLanguageSettingEntry newEntries[], - int op) { + ICLanguageSettingEntry newEntries[], int op) { ICLanguageSettingEntry result[]; switch (op) { - case OP_ADD:{ - Set oldSet = new HashSet(Arrays.asList(oldEntries)); - Set newSet = new HashSet(Arrays.asList(newEntries)); + case OP_ADD: { + Set oldSet = new HashSet( + Arrays.asList(oldEntries)); + Set newSet = new HashSet( + Arrays.asList(newEntries)); newSet.removeAll(oldSet); if (newSet.size() == 0) { result = oldEntries; @@ -1489,9 +1528,11 @@ public class PathEntryTranslator { } break; } - case OP_REMOVE:{ - Set oldSet = new HashSet(Arrays.asList(oldEntries)); - Set newSet = new HashSet(Arrays.asList(newEntries)); + case OP_REMOVE: { + Set oldSet = new HashSet( + Arrays.asList(oldEntries)); + Set newSet = new HashSet( + Arrays.asList(newEntries)); oldSet.removeAll(newSet); if (oldSet.size() == 0) { result = new ICLanguageSettingEntry[0]; @@ -1517,10 +1558,11 @@ public class PathEntryTranslator { private void propagateValues(PathSettingsContainer cr, List langEntryInfoList) { - RcDesInfo rcDes = (RcDesInfo)cr.getValue(); + RcDesInfo rcDes = (RcDesInfo) cr.getValue(); if (rcDes != null) { List rEntries = rcDes.fResolvedEntries; - List curLanfInfos = new ArrayList(rEntries.size() + langEntryInfoList.size()); + List curLanfInfos = new ArrayList( + rEntries.size() + langEntryInfoList.size()); for (ResolvedEntry re : rEntries) { LangEntryInfo li = createLangEntryInfo(re); if (li != null) { @@ -1566,18 +1608,18 @@ public class PathEntryTranslator { switch (peKind) { case IPathEntry.CDT_LIBRARY: return ICSettingEntry.LIBRARY_FILE; -// case IPathEntry.CDT_PROJECT: -// return ICLanguageSettingEntry; -// case IPathEntry.CDT_SOURCE: -// return INDEX_CDT_SOURCE; + // case IPathEntry.CDT_PROJECT: + // return ICLanguageSettingEntry; + // case IPathEntry.CDT_SOURCE: + // return INDEX_CDT_SOURCE; case IPathEntry.CDT_INCLUDE: return ICSettingEntry.INCLUDE_PATH; -// case IPathEntry.CDT_CONTAINER: -// return INDEX_CDT_CONTAINER; + // case IPathEntry.CDT_CONTAINER: + // return INDEX_CDT_CONTAINER; case IPathEntry.CDT_MACRO: return ICSettingEntry.MACRO; -// case IPathEntry.CDT_OUTPUT: -// return INDEX_CDT_OUTPUT; + // case IPathEntry.CDT_OUTPUT: + // return INDEX_CDT_OUTPUT; case IPathEntry.CDT_INCLUDE_FILE: return ICSettingEntry.INCLUDE_FILE; case IPathEntry.CDT_MACRO_FILE: @@ -1590,14 +1632,14 @@ public class PathEntryTranslator { switch (peKind) { case IPathEntry.CDT_LIBRARY: return ICSettingEntry.LIBRARY_FILE; -// case IPathEntry.CDT_PROJECT: -// return ICLanguageSettingEntry; + // case IPathEntry.CDT_PROJECT: + // return ICLanguageSettingEntry; case IPathEntry.CDT_SOURCE: return ICSettingEntry.SOURCE_PATH; case IPathEntry.CDT_INCLUDE: return ICSettingEntry.INCLUDE_PATH; -// case IPathEntry.CDT_CONTAINER: -// return INDEX_CDT_CONTAINER; + // case IPathEntry.CDT_CONTAINER: + // return INDEX_CDT_CONTAINER; case IPathEntry.CDT_MACRO: return ICSettingEntry.MACRO; case IPathEntry.CDT_OUTPUT: @@ -1641,16 +1683,15 @@ public class PathEntryTranslator { private ResolvedEntry createResolvedEntry(IPathEntry entry, PathEntryResolveInfoElement el) { switch (entry.getEntryKind()) { -// case IPathEntry.CDT_PROJECT: -// //should not be here + // case IPathEntry.CDT_PROJECT: + // //should not be here case IPathEntry.CDT_CONTAINER: - //the case of extension path entry container + // the case of extension path entry container return null; } return new ResolvedEntry(entry, el); } - private ResolvedEntry[] getResolvedEntries(IPathEntry[] usrEntries, IPathEntry[] sysEntries) { int length = usrEntries != null ? usrEntries.length : 0; if (sysEntries != null) @@ -1675,12 +1716,13 @@ public class PathEntryTranslator { IPath containerFullPath = container.getFullPath(); IPath fullPath = containerFullPath.append(path); PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullPath, false, false); - ResourceInfo[] baseInfos = (ResourceInfo[])cr.getValue(); + ResourceInfo[] baseInfos = (ResourceInfo[]) cr.getValue(); ResourceInfo[] result; if (!baseInfos[0].fExists) { - // resource does not exist, always create new rc info and not add it to map + // resource does not exist, always create new rc info and not add it + // to map ResourceInfo inexistent = new ResourceInfo(container.getFolder(path), false); - result = new ResourceInfo[]{inexistent}; + result = new ResourceInfo[] { inexistent }; } else { // base exists IPath baseTranslatedPath = cr.getPath(); @@ -1719,7 +1761,7 @@ public class PathEntryTranslator { for (int k = 0; k < baseInfos.length; k++) { baseInfo = baseInfos[k]; - rc = (IFolder)baseInfo.fRc; + rc = (IFolder) baseInfo.fRc; rc = rc.getFolder(filter); result[k] = new ResourceInfo(rc, false); } @@ -1740,7 +1782,7 @@ public class PathEntryTranslator { if (baseRc.getType() == IResource.FILE) { continue; } else { - IContainer baseCr = (IContainer)baseRc; + IContainer baseCr = (IContainer) baseRc; IResource rc = baseCr.findMember(seg); if (rc != null) { ResourceInfo rcInfo = new ResourceInfo(rc, true); @@ -1785,10 +1827,10 @@ public class PathEntryTranslator { return false; } - private void addResolvedFilterToMap(IPath fullFilterPath ,ResourceInfo[] resolved, boolean check) { + private void addResolvedFilterToMap(IPath fullFilterPath, ResourceInfo[] resolved, boolean check) { if (check) { PathSettingsContainer cr = fTranslatedFilters.getChildContainer(fullFilterPath, false, false); - ResourceInfo[] infos = (ResourceInfo[])cr.getValue(); + ResourceInfo[] infos = (ResourceInfo[]) cr.getValue(); if (!infos[0].fExists) return; } @@ -1824,7 +1866,7 @@ public class PathEntryTranslator { private void addRcInfoToMap(ResourceInfo rcInfo) { IPath fullPath = rcInfo.fRc.getFullPath(); fResourceMap.put(fullPath, rcInfo); - addResolvedFilterToMap(fullPath, new ResourceInfo[]{rcInfo}, true); + addResolvedFilterToMap(fullPath, new ResourceInfo[] { rcInfo }, true); } public static IPathEntry[] decodePathEntries(IProject project, ICStorageElement el) { @@ -1897,81 +1939,85 @@ public class PathEntryTranslator { // recreate the entry switch (kind) { - case IPathEntry.CDT_PROJECT: - return CoreModel.newProjectEntry(path, isExported); - case IPathEntry.CDT_LIBRARY: { - IPath libraryPath = new Path(getAttribute(element, ATTRIBUTE_LIBRARY)); - // source attachment info (optional) - IPath sourceAttachmentPath = element.getAttribute(ATTRIBUTE_SOURCEPATH) != null ? new Path( - element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null; - IPath sourceAttachmentRootPath = element.getAttribute(ATTRIBUTE_ROOTPATH) != null ? new Path( - element.getAttribute(ATTRIBUTE_ROOTPATH)) : null; - IPath sourceAttachmentPrefixMapping = element.getAttribute(ATTRIBUTE_PREFIXMAPPING) != null ? new Path( - element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null; + case IPathEntry.CDT_PROJECT: + return CoreModel.newProjectEntry(path, isExported); + case IPathEntry.CDT_LIBRARY: { + IPath libraryPath = new Path(getAttribute(element, ATTRIBUTE_LIBRARY)); + // source attachment info (optional) + IPath sourceAttachmentPath = element.getAttribute(ATTRIBUTE_SOURCEPATH) != null + ? new Path(element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null; + IPath sourceAttachmentRootPath = element.getAttribute(ATTRIBUTE_ROOTPATH) != null + ? new Path(element.getAttribute(ATTRIBUTE_ROOTPATH)) : null; + IPath sourceAttachmentPrefixMapping = element.getAttribute(ATTRIBUTE_PREFIXMAPPING) != null + ? new Path(element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null; - if (!baseRef.isEmpty()) { - return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath); - } - return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath, - sourceAttachmentPrefixMapping, isExported); + if (!baseRef.isEmpty()) { + return CoreModel.newLibraryRefEntry(path, baseRef, libraryPath); } - case IPathEntry.CDT_SOURCE: { - // must be an entry in this project or specify another + return CoreModel.newLibraryEntry(path, basePath, libraryPath, sourceAttachmentPath, + sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); + } + case IPathEntry.CDT_SOURCE: { + // must be an entry in this project or specify another + // project + String projSegment = path.segment(0); + if (projSegment != null && projSegment.equals(project.getName())) { // this // project - String projSegment = path.segment(0); - if (projSegment != null && projSegment.equals(project.getName())) { // this - // project - return CoreModel.newSourceEntry(path, exclusionPatterns); - } - // another project - return CoreModel.newProjectEntry(path, isExported); + return CoreModel.newSourceEntry(path, exclusionPatterns); } - case IPathEntry.CDT_OUTPUT: - return CoreModel.newOutputEntry(path, exclusionPatterns); - case IPathEntry.CDT_INCLUDE: { - // include path info - IPath includePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE)); - // isSysteminclude - boolean isSystemInclude = false; - if (element.getAttribute(ATTRIBUTE_SYSTEM) != null) { - isSystemInclude = getAttribute(element, ATTRIBUTE_SYSTEM).equals(VALUE_TRUE); - } - if (!baseRef.isEmpty()) { - return CoreModel.newIncludeRefEntry(path, baseRef, includePath); - } - return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported); + // another project + return CoreModel.newProjectEntry(path, isExported); + } + case IPathEntry.CDT_OUTPUT: + return CoreModel.newOutputEntry(path, exclusionPatterns); + case IPathEntry.CDT_INCLUDE: { + // include path info + IPath includePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE)); + // isSysteminclude + boolean isSystemInclude = false; + if (element.getAttribute(ATTRIBUTE_SYSTEM) != null) { + isSystemInclude = getAttribute(element, ATTRIBUTE_SYSTEM).equals(VALUE_TRUE); } - case IPathEntry.CDT_INCLUDE_FILE: { - // include path info - IPath includeFilePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE_FILE)); - return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, isExported); + if (!baseRef.isEmpty()) { + return CoreModel.newIncludeRefEntry(path, baseRef, includePath); } - case IPathEntry.CDT_MACRO: { - String macroName = getAttribute(element, ATTRIBUTE_NAME); - String macroValue = getAttribute(element, ATTRIBUTE_VALUE); - if (!baseRef.isEmpty()) { - return CoreModel.newMacroRefEntry(path, baseRef, macroName); - } - return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported); - } - case IPathEntry.CDT_MACRO_FILE: { - IPath macroFilePath = new Path(getAttribute(element, ATTRIBUTE_MACRO_FILE)); - return CoreModel.newMacroFileEntry(path, basePath, baseRef, macroFilePath, exclusionPatterns, isExported); - } - case IPathEntry.CDT_CONTAINER: { - IPath id = new Path(getAttribute(element, ATTRIBUTE_PATH)); - return CoreModel.newContainerEntry(id, isExported); - } - default: { - ICModelStatus status = new CModelStatus(IStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - throw new CModelException(status); + return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, + isExported); + } + case IPathEntry.CDT_INCLUDE_FILE: { + // include path info + IPath includeFilePath = new Path(getAttribute(element, ATTRIBUTE_INCLUDE_FILE)); + return CoreModel.newIncludeFileEntry(path, basePath, baseRef, includeFilePath, exclusionPatterns, + isExported); + } + case IPathEntry.CDT_MACRO: { + String macroName = getAttribute(element, ATTRIBUTE_NAME); + String macroValue = getAttribute(element, ATTRIBUTE_VALUE); + if (!baseRef.isEmpty()) { + return CoreModel.newMacroRefEntry(path, baseRef, macroName); } + return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported); + } + case IPathEntry.CDT_MACRO_FILE: { + IPath macroFilePath = new Path(getAttribute(element, ATTRIBUTE_MACRO_FILE)); + return CoreModel.newMacroFileEntry(path, basePath, baseRef, macroFilePath, exclusionPatterns, + isExported); + } + case IPathEntry.CDT_CONTAINER: { + IPath id = new Path(getAttribute(element, ATTRIBUTE_PATH)); + return CoreModel.newContainerEntry(id, isExported); + } + default: { + ICModelStatus status = new CModelStatus(IStatus.ERROR, + "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CModelException(status); + } } } private static CConfigurationData getCfgData(ICConfigurationDescription cfgDescription) { - return cfgDescription instanceof CConfigurationDescriptionCache ? - (CConfigurationData)cfgDescription : ((IInternalCCfgInfo)cfgDescription).getConfigurationData(false); + return cfgDescription instanceof CConfigurationDescriptionCache ? (CConfigurationData) cfgDescription + : ((IInternalCCfgInfo) cfgDescription).getConfigurationData(false); } private static void addOutputEntries(PathEntryCollector cr, CConfigurationData cfgData) { @@ -1984,20 +2030,22 @@ public class PathEntryTranslator { } } - public static PathEntryCollector collectEntries(IProject project, final ICConfigurationDescription cfgDescription) { + public static PathEntryCollector collectEntries(IProject project, + final ICConfigurationDescription cfgDescription) { CConfigurationData cfgData = getCfgData(cfgDescription); ReferenceSettingsInfo refInfo = new ReferenceSettingsInfo(cfgDescription); - ICConfigurationDescription[] allCfgDescriptions = cfgDescription.isPreferenceConfiguration() ? - new ICConfigurationDescription[] { cfgDescription } : - cfgDescription.getProjectDescription().getConfigurations(); + ICConfigurationDescription[] allCfgDescriptions = cfgDescription.isPreferenceConfiguration() + ? new ICConfigurationDescription[] { cfgDescription } + : cfgDescription.getProjectDescription().getConfigurations(); CConfigurationData[] allDatas = new CConfigurationData[allCfgDescriptions.length]; for (int i = 0; i < allCfgDescriptions.length; i++) { allDatas[i] = getCfgData(allCfgDescriptions[i]); } - final PathEntryCollector collector = new PathEntryCollector(project/*, cfgDescription*/); + final PathEntryCollector collector = new PathEntryCollector( + project/* , cfgDescription */); PathSettingsContainer rcDatas = createRcDataHolder(cfgData); ICSourceEntry sEntries[] = cfgData.getSourceEntries(); if (sEntries != null && sEntries.length != 0) { @@ -2017,13 +2065,14 @@ public class PathEntryTranslator { rcDatas.accept(new IPathSettingsContainerVisitor() { @Override public boolean visit(PathSettingsContainer container) { - CResourceData rcData = (CResourceData)container.getValue(); + CResourceData rcData = (CResourceData) container.getValue(); if (rcData != null) { PathEntryCollector child = collector.createChild(container.getPath()); for (int kind : kinds) { Set set = new LinkedHashSet(); if (collectResourceDataEntries(cfgDescription, kind, rcData, set)) { - ICLanguageSettingEntry[] entries = set.toArray(new ICLanguageSettingEntry[set.size()]); + ICLanguageSettingEntry[] entries = set + .toArray(new ICLanguageSettingEntry[set.size()]); child.setEntries(kind, entries, exportedSettings); } } @@ -2034,16 +2083,18 @@ public class PathEntryTranslator { return collector; } - private static boolean collectResourceDataEntries(ICConfigurationDescription cfgDescription, int kind, CResourceData rcData, Set list) { + private static boolean collectResourceDataEntries(ICConfigurationDescription cfgDescription, int kind, + CResourceData rcData, Set list) { CLanguageData[] lDatas = null; if (rcData instanceof CFolderData) { - lDatas = ((CFolderData)rcData).getLanguageDatas(); + lDatas = ((CFolderData) rcData).getLanguageDatas(); } else if (rcData instanceof CFileData) { - CLanguageData lData = ((CFileData)rcData).getLanguageData(); + CLanguageData lData = ((CFileData) rcData).getLanguageData(); if (lData != null) - lDatas = new CLanguageData[] {lData}; + lDatas = new CLanguageData[] { lData }; } else { - Exception e = new Exception(UtilMessages.getString("PathEntryTranslator.1") + rcData.getClass().getName()); //$NON-NLS-1$ + Exception e = new Exception( + UtilMessages.getString("PathEntryTranslator.1") + rcData.getClass().getName()); //$NON-NLS-1$ IStatus status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e); CCorePlugin.log(status); } @@ -2055,13 +2106,19 @@ public class PathEntryTranslator { if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(project)) { IResource rc = findResourceInWorkspace(project, rcData.getPath()); if (rc == null) { - // If resource does not exist make a handle to be able to supply the path. + // If resource does not exist make a handle to be able to supply + // the path. // This does not create actual resource. - // Gotta be a folder so language settings provider won't filter out languages. + // Gotta be a folder so language settings provider won't filter + // out languages. rc = project.getFolder(rcData.getPath()); } - for (CLanguageData lData : lDatas) { - list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, lData.getLanguageId(), kind)); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + if (config != null) { + for (CLanguageData lData : lDatas) { + list.addAll(LanguageSettingsProvidersSerializer.getSettingEntriesByKind(config, rc, + lData.getLanguageId(), kind)); + } } return list.size() > 0; @@ -2075,7 +2132,8 @@ public class PathEntryTranslator { return supported; } - private static boolean collectLanguageDataEntries(int kind, CLanguageData lData, Set list) { + private static boolean collectLanguageDataEntries(int kind, CLanguageData lData, + Set list) { if ((kind & lData.getSupportedEntryKinds()) != 0) { ICLanguageSettingEntry[] entries = lData.getEntries(kind); if (entries != null && entries.length != 0) { @@ -2087,7 +2145,8 @@ public class PathEntryTranslator { return false; } - public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfgDescription, int flags) { + public static IPathEntry[] getPathEntries(IProject project, ICConfigurationDescription cfgDescription, + int flags) { PathEntryCollector cr = collectEntries(project, cfgDescription); return cr.getEntries(flags, cfgDescription); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java index a9ea09964e7..a4612599e17 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsProvidersSerializer.java @@ -41,6 +41,7 @@ import org.eclipse.cdt.internal.core.settings.model.CConfigurationSpecSettings; import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo; import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages; import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -69,7 +70,8 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * Helper class handling serialization and notifications for language settings entries {@link ICLanguageSettingEntry}. + * Helper class handling serialization and notifications for language settings entries + * {@link ICLanguageSettingEntry}. */ public class LanguageSettingsProvidersSerializer { public static final String PROVIDER_EXTENSION_POINT_ID = LanguageSettingsExtensionManager.PROVIDER_EXTENSION_POINT_ID; @@ -118,17 +120,22 @@ public class LanguageSettingsProvidersSerializer { */ private static class NotAccessibleProvider implements ILanguageSettingsProvider { private final String id; + private NotAccessibleProvider(String providerId) { this.id = providerId; } + @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { return null; } + @Override public String getName() { return null; } + @Override public String getId() { return id; @@ -150,10 +157,11 @@ public class LanguageSettingsProvidersSerializer { /** * Wrapper for workspace providers to ensure level of indirection. That way workspace providers - * can be changed/replaced without notifying/changing the configurations which keep the providers - * in their lists. + * can be changed/replaced without notifying/changing the configurations which keep the + * providers in their lists. */ - private static class LanguageSettingsWorkspaceProvider implements ILanguageSettingsProvider, ICListenerAgent { + private static class LanguageSettingsWorkspaceProvider + implements ILanguageSettingsProvider, ICListenerAgent { private String providerId; private int projectCount = 0; @@ -170,15 +178,28 @@ public class LanguageSettingsProvidersSerializer { @Override public String getName() { ILanguageSettingsProvider rawProvider = getRawProvider(); - String name = rawProvider!=null ? rawProvider.getName() : null; + String name = rawProvider != null ? rawProvider.getName() : null; return name; } @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { ILanguageSettingsProvider rawProvider = getRawProvider(); - List entries = rawProvider!=null ? rawProvider.getSettingEntries(cfgDescription, rc, languageId) : null; - return entries; + if (rawProvider != null) { + if (config != null) { + ICConfigurationDescription cfgDesc = config.getAdapter(ICConfigurationDescription.class); + if (cfgDesc != null) { + List entriesOld = rawProvider.getSettingEntries(cfgDesc, rc, + languageId); + if (entriesOld != null) { + return entriesOld; + } + } + } + return rawProvider.getSettingEntries(config, rc, languageId); + } + return null; } /** @@ -203,13 +224,13 @@ public class LanguageSettingsProvidersSerializer { @SuppressWarnings("nls") @Override public String toString() { - return "id="+getId()+", name="+getName(); + return "id=" + getId() + ", name=" + getName(); } /** - * We count number of times workspace provider (not the raw one!) associated - * with a project. If a project includes it multiple times via different configurations - * it still counts as 1. + * We count number of times workspace provider (not the raw one!) associated with a + * project. If a project includes it multiple times via different configurations it + * still counts as 1. */ private int getProjectCount() { return projectCount; @@ -249,17 +270,18 @@ public class LanguageSettingsProvidersSerializer { */ private static class LanguageSettingsChangeEvent implements ILanguageSettingsChangeEvent { private String projectName = null; - private Map deltaMap = new HashMap(); + private Map deltaMap = new HashMap(); /** - * The act of creating event resets internal delta count in configuration state. - * That implies that when the event is retrieved it must be fired or delta will go missing. - * That side effect is here to ensure atomic processing of firing & resetting the delta. + * The act of creating event resets internal delta count in configuration state. That + * implies that when the event is retrieved it must be fired or delta will go missing. That + * side effect is here to ensure atomic processing of firing & resetting the delta. */ public LanguageSettingsChangeEvent(ICProjectDescription prjDescription) { if (!prjDescription.isReadOnly()) { // The logic goes that we send notifications only for acting description but not for currently being prepared to set - String msg = "Project description " + prjDescription.getName() + " is expected to be read-only"; //$NON-NLS-1$ //$NON-NLS-2$ + String msg = "Project description " + prjDescription.getName() //$NON-NLS-1$ + + " is expected to be read-only"; //$NON-NLS-1$ CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg, new Exception(msg))); } @@ -275,7 +297,8 @@ public class LanguageSettingsProvidersSerializer { } if (specSettings != null) { String cfgId = cfgDescription.getId(); - if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(prjDescription.getProject())) { + if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled( + prjDescription.getProject())) { LanguageSettingsDelta delta = specSettings.dropDelta(); if (delta != null) { deltaMap.put(cfgId, delta); @@ -284,9 +307,11 @@ public class LanguageSettingsProvidersSerializer { deltaMap.remove(cfgId); } } else { - IStatus ss = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Internal error: Missing specSettings for " //$NON-NLS-1$ - + cfgDescription.getClass().getSimpleName()); - CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, ss.getMessage(), new CoreException(ss))); + IStatus ss = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, + "Internal error: Missing specSettings for " //$NON-NLS-1$ + + cfgDescription.getClass().getSimpleName()); + CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, ss.getMessage(), + new CoreException(ss))); } } } @@ -305,8 +330,8 @@ public class LanguageSettingsProvidersSerializer { @SuppressWarnings("nls") @Override public String toString() { - return "LanguageSettingsChangeEvent for project=[" + getProjectName() + "]" - + ", configurations=" + deltaMap.keySet(); + return "LanguageSettingsChangeEvent for project=[" + getProjectName() + "]" + ", configurations=" + + deltaMap.keySet(); } @Override @@ -341,11 +366,12 @@ public class LanguageSettingsProvidersSerializer { } /** - * Tells if language settings entries of the provider are persisted with the project - * (under .settings/ folder) or in workspace area. Persistence in the project area lets - * the entries migrate with the project. + * Tells if language settings entries of the provider are persisted with the project (under + * .settings/ folder) or in workspace area. Persistence in the project area lets the entries + * migrate with the project. * - * @param provider - provider to check the persistence mode. + * @param provider + * - provider to check the persistence mode. * @return {@code true} if LSE persisted with the project or {@code false} if in the workspace. */ public static boolean isStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider) { @@ -355,18 +381,22 @@ public class LanguageSettingsProvidersSerializer { /** * Define where language settings are persisted for the provider. * - * @param provider - provider to set the persistence mode. - * @param storeEntriesWithProject - {@code true} if with the project, - * {@code false} if in workspace area. + * @param provider + * - provider to set the persistence mode. + * @param storeEntriesWithProject + * - {@code true} if with the project, {@code false} if in workspace area. */ - public static void setStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, boolean storeEntriesWithProject) { + public static void setStoringEntriesInProjectArea(LanguageSettingsSerializableProvider provider, + boolean storeEntriesWithProject) { provider.setPropertyBool(ATTR_STORE_ENTRIES_WITH_PROJECT, storeEntriesWithProject); } /** - * Determine location of the project store of language settings providers in the plug-in state area. + * Determine location of the project store of language settings providers in the plug-in state + * area. * - * @param store - name of the store. + * @param store + * - name of the store. * @return location of the store in the plug-in state area. */ private static IFile getStoreInProjectArea(IProject project) { @@ -376,7 +406,8 @@ public class LanguageSettingsProvidersSerializer { /** * Determine location of the store in the plug-in state area. * - * @param store - name of the store. + * @param store + * - name of the store. * @return location of the store in the plug-in state area. */ private static URI getStoreInWorkspaceArea(String store) { @@ -387,22 +418,26 @@ public class LanguageSettingsProvidersSerializer { /** * Set and store user defined providers in workspace area. * - * @param providers - array of user defined providers - * @throws CoreException in case of problems + * @param providers + * - array of user defined providers + * @throws CoreException + * in case of problems */ public static void setWorkspaceProviders(List providers) throws CoreException { setWorkspaceProvidersInternal(providers); serializeLanguageSettingsWorkspaceInBackground(); // generate preference change event for preference change listeners (value is not intended to be used) IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID); - prefs.putBoolean(PREFERENCE_WORSPACE_PROVIDERS_SET, ! prefs.getBoolean(PREFERENCE_WORSPACE_PROVIDERS_SET, false)); + prefs.putBoolean(PREFERENCE_WORSPACE_PROVIDERS_SET, + !prefs.getBoolean(PREFERENCE_WORSPACE_PROVIDERS_SET, false)); } /** * Internal method to set user defined providers in memory. * - * @param providers - list of user defined providers. If {@code null} - * is passed user defined providers are cleared. + * @param providers + * - list of user defined providers. If {@code null} is passed user defined providers + * are cleared. */ private static void setWorkspaceProvidersInternal(List providers) { Map rawNewProviders = new HashMap(); @@ -423,7 +458,8 @@ public class LanguageSettingsProvidersSerializer { // this list is independent from the internal list of extensions in LanguageSettingsExtensionManager for (String id : LanguageSettingsExtensionManager.getExtensionProviderIds()) { if (!rawNewProviders.containsKey(id)) { - ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.getExtensionProviderCopy(id, true); + ILanguageSettingsProvider provider = LanguageSettingsExtensionManager + .getExtensionProviderCopy(id, true); if (provider == null) { provider = LanguageSettingsExtensionManager.loadProvider(id); } @@ -439,7 +475,8 @@ public class LanguageSettingsProvidersSerializer { for (ICListenerAgent oldListener : oldListeners) { if (!isInList(newListeners, oldListener)) { - LanguageSettingsWorkspaceProvider wspProvider = (LanguageSettingsWorkspaceProvider) globalWorkspaceProviders.get(((ILanguageSettingsProvider)oldListener).getId()); + LanguageSettingsWorkspaceProvider wspProvider = (LanguageSettingsWorkspaceProvider) globalWorkspaceProviders + .get(((ILanguageSettingsProvider) oldListener).getId()); if (wspProvider != null && wspProvider.getProjectCount() > 0) { oldListener.unregisterListener(); } @@ -448,7 +485,8 @@ public class LanguageSettingsProvidersSerializer { for (ICListenerAgent newListener : newListeners) { if (!isInList(oldListeners, newListener)) { - LanguageSettingsWorkspaceProvider wspProvider = (LanguageSettingsWorkspaceProvider) globalWorkspaceProviders.get(((ILanguageSettingsProvider)newListener).getId()); + LanguageSettingsWorkspaceProvider wspProvider = (LanguageSettingsWorkspaceProvider) globalWorkspaceProviders + .get(((ILanguageSettingsProvider) newListener).getId()); if (wspProvider != null && wspProvider.getProjectCount() > 0) { newListener.registerListener(null); } @@ -461,11 +499,13 @@ public class LanguageSettingsProvidersSerializer { /** * Create event for language settings changes of workspace providers in a project. */ - private static LanguageSettingsChangeEvent createEvent(ICProjectDescription prjDescription, List providerIds) { + private static LanguageSettingsChangeEvent createEvent(ICProjectDescription prjDescription, + List providerIds) { ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - for (ILanguageSettingsProvider provider : ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { + for (ILanguageSettingsProvider provider : ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders()) { if (isWorkspaceProvider(provider) && providerIds.contains(provider.getId())) { LanguageSettingsChangeEvent event = new LanguageSettingsChangeEvent(prjDescription); if (event.getConfigurationDescriptionIds().length > 0) { @@ -483,7 +523,8 @@ public class LanguageSettingsProvidersSerializer { /** * Compute events for language settings changes in workspace. */ - private static List createLanguageSettingsChangeEvents(List providers) { + private static List createLanguageSettingsChangeEvents( + List providers) { List events = new ArrayList(); List providerIds = new ArrayList(); @@ -497,7 +538,8 @@ public class LanguageSettingsProvidersSerializer { for (IProject project : projects) { try { if (project.isAccessible()) { - ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project, false); + ICProjectDescription prjDescription = CCorePlugin.getDefault() + .getProjectDescription(project, false); if (prjDescription != null) { LanguageSettingsChangeEvent event = createEvent(prjDescription, providerIds); if (event != null) { @@ -507,8 +549,9 @@ public class LanguageSettingsProvidersSerializer { } } catch (Throwable e) { // log and swallow any exception - CCorePlugin.log("Error creating event about changes in workspace language settings providers, " //$NON-NLS-1$ - + "project=" + project.getName(), e); //$NON-NLS-1$ + CCorePlugin + .log("Error creating event about changes in workspace language settings providers, " //$NON-NLS-1$ + + "project=" + project.getName(), e); //$NON-NLS-1$ } } @@ -518,6 +561,7 @@ public class LanguageSettingsProvidersSerializer { /** * Save language settings providers of the workspace (global providers) to persistent storage. + * * @throws CoreException */ public static void serializeLanguageSettingsWorkspace() throws CoreException { @@ -526,11 +570,11 @@ public class LanguageSettingsProvidersSerializer { List serializingWorkspaceProviders = new ArrayList(); for (ILanguageSettingsProvider provider : rawGlobalWorkspaceProviders.values()) { if (provider instanceof ILanguageSettingsBroadcastingProvider) { - broadcastingWorkspaceProviders.add((ILanguageSettingsBroadcastingProvider)provider); + broadcastingWorkspaceProviders.add((ILanguageSettingsBroadcastingProvider) provider); } if (provider instanceof LanguageSettingsSerializableProvider) { if (!LanguageSettingsManager.isEqualExtensionProvider(provider, true)) { - serializingWorkspaceProviders.add((LanguageSettingsSerializableProvider)provider); + serializingWorkspaceProviders.add((LanguageSettingsSerializableProvider) provider); } } } @@ -550,7 +594,7 @@ public class LanguageSettingsProvidersSerializer { Document doc = XmlUtil.newDocument(); Element rootElement = XmlUtil.appendElement(doc, ELEM_PLUGIN); Element elementExtension = XmlUtil.appendElement(rootElement, ELEM_EXTENSION, - new String[] {ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + new String[] { ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID }); for (LanguageSettingsSerializableProvider provider : serializingWorkspaceProviders) { provider.serialize(elementExtension); @@ -582,8 +626,8 @@ public class LanguageSettingsProvidersSerializer { } /** - * Save language settings providers of the workspace (global providers) to persistent storage - * in background. + * Save language settings providers of the workspace (global providers) to persistent storage in + * background. */ public static void serializeLanguageSettingsWorkspaceInBackground() { Job[] jobs = Job.getJobManager().find(JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE); @@ -594,11 +638,14 @@ public class LanguageSettingsProvidersSerializer { } } - Job job = new WorkspaceJob(SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializeJobName")) { //$NON-NLS-1$ + Job job = new WorkspaceJob( + SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializeJobName")) { //$NON-NLS-1$ @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { - monitor.beginTask(SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializingForWorkspace"), //$NON-NLS-1$ + monitor.beginTask( + SettingsModelMessages + .getString("LanguageSettingsProvidersSerializer.SerializingForWorkspace"), //$NON-NLS-1$ TICKS_SERIALIZING); serializeLanguageSettingsWorkspace(); monitor.worked(TICKS_SERIALIZING); @@ -610,6 +657,7 @@ public class LanguageSettingsProvidersSerializer { monitor.done(); } } + @Override public boolean belongsTo(Object family) { return family == JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_WORKSPACE; @@ -620,7 +668,6 @@ public class LanguageSettingsProvidersSerializer { job.schedule(); } - /** * Load language settings for workspace. */ @@ -636,7 +683,7 @@ public class LanguageSettingsProvidersSerializer { Thread.currentThread().interrupt(); } - List providers = null; + List providers = null; URI uriStoreWsp = getStoreInWorkspaceArea(STORAGE_WORKSPACE_LANGUAGE_SETTINGS); @@ -661,7 +708,8 @@ public class LanguageSettingsProvidersSerializer { Node providerNode = providerNodes.item(i); final String providerId = XmlUtil.determineAttributeValue(providerNode, ATTR_ID); if (userDefinedProvidersIds.contains(providerId)) { - String msg = "Ignored an attempt to persist duplicate language settings provider, id=" + providerId; //$NON-NLS-1$ + String msg = "Ignored an attempt to persist duplicate language settings provider, id=" //$NON-NLS-1$ + + providerId; CCorePlugin.log(new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg, new Exception())); continue; } @@ -683,23 +731,24 @@ public class LanguageSettingsProvidersSerializer { } /** - * @noreference This method is not intended to be referenced by clients. - * It is public solely for benefit of JUnit testing. + * @noreference This method is not intended to be referenced by clients. It is public solely for + * benefit of JUnit testing. */ - public static void serializeLanguageSettingsInternal(Element projectElementPrjStore, Element projectElementWspStore, ICProjectDescription prjDescription) { + public static void serializeLanguageSettingsInternal(Element projectElementPrjStore, + Element projectElementWspStore, ICProjectDescription prjDescription) { ICConfigurationDescription[] cfgDescriptions = prjDescription.getConfigurations(); for (ICConfigurationDescription cfgDescription : cfgDescriptions) { if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) continue; - // no lazy initialization as we may need to save 0 providers when it is different from default - Element elementConfiguration = XmlUtil.appendElement(projectElementPrjStore, ELEM_CONFIGURATION, new String[] { - ATTR_ID, cfgDescription.getId(), - ATTR_NAME, cfgDescription.getName(), - }); + // no lazy initialization as we may need to save 0 providers when it + // is different from default + Element elementConfiguration = XmlUtil.appendElement(projectElementPrjStore, ELEM_CONFIGURATION, + new String[] { ATTR_ID, cfgDescription.getId(), ATTR_NAME, cfgDescription.getName(), }); Element elementConfigurationWsp = null; - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); if (providers.size() > 0) { Element elementExtension = null; Element elementExtensionWsp = null; @@ -707,65 +756,63 @@ public class LanguageSettingsProvidersSerializer { for (ILanguageSettingsProvider provider : providers) { if (isWorkspaceProvider(provider)) { if (elementExtension == null) { - elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, + new String[] { ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID }); } // Element elementProviderReference = XmlUtil.appendElement(elementExtension, ELEM_PROVIDER_REFERENCE, new String[] { - ATTR_ID, provider.getId(), - ATTR_REF, VALUE_REF_SHARED_PROVIDER, - }); + ATTR_ID, provider.getId(), ATTR_REF, VALUE_REF_SHARED_PROVIDER, }); continue; } if (!(provider instanceof LanguageSettingsSerializableProvider)) { if (elementExtension == null) { - elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, + new String[] { ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID }); } // Element elementProvider = - XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] { - ATTR_ID, provider.getId(), - ATTR_NAME, provider.getName(), - ATTR_CLASS, provider.getClass().getCanonicalName(), - }); + XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, + new String[] { ATTR_ID, provider.getId(), ATTR_NAME, provider.getName(), + ATTR_CLASS, provider.getClass().getCanonicalName(), }); } else if (LanguageSettingsManager.isEqualExtensionProvider(provider, true)) { if (elementExtension == null) { - elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, + new String[] { ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID }); } // Element elementProvider = - XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] { - ATTR_ID, provider.getId(), - ATTR_COPY_OF, VALUE_COPY_OF_EXTENSION, - }); + XmlUtil.appendElement(elementExtension, ELEM_PROVIDER, new String[] { ATTR_ID, + provider.getId(), ATTR_COPY_OF, VALUE_COPY_OF_EXTENSION, }); } else { try { LanguageSettingsSerializableProvider lss = (LanguageSettingsSerializableProvider) provider; - boolean isWspStorageAvailable = (projectElementWspStore != null) && (projectElementPrjStore != projectElementWspStore); + boolean isWspStorageAvailable = (projectElementWspStore != null) + && (projectElementPrjStore != projectElementWspStore); if (isStoringEntriesInProjectArea(lss) || !isWspStorageAvailable) { if (elementExtension == null) { - elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtension = XmlUtil.appendElement(elementConfiguration, + ELEM_EXTENSION, new String[] { ATTR_EXTENSION_POINT, + PROVIDER_EXTENSION_POINT_ID }); } lss.serialize(elementExtension); } else { if (elementExtension == null) { - elementExtension = XmlUtil.appendElement(elementConfiguration, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtension = XmlUtil.appendElement(elementConfiguration, + ELEM_EXTENSION, new String[] { ATTR_EXTENSION_POINT, + PROVIDER_EXTENSION_POINT_ID }); } if (elementExtensionWsp == null) { if (elementConfigurationWsp == null) { - elementConfigurationWsp = XmlUtil.appendElement(projectElementWspStore, ELEM_CONFIGURATION, new String[] { - ATTR_ID, cfgDescription.getId(), - ATTR_NAME, cfgDescription.getName(), - }); + elementConfigurationWsp = XmlUtil.appendElement( + projectElementWspStore, ELEM_CONFIGURATION, + new String[] { ATTR_ID, cfgDescription.getId(), ATTR_NAME, + cfgDescription.getName(), }); } - elementExtensionWsp = XmlUtil.appendElement(elementConfigurationWsp, ELEM_EXTENSION, new String[] { - ATTR_EXTENSION_POINT, PROVIDER_EXTENSION_POINT_ID}); + elementExtensionWsp = XmlUtil.appendElement(elementConfigurationWsp, + ELEM_EXTENSION, new String[] { ATTR_EXTENSION_POINT, + PROVIDER_EXTENSION_POINT_ID }); } - Element elementProviderWsp = XmlUtil.appendElement(elementExtensionWsp, ELEM_PROVIDER, new String[] { - ATTR_ID, provider.getId() }); // no attributes kept in workspace storage + Element elementProviderWsp = XmlUtil.appendElement(elementExtensionWsp, + ELEM_PROVIDER, new String[] { ATTR_ID, provider.getId() }); // no attributes kept in workspace storage // split storage lss.serializeAttributes(elementExtension); @@ -773,7 +820,7 @@ public class LanguageSettingsProvidersSerializer { } } catch (Throwable e) { // protect from any exceptions from implementers - CCorePlugin.log("Exception trying serialize provider "+provider.getId(), e); //$NON-NLS-1$ + CCorePlugin.log("Exception trying serialize provider " + provider.getId(), e); //$NON-NLS-1$ } } } @@ -791,13 +838,15 @@ public class LanguageSettingsProvidersSerializer { continue; } - String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); + String[] defaultIds = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getDefaultLanguageSettingsProvidersIds(); if (defaultIds == null) { defaultIds = ScannerDiscoveryLegacySupport.getDefaultProviderIdsLegacy(cfgDescription); } // check size - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); if (providers.size() != defaultIds.length) { return false; } @@ -830,20 +879,24 @@ public class LanguageSettingsProvidersSerializer { /** * Save language settings providers of a project to persistent storage. * - * @param prjDescription - project description of the project. - * @throws CoreException if something goes wrong. + * @param prjDescription + * - project description of the project. + * @throws CoreException + * if something goes wrong. */ public static void serializeLanguageSettings(ICProjectDescription prjDescription) throws CoreException { IProject project = prjDescription.getProject(); try { - // Add the storage module to .cpoject and persist on disk as a side effect of adding + // Add the storage module to .cpoject and persist on disk as a side + // effect of adding prjDescription.getStorage(CPROJECT_STORAGE_MODULE_LANGUAGE_SETTINGS_PROVIDERS, true); } catch (CoreException e) { CCorePlugin.log("Internal error while trying to serialize language settings", e); //$NON-NLS-1$ } try { - // The storage could be split in two, one for provider properties, another one for entries, + // The storage could be split in two, one for provider properties, + // another one for entries, // depending on provider flag // Document to store in project area @@ -853,20 +906,24 @@ public class LanguageSettingsProvidersSerializer { Document docStoreWsp = XmlUtil.newDocument(); Element projectElementStoreWsp = XmlUtil.appendElement(docStoreWsp, ELEM_PROJECT); - URI uriStoreWsp = getStoreInWorkspaceArea(project.getName()+'.'+STORAGE_WORKSPACE_LANGUAGE_SETTINGS); + URI uriStoreWsp = getStoreInWorkspaceArea( + project.getName() + '.' + STORAGE_WORKSPACE_LANGUAGE_SETTINGS); LanguageSettingsChangeEvent event = null; try { - // Note that need for serialization may exist even if LS *entries* event delta is empty, + // Note that need for serialization may exist even if LS + // *entries* event delta is empty, // as set of providers or their properties may differ serializingLock.acquire(); if (!isEqualToDefaultProviders(prjDescription)) { - serializeLanguageSettingsInternal(projectElementStorePrj, projectElementStoreWsp, prjDescription); + serializeLanguageSettingsInternal(projectElementStorePrj, projectElementStoreWsp, + prjDescription); } - // Absent store means default providers as specified in the toolchain + // Absent store means default providers as specified in the + // toolchain IFile fileStorePrj = getStoreInProjectArea(project); boolean isProjectStoreEmpty = projectElementStorePrj.getChildNodes().getLength() == 0; if (isProjectStoreEmpty) { @@ -888,7 +945,7 @@ public class LanguageSettingsProvidersSerializer { } else { String eol = Util.getLineSeparator(uriStoreWsp); if (eol == null) { - eol = Util.getDefaultLineSeparator(project); + eol = Util.getDefaultLineSeparator(project); } XmlUtil.serializeXml(docStoreWsp, uriStoreWsp, eol); } @@ -913,25 +970,31 @@ public class LanguageSettingsProvidersSerializer { /** * Save language settings providers of a project to persistent storage in background. * - * @param prjDescription - project description of the project. + * @param prjDescription + * - project description of the project. */ public static void serializeLanguageSettingsInBackground(final ICProjectDescription prjDescription) { - Job job = new Job(SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializeJobName")) { //$NON-NLS-1$ + Job job = new Job( + SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializeJobName")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { try { - monitor.beginTask(NLS.bind(SettingsModelMessages.getString("LanguageSettingsProvidersSerializer.SerializingForProject"), //$NON-NLS-1$ + monitor.beginTask(NLS.bind( + SettingsModelMessages + .getString("LanguageSettingsProvidersSerializer.SerializingForProject"), //$NON-NLS-1$ prjDescription.getName()), TICKS_SERIALIZING); serializeLanguageSettings(prjDescription); monitor.worked(TICKS_SERIALIZING); return Status.OK_STATUS; } catch (Throwable e) { - String msg = "Internal error running job of serializing language settings for project " + prjDescription.getName(); //$NON-NLS-1$ + String msg = "Internal error running job of serializing language settings for project " //$NON-NLS-1$ + + prjDescription.getName(); return new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, msg, e); } finally { monitor.done(); } } + @Override public boolean belongsTo(Object family) { return family == JOB_FAMILY_SERIALIZE_LANGUAGE_SETTINGS_PROJECT; @@ -964,19 +1027,15 @@ public class LanguageSettingsProvidersSerializer { /** * Load language settings to the project description from XML. * - * @noreference This method is not intended to be referenced by clients. - * It is public solely for benefit of JUnit testing. + * @noreference This method is not intended to be referenced by clients. It is public solely for + * benefit of JUnit testing. */ - public static void loadLanguageSettingsInternal(Element projectElementPrj, Element projectElementWsp, ICProjectDescription prjDescription) { + public static void loadLanguageSettingsInternal(Element projectElementPrj, Element projectElementWsp, + ICProjectDescription prjDescription) { /* - - - - - - - - + * + * */ NodeList configurationNodes = projectElementPrj.getChildNodes(); for (int ic = 0; ic < configurationNodes.getLength(); ic++) { @@ -1006,13 +1065,16 @@ public class LanguageSettingsProvidersSerializer { } else if (isElementWithName(providerNode, ELEM_PROVIDER)) { String providerClass = XmlUtil.determineAttributeValue(providerNode, ATTR_CLASS); if (providerClass == null || providerClass.isEmpty()) { - // provider is copied from extension if "class" is not supplied + // provider is copied from extension if "class" is + // not supplied String providerId = XmlUtil.determineAttributeValue(providerNode, ATTR_ID); provider = LanguageSettingsManager.getExtensionProviderCopy(providerId, true); if (provider == null) { - String msg = "Internal Error trying to retrieve copy of extension provider id=" + providerId; //$NON-NLS-1$ - CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, msg, new Exception(msg))); + String msg = "Internal Error trying to retrieve copy of extension provider id=" //$NON-NLS-1$ + + providerId; + CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, msg, + new Exception(msg))); provider = LanguageSettingsManager.getWorkspaceProvider(providerId); } @@ -1022,7 +1084,8 @@ public class LanguageSettingsProvidersSerializer { } catch (CoreException e) { @SuppressWarnings("nls") String msg = "Error loading provider class=[" + providerClass + "] " - + "in project=" + prjDescription.getProject().getName() + ", cfg=[" + cfgId + "]"; + + "in project=" + prjDescription.getProject().getName() + ", cfg=[" + + cfgId + "]"; CCorePlugin.log(msg, e); } if (provider instanceof LanguageSettingsSerializableProvider) { @@ -1047,7 +1110,8 @@ public class LanguageSettingsProvidersSerializer { /** * Set providers into configuration description avoiding triggering an event. */ - private static void setProvidersWithoutNotification(ICConfigurationDescription cfgDescription, List providers) { + private static void setProvidersWithoutNotification(ICConfigurationDescription cfgDescription, + List providers) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); if (cfgDescription instanceof IInternalCCfgInfo) { @@ -1071,17 +1135,12 @@ public class LanguageSettingsProvidersSerializer { /** * Load provider entries for the given configuration from XML Element. */ - private static void loadProviderEntries(LanguageSettingsSerializableProvider provider, - String cfgId, Element projectElement) { + private static void loadProviderEntries(LanguageSettingsSerializableProvider provider, String cfgId, + Element projectElement) { /* - - - - - - - - + * + * */ NodeList configurationNodes = projectElement.getChildNodes(); for (int ic = 0; ic < configurationNodes.getLength(); ic++) { @@ -1123,17 +1182,20 @@ public class LanguageSettingsProvidersSerializer { */ private static ILanguageSettingsProvider loadProvider(Node providerNode) throws CoreException { String attrClass = XmlUtil.determineAttributeValue(providerNode, ATTR_CLASS); - ILanguageSettingsProvider provider = LanguageSettingsExtensionManager.instantiateProviderClass(attrClass); + ILanguageSettingsProvider provider = LanguageSettingsExtensionManager + .instantiateProviderClass(attrClass); if (provider instanceof LanguageSettingsSerializableProvider) { - ((LanguageSettingsSerializableProvider)provider).load((Element) providerNode); + ((LanguageSettingsSerializableProvider) provider).load((Element) providerNode); } return provider; } /** * Load language settings from workspace and project storages for the given project description. - * @param prjDescription - project description to load language settings. + * + * @param prjDescription + * - project description to load language settings. */ public static void loadLanguageSettings(ICProjectDescription prjDescription) { IProject project = prjDescription.getProject(); @@ -1145,7 +1207,8 @@ public class LanguageSettingsProvidersSerializer { doc = XmlUtil.loadXml(storeInPrjArea); Element rootElementPrj = doc.getDocumentElement(); // - URI uriStoreWsp = getStoreInWorkspaceArea(project.getName()+'.'+STORAGE_WORKSPACE_LANGUAGE_SETTINGS); + URI uriStoreWsp = getStoreInWorkspaceArea( + project.getName() + '.' + STORAGE_WORKSPACE_LANGUAGE_SETTINGS); Document docWsp = null; try { serializingLock.acquire(); @@ -1164,12 +1227,15 @@ public class LanguageSettingsProvidersSerializer { CCorePlugin.log("Can't load preferences from file " + storeInPrjArea.getLocation(), e); //$NON-NLS-1$ } } else { - // If storage in project area does not exist set default providers defined in the tool-chain + // If storage in project area does not exist set default providers + // defined in the tool-chain for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription).getDefaultLanguageSettingsProvidersIds(); + String[] ids = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getDefaultLanguageSettingsProvidersIds(); if (ids != null) { - List providers = new ArrayList(ids.length); + List providers = new ArrayList( + ids.length); for (String id : ids) { if (LanguageSettingsExtensionManager.isPreferShared(id)) { providers.add(LanguageSettingsManager.getWorkspaceProvider(id)); @@ -1177,7 +1243,8 @@ public class LanguageSettingsProvidersSerializer { providers.add(LanguageSettingsManager.getExtensionProviderCopy(id, true)); } } - ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription) + .setLanguageSettingProviders(providers); } } } @@ -1188,12 +1255,13 @@ public class LanguageSettingsProvidersSerializer { } /** - * Get Language Settings Provider from the list of workspace providers, - * see {@link #getWorkspaceProviders()}. + * Get Language Settings Provider from the list of workspace providers, see + * {@link #getWorkspaceProviders()}. * - * @param id - ID of provider to find. - * @return the workspace provider. If provider is not defined - still workspace - * provider wrapper is created and returned. + * @param id + * - ID of provider to find. + * @return the workspace provider. If provider is not defined - still workspace provider wrapper + * is created and returned. */ public static ILanguageSettingsProvider getWorkspaceProvider(String id) { ILanguageSettingsProvider provider = globalWorkspaceProviders.get(id); @@ -1205,11 +1273,13 @@ public class LanguageSettingsProvidersSerializer { } /** - * Helper method to get to real underlying provider collecting entries as opposed - * to wrapper which is normally used for workspace provider. + * Helper method to get to real underlying provider collecting entries as opposed to wrapper + * which is normally used for workspace provider. + * * @see #isWorkspaceProvider(ILanguageSettingsProvider) * - * @param id - ID of the provider. + * @param id + * - ID of the provider. * @return raw underlying provider. */ public static ILanguageSettingsProvider getRawWorkspaceProvider(String id) { @@ -1217,12 +1287,11 @@ public class LanguageSettingsProvidersSerializer { } /** - * Get Language Settings Providers defined in the workspace. That includes - * user-defined providers and after that providers defined as extensions via - * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. - * Note that this returns wrappers around workspace provider so underlying - * provider could be replaced internally without need to change configuration. - * See also {@link #getRawWorkspaceProvider(String)}. + * Get Language Settings Providers defined in the workspace. That includes user-defined + * providers and after that providers defined as extensions via + * {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point. Note that this returns + * wrappers around workspace provider so underlying provider could be replaced internally + * without need to change configuration. See also {@link #getRawWorkspaceProvider(String)}. * * @return list of workspace providers. */ @@ -1235,12 +1304,12 @@ public class LanguageSettingsProvidersSerializer { } /** - * Checks if the provider is a workspace level provider. - * This method is intended to check providers retrieved from a configuration. - * Raw providers from {@link #getRawWorkspaceProvider(String)} - * are not considered as workspace providers. + * Checks if the provider is a workspace level provider. This method is intended to check + * providers retrieved from a configuration. Raw providers from + * {@link #getRawWorkspaceProvider(String)} are not considered as workspace providers. * - * @param provider - provider to check. + * @param provider + * - provider to check. * @return {@code true} if the given provider is workspace provider, {@code false} otherwise. */ public static boolean isWorkspaceProvider(ILanguageSettingsProvider provider) { @@ -1251,7 +1320,8 @@ public class LanguageSettingsProvidersSerializer { * Check that this particular element is in the list. */ private static boolean isInList(Collection list, T element) { - // list.contains(element) won't do it as we are interested in exact object, not in equal object + // list.contains(element) won't do it as we are interested in exact + // object, not in equal object for (T elem : list) { if (elem == element) return true; @@ -1262,7 +1332,8 @@ public class LanguageSettingsProvidersSerializer { /** * Check that this particular element is in the association list. */ - private static boolean isListenerInTheListOfAssociations(Collection list, ICListenerAgent element) { + private static boolean isListenerInTheListOfAssociations(Collection list, + ICListenerAgent element) { for (ListenerAssociation la : list) { // we are interested in exact object, not in equal object if (la.listener == element) @@ -1272,15 +1343,16 @@ public class LanguageSettingsProvidersSerializer { } /** - * Get a providers list including only providers of type {@link ICListenerAgent} - * for a given project description - collecting from all configurations. + * Get a providers list including only providers of type {@link ICListenerAgent} for a given + * project description - collecting from all configurations. */ private static List getListeners(ICProjectDescription prjDescription) { List listeners = new ArrayList(); if (prjDescription != null) { for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); for (ILanguageSettingsProvider provider : providers) { if (provider instanceof ICListenerAgent) { ICListenerAgent listener = (ICListenerAgent) provider; @@ -1296,7 +1368,8 @@ public class LanguageSettingsProvidersSerializer { } /** - * Pick from the list providers which are listeners, i.e. instances of type {@link ICListenerAgent}. + * Pick from the list providers which are listeners, i.e. instances of type + * {@link ICListenerAgent}. */ private static List selectListeners(Collection values) { List listeners = new ArrayList(); @@ -1308,15 +1381,16 @@ public class LanguageSettingsProvidersSerializer { } /** - * Get a providers list including only providers of type {@link ICListenerAgent} - * for a given project description - collecting from all configurations. + * Get a providers list including only providers of type {@link ICListenerAgent} for a given + * project description - collecting from all configurations. */ private static List getListenersAssociations(ICProjectDescription prjDescription) { List associations = new ArrayList(); if (prjDescription != null) { for (ICConfigurationDescription cfgDescription : prjDescription.getConfigurations()) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); List listeners = selectListeners(providers); for (ICListenerAgent listener : listeners) { if (!isListenerInTheListOfAssociations(associations, listener)) { @@ -1330,13 +1404,16 @@ public class LanguageSettingsProvidersSerializer { } /** - * Unregister listeners which are not used anymore and register new listeners. - * The method is called when project description is applied to workspace. + * Unregister listeners which are not used anymore and register new listeners. The method is + * called when project description is applied to workspace. * - * @param oldPrjDescription - old project descriptions being replaced in the workspace. - * @param newPrjDescription - new project description being applied to the workspace. + * @param oldPrjDescription + * - old project descriptions being replaced in the workspace. + * @param newPrjDescription + * - new project description being applied to the workspace. */ - public static void reRegisterListeners(ICProjectDescription oldPrjDescription, ICProjectDescription newPrjDescription) { + public static void reRegisterListeners(ICProjectDescription oldPrjDescription, + ICProjectDescription newPrjDescription) { if (oldPrjDescription == newPrjDescription) { return; } @@ -1356,7 +1433,8 @@ public class LanguageSettingsProvidersSerializer { oldListener.unregisterListener(); } catch (Throwable e) { // protect from any exceptions from implementers - CCorePlugin.log("Exception trying unregister listener "+((ILanguageSettingsProvider) oldListener).getId(), e); //$NON-NLS-1$ + CCorePlugin.log("Exception trying unregister listener " //$NON-NLS-1$ + + ((ILanguageSettingsProvider) oldListener).getId(), e); } } } @@ -1375,7 +1453,8 @@ public class LanguageSettingsProvidersSerializer { newListener.registerListener(newListenerAssociation.cfgDescription); } catch (Throwable e) { // protect from any exceptions from implementers - CCorePlugin.log("Exception trying register listener "+((ILanguageSettingsProvider) newListener).getId(), e); //$NON-NLS-1$ + CCorePlugin.log("Exception trying register listener " //$NON-NLS-1$ + + ((ILanguageSettingsProvider) newListener).getId(), e); } } } @@ -1386,7 +1465,8 @@ public class LanguageSettingsProvidersSerializer { /** * Adds a listener that will be notified of changes in language settings. * - * @param listener - the listener to add + * @param listener + * - the listener to add */ public static void registerLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener) { fLanguageSettingsChangeListeners.add(listener); @@ -1395,7 +1475,8 @@ public class LanguageSettingsProvidersSerializer { /** * Removes a language settings change listener. * - * @param listener - the listener to remove. + * @param listener + * - the listener to remove. */ public static void unregisterLanguageSettingsChangeListener(ILanguageSettingsChangeListener listener) { fLanguageSettingsChangeListeners.remove(listener); @@ -1404,7 +1485,8 @@ public class LanguageSettingsProvidersSerializer { /** * Notifies all language settings change listeners of a change in language settings entries. * - * @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast. + * @param event + * - the {@link ILanguageSettingsChangeEvent} event to be broadcast. */ private static void notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent event) { for (Object listener : fLanguageSettingsChangeListeners.getListeners()) { @@ -1416,44 +1498,59 @@ public class LanguageSettingsProvidersSerializer { * Get list of setting entries from the pool in {@link LanguageSettingsStorage}. */ private static List getSettingEntriesPooled(ILanguageSettingsProvider provider, - ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + IBuildConfiguration config, IResource rc, String languageId) { try { - return LanguageSettingsStorage.getPooledList(provider.getSettingEntries(cfgDescription, rc, languageId)); + if (config != null) { + ICConfigurationDescription cfgDesc = config.getAdapter(ICConfigurationDescription.class); + if (cfgDesc != null) { + List entriesOld = provider.getSettingEntries(cfgDesc, rc, languageId); + if (entriesOld != null) { + return LanguageSettingsStorage.getPooledList(entriesOld); + } + } + } + return LanguageSettingsStorage.getPooledList(provider.getSettingEntries(config, rc, languageId)); } catch (Throwable e) { - String cfgId = cfgDescription!=null ? cfgDescription.getId() : null; + String cfgId = config != null ? config.getName() : null; @SuppressWarnings("nls") - String msg = "Exception in provider "+provider.getId()+": getSettingEntries("+cfgId+", "+rc+", "+languageId+")"; + String msg = "Exception in provider " + provider.getId() + ": getSettingEntries(" + cfgId + ", " + + rc + ", " + languageId + ")"; CCorePlugin.log(msg, e); - // return empty list to prevent getting potentially non-empty list from up the resource tree + // return empty list to prevent getting potentially non-empty list + // from up the resource tree return LanguageSettingsStorage.getPooledEmptyList(); } } /** - * Returns the list of setting entries of the given provider - * for the given configuration description, resource and language. - * This method reaches to the parent folder of the resource recursively - * if the resource does not define the entries for the given provider. + * Returns the list of setting entries of the given provider for the given configuration + * description, resource and language. This method reaches to the parent folder of the resource + * recursively if the resource does not define the entries for the given provider. * - * @param provider - language settings provider. - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. + * @param provider + * - language settings provider. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. * * @return the list of setting entries which is unmodifiable. Never returns {@code null} - * although individual providers mandated to return {@code null} if no settings defined. + * although individual providers mandated to return {@code null} if no settings defined. */ - public static List getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider, ICConfigurationDescription cfgDescription, IResource rc, String languageId) { - Assert.isTrue( !(rc instanceof IWorkspaceRoot) ); + public static List getSettingEntriesUpResourceTree( + ILanguageSettingsProvider provider, IBuildConfiguration config, IResource rc, String languageId) { + Assert.isTrue(!(rc instanceof IWorkspaceRoot)); if (provider != null) { - List entries = getSettingEntriesPooled(provider, cfgDescription, rc, languageId); + List entries = getSettingEntriesPooled(provider, config, rc, languageId); if (entries != null) { return entries; } if (rc != null) { IResource parentFolder = (rc instanceof IProject) ? null : rc.getParent(); if (parentFolder != null) { - return getSettingEntriesUpResourceTree(provider, cfgDescription, parentFolder, languageId); + return getSettingEntriesUpResourceTree(provider, config, parentFolder, languageId); } // if out of parent resources - get default entries entries = getSettingEntriesPooled(provider, null, null, languageId); @@ -1474,47 +1571,61 @@ public class LanguageSettingsProvidersSerializer { } /** - * Returns the list of setting entries of a certain kind (such as include paths) - * for the given configuration description, resource and language. This is a - * combined list for all providers taking into account settings of parent folder - * if settings for the given resource are not defined. + * Returns the list of setting entries of a certain kind (such as include paths) for the given + * configuration description, resource and language. This is a combined list for all providers + * taking into account settings of parent folder if settings for the given resource are not + * defined. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. - * @param kind - kind of language settings entries, such as - * {@link ICSettingEntry#INCLUDE_PATH} etc. This is a binary flag - * and it is possible to specify composite kind. - * Use {@link ICSettingEntry#ALL} to get all kinds. - * @param checkLocality - specifies if parameter {@code isLocal} should be considered. - * @param isLocal - {@code true} if "local" entries should be provided and - * {@code false} for "system" entries. This makes sense for include paths where - * [#include "..."] is "local" and [#include <...>] is system. + * @param cfgDescription + * - configuration description. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. + * @param kind + * - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} + * etc. This is a binary flag and it is possible to specify composite kind. Use + * {@link ICSettingEntry#ALL} to get all kinds. + * @param checkLocality + * - specifies if parameter {@code isLocal} should be considered. + * @param isLocal + * - {@code true} if "local" entries should be provided and {@code false} for + * "system" entries. This makes sense for include paths where [#include "..."] is + * "local" and [#include <...>] is system. * * @return the list of setting entries found. */ - private static List getSettingEntriesByKind(ICConfigurationDescription cfgDescription, + private static List getSettingEntriesByKind(IBuildConfiguration config, IResource rc, String languageId, int kind, boolean checkLocality, boolean isLocal) { + if (config == null) { + return null; + } - if (!(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) { + ICConfigurationDescription cfgDescription = config.getAdapter(ICConfigurationDescription.class); + + if (cfgDescription == null || !(cfgDescription instanceof ILanguageSettingsProvidersKeeper)) { return null; } List entries = new ArrayList(); List alreadyAdded = new ArrayList(); - List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); - for (ILanguageSettingsProvider provider: providers) { - List providerEntries = getSettingEntriesUpResourceTree(provider, cfgDescription, rc, languageId); + List providers = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); + for (ILanguageSettingsProvider provider : providers) { + List providerEntries = getSettingEntriesUpResourceTree(provider, config, + rc, languageId); for (ICLanguageSettingEntry entry : providerEntries) { if (entry != null) { String entryName = entry.getName(); boolean isRightKind = checkBit(kind, entry.getKind()); // Only first entry is considered - // Entry flagged as "UNDEFINED" prevents adding entry with the same name down the line + // Entry flagged as "UNDEFINED" prevents adding entry with + // the same name down the line if (isRightKind && !alreadyAdded.contains(entryName)) { int flags = entry.getFlags(); - boolean isRightLocal = !checkLocality || (checkBit(flags, ICSettingEntry.LOCAL) == isLocal); + boolean isRightLocal = !checkLocality + || (checkBit(flags, ICSettingEntry.LOCAL) == isLocal); if (isRightLocal) { if (!checkBit(flags, ICSettingEntry.UNDEFINED)) { entries.add(entry); @@ -1530,77 +1641,95 @@ public class LanguageSettingsProvidersSerializer { } /** - * Returns the list of setting entries of a certain kind (such as include paths) - * for the given configuration description, resource and language. This is a - * combined list for all providers taking into account settings of parent folder - * if settings for the given resource are not defined. For include paths both - * local (#include "...") and system (#include <...>) entries are returned. + * Returns the list of setting entries of a certain kind (such as include paths) for the given + * configuration description, resource and language. This is a combined list for all providers + * taking into account settings of parent folder if settings for the given resource are not + * defined. For include paths both local (#include "...") and system (#include <...>) entries + * are returned. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. - * @param kind - kind of language settings entries, such as - * {@link ICSettingEntry#INCLUDE_PATH} etc. This is a binary flag - * and it is possible to specify composite kind. - * Use {@link ICSettingEntry#ALL} to get all kinds. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. + * @param kind + * - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} + * etc. This is a binary flag and it is possible to specify composite kind. Use + * {@link ICSettingEntry#ALL} to get all kinds. * * @return the list of setting entries. */ - public static List getSettingEntriesByKind(ICConfigurationDescription cfgDescription, IResource rc, String languageId, int kind) { - return getSettingEntriesByKind(cfgDescription, rc, languageId, kind, /* checkLocality */ false, /* isLocal */ false); + public static List getSettingEntriesByKind(IBuildConfiguration config, + IResource rc, String languageId, int kind) { + return getSettingEntriesByKind(config, rc, languageId, kind, /* checkLocality */ false, + /* isLocal */ false); } /** - * Returns the list of "system" (such as [#include <...>]) setting entries of a certain kind - * for the given configuration description, resource and language. This is a - * combined list for all providers taking into account settings of parent folder - * if settings for the given resource are not defined. + * Returns the list of "system" (such as [#include <...>]) setting entries of a certain kind for + * the given configuration description, resource and language. This is a combined list for all + * providers taking into account settings of parent folder if settings for the given resource + * are not defined. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. - * @param kind - kind of language settings entries, such as - * {@link ICSettingEntry#INCLUDE_PATH} etc. This is a binary flag - * and it is possible to specify composite kind. - * Use {@link ICSettingEntry#ALL} to get all kinds. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. + * @param kind + * - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} + * etc. This is a binary flag and it is possible to specify composite kind. Use + * {@link ICSettingEntry#ALL} to get all kinds. * * @return the list of setting entries. */ - public static List getSystemSettingEntriesByKind(ICConfigurationDescription cfgDescription, IResource rc, String languageId, int kind) { - return getSettingEntriesByKind(cfgDescription, rc, languageId, kind, /* checkLocality */ true, /* isLocal */ false); + public static List getSystemSettingEntriesByKind(IBuildConfiguration config, + IResource rc, String languageId, int kind) { + return getSettingEntriesByKind(config, rc, languageId, kind, /* checkLocality */ true, + /* isLocal */ false); } /** - * Returns the list of "local" (such as [#include "..."]) setting entries of a certain kind - * for the given configuration description, resource and language. This is a - * combined list for all providers taking into account settings of parent folder - * if settings for the given resource are not defined. + * Returns the list of "local" (such as [#include "..."]) setting entries of a certain kind for + * the given configuration description, resource and language. This is a combined list for all + * providers taking into account settings of parent folder if settings for the given resource + * are not defined. * - * @param cfgDescription - configuration description. - * @param rc - resource such as file or folder. - * @param languageId - language id. - * @param kind - kind of language settings entries, such as - * {@link ICSettingEntry#INCLUDE_PATH} etc. This is a binary flag - * and it is possible to specify composite kind. - * Use {@link ICSettingEntry#ALL} to get all kinds. + * @param config + * - configuration. + * @param rc + * - resource such as file or folder. + * @param languageId + * - language id. + * @param kind + * - kind of language settings entries, such as {@link ICSettingEntry#INCLUDE_PATH} + * etc. This is a binary flag and it is possible to specify composite kind. Use + * {@link ICSettingEntry#ALL} to get all kinds. * * @return the list of setting entries. */ - public static List getLocalSettingEntriesByKind(ICConfigurationDescription cfgDescription, IResource rc, String languageId, int kind) { - return getSettingEntriesByKind(cfgDescription, rc, languageId, kind, /* checkLocality */ true, /* isLocal */ true); + public static List getLocalSettingEntriesByKind(IBuildConfiguration config, + IResource rc, String languageId, int kind) { + return getSettingEntriesByKind(config, rc, languageId, kind, /* checkLocality */ true, + /* isLocal */ true); } /** * Deep clone of a list of language settings providers. * - * @param baseProviders - list of providers to clone. + * @param baseProviders + * - list of providers to clone. * @return newly cloned list. */ - public static List cloneProviders(List baseProviders) { + public static List cloneProviders( + List baseProviders) { List newProviders = new ArrayList(); for (ILanguageSettingsProvider provider : baseProviders) { if (provider instanceof ILanguageSettingsEditableProvider) { - ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) provider, true); + ILanguageSettingsEditableProvider newProvider = LanguageSettingsManager + .getProviderCopy((ILanguageSettingsEditableProvider) provider, true); if (newProvider != null) { provider = newProvider; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java index 3d0a2f8cd5f..c5fc0686f5c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java @@ -42,9 +42,11 @@ import org.eclipse.cdt.internal.core.parser.ParserSettings2; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages; import org.eclipse.cdt.utils.EFSExtensionManager; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; @@ -52,14 +54,15 @@ import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; /** - * Implementation of {@link IScannerInfoProvider} backed by the list of - * language settings providers of "default settings configuration" - * (see {@link ICProjectDescription#getDefaultSettingConfiguration()}). + * Implementation of {@link IScannerInfoProvider} backed by the list of language settings providers + * of "default settings configuration" (see + * {@link ICProjectDescription#getDefaultSettingConfiguration()}). * * @see IScannerInfo#getIncludePaths() * */ -public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider, ILanguageSettingsChangeListener { +public class LanguageSettingsScannerInfoProvider + implements IScannerInfoProvider, ILanguageSettingsChangeListener { private static final String FRAMEWORK_PRIVATE_HEADERS_INCLUDE = "/__framework__.framework/PrivateHeaders/__header__"; //$NON-NLS-1$ private static final String FRAMEWORK_HEADERS_INCLUDE = "/__framework__.framework/Headers/__header__"; //$NON-NLS-1$ private static final ExtendedScannerInfo DUMMY_SCANNER_INFO = new ExtendedScannerInfo(); @@ -69,20 +72,26 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider @Override public ExtendedScannerInfo getScannerInformation(IResource rc) { IProject project = rc.getProject(); - if (project==null) + if (project == null) return DUMMY_SCANNER_INFO; - ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); - if (prjDescription==null) + ICProjectDescription prjDescription = CProjectDescriptionManager.getInstance() + .getProjectDescription(project, false); + if (prjDescription == null) return DUMMY_SCANNER_INFO; ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); - if (cfgDescription==null) + if (cfgDescription == null) + return DUMMY_SCANNER_INFO; + + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + if (config == null) return DUMMY_SCANNER_INFO; List languageIds = LanguageSettingsManager.getLanguages(rc, cfgDescription); if (languageIds.isEmpty()) { - String msg = NLS.bind(SettingsModelMessages.getString("LanguageSettingsScannerInfoProvider.UnableToDetermineLanguage"), rc.toString()); //$NON-NLS-1$ + String msg = NLS.bind(SettingsModelMessages.getString( + "LanguageSettingsScannerInfoProvider.UnableToDetermineLanguage"), rc.toString()); //$NON-NLS-1$ IStatus status = new Status(IStatus.WARNING, CCorePlugin.PLUGIN_ID, msg, new Exception()); CCorePlugin.log(status); return DUMMY_SCANNER_INFO; @@ -95,24 +104,24 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider LinkedHashSet macroEntries = new LinkedHashSet(); for (String langId : languageIds) { - List incSys = LanguageSettingsProvidersSerializer.getSystemSettingEntriesByKind(cfgDescription, rc, langId, - ICSettingEntry.INCLUDE_PATH); + List incSys = LanguageSettingsProvidersSerializer + .getSystemSettingEntriesByKind(config, rc, langId, ICSettingEntry.INCLUDE_PATH); includePathEntries.addAll(incSys); - List incLocal = LanguageSettingsProvidersSerializer.getLocalSettingEntriesByKind(cfgDescription, rc, langId, - ICSettingEntry.INCLUDE_PATH); + List incLocal = LanguageSettingsProvidersSerializer + .getLocalSettingEntriesByKind(config, rc, langId, ICSettingEntry.INCLUDE_PATH); includePathLocalEntries.addAll(incLocal); - List incFiles = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, langId, - ICSettingEntry.INCLUDE_FILE); + List incFiles = LanguageSettingsProvidersSerializer + .getSettingEntriesByKind(config, rc, langId, ICSettingEntry.INCLUDE_FILE); includeFileEntries.addAll(incFiles); - List macroFiles = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, langId, - ICSettingEntry.MACRO_FILE); + List macroFiles = LanguageSettingsProvidersSerializer + .getSettingEntriesByKind(config, rc, langId, ICSettingEntry.MACRO_FILE); macroFileEntries.addAll(macroFiles); - List macros = LanguageSettingsProvidersSerializer.getSettingEntriesByKind(cfgDescription, rc, langId, - ICSettingEntry.MACRO); + List macros = LanguageSettingsProvidersSerializer + .getSettingEntriesByKind(config, rc, langId, ICSettingEntry.MACRO); macroEntries.addAll(macros); } @@ -123,13 +132,14 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider Map definedMacros = new HashMap(); for (ICLanguageSettingEntry entry : macroEntries) { - ICMacroEntry macroEntry = (ICMacroEntry)entry; + ICMacroEntry macroEntry = (ICMacroEntry) entry; String name = macroEntry.getName(); String value = macroEntry.getValue(); definedMacros.put(name, value); } - ExtendedScannerInfo extendedScannerInfo = new ExtendedScannerInfo(definedMacros, includePaths, macroFiles, includeFiles, includePathsLocal); + ExtendedScannerInfo extendedScannerInfo = new ExtendedScannerInfo(definedMacros, includePaths, + macroFiles, includeFiles, includePathsLocal); extendedScannerInfo.setParserSettings(new ParserSettings2(project)); return extendedScannerInfo; } @@ -146,8 +156,8 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } /** - * Get build working directory for the provided configuration. Returns - * project location if none defined. + * Get build working directory for the provided configuration. Returns project location if none + * defined. */ private static IPath getBuildCWD(ICConfigurationDescription cfgDescription) { IPath buildCWD = cfgDescription.getBuildSetting().getBuilderCWD(); @@ -180,11 +190,14 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } /** - * Resolve location to file system location in a configuration context. - * Resolving includes replacing build/environment variables with values, making relative path absolute etc. + * Resolve location to file system location in a configuration context. Resolving includes + * replacing build/environment variables with values, making relative path absolute etc. * - * @param location - location to resolve. If relative, it is taken to be rooted in build working directory. - * @param cfgDescription - the configuration context. + * @param location + * - location to resolve. If relative, it is taken to be rooted in build working + * directory. + * @param cfgDescription + * - the configuration context. * @return resolved file system location. */ private static String resolveEntry(String location, ICConfigurationDescription cfgDescription) { @@ -225,7 +238,8 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider /** * Convert path delimiters to OS representation avoiding using org.eclipse.core.runtime.Path - * being careful to preserve "../" segments and not let collapsing them which is not correct for symbolic links. + * being careful to preserve "../" segments and not let collapsing them which is not correct for + * symbolic links. */ private String toOSString(String loc) { // use OS file separators (i.e. '\' on Windows) @@ -239,16 +253,19 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider * Convert the path entries to absolute file system locations represented as String array. * Resolve the entries which are not resolved. * - * @param entriesPath - language settings path entries. - * @param cfgDescription - configuration description for resolving entries. + * @param entriesPath + * - language settings path entries. + * @param cfgDescription + * - configuration description for resolving entries. * @return array of the locations. */ - private String[] convertToLocations(LinkedHashSet entriesPath, ICConfigurationDescription cfgDescription) { + private String[] convertToLocations(LinkedHashSet entriesPath, + ICConfigurationDescription cfgDescription) { List locations = new ArrayList(entriesPath.size()); for (ICLanguageSettingEntry entry : entriesPath) { - ICPathEntry entryPath = (ICPathEntry)entry; + ICPathEntry entryPath = (ICPathEntry) entry; if (entryPath.isValueWorkspacePath()) { - ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] {entry}; + ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] { entry }; if (!entry.isResolved()) { entries = CDataUtil.resolveEntries(entries, cfgDescription); } @@ -307,7 +324,8 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } if (listenersMap == null) { - listenersMap = Collections.synchronizedMap(new HashMap>()); + listenersMap = Collections + .synchronizedMap(new HashMap>()); } IProject project = resource.getProject(); @@ -346,12 +364,14 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider if (project != null) { ICProjectDescription prjDescription = CCorePlugin.getDefault().getProjectDescription(project); if (prjDescription != null) { - ICConfigurationDescription indexedCfgDescription = prjDescription.getDefaultSettingConfiguration(); + ICConfigurationDescription indexedCfgDescription = prjDescription + .getDefaultSettingConfiguration(); String indexedCfgId = indexedCfgDescription.getId(); for (String cfgId : event.getConfigurationDescriptionIds()) { if (cfgId.equals(indexedCfgId)) { - for (Entry> entry : listenersMap.entrySet()) { + for (Entry> entry : listenersMap + .entrySet()) { IResource rc = entry.getKey(); List listeners = listenersMap.get(rc); if (listeners != null && !listeners.isEmpty()) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java index ee3ae24a027..8c402a44d2e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/PathEntryScannerInfoLanguageSettingsProvider.java @@ -41,20 +41,29 @@ import org.eclipse.cdt.internal.core.model.CModelManager; import org.eclipse.cdt.internal.core.model.DefaultPathEntryStore; import org.eclipse.cdt.internal.core.model.PathEntryManager; import org.eclipse.cdt.internal.core.model.PathEntryUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; /** - * Wrapper class intended to provide backward compatibility with ScannerInfo supplied by {@link PathEntryManager}. + * Wrapper class intended to provide backward compatibility with ScannerInfo + * supplied by {@link PathEntryManager}. */ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettingsBaseProvider { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config == null) { + return null; + } + + ICConfigurationDescription cfgDescription = config.getAdapter(ICConfigurationDescription.class); if (cfgDescription == null) { return null; } + ICProjectDescription prjDescription = cfgDescription.getProjectDescription(); if (prjDescription == null) { return null; @@ -72,7 +81,8 @@ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettin @Override public int compare(IPathEntry macro1, IPathEntry macro2) { if (macro1 instanceof IMacroEntry && macro2 instanceof IMacroEntry) { - return ((IMacroEntry)macro1).getMacroName().compareTo(((IMacroEntry)macro2).getMacroName()); + return ((IMacroEntry) macro1).getMacroName() + .compareTo(((IMacroEntry) macro2).getMacroName()); } return 0; } @@ -82,17 +92,20 @@ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettin pathEntriesMap.put(IPathEntry.CDT_LIBRARY, new LinkedHashSet()); IPathEntryStore pathEntryStore = new DefaultPathEntryStore(project); - int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY; + int typesMask = IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO | IPathEntry.CDT_INCLUDE_FILE + | IPathEntry.CDT_MACRO_FILE | IPathEntry.CDT_LIBRARY; try { IPathEntry[] storePathEntries = pathEntryStore.getRawPathEntries(); for (IPathEntry storePathEntry : storePathEntries) { if (storePathEntry instanceof IContainerEntry) { try { - IPathEntryContainer container = PathEntryManager.getDefault().getPathEntryContainer((IContainerEntry) storePathEntry, cproject); + IPathEntryContainer container = PathEntryManager.getDefault() + .getPathEntryContainer((IContainerEntry) storePathEntry, cproject); if (container != null) { IPathEntry[] pathEntries = null; if (container instanceof IPathEntryContainerExtension) { - pathEntries = ((IPathEntryContainerExtension)container).getPathEntries(rc.getFullPath(), typesMask); + pathEntries = ((IPathEntryContainerExtension) container) + .getPathEntries(rc.getFullPath(), typesMask); } else { pathEntries = container.getPathEntries(); } @@ -124,10 +137,12 @@ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettin } } - return LanguageSettingsSerializableStorage.getPooledList(new ArrayList(lsEntries)); + return LanguageSettingsSerializableStorage + .getPooledList(new ArrayList(lsEntries)); } - private void collectPathEntry(LinkedHashMap> pathEntriesMap, IPath projectPath, IPathEntry pathEntry) { + private void collectPathEntry(LinkedHashMap> pathEntriesMap, IPath projectPath, + IPathEntry pathEntry) { switch (pathEntry.getEntryKind()) { case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_MACRO: @@ -145,14 +160,16 @@ public class PathEntryScannerInfoLanguageSettingsProvider extends LanguageSettin private ICLanguageSettingEntry toLanguageSettingsEntry(IPathEntry pathEntry) { switch (pathEntry.getEntryKind()) { case IPathEntry.CDT_INCLUDE: - IIncludeEntry includeEntry = (IIncludeEntry)pathEntry; - return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL); + IIncludeEntry includeEntry = (IIncludeEntry) pathEntry; + return CDataUtil.createCIncludePathEntry(includeEntry.getFullIncludePath().toOSString(), + includeEntry.isSystemInclude() ? 0 : ICSettingEntry.LOCAL); case IPathEntry.CDT_MACRO: IMacroEntry macroEntry = (IMacroEntry) pathEntry; return CDataUtil.createCMacroEntry(macroEntry.getMacroName(), macroEntry.getMacroValue(), 0); case IPathEntry.CDT_INCLUDE_FILE: IIncludeFileEntry includeFileEntry = (IIncludeFileEntry) pathEntry; - return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), 0); + return CDataUtil.createCIncludeFileEntry(includeFileEntry.getFullIncludeFilePath().toOSString(), + 0); case IPathEntry.CDT_MACRO_FILE: IMacroFileEntry macroFileEntry = (IMacroFileEntry) pathEntry; return CDataUtil.createCMacroFileEntry(macroFileEntry.getFullMacroFilePath().toOSString(), 0); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java index 68dc700d0be..51d4f0e38b5 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ReferencedProjectsLanguageSettingsProvider.java @@ -22,7 +22,9 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; /** * Language settings provider to provide entries exported from referenced projects. @@ -39,7 +41,8 @@ public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettings }; @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { if (recursiveCallIndicator.get()) { // Recursive call indicates that the provider of a referenced project is called. // Only exported entries of the original configuration should be considered, @@ -47,6 +50,11 @@ public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettings return null; } + if (config == null) { + return null; + } + + ICConfigurationDescription cfgDescription = config.getAdapter(ICConfigurationDescription.class); if (cfgDescription == null) { return null; } @@ -58,14 +66,18 @@ public class ReferencedProjectsLanguageSettingsProvider extends LanguageSettings try { recursiveCallIndicator.set(true); List entries = new ArrayList(); - ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil.getReferencedConfigurationDescriptions(cfgDescription, false); + ICConfigurationDescription[] refCfgDescriptions = CoreModelUtil + .getReferencedConfigurationDescriptions(cfgDescription, false); for (ICConfigurationDescription refCfgDescription : refCfgDescriptions) { - List refEntries = LanguageSettingsManager.getSettingEntriesByKind(refCfgDescription, rc, languageId, ICSettingEntry.ALL); + IBuildConfiguration refConfig = Adapters.adapt(refCfgDescription, IBuildConfiguration.class); + List refEntries = LanguageSettingsManager + .getSettingEntriesByKind(refConfig, rc, languageId, ICSettingEntry.ALL); for (ICLanguageSettingEntry refEntry : refEntries) { int flags = refEntry.getFlags(); if ((flags & ICSettingEntry.EXPORTED) == ICSettingEntry.EXPORTED) { // create a new entry with EXPORTED flag cleared - ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, flags & ~ICSettingEntry.EXPORTED); + ICLanguageSettingEntry entry = CDataUtil.createEntry(refEntry, + flags & ~ICSettingEntry.EXPORTED); entries.add(entry); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java index 956b7919d1a..5d488472811 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/ScannerInfoExtensionLanguageSettingsProvider.java @@ -28,16 +28,29 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CExtensionUtil; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; /** - * Wrapper class intended to provide backward compatibility with ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider extension point + * Wrapper class intended to provide backward compatibility with + * ScannerInfoProvider defined by org.eclipse.cdt.core.ScannerInfoProvider + * extension point */ public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettingsBaseProvider { @Override - public List getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { + if (config == null) { + return null; + } + + ICConfigurationDescription cfgDescription = config.getAdapter(ICConfigurationDescription.class); + if (cfgDescription == null) { + return null; + } + List entries = new ArrayList(); IScannerInfoProvider scannerInfoProvider = getScannerInfoProvider(cfgDescription); if (scannerInfoProvider != null) { @@ -46,15 +59,15 @@ public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettin if (si instanceof IExtendedScannerInfo) { addLocalIncludePaths(entries, (IExtendedScannerInfo) si); } - + addSystemIncludePaths(entries, si); addDefinedSymbols(entries, si); - + if (si instanceof IExtendedScannerInfo) { addIncludeFiles(entries, (IExtendedScannerInfo) si); addMacroFiles(entries, (IExtendedScannerInfo) si); } - + if (!entries.isEmpty()) { return LanguageSettingsSerializableStorage.getPooledList(entries); } @@ -64,9 +77,11 @@ public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettin } /** - * Return ScannerInfoProvider defined in configuration metadata in .cproject. + * Return ScannerInfoProvider defined in configuration metadata in + * .cproject. * - * @param cfgDescription - configuration description. + * @param cfgDescription + * - configuration description. * @return an instance of ScannerInfoProvider or {@code null}. */ public IScannerInfoProvider getScannerInfoProvider(ICConfigurationDescription cfgDescription) { @@ -80,8 +95,9 @@ public class ScannerInfoExtensionLanguageSettingsProvider extends LanguageSettin ICConfigExtensionReference ref = refs[0]; try { AbstractCExtension cExtension = null; - IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", false); //$NON-NLS-1$ - cExtension = (AbstractCExtension)el.createExecutableExtension("run"); //$NON-NLS-1$ + IConfigurationElement el = CExtensionUtil.getFirstConfigurationElement(ref, "cextension", //$NON-NLS-1$ + false); + cExtension = (AbstractCExtension) el.createExecutableExtension("run"); //$NON-NLS-1$ cExtension.setExtensionReference(ref); cExtension.setProject(ref.getConfiguration().getProjectDescription().getProject()); if (cExtension instanceof IScannerInfoProvider) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/BuildConfigAdapterFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/BuildConfigAdapterFactory.java new file mode 100644 index 00000000000..56fd2528a6c --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/BuildConfigAdapterFactory.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.settings.model; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.runtime.IAdapterFactory; + +public class BuildConfigAdapterFactory implements IAdapterFactory { + + @Override + @SuppressWarnings("unchecked") + public T getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof IBuildConfiguration + && adapterType.equals(ICConfigurationDescription.class)) { + IBuildConfiguration buildConfig = (IBuildConfiguration) adaptableObject; + ICProjectDescription prjDesc = CCorePlugin.getDefault() + .getProjectDescription(buildConfig.getProject()); + if (prjDesc != null) { + return (T) prjDesc.getConfigurationById(buildConfig.getName()); + } + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[] { ICConfigurationDescription.class }; + } + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationAdapterFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationAdapterFactory.java new file mode 100644 index 00000000000..10a4887c7b6 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CConfigurationAdapterFactory.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2016 QNX Software Systems and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.cdt.internal.core.settings.model; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResourceStatus; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.NullProgressMonitor; + +public class CConfigurationAdapterFactory implements IAdapterFactory { + + @Override + @SuppressWarnings("unchecked") + public T getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof ICConfigurationDescription + && adapterType.equals(IBuildConfiguration.class)) { + ICConfigurationDescription cfgDesc = (ICConfigurationDescription) adaptableObject; + IProject project = cfgDesc.getProjectDescription().getProject(); + if (project != null) { + String configId = cfgDesc.getId(); + try { + IBuildConfiguration config = project.getBuildConfig(configId); + if (config == null) { + CCorePlugin.log(String.format("null config %s: %s", project.getName(), configId)); //$NON-NLS-1$ + } + return (T) config; + } catch (CoreException e) { + if (!ResourcesPlugin.getWorkspace().isTreeLocked() && + e.getStatus().getCode() == IResourceStatus.BUILD_CONFIGURATION_NOT_FOUND) { + try { + Set configNames = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + configNames.add(config.getName()); + } + configNames.add(configId); + + IProjectDescription projectDesc = project.getDescription(); + projectDesc.setBuildConfigs( + configNames.toArray(new String[configNames.size()])); + project.setDescription(projectDesc, new NullProgressMonitor()); + return (T) project.getBuildConfig(configId); + } catch (CoreException e2) { + CCorePlugin.log(e2.getStatus()); + } + } else { + CCorePlugin.log(e.getStatus()); + } + } + } + } + return null; + } + + @Override + public Class[] getAdapterList() { + return new Class[] { IBuildConfiguration.class }; + } + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index d30b08a456b..a70955e1fae 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -35,17 +35,19 @@ import org.eclipse.core.runtime.QualifiedName; public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer { private static final String ACTIVE_CFG = "activeConfiguration"; //$NON-NLS-1$ - private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG); + private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, + ACTIVE_CFG); private static final String SETTING_CFG = "settingConfiguration"; //$NON-NLS-1$ - private static final QualifiedName SETTING_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, SETTING_CFG); + private static final QualifiedName SETTING_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, + SETTING_CFG); private CfgIdPair fActiveCfgInfo; private CfgIdPair fSettingCfgInfo; private CProjectDescriptionPreferences fPrefs; -// private ICConfigurationDescription fActiveCfg; -// private String fActiveCfgId; -// private ICConfigurationDescription fIndexCfg; -// private String fIndexCfgId; + // private ICConfigurationDescription fActiveCfg; + // private String fActiveCfgId; + // private ICConfigurationDescription fIndexCfg; + // private String fIndexCfgId; private volatile IProject fProject; private final ICSettingsStorage fStorage; private final ICStorageElement fRootStorageElement; @@ -153,7 +155,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } - public CProjectDescription(IProject project, ICSettingsStorage storage, ICStorageElement element, boolean loading, boolean isCreating) throws CoreException { + public CProjectDescription(IProject project, ICSettingsStorage storage, ICStorageElement element, + boolean loading, boolean isCreating) throws CoreException { fProject = project; fStorage = storage; fRootStorageElement = element; @@ -200,9 +203,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } -// doneInitializing(); + // doneInitializing(); -// fIsLoading = false; + // fIsLoading = false; } public boolean applyDatas(SettingsContext context) { @@ -222,18 +225,16 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } -// doneInitializing(); + // doneInitializing(); -// fIsApplying = false; + // fIsApplying = false; return modified; } /** - * Called when the read-only project description has / is being set - * fIsApplying => false - * setModified (false) - * set the ICSettingsStorage to readonly + * Called when the read-only project description has / is being set fIsApplying => false + * setModified (false) set the ICSettingsStorage to readonly */ public void doneApplying() { doneInitializing(); @@ -259,7 +260,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon private void doneInitializing() { for (ICConfigurationDescription cfg : fCfgMap.values()) { - // FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please! + // FIXME How and why are we down casting to a + // CConfigurationDescriptionCache. Comments, please! CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) cfg; cache.doneInitialization(); } @@ -285,7 +287,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon * @param el * @param isCreating */ - public CProjectDescription(CProjectDescription base, boolean saving, ICSettingsStorage storage, ICStorageElement el, boolean isCreating) { + public CProjectDescription(CProjectDescription base, boolean saving, ICSettingsStorage storage, + ICStorageElement el, boolean isCreating) { fActiveCfgInfo = new CfgIdPair(base.fActiveCfgInfo); fSettingCfgInfo = new CfgIdPair(base.fSettingCfgInfo); fProject = base.fProject; @@ -296,7 +299,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon fIsApplying = saving || base.fIsApplying; fIsCreating = isCreating; - fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false); + fPrefs = new CProjectDescriptionPreferences(base.fPrefs, + (CProjectDescriptionPreferences) CProjectDescriptionManager.getInstance() + .getProjectDescriptionWorkspacePreferences(false), + false); for (Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();) { try { @@ -308,7 +314,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon baseCache = (CConfigurationDescriptionCache) baseData; baseData = baseCache.getConfigurationData(); } - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription) cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null); + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache( + (ICConfigurationDescription) cfgDes, baseData, baseCache, + cfgDes.getSpecSettings(), this, null); configurationCreated(cache); } else { CConfigurationData baseData = cfgDes.getConfigurationData(false); @@ -321,16 +329,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } // Shallow cloning the base map - Map cloneMap = Collections.synchronizedMap(new HashMap()); - synchronized(base.fPropertiesMap) { + Map cloneMap = Collections + .synchronizedMap(new HashMap()); + synchronized (base.fPropertiesMap) { cloneMap.putAll(base.fPropertiesMap); } fPropertiesMap = cloneMap; } /** - * Convert the current CConfigurationDescriptions to cached versions - * This occurs during the SetCProjectDescription Operation + * Convert the current CConfigurationDescriptions to cached versions This occurs during the + * SetCProjectDescription Operation */ void switchToCachedConfigurationDescriptions() throws CoreException { for (Map.Entry e : fCfgMap.entrySet()) { @@ -342,8 +351,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon baseCache = (CConfigurationDescriptionCache) baseData; baseData = baseCache.getConfigurationData(); } - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache, - cfgDes.getSpecSettings(), this, null); + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, + baseCache, cfgDes.getSpecSettings(), this, null); e.setValue(cache); } } @@ -355,7 +364,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon @Override public ICConfigurationDescription createConfiguration(String id, String name, - ICConfigurationDescription base) throws CoreException{ + ICConfigurationDescription base) throws CoreException { if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this); @@ -400,7 +409,6 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); - CConfigurationDescription cfgDes = (CConfigurationDescription) getConfigurationByName(name); if (cfgDes != null) { cfgDes.removeConfiguration(); @@ -424,8 +432,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } @Override - public void setActiveConfiguration( - ICConfigurationDescription cfg) throws WriteAccessException { + public void setActiveConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); if (cfg == null) @@ -448,13 +455,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } @Override - public ICStorageElement importStorage(String id, ICStorageElement el) throws UnsupportedOperationException, CoreException { + public ICStorageElement importStorage(String id, ICStorageElement el) + throws UnsupportedOperationException, CoreException { return getStorageBase().importStorage(id, el); } -// public boolean containsStorage(String id) throws CoreException { -// return getStorageBase().containsStorage(id); -// } + // public boolean containsStorage(String id) throws CoreException { + // return getStorageBase().containsStorage(id); + // } @Override public ICSettingObject[] getChildSettings() { @@ -468,7 +476,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon @Override public String getId() { - //TODO: + // TODO: return null; } @@ -489,7 +497,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon @Override public boolean isValid() { - return /*fProject.exists() &&*/ fCfgMap.size() > 0; + return /* fProject.exists() && */ fCfgMap.size() > 0; } @Override @@ -517,25 +525,27 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if (fRootStorageElement == null) throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$ -// if (fRootStorageElement == null) { -// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly()); -// } + // if (fRootStorageElement == null) { + // fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, + // true, true, isReadOnly()); + //} return fRootStorageElement; } -// ICStorageElement doGetCachedRootStorageElement() { -// return fRootStorageElement; -// } + // ICStorageElement doGetCachedRootStorageElement() { + // return fRootStorageElement; + // } - ICSettingsStorage getStorageBase() throws CoreException{ + ICSettingsStorage getStorageBase() throws CoreException { if (fStorage == null) -// fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement()); + // fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement()); throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$ return fStorage; } @Override - public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException { + public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) + throws CoreException { if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this); @@ -543,7 +553,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return cfg; } - public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{ + public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) + throws CoreException { if (fIsReadOnly) throw ExceptionFactory.createIsReadOnlyException(); CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this); @@ -668,10 +679,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon CConfigurationDescription des = (CConfigurationDescription) getChildSettingById(cfgCache.getId()); if (des != null) { des.setData(cfgCache); -// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false); -// rcDes = des.getResourceDescription(new Path("dd"), false); -// ICBuildSetting bs = des.getBuildSetting(); -// ICLanguageSetting lss[] = ((ICFolderDescription) rcDes).getLanguageSettings(); + // ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false); + // rcDes = des.getResourceDescription(new Path("dd"), false); + // ICBuildSetting bs = des.getBuildSetting(); + // ICLanguageSetting lss[] = ((ICFolderDescription) rcDes).getLanguageSettings(); } } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index 617ed549468..38f09979f1e 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -98,10 +98,12 @@ import org.eclipse.cdt.internal.core.settings.model.xml.InternalXmlStorageElemen import org.eclipse.cdt.internal.core.settings.model.xml.XmlStorage; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceStatus; import org.eclipse.core.resources.ISavedState; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; @@ -134,59 +136,63 @@ import org.xml.sax.SAXException; import com.ibm.icu.text.MessageFormat; /** - * The CProjectDescriptionManager is to marshall the loading and storing - * of CDT Project Descriptions. + * The CProjectDescriptionManager is to marshall the loading and storing of CDT Project + * Descriptions. * * This class delegates loading and store of the project model to the appropriate - * AbstractCProjectDescriptionStorage for the Project Description. [ Discovered at Project load + * AbstractCProjectDescriptionStorage for the Project Description. [ Discovered at Project load * time.] * - * Users should not synchronize on the singleton instance of this class. It is the job of - * the AbstractCProjectDescriptionStorage to ensure thread safe access to the backing store - * as described in that interface. + * Users should not synchronize on the singleton instance of this class. It is the job of the + * AbstractCProjectDescriptionStorage to ensure thread safe access to the backing store as described + * in that interface. * * Previously this class created and persisted + * * @see ICProjectDescriptionManager */ public class CProjectDescriptionManager implements ICProjectDescriptionManager { - public static final int INTERNAL_GET_IGNORE_CLOSE = 1 << 31 ; + public static final int INTERNAL_GET_IGNORE_CLOSE = 1 << 31; - private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$ - /** Preference Version 4.0 & 5.0 are equivalent for us. Version was inadvertently bumped - * when during project description storage work. - * This is the minimum preference version we support loading.*/ + private static final String VERSION_ELEMENT_NAME = "fileVersion"; //$NON-NLS-1$ + /** + * Preference Version 4.0 & 5.0 are equivalent for us. Version was inadvertently bumped when + * during project description storage work. This is the minimum preference version we support + * loading. + */ public static final Version MIN_DESCRIPTION_VERSION = new Version("4.0"); //$NON-NLS-1$ /** Current preference file storage version */ - public static final Version DESCRIPTION_VERSION = new Version("5.0"); //$NON-NLS-1$ - public final static String MODULE_ID = "org.eclipse.cdt.core.settings"; //$NON-NLS-1$ - static final String CONFIGURATION = "cconfiguration"; //$NON-NLS-1$ + public static final Version DESCRIPTION_VERSION = new Version("5.0"); //$NON-NLS-1$ + public final static String MODULE_ID = "org.eclipse.cdt.core.settings"; //$NON-NLS-1$ + static final String CONFIGURATION = "cconfiguration"; //$NON-NLS-1$ private static final ICLanguageSettingEntry[] EMPTY_LANGUAGE_SETTINGS_ENTRIES_ARRAY = new ICLanguageSettingEntry[0]; private static final ICElementDelta[] EMPTY_CELEMENT_DELTA = new ICElementDelta[0]; private static final ICLanguageSetting[] EMPTY_LANGUAGE_SETTINGS_ARRAY = new ICLanguageSetting[0]; - private static final String PREFERENCES_STORAGE = "preferences"; //$NON-NLS-1$ - private static final String PREFERENCE_BUILD_SYSTEM_ELEMENT = "buildSystem"; //$NON-NLS-1$ - private static final String PREFERENCES_ELEMENT = "preferences"; //$NON-NLS-1$ - private static final String ID = "id"; //$NON-NLS-1$ - private static final String PREFERENCE_CFG_ID_PREFIX = "preference."; //$NON-NLS-1$ + private static final String PREFERENCES_STORAGE = "preferences"; //$NON-NLS-1$ + private static final String PREFERENCE_BUILD_SYSTEM_ELEMENT = "buildSystem"; //$NON-NLS-1$ + private static final String PREFERENCES_ELEMENT = "preferences"; //$NON-NLS-1$ + private static final String ID = "id"; //$NON-NLS-1$ + private static final String PREFERENCE_CFG_ID_PREFIX = "preference."; //$NON-NLS-1$ private static final String PREFERENCE_CFG_NAME = SettingsModelMessages.getString("CProjectDescriptionManager.15"); //$NON-NLS-1$ - private static final String ROOT_PREFERENCE_ELEMENT = "preferences"; //$NON-NLS-1$ + private static final String ROOT_PREFERENCE_ELEMENT = "preferences"; //$NON-NLS-1$ private static final String DEFAULT_CFG_ID_PREFIX = CCorePlugin.PLUGIN_ID + ".default.config"; //$NON-NLS-1$ private static final String DEFAULT_CFG_NAME = "Configuration"; //$NON-NLS-1$ - private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "scannerInfoProvider"); //$NON-NLS-1$ + private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, + "scannerInfoProvider"); //$NON-NLS-1$ static class CompositeWorkspaceRunnable implements IWorkspaceRunnable { private List fRunnables = new ArrayList(); private String fName; private boolean fStopOnErr; - CompositeWorkspaceRunnable(String name){ - if(name == null) - name = ""; //$NON-NLS-1$ + CompositeWorkspaceRunnable(String name) { + if (name == null) + name = ""; //$NON-NLS-1$ fName = name; } - public void add(IWorkspaceRunnable runnable){ + public void add(IWorkspaceRunnable runnable) { fRunnables.add(runnable); } @@ -199,11 +205,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1); try { r.run(subMonitor); - } catch (CoreException e){ - if(fStopOnErr) + } catch (CoreException e) { + if (fStopOnErr) throw e; } catch (RuntimeException e) { - if(fStopOnErr) + if (fStopOnErr) throw e; } finally { subMonitor.done(); @@ -214,7 +220,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - public boolean isEmpty(){ + public boolean isEmpty() { return fRunnables.isEmpty(); } } @@ -222,7 +228,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * Container class for ICProjectDescription change listeners */ - private static class ListenerDescriptor{ + private static class ListenerDescriptor { final ICProjectDescriptionListener fListener; final int fEventTypes; @@ -231,7 +237,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { fEventTypes = eventTypes; } - public boolean handlesEvent(int eventType){ + public boolean handlesEvent(int eventType) { return (eventType & fEventTypes) != 0; } } @@ -246,13 +252,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private CProjectDescriptionWorkspacePreferences fPreferences; private boolean fAllowEmptyCreatingDescription = true; // allowed by default - private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){ + private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer() { @Override public void updateChild(CDataProxy child, boolean write) { - if(write){ + if (write) { try { - ((CConfigurationDescription)child).doWritable(); + ((CConfigurationDescription) child).doWritable(); } catch (CoreException e) { CCorePlugin.log(e); } @@ -268,11 +274,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** The CProjectDescriptionManager instance */ private static volatile CProjectDescriptionManager fInstance; - private CProjectDescriptionManager(){} + private CProjectDescriptionManager() { + } - public static CProjectDescriptionManager getInstance(){ - if(fInstance == null) - synchronized(CProjectDescriptionManager.class) { + public static CProjectDescriptionManager getInstance() { + if (fInstance == null) + synchronized (CProjectDescriptionManager.class) { if (fInstance == null) { fInstance = new CProjectDescriptionManager(); fInstance.initProviderInfo(); @@ -301,40 +308,41 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * - * @param from Project to move the description from - * @param to Project where the description is moved to - * @return ICProjectDescription - non serialized, modified, writable - * project description. To serialize, call setProjectDescription() + * @param from + * Project to move the description from + * @param to + * Project where the description is moved to + * @return ICProjectDescription - non serialized, modified, writable project description. + * To serialize, call setProjectDescription() * */ public ICProjectDescription projectMove(IProject from, IProject to) { CProjectDescriptionStorageManager.getInstance().projectMove(from, to); int flags = CProjectDescriptionManager.INTERNAL_GET_IGNORE_CLOSE | - ICProjectDescriptionManager.GET_WRITABLE; - CProjectDescription des = (CProjectDescription)getProjectDescription(to, flags); + ICProjectDescriptionManager.GET_WRITABLE; + CProjectDescription des = (CProjectDescription) getProjectDescription(to, flags); // set configuration descriptions to "writable" state if (des != null) { for (ICConfigurationDescription cfgDes : des.getConfigurations()) { - des.updateChild((CConfigurationDescription)cfgDes, true); + des.updateChild((CConfigurationDescription) cfgDes, true); } } return des; } - - public Job startup(){ - if(fRcChangeHandler == null){ + public Job startup() { + if (fRcChangeHandler == null) { fRcChangeHandler = new ResourceChangeHandler(); ResourcesPlugin.getWorkspace().addResourceChangeListener( fRcChangeHandler, IResourceChangeEvent.POST_CHANGE - | IResourceChangeEvent.PRE_DELETE - | IResourceChangeEvent.PRE_CLOSE - /*| IResourceChangeEvent.POST_BUILD*/); + | IResourceChangeEvent.PRE_DELETE + | IResourceChangeEvent.PRE_CLOSE + /* | IResourceChangeEvent.POST_BUILD */); - if(fDescriptorManager == null){ + if (fDescriptorManager == null) { fDescriptorManager = CConfigBasedDescriptorManager.getInstance(); fDescriptorManager.startup(); } @@ -346,12 +354,49 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { private Job createPostStartupJob() { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - Job rcJob = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.0")){ //$NON-NLS-1$ + Job rcJob = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.0")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { - try{ + try { startSaveParticipant(); - } catch (CoreException e){ + // startup mapping of ICConfigurationDescriptors to IBuildConfigurations + CProjectDescriptionManager manager = CProjectDescriptionManager.getInstance(); + manager.addCProjectDescriptionListener(new ICProjectDescriptionListener() { + @Override + public void handleEvent(CProjectDescriptionEvent event) { + ICProjectDescription projDesc = event.getNewCProjectDescription(); + IProject project = projDesc.getProject(); + for (ICConfigurationDescription desc : projDesc.getConfigurations()) { + String id = desc.getId(); + try { + project.getBuildConfig(id); + } catch (CoreException e) { + if (e.getStatus().getCode() == IResourceStatus.BUILD_CONFIGURATION_NOT_FOUND) { + try { + Set configNames = new HashSet<>(); + for (IBuildConfiguration config : project.getBuildConfigs()) { + configNames.add(config.getName()); + } + configNames.add(id); + + // CCorePlugin.log(String.format("adding %s: %s", project.getName(), id)); //$NON-NLS-1$ + IProjectDescription projectDesc = project.getDescription(); + projectDesc.setBuildConfigs( + configNames.toArray(new String[configNames.size()])); + project.setDescription(projectDesc, new NullProgressMonitor()); + // CCorePlugin.log( + // String.format("Config added %s: %s", project.getName(), id)); //$NON-NLS-1$ + } catch (CoreException e2) { + CCorePlugin.log(e2.getStatus()); + } + } else { + CCorePlugin.log(e.getStatus()); + } + } + } + } + }, CProjectDescriptionEvent.LOADED | CProjectDescriptionEvent.ABOUT_TO_APPLY); + } catch (CoreException e) { CCorePlugin.log(e); return e.getStatus(); } @@ -368,32 +413,33 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { rcJob.setPriority(Job.INTERACTIVE); rcJob.setSystem(true); return rcJob; + } /* - * This method adds a save participant and resource change listener - * Throws CoreException if the methods fails to add a save participant. - * The resource change listener in not added in this case either. + * This method adds a save participant and resource change listener Throws CoreException if the + * methods fails to add a save participant. The resource change listener in not added in this + * case either. */ - private void startSaveParticipant() throws CoreException{ + private void startSaveParticipant() throws CoreException { // Set up a listener for resource change events - ISavedState lastState = - ResourcesPlugin.getWorkspace().addSaveParticipant(CCorePlugin.PLUGIN_ID, fRcChangeHandler); + ISavedState lastState = ResourcesPlugin.getWorkspace().addSaveParticipant(CCorePlugin.PLUGIN_ID, + fRcChangeHandler); if (lastState != null) { lastState.processResourceChangeEvents(fRcChangeHandler); } } - public void shutdown(){ + public void shutdown() { CExternalSettingsManager.getInstance().shutdown(); - if(fDescriptorManager != null) { + if (fDescriptorManager != null) { fDescriptorManager.shutdown(); fDescriptorManager = null; } - if(fRcChangeHandler != null) { + if (fRcChangeHandler != null) { ResourcesPlugin.getWorkspace().removeResourceChangeListener(fRcChangeHandler); fRcChangeHandler = null; } @@ -420,17 +466,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } catch (CoreException e) { // FIXME Currently the resource change handler ResourceChangeHandler.getProjectDescription(...) // Does this when the project is closed. Don't log an error or the tests will fail -// CCorePlugin.log(e); + // CCorePlugin.log(e); } return null; } /** * Base method for getting a Project's Description + * * @param project * @param flags * @return ICProjectDescription - * @throws CoreException if project description isn't available + * @throws CoreException + * if project description isn't available */ private ICProjectDescription getProjectDescriptionInternal(IProject project, int flags) throws CoreException { AbstractCProjectDescriptionStorage storage = getProjectDescriptionStorage(project); @@ -439,14 +487,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * Run the workspace modification in the current thread using the workspace scheduling rule - * Equivalent to: runWspModification(IWorkspaceRunnable, ResourcecPlugin.getWorkspace().getRoot(), IProgressMonitor) - *

- * Note that if the workspace is locked, or the current job / thread doesn't contain the workspace - * scheduling rule, then we schedule a job to run the {@link IWorkspaceRunnable} - *

+ * Equivalent to: + * runWspModification(IWorkspaceRunnable, ResourcecPlugin.getWorkspace().getRoot(), IProgressMonitor) + *
+ *
+ * Note that if the workspace is locked, or the current job / thread doesn't contain the + * workspace scheduling rule, then we schedule a job to run the {@link IWorkspaceRunnable}
+ *
* The scheduled job is returned, or null if the operation was run immediately. * - * @param runnable the IWorkspaceRunnable to run + * @param runnable + * the IWorkspaceRunnable to run * @param monitor * @return scheduled job or null if the operation was run immediately */ @@ -455,18 +506,20 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * Either runs the modification in the current thread (if the workspace is not locked) - * or schedules a runnable to perform the operation + * Either runs the modification in the current thread (if the workspace is not locked) or + * schedules a runnable to perform the operation + * * @param runnable * @param monitor * @return scheduled job or null if the operation was run immediately */ - public static Job runWspModification(final IWorkspaceRunnable runnable, final ISchedulingRule rule, IProgressMonitor monitor){ - if(monitor == null) + public static Job runWspModification(final IWorkspaceRunnable runnable, final ISchedulingRule rule, + IProgressMonitor monitor) { + if (monitor == null) monitor = new NullProgressMonitor(); // Should the rule be scheduled, or run immediately - boolean scheduleRule = ResourcesPlugin.getWorkspace().isTreeLocked(); + boolean scheduleRule = ResourcesPlugin.getWorkspace().isTreeLocked(); // Check whether current job contains rule 'rule' // If not, we must schedule another job to execute the runnable @@ -476,22 +529,22 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { scheduleRule = true; } - if(!scheduleRule) { + if (!scheduleRule) { // Run immediately IJobManager mngr = Job.getJobManager(); - try{ + try { mngr.beginRule(rule, monitor); runAtomic(runnable, rule, monitor); } catch (Exception e) { CCorePlugin.log(e); } finally { - if(!scheduleRule) + if (!scheduleRule) monitor.done(); mngr.endRule(rule); } } else { // schedule a job for it - Job job = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.12")){ //$NON-NLS-1$ + Job job = new Job(SettingsModelMessages.getString("CProjectDescriptionManager.12")) { //$NON-NLS-1$ @Override protected IStatus run(IProgressMonitor monitor) { try { @@ -514,14 +567,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return null; } - private static void runAtomic(final IWorkspaceRunnable r, ISchedulingRule rule, IProgressMonitor monitor) throws CoreException{ + private static void runAtomic(final IWorkspaceRunnable r, ISchedulingRule rule, IProgressMonitor monitor) + throws CoreException { IWorkspace wsp = ResourcesPlugin.getWorkspace(); - wsp.run(new IWorkspaceRunnable(){ + wsp.run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { try { r.run(monitor); - } catch (Exception e){ + } catch (Exception e) { CCorePlugin.log(e); throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, e.getMessage(), e)); } @@ -530,13 +584,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } @Override - public void updateProjectDescriptions(IProject[] projects, IProgressMonitor monitor) throws CoreException{ - if(monitor == null) + public void updateProjectDescriptions(IProject[] projects, IProgressMonitor monitor) throws CoreException { + if (monitor == null) monitor = new NullProgressMonitor(); try { IWorkspace wsp = ResourcesPlugin.getWorkspace(); - if(projects == null) + if (projects == null) projects = wsp.getRoot().getProjects(); final ICProjectDescription dessWritable[] = new ICProjectDescription[projects.length]; final ICProjectDescription dessCache[] = new ICProjectDescription[projects.length]; @@ -550,10 +604,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - if(num != 0){ + if (num != 0) { final int[] fi = new int[1]; fi[0] = num; - runWspModification(new IWorkspaceRunnable(){ + runWspModification(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { @@ -572,7 +626,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { false)) { setProjectDescription(des.getProject(), des, true, subMonitor); } - } catch (CoreException e){ + } catch (CoreException e) { CCorePlugin.log(e); } finally { subMonitor.done(); @@ -588,38 +642,39 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } - public ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des){ + public ICProjectConverter getConverter(IProject project, String oldOwnerId, ICProjectDescription des) { CProjectConverterDesciptor[] converterDess = getConverterDescriptors(); ICProjectConverter converter = null; for (CProjectConverterDesciptor converterDes : converterDess) { - if(converterDes.canConvertProject(project, oldOwnerId, des)){ + if (converterDes.canConvertProject(project, oldOwnerId, des)) { try { converter = converterDes.getConverter(); } catch (CoreException e) { } - if(converter != null) + if (converter != null) break; } } return converter; } - private CProjectConverterDesciptor[] getConverterDescriptors(){ - if(fConverters == null){ + private CProjectConverterDesciptor[] getConverterDescriptors() { + if (fConverters == null) { initConverterInfoSynch(); } return fConverters; } - private synchronized void initConverterInfoSynch(){ - if(fConverters != null) + private synchronized void initConverterInfoSynch() { + if (fConverters != null) return; - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CProjectConverterDesciptor.PROJECT_CONVERTER_EXTPOINT_ID); + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint(CProjectConverterDesciptor.PROJECT_CONVERTER_EXTPOINT_ID); IExtension exts[] = extensionPoint.getExtensions(); CProjectConverterDesciptor[] dess = new CProjectConverterDesciptor[exts.length]; - for(int i = 0; i < exts.length; i++){ + for (int i = 0; i < exts.length; i++) { dess[i] = new CProjectConverterDesciptor(exts[i]); } @@ -627,12 +682,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } @Override - public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException{ + public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException { return createProjectDescription(project, loadIfExists, false); } @Override - public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, boolean creating) throws CoreException{ + public ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists, boolean creating) + throws CoreException { int flags = ICProjectDescriptionManager.GET_WRITABLE | ICProjectDescriptionManager.GET_CREATE_DESCRIPTION; flags |= loadIfExists ? 0 : ICProjectDescriptionManager.GET_EMPTY_PROJECT_DESCRIPTION; flags |= creating ? ICProjectDescriptionManager.PROJECT_CREATING : 0; @@ -640,14 +696,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return getProjectDescriptionInternal(project, flags); } - public ScannerInfoProviderProxy getScannerInfoProviderProxy(IProject project){ + public ScannerInfoProviderProxy getScannerInfoProviderProxy(IProject project) { ICProjectDescription des = getProjectDescription(project, false); - if(des == null){ + if (des == null) { return new ScannerInfoProviderProxy(project); } - ScannerInfoProviderProxy provider = (ScannerInfoProviderProxy)des.getSessionProperty(SCANNER_INFO_PROVIDER_PROPERTY); - if(provider == null){ + ScannerInfoProviderProxy provider = (ScannerInfoProviderProxy) des + .getSessionProperty(SCANNER_INFO_PROVIDER_PROPERTY); + if (provider == null) { provider = new ScannerInfoProviderProxy(project); des.setSessionProperty(SCANNER_INFO_PROVIDER_PROPERTY, provider); } else { @@ -658,18 +715,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } @Override - public ICProjectDescription getProjectDescription(IProject project){ + public ICProjectDescription getProjectDescription(IProject project) { return getProjectDescription(project, true); } /* * returns true if the project description was modified false - otherwise */ - public boolean checkHandleActiveCfgChange(CProjectDescription newDes, ICProjectDescription oldDes, IProjectDescription eDes, IProgressMonitor monitor){ - if(newDes == null) + public boolean checkHandleActiveCfgChange(CProjectDescription newDes, ICProjectDescription oldDes, + IProjectDescription eDes, IProgressMonitor monitor) { + if (newDes == null) return false; ICConfigurationDescription newCfg = newDes.getActiveConfiguration(); - if(newCfg == null) + if (newCfg == null) return false; ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null; @@ -680,14 +738,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { boolean modified = false; try { - if(checkBuildSystemChange(eDes, newCfg, oldCfg, monitor)) + if (checkBuildSystemChange(eDes, newCfg, oldCfg, monitor)) modified = true; } catch (CoreException e) { CCorePlugin.log(e); } try { - if(checkProjectRefChange(eDes, newDes, newCfg, oldCfg, monitor)) + if (checkProjectRefChange(eDes, newDes, newCfg, oldCfg, monitor)) modified = true; } catch (CoreException e) { CCorePlugin.log(e); @@ -696,17 +754,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return modified; } -// String loadActiveCfgId(ICProjectDescription des){ -// try { -// return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY); -// } catch (CoreException e) { -// CCorePlugin.log(e); -// } -// return null; -// } + // String loadActiveCfgId(ICProjectDescription des){ + // try { + // return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY); + // } catch (CoreException e) { + // CCorePlugin.log(e); + // } + // return null; + // } - private Collection projSetFromProjNameSet(Collection projNames){ - if(projNames.size() == 0) + private Collection projSetFromProjNameSet(Collection projNames) { + if (projNames.size() == 0) return new HashSet(0); Set set = new LinkedHashSet(); @@ -722,8 +780,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { * Fix up platform references having changed CDT configuration references */ @SuppressWarnings("unchecked") - private boolean checkProjectRefChange(IProjectDescription des, ICProjectDescription newCDesc, ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg, IProgressMonitor monitor) throws CoreException{ - if(newCfg == null) + private boolean checkProjectRefChange(IProjectDescription des, ICProjectDescription newCDesc, + ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg, IProgressMonitor monitor) + throws CoreException { + if (newCfg == null) return false; Map oldMap = oldCfg != null ? oldCfg.getReferenceInfo() : Collections.EMPTY_MAP; @@ -764,41 +824,38 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return true; } - -// private void checkBuildSystemChange(IProject project, String newBsId, String oldBsId, IProgressMonitor monitor) throws CoreException{ -// checkBuildSystemChange(project, null, newBsId, oldBsId, monitor); -// } + // private void checkBuildSystemChange(IProject project, String newBsId, String oldBsId, IProgressMonitor monitor) throws CoreException{ + // checkBuildSystemChange(project, null, newBsId, oldBsId, monitor); + // } private boolean checkActiveCfgChange(CProjectDescription des, ICProjectDescription oldDes -// ICConfigurationDescription newCfg, -// ICConfigurationDescription oldCfg - ){ + // ICConfigurationDescription newCfg, + // ICConfigurationDescription oldCfg + ) { ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null; -// String newId = newCfg.getId(); + // String newId = newCfg.getId(); String oldId = oldCfg != null ? oldCfg.getId() : null; - return des.checkPersistActiveCfg(oldId, false); } private boolean checkSettingCfgChange(CProjectDescription des, ICProjectDescription oldDes -// ICConfigurationDescription newCfg, -// ICConfigurationDescription oldCfg - ){ + // ICConfigurationDescription newCfg, + // ICConfigurationDescription oldCfg + ) { ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getDefaultSettingConfiguration() : null; -// String newId = newCfg.getId(); + // String newId = newCfg.getId(); String oldId = oldCfg != null ? oldCfg.getId() : null; - return des.checkPersistSettingCfg(oldId, false); } private boolean checkBuildSystemChange(IProjectDescription des, ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg, - IProgressMonitor monitor) throws CoreException{ + IProgressMonitor monitor) throws CoreException { String newBsId = newCfg != null ? newCfg.getBuildSystemId() : null; String oldBsId = oldCfg != null ? oldCfg.getBuildSystemId() : null; @@ -819,8 +876,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { // Get the set of items to remove ({oldNatures} - {newNatures}) + conflictingNatures Set toRemove = new HashSet(oldNatures); - toRemove.removeAll(newNatures); // Don't remove items we're re-adding - toRemove.addAll(conflictingNatures); // Add conflicting natures for removal + toRemove.removeAll(newNatures); // Don't remove items we're re-adding + toRemove.addAll(conflictingNatures); // Add conflicting natures for removal // Modify an ordered set of the existing natures with the changes final LinkedHashSet cur = new LinkedHashSet(Arrays.asList(natureIds)); cur.addAll(newNatures); @@ -841,44 +898,56 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } @Override - public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException { + public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, + IProgressMonitor monitor) throws CoreException { int flags = force ? SET_FORCE : 0; setProjectDescription(project, des, flags, monitor); } - static boolean checkFlags(int flags, int check){ + static boolean checkFlags(int flags, int check) { return (flags & check) == check; } /** ThreadLocal flag to let CDescriptor know whether already in a setProjectDescription */ - ThreadLocal settingProjectDescription = new ThreadLocal(){@Override protected Boolean initialValue() {return false;}}; + ThreadLocal settingProjectDescription = new ThreadLocal() { + @Override + protected Boolean initialValue() { + return false; + } + }; + @Override - public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException { + public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) + throws CoreException { boolean originalState = isCurrentThreadSetProjectDescription(); try { - if (originalState) { + if (originalState) { // Technically this is not critical problem since the recursive setProjectDescription() gets scheduled in background thread. // But it is quite likely to be an error on part of the caller unaware that their listener can be called from inside setProjectDescription(). // To avoid the log entry the callers should check CProjectDescriptionManager.isCurrentThreadSetProjectDescription() // and schedule the update in background thread themselves. - CCorePlugin.logStackTrace(IStatus.INFO, "Recursive setProjectDescription from event listener, project=" + project); //$NON-NLS-1$ + CCorePlugin.logStackTrace(IStatus.INFO, + "Recursive setProjectDescription from event listener, project=" + project); //$NON-NLS-1$ } settingProjectDescription.set(true); - if(des != null){ + if (des != null) { if (!project.isAccessible()) - throw ExceptionFactory.createCoreException(MessageFormat.format(CCorePlugin.getResourceString("ProjectDescription.ProjectNotAccessible"), new Object[] {project.getName()})); //$NON-NLS-1$ + throw ExceptionFactory.createCoreException(MessageFormat.format( + CCorePlugin.getResourceString("ProjectDescription.ProjectNotAccessible"), //$NON-NLS-1$ + new Object[] { project.getName() })); - if(!des.isValid() && (!fAllowEmptyCreatingDescription || !des.isCdtProjectCreating())) - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName()); //$NON-NLS-1$ + if (!des.isValid() && (!fAllowEmptyCreatingDescription || !des.isCdtProjectCreating())) + throw ExceptionFactory.createCoreException( + SettingsModelMessages.getString("CProjectDescriptionManager.17") + project.getName()); //$NON-NLS-1$ - if(!checkFlags(flags, SET_FORCE) && !des.isModified()) + if (!checkFlags(flags, SET_FORCE) && !des.isModified()) return; - if(((CProjectDescription)des).isLoading()){ + if (((CProjectDescription) des).isLoading()) { throw ExceptionFactory.createCoreException("description is being loadded"); //$NON-NLS-1$ } - if(((CProjectDescription)des).isApplying()){ + if (((CProjectDescription) des).isApplying()) { throw ExceptionFactory.createCoreException("description is being applied"); //$NON-NLS-1$ } } @@ -889,7 +958,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * Indicates that a setProjectDescription is currently in progress to prevent recursive setProjectDescription + * Indicates that a setProjectDescription is currently in progress to prevent recursive + * setProjectDescription + * * @return boolean */ public boolean isCurrentThreadSetProjectDescription() { @@ -898,22 +969,29 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * Base for getting a project desc's storage. project must be accessible. + * * @param project * @return ProjectDescription storage - * @throws CoreException if Project isn't accessible + * @throws CoreException + * if Project isn't accessible */ private AbstractCProjectDescriptionStorage getProjectDescriptionStorage(IProject project) throws CoreException { if (project == null || !project.isAccessible()) - throw ExceptionFactory.createCoreException(MessageFormat.format(CCorePlugin.getResourceString("ProjectDescription.ProjectNotAccessible"), new Object[] {project != null ? project.getName() : ""})); //$NON-NLS-1$ //$NON-NLS-2$ - AbstractCProjectDescriptionStorage storage = CProjectDescriptionStorageManager.getInstance().getProjectDescriptionStorage(project); + throw ExceptionFactory.createCoreException( + MessageFormat.format(CCorePlugin.getResourceString("ProjectDescription.ProjectNotAccessible"), //$NON-NLS-1$ + new Object[] { project != null ? project.getName() : "" })); //$NON-NLS-1$ + AbstractCProjectDescriptionStorage storage = CProjectDescriptionStorageManager.getInstance() + .getProjectDescriptionStorage(project); if (storage == null) - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.FailedToGetStorage") + project.getName()); //$NON-NLS-1$ + throw ExceptionFactory.createCoreException( + SettingsModelMessages.getString("CProjectDescriptionManager.FailedToGetStorage") //$NON-NLS-1$ + + project.getName()); return storage; } /** - * Return an ICSettingsStorage based on the provided ICStorageElement - * in the given IProject + * Return an ICSettingsStorage based on the provided ICStorageElement in the given IProject + * * @param project * @return ICSettingsStorages */ @@ -921,10 +999,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { if (project != null) return getProjectDescriptionStorage(project).getStorageForElement(element); // project is null means it's a preference element, uses XmlStorages - return new XmlStorage((InternalXmlStorageElement)element); + return new XmlStorage((InternalXmlStorageElement) element); } - private void serializePreference(String key, InternalXmlStorageElement element) throws CoreException{ + private void serializePreference(String key, InternalXmlStorageElement element) throws CoreException { Document doc = element.fElement.getOwnerDocument(); // Transform the document to something we can save in a file @@ -932,41 +1010,41 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { FileOutputStream fileStream = null; try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(stream); transformer.transform(source, result); // Save the document File file = getPreferenceFile(key); - String utfString = stream.toString("UTF-8"); //$NON-NLS-1$ + String utfString = stream.toString("UTF-8"); //$NON-NLS-1$ if (file.exists()) { -// if (projectFile.isReadOnly()) { -// -// // Inform Eclipse that we are intending to modify this file -// // This will provide the user the opportunity, via UI prompts, to fetch the file from source code control -// // reset a read-only file protection to write etc. -// // If there is no shell, i.e. shell is null, then there will be no user UI interaction -// -// //TODO -// //IStatus status = projectFile.getWorkspace().validateEdit(new IFile[]{projectFile}, shell); -// -// // If the file is still read-only, then we should not attempt the write, since it will -// // just fail - just throw an exception, to be caught below, and inform the user -// // For other non-successful status, we take our chances, attempt the write, and pass -// // along any exception thrown -// -// //if (!status.isOK()) { -// // if (status.getCode() == IResourceStatus.READ_ONLY_LOCAL) { -// // stream.close(); -// // throw new CoreException(status); -// //} -// //} -// } -// projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ + // if (projectFile.isReadOnly()) { + // + // // Inform Eclipse that we are intending to modify this file + // // This will provide the user the opportunity, via UI prompts, to fetch the file from source code control + // // reset a read-only file protection to write etc. + // // If there is no shell, i.e. shell is null, then there will be no user UI interaction + // + // //TODO + // //IStatus status = projectFile.getWorkspace().validateEdit(new IFile[]{projectFile}, shell); + // + // // If the file is still read-only, then we should not attempt the write, since it will + // // just fail - just throw an exception, to be caught below, and inform the user + // // For other non-successful status, we take our chances, attempt the write, and pass + // // along any exception thrown + // + // //if (!status.isOK()) { + // // if (status.getCode() == IResourceStatus.READ_ONLY_LOCAL) { + // // stream.close(); + // // throw new CoreException(status); + // //} + // //} + // } + // projectFile.setContents(new ByteArrayInputStream(utfString.getBytes("UTF-8")), IResource.FORCE, new NullProgressMonitor()); //$NON-NLS-1$ } else { file.createNewFile(); } @@ -974,14 +1052,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { byte[] bytes; try { bytes = utfString.getBytes("UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e){ + } catch (UnsupportedEncodingException e) { bytes = utfString.getBytes(); } fileStream.write(bytes); fileStream.close(); // Close the streams stream.close(); - } catch (TransformerConfigurationException e){ + } catch (TransformerConfigurationException e) { throw ExceptionFactory.createCoreException(e); } catch (TransformerException e) { throw ExceptionFactory.createCoreException(e); @@ -990,43 +1068,51 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - ICLanguageSetting findLanguagSettingForFile(String fileName, IProject project, ICLanguageSetting settings[]){ - // if(cType != null){ - // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true); - // if(setting == null) - // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false); - // } + ICLanguageSetting findLanguagSettingForFile(String fileName, IProject project, ICLanguageSetting settings[]) { + // if(cType != null){ + // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, true); + // if(setting == null) + // setting = findLanguageSettingForContentTypeId(cType.getId(), settings, false); + // } ICLanguageSetting setting = null; int index = fileName.lastIndexOf('.'); - if(index > 0){ + if (index > 0) { String ext = fileName.substring(index + 1).trim(); - if(ext.length() > 0){ + if (ext.length() > 0) { setting = findLanguageSettingForExtension(ext, settings); } } return setting; } - public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/*, boolean src*/){ + public ICLanguageSetting findLanguageSettingForContentTypeId(String id, ICLanguageSetting settings[]/* + * , + * boolean + * src + */) { for (ICLanguageSetting setting : settings) { String ids[] = setting.getSourceContentTypeIds(); - if(ListComparator.indexOf(id, ids) != -1) + if (ListComparator.indexOf(id, ids) != -1) return setting; } return null; } - public ICLanguageSetting[] findCompatibleSettingsForContentTypeId(String id, ICLanguageSetting[] settings/*, boolean src*/){ + public ICLanguageSetting[] findCompatibleSettingsForContentTypeId(String id, ICLanguageSetting[] settings/* + * , + * boolean + * src + */) { IContentTypeManager manager = Platform.getContentTypeManager(); IContentType cType = manager.getContentType(id); - if(cType != null){ - String [] exts = cType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); - if(exts != null && exts.length != 0){ + if (cType != null) { + String[] exts = cType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); + if (exts != null && exts.length != 0) { List list = new ArrayList(); ICLanguageSetting setting; for (String ext : exts) { - setting = findLanguageSettingForExtension(ext, settings/*, src*/); - if(setting != null) + setting = findLanguageSettingForExtension(ext, settings/* , src */); + if (setting != null) list.add(setting); } return list.toArray(new ICLanguageSetting[list.size()]); @@ -1035,22 +1121,21 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return EMPTY_LANGUAGE_SETTINGS_ARRAY; } - public ICLanguageSetting findLanguageSettingForExtension(String ext, ICLanguageSetting settings[]/*, boolean src*/){ + public ICLanguageSetting findLanguageSettingForExtension(String ext, ICLanguageSetting settings[]/* + * , + * boolean + * src + */) { for (ICLanguageSetting setting : settings) { String exts[] = setting.getSourceExtensions(); -/* if(src){ - if(setting.getSourceContentType() == null){ - exts = setting.getSourceExtensions(); - } - } else { - if(setting.getHeaderContentType() == null){ - exts = setting.getHeaderExtensions(); - } - } -*/ - if(exts != null && exts.length != 0){ - for (String ex: exts) { - if(ext.equals(ex)) + /* + * if(src){ if(setting.getSourceContentType() == null){ exts = + * setting.getSourceExtensions(); } } else { if(setting.getHeaderContentType() == null){ + * exts = setting.getHeaderExtensions(); } } + */ + if (exts != null && exts.length != 0) { + for (String ex : exts) { + if (ext.equals(ex)) return setting; } } @@ -1059,22 +1144,22 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * Returns a map of configurations elements as discovered from the supplied project - * description + * Returns a map of configurations elements as discovered from the supplied project description + * * @param des * @return Map String -> ICStorageElement: configuration name -> configuration ICStorageElement * @throws CoreException */ - Map createCfgStorages(ICProjectDescription des) throws CoreException{ + Map createCfgStorages(ICProjectDescription des) throws CoreException { LinkedHashMap map = new LinkedHashMap(); ICStorageElement rootElement = des.getStorage(MODULE_ID, false); - if(rootElement != null){ + if (rootElement != null) { ICStorageElement children[] = rootElement.getChildren(); for (ICStorageElement el : children) { - if(CONFIGURATION.equals(el.getName())){ + if (CONFIGURATION.equals(el.getName())) { String id = el.getAttribute(CConfigurationSpecSettings.ID); - if(id != null) + if (id != null) map.put(id, el); } } @@ -1084,25 +1169,30 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * Create the configuration storage cfgId in the project description - * @param storage the root settingsStorage of the project - * @param cfgId the configuration Id desire - * @return the cfgId as discovered in the project description or a new ICStorageElement with that Id - * @throws CoreException on failure to create storage + * + * @param storage + * the root settingsStorage of the project + * @param cfgId + * the configuration Id desire + * @return the cfgId as discovered in the project description or a new ICStorageElement with + * that Id + * @throws CoreException + * on failure to create storage */ - ICStorageElement createStorage(ICSettingsStorage storage, String cfgId) throws CoreException { + ICStorageElement createStorage(ICSettingsStorage storage, String cfgId) throws CoreException { ICStorageElement rootElement = storage.getStorage(MODULE_ID, true); // throws CoreException ICStorageElement children[] = rootElement.getChildren(); ICStorageElement element = null; for (ICStorageElement el : children) { - if(CONFIGURATION.equals(el.getName()) - && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))){ + if (CONFIGURATION.equals(el.getName()) + && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))) { element = el; break; } } - if(element == null){ + if (element == null) { element = rootElement.createChild(CONFIGURATION); element.setAttribute(CConfigurationSpecSettings.ID, cfgId); } @@ -1111,24 +1201,29 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * Creates a new configuration storage based on an existing 'base' storage. - * If a configuration with the new ID already exists in the passed in project storage - * a CoreException is thrown. - * @param storage the setting storage of the current project description - * @param cfgId configID of the new configuration - must be unique in - * @param base the base (spec settings) storage element from which settings should be copied. + * Creates a new configuration storage based on an existing 'base' storage. If a configuration + * with the new ID already exists in the passed in project storage a CoreException is thrown. + * + * @param storage + * the setting storage of the current project description + * @param cfgId + * configID of the new configuration - must be unique in + * @param base + * the base (spec settings) storage element from which settings should be copied. * @return ICStorageElement representing the new configuration - * @throws CoreException on failure + * @throws CoreException + * on failure */ - ICStorageElement createStorage(ICSettingsStorage storage, String cfgId, ICStorageElement base) throws CoreException{ + ICStorageElement createStorage(ICSettingsStorage storage, String cfgId, ICStorageElement base) + throws CoreException { ICStorageElement rootElement = storage.getStorage(MODULE_ID, true); ICStorageElement children[] = rootElement.getChildren(); for (ICStorageElement child : children) { - if(CONFIGURATION.equals(child.getName()) + if (CONFIGURATION.equals(child.getName()) && cfgId.equals(child.getAttribute(CConfigurationSpecSettings.ID))) throw ExceptionFactory.createCoreException(MessageFormat .format(SettingsModelMessages.getString("CProjectDescriptionManager.cfgIDAlreadyExists"), //$NON-NLS-1$ - new Object[] {cfgId})); + new Object[] { cfgId })); } ICStorageElement config = rootElement.importChild(base); config.setAttribute(CConfigurationSpecSettings.ID, cfgId); @@ -1137,18 +1232,21 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { /** * Remove the storage with the supplied configuration Id from the project - * @param storage The root settingsStorage of the project - * @param cfgId the configuration ID which would be + * + * @param storage + * The root settingsStorage of the project + * @param cfgId + * the configuration ID which would be * @throws CoreException */ - void removeStorage(ICSettingsStorage storage, String cfgId) throws CoreException{ + void removeStorage(ICSettingsStorage storage, String cfgId) throws CoreException { ICStorageElement rootElement = storage.getStorage(MODULE_ID, false); - if(rootElement != null){ + if (rootElement != null) { ICStorageElement children[] = rootElement.getChildren(); - for (ICStorageElement el: children) { - if(CONFIGURATION.equals(el.getName()) - && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))){ + for (ICStorageElement el : children) { + if (CONFIGURATION.equals(el.getName()) + && cfgId.equals(el.getAttribute(CConfigurationSpecSettings.ID))) { rootElement.removeChild(el); break; } @@ -1157,59 +1255,62 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } void notifyCached(ICConfigurationDescription des, CConfigurationData data, IProgressMonitor monitor) { - if(monitor == null) + if (monitor == null) monitor = new NullProgressMonitor(); try { CConfigurationDataProvider provider = getProvider(des); provider.dataCached(des, data, monitor); - } catch (CoreException e){ + } catch (CoreException e) { CCorePlugin.log(e); } } - void removeData(ICConfigurationDescription des, CConfigurationData data, IProgressMonitor monitor) throws CoreException{ - if(monitor == null) + void removeData(ICConfigurationDescription des, CConfigurationData data, IProgressMonitor monitor) + throws CoreException { + if (monitor == null) monitor = new NullProgressMonitor(); CConfigurationDataProvider provider = getProvider(des); provider.removeConfiguration(des, data, monitor); } - CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, CConfigurationData base, boolean clone, IProgressMonitor monitor) throws CoreException{ - if(monitor == null) + CConfigurationData createData(ICConfigurationDescription des, ICConfigurationDescription baseDescription, + CConfigurationData base, boolean clone, IProgressMonitor monitor) throws CoreException { + if (monitor == null) monitor = new NullProgressMonitor(); CConfigurationDataProvider provider = getProvider(des); return provider.createConfiguration(des, baseDescription, base, clone, monitor); } - CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException{ + CConfigurationDataProvider getProvider(ICConfigurationDescription des) throws CoreException { CConfigurationDataProviderDescriptor providerDes = getCfgProviderDescriptor(des); - if(providerDes == null) + if (providerDes == null) throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.1")); //$NON-NLS-1$ return providerDes.getProvider(); } - private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(ICConfigurationDescription des){ + private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(ICConfigurationDescription des) { return getCfgProviderDescriptor(des.getBuildSystemId()); } - private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(String id){ + private CConfigurationDataProviderDescriptor getCfgProviderDescriptor(String id) { initProviderInfo(); return fProviderMap.get(id); } - private void initProviderInfo(){ - if(fProviderMap != null) + private void initProviderInfo() { + if (fProviderMap != null) return; synchronized (this) { - if(fProviderMap != null) + if (fProviderMap != null) return; - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CConfigurationDataProviderDescriptor.DATA_PROVIDER_EXTPOINT_ID); + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint(CConfigurationDataProviderDescriptor.DATA_PROVIDER_EXTPOINT_ID); IExtension exts[] = extensionPoint.getExtensions(); fProviderMap = new HashMap(exts.length); @@ -1220,82 +1321,86 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } -/* CConfigurationSpecSettings createConfigurationSpecSettings(ICConfigurationDescription cfg) throws CoreException{ - CConfigurationSpecSettings settings = null; - if(cfg instanceof CConfigurationDescriptionCache){ - settings = new CConfigurationSpecSettings(cfg, createStorage(cfg.getProjectDescription(), cfg.getId())); - } else { - ICProjectDescription des = getProjecDescription(cfg.getProjectDescription().getProject(), false); - CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)des.getConfigurationById(cfg.getId()); - if(cache != null){ - settings = new CConfigurationSpecSettings(cfg, cache.getSpecSettings()); - } else { - settings = new CConfigurationSpecSettings(cfg, createStorage(cfg.getProjectDescription(), cfg.getId())); - } - } - return settings; - } -*/ + /* + * CConfigurationSpecSettings createConfigurationSpecSettings(ICConfigurationDescription cfg) + * throws CoreException{ CConfigurationSpecSettings settings = null; if(cfg instanceof + * CConfigurationDescriptionCache){ settings = new CConfigurationSpecSettings(cfg, + * createStorage(cfg.getProjectDescription(), cfg.getId())); } else { ICProjectDescription des = + * getProjecDescription(cfg.getProjectDescription().getProject(), false); + * CConfigurationDescriptionCache cache = + * (CConfigurationDescriptionCache)des.getConfigurationById(cfg.getId()); if(cache != null){ + * settings = new CConfigurationSpecSettings(cfg, cache.getSpecSettings()); } else { settings = + * new CConfigurationSpecSettings(cfg, createStorage(cfg.getProjectDescription(), cfg.getId())); + * } } return settings; } + */ - public ICStorageElement createPreferenceStorage(String key, boolean createEmptyIfNotFound, boolean readOnly) throws CoreException{ + public ICStorageElement createPreferenceStorage(String key, boolean createEmptyIfNotFound, boolean readOnly) + throws CoreException { try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = null; Element element = null; InputStream stream = null; - try{ - stream = getPreferenceProperty(key); - if(stream != null){ - doc = builder.parse(stream); + try { + stream = getPreferenceProperty(key); + if (stream != null) { + doc = builder.parse(stream); - // Get the first element in the project file - Node rootElement = doc.getFirstChild(); + // Get the first element in the project file + Node rootElement = doc.getFirstChild(); - if (rootElement.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) { - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.2")); //$NON-NLS-1$ - } else { - String fileVersion = rootElement.getNodeValue(); - Version version = new Version(fileVersion); - // Make sure that the version is compatible with the manager - // Version must between min version and current version inclusive - if (MIN_DESCRIPTION_VERSION.compareTo(version) > 0 || DESCRIPTION_VERSION.compareTo(version) < 0) { - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.3")); //$NON-NLS-1$ - } + if (rootElement.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) { + throw ExceptionFactory + .createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.2")); //$NON-NLS-1$ + } else { + String fileVersion = rootElement.getNodeValue(); + Version version = new Version(fileVersion); + // Make sure that the version is compatible with the manager + // Version must between min version and current version inclusive + if (MIN_DESCRIPTION_VERSION.compareTo(version) > 0 + || DESCRIPTION_VERSION.compareTo(version) < 0) { + throw ExceptionFactory.createCoreException( + SettingsModelMessages.getString("CProjectDescriptionManager.3")); //$NON-NLS-1$ } - - // Now get the project root element (there should be only one) - NodeList nodes = doc.getElementsByTagName(ROOT_PREFERENCE_ELEMENT); - if (nodes.getLength() == 0) - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.4")); //$NON-NLS-1$ - Node node = nodes.item(0); - if(node.getNodeType() != Node.ELEMENT_NODE) - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.5")); //$NON-NLS-1$ - element = (Element)node; - } else if(!createEmptyIfNotFound){ - throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.6")); //$NON-NLS-1$ } - } catch (FactoryConfigurationError e) { - if(!createEmptyIfNotFound) - throw ExceptionFactory.createCoreException(e.getLocalizedMessage()); - } catch (SAXException e) { - if(!createEmptyIfNotFound) - throw ExceptionFactory.createCoreException(e); - } catch (IOException e) { - if(!createEmptyIfNotFound) - throw ExceptionFactory.createCoreException(e); - } finally { - if(stream != null){ - try { - stream.close(); - } catch (IOException e) { - } + + // Now get the project root element (there should be only one) + NodeList nodes = doc.getElementsByTagName(ROOT_PREFERENCE_ELEMENT); + if (nodes.getLength() == 0) + throw ExceptionFactory + .createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.4")); //$NON-NLS-1$ + Node node = nodes.item(0); + if (node.getNodeType() != Node.ELEMENT_NODE) + throw ExceptionFactory + .createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.5")); //$NON-NLS-1$ + element = (Element) node; + } else if (!createEmptyIfNotFound) { + throw ExceptionFactory + .createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.6")); //$NON-NLS-1$ + } + } catch (FactoryConfigurationError e) { + if (!createEmptyIfNotFound) + throw ExceptionFactory.createCoreException(e.getLocalizedMessage()); + } catch (SAXException e) { + if (!createEmptyIfNotFound) + throw ExceptionFactory.createCoreException(e); + } catch (IOException e) { + if (!createEmptyIfNotFound) + throw ExceptionFactory.createCoreException(e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { } } + } - if(element == null) { + if (element == null) { doc = builder.newDocument(); - ProcessingInstruction instruction = doc.createProcessingInstruction(VERSION_ELEMENT_NAME, DESCRIPTION_VERSION.toString()); + ProcessingInstruction instruction = doc.createProcessingInstruction(VERSION_ELEMENT_NAME, + DESCRIPTION_VERSION.toString()); doc.appendChild(instruction); element = doc.createElement(ROOT_PREFERENCE_ELEMENT); doc.appendChild(element); @@ -1319,7 +1424,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return stream; } - private File getPreferenceFile(String key){ + private File getPreferenceFile(String key) { IPath path = CCorePlugin.getDefault().getStateLocation(); path = path.append(key); return path.toFile(); @@ -1328,21 +1433,21 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { public static File toLocalFile(URI uri, IProgressMonitor monitor) throws CoreException { IFileStore fileStore = EFS.getStore(uri); File localFile = fileStore.toLocalFile(EFS.NONE, monitor); - if (localFile ==null) + if (localFile == null) // non local file system - localFile= fileStore.toLocalFile(EFS.CACHE, monitor); + localFile = fileStore.toLocalFile(EFS.CACHE, monitor); return localFile; } - ICDescriptionDelta createDelta(ICProjectDescription newDescription, ICProjectDescription oldDescription){ + ICDescriptionDelta createDelta(ICProjectDescription newDescription, ICProjectDescription oldDescription) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newDescription, oldDescription); - if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) { ICConfigurationDescription[] cfgs = newDescription.getConfigurations(); for (ICConfigurationDescription cfg : cfgs) { ICConfigurationDescription oldCfg = oldDescription.getConfigurationById(cfg.getId()); CProjectDescriptionDelta cfgDelta = createDelta(cfg, oldCfg); - if(cfgDelta != null){ + if (cfgDelta != null) { delta.addChild(cfgDelta); } } @@ -1350,26 +1455,26 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { cfgs = oldDescription.getConfigurations(); for (ICConfigurationDescription cfg : cfgs) { ICConfigurationDescription newCfg = newDescription.getConfigurationById(cfg.getId()); - if(newCfg == null) + if (newCfg == null) delta.addChild(createDelta(null, cfg)); } - if(checkCfgChange(newDescription, oldDescription, true)) + if (checkCfgChange(newDescription, oldDescription, true)) delta.addChangeFlags(ICDescriptionDelta.ACTIVE_CFG); - if(checkCfgChange(newDescription, oldDescription, false)) + if (checkCfgChange(newDescription, oldDescription, false)) delta.addChangeFlags(ICDescriptionDelta.INDEX_CFG); - if(oldDescription.isCdtProjectCreating() && !newDescription.isCdtProjectCreating()) + if (oldDescription.isCdtProjectCreating() && !newDescription.isCdtProjectCreating()) delta.addChangeFlags(ICDescriptionDelta.PROJECT_CREAION_COMPLETED); } return delta.isEmpty() ? null : delta; } - private boolean checkCfgChange(ICProjectDescription newDes, ICProjectDescription oldDes, boolean active){ + private boolean checkCfgChange(ICProjectDescription newDes, ICProjectDescription oldDes, boolean active) { ICConfigurationDescription newCfg, oldCfg; - if(active){ + if (active) { newCfg = newDes.getActiveConfiguration(); oldCfg = oldDes.getActiveConfiguration(); } else { @@ -1377,80 +1482,77 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { oldCfg = oldDes.getDefaultSettingConfiguration(); } - if(newCfg == null){ + if (newCfg == null) { return oldCfg != null; - } else if (oldCfg == null){ + } else if (oldCfg == null) { return true; } return !newCfg.getId().equals(oldCfg.getId()); } -/* void postProcessNewDescriptionCache(CProjectDescription des, ICProjectDescriptionDelta delta){ - if(delta == null && delta.getDeltaKind() != ICProjectDescriptionDelta.CHANGED) - return; - - ICConfigurationDescription indexCfg = des.getIndexConfiguration(); - ICConfigurationDescription activeCfg = des.getActiveConfiguration(); - ICProjectDescriptionDelta activeCfgDelta = findDelta(activeCfg.getId(), delta); - if(indexCfg != activeCfg){ - switch(activeCfgDelta.getDeltaKind()){ - case ICProjectDescriptionDelta.CHANGED: - des.setIndexConfiguration(activeCfg); - } - } - - - } -*/ - private ICDescriptionDelta findDelta(String id, ICDescriptionDelta delta){ + /* + * void postProcessNewDescriptionCache(CProjectDescription des, ICProjectDescriptionDelta + * delta){ if(delta == null && delta.getDeltaKind() != ICProjectDescriptionDelta.CHANGED) + * return; + * + * ICConfigurationDescription indexCfg = des.getIndexConfiguration(); ICConfigurationDescription + * activeCfg = des.getActiveConfiguration(); ICProjectDescriptionDelta activeCfgDelta = + * findDelta(activeCfg.getId(), delta); if(indexCfg != activeCfg){ + * switch(activeCfgDelta.getDeltaKind()){ case ICProjectDescriptionDelta.CHANGED: + * des.setIndexConfiguration(activeCfg); } } + * + * + * } + */ + private ICDescriptionDelta findDelta(String id, ICDescriptionDelta delta) { ICDescriptionDelta children[] = delta.getChildren(); ICSettingObject obj; for (ICDescriptionDelta child : children) { obj = child.getSetting(); - if(obj.getId().equals(id)) + if (obj.getId().equals(id)) return child; } return null; } - public int calculateDescriptorFlags(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg){ + public int calculateDescriptorFlags(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg) { try { int flags = 0; - CConfigurationSpecSettings newSettings = ((IInternalCCfgInfo)newCfg).getSpecSettings(); - CConfigurationSpecSettings oldSettings = ((IInternalCCfgInfo)oldCfg).getSpecSettings(); + CConfigurationSpecSettings newSettings = ((IInternalCCfgInfo) newCfg).getSpecSettings(); + CConfigurationSpecSettings oldSettings = ((IInternalCCfgInfo) oldCfg).getSpecSettings(); String newId = newSettings.getCOwnerId(); String oldId = oldSettings.getCOwnerId(); - if(!CDataUtil.objectsEqual(newId, oldId)) + if (!CDataUtil.objectsEqual(newId, oldId)) flags |= ICDescriptionDelta.OWNER; Map newMap = newSettings.getExtensionMapCopy(); Map oldMap = oldSettings.getExtensionMapCopy(); Iterator> iter = newMap.entrySet().iterator(); - while(iter.hasNext()) { + while (iter.hasNext()) { Map.Entry entry = iter.next(); iter.remove(); CConfigExtensionReference[] oldRefs = oldMap.remove(entry.getKey()); - if(oldRefs == null){ + if (oldRefs == null) { flags |= ICDescriptionDelta.EXT_REF; break; } CConfigExtensionReference[] newRefs = entry.getValue(); - if(newRefs.length != oldRefs.length){ + if (newRefs.length != oldRefs.length) { flags |= ICDescriptionDelta.EXT_REF; break; } Set newSet = new HashSet(Arrays.asList(newRefs)); Set oldSet = new HashSet(Arrays.asList(oldRefs)); - if(newSet.size() != oldSet.size()){ + if (newSet.size() != oldSet.size()) { flags |= ICDescriptionDelta.EXT_REF; break; } newSet.removeAll(oldSet); - if(newSet.size() != 0){ + if (newSet.size() != 0) { flags |= ICDescriptionDelta.EXT_REF; break; } @@ -1463,17 +1565,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return 0; } - public CProjectDescriptionDelta createDelta(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg){ + public CProjectDescriptionDelta createDelta(ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newCfg, oldCfg); - IInternalCCfgInfo newInfo = (IInternalCCfgInfo)newCfg; - IInternalCCfgInfo oldInfo = (IInternalCCfgInfo)oldCfg; - if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + IInternalCCfgInfo newInfo = (IInternalCCfgInfo) newCfg; + IInternalCCfgInfo oldInfo = (IInternalCCfgInfo) oldCfg; + if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) { ICFolderDescription[] foDess = newCfg.getFolderDescriptions(); for (ICFolderDescription foDes : foDess) { ICResourceDescription oldDes = oldCfg.getResourceDescription(foDes.getPath(), true); - if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FOLDER){ - CProjectDescriptionDelta foDelta = createDelta(foDes, (ICFolderDescription)oldDes); - if(foDelta != null) + if (oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FOLDER) { + CProjectDescriptionDelta foDelta = createDelta(foDes, (ICFolderDescription) oldDes); + if (foDelta != null) delta.addChild(foDelta); } else { delta.addChild(createDelta(foDes, null)); @@ -1483,7 +1585,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { foDess = oldCfg.getFolderDescriptions(); for (ICFolderDescription foDes : foDess) { ICResourceDescription newDes = newCfg.getResourceDescription(foDes.getPath(), true); - if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FOLDER){ + if (newDes == null || newDes.getType() != ICSettingBase.SETTING_FOLDER) { delta.addChild(createDelta(null, foDes)); } } @@ -1491,9 +1593,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ICFileDescription[] fiDess = newCfg.getFileDescriptions(); for (ICFileDescription fiDes : fiDess) { ICResourceDescription oldDes = oldCfg.getResourceDescription(fiDes.getPath(), true); - if(oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FILE){ - CProjectDescriptionDelta fiDelta = createDelta(fiDes, (ICFileDescription)oldDes); - if(fiDelta != null) + if (oldDes != null && oldDes.getType() == ICSettingBase.SETTING_FILE) { + CProjectDescriptionDelta fiDelta = createDelta(fiDes, (ICFileDescription) oldDes); + if (fiDelta != null) delta.addChild(fiDelta); } else { delta.addChild(createDelta(fiDes, null)); @@ -1503,20 +1605,21 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { fiDess = oldCfg.getFileDescriptions(); for (ICFileDescription fiDes : fiDess) { ICResourceDescription newDes = newCfg.getResourceDescription(fiDes.getPath(), true); - if(newDes == null || newDes.getType() != ICSettingBase.SETTING_FILE){ + if (newDes == null || newDes.getType() != ICSettingBase.SETTING_FILE) { delta.addChild(createDelta(null, fiDes)); } } CProjectDescriptionDelta bsDelta = createDelta(newCfg.getBuildSetting(), oldCfg.getBuildSetting()); - if(bsDelta != null) + if (bsDelta != null) delta.addChild(bsDelta); - CProjectDescriptionDelta tpsDelta = createDelta(newCfg.getTargetPlatformSetting(), oldCfg.getTargetPlatformSetting()); - if(tpsDelta != null) + CProjectDescriptionDelta tpsDelta = createDelta(newCfg.getTargetPlatformSetting(), + oldCfg.getTargetPlatformSetting()); + if (tpsDelta != null) delta.addChild(tpsDelta); - if(!newCfg.getName().equals(oldCfg.getName())){ + if (!newCfg.getName().equals(oldCfg.getName())) { delta.addChangeFlags(ICDescriptionDelta.NAME); } @@ -1527,38 +1630,38 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ICSourceEntry newEntries[] = newCfg.getSourceEntries(); ICSourceEntry oldEntries[] = oldCfg.getSourceEntries(); - if(newEntries.length > oldEntries.length){ + if (newEntries.length > oldEntries.length) { delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED); } else { for (ICSourceEntry newEntry : newEntries) { boolean found = false; for (ICSourceEntry oldEntry : oldEntries) { - if(newEntry.equals(oldEntry)){ + if (newEntry.equals(oldEntry)) { found = true; break; } } - if(!found){ + if (!found) { delta.addChangeFlags(ICDescriptionDelta.SOURCE_ADDED); break; } } } - if(oldEntries.length > newEntries.length){ + if (oldEntries.length > newEntries.length) { delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED); } else { for (ICSourceEntry oldEntry : oldEntries) { boolean found = false; for (ICSourceEntry newEntry : newEntries) { - if(oldEntry.equals(newEntry)){ + if (oldEntry.equals(newEntry)) { found = true; break; } } - if(!found){ + if (!found) { delta.addChangeFlags(ICDescriptionDelta.SOURCE_REMOVED); break; } @@ -1568,9 +1671,9 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { try { CConfigurationSpecSettings newSettings = newInfo.getSpecSettings(); CConfigurationSpecSettings oldSettings = oldInfo.getSpecSettings(); - if(!newSettings.extRefSettingsEqual(oldSettings)) + if (!newSettings.extRefSettingsEqual(oldSettings)) delta.addChangeFlags(ICDescriptionDelta.EXT_REF); - } catch (CoreException e){ + } catch (CoreException e) { CCorePlugin.log(e); } @@ -1580,57 +1683,57 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { List oldLSProviders = null; if (oldCfg instanceof ILanguageSettingsProvidersKeeper) oldLSProviders = ((ILanguageSettingsProvidersKeeper) oldCfg).getLanguageSettingProviders(); - if(newLSProviders != oldLSProviders && (newLSProviders == null || !newLSProviders.equals(oldLSProviders))) + if (newLSProviders != oldLSProviders && (newLSProviders == null || !newLSProviders.equals(oldLSProviders))) delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_SETTINGS_PROVIDERS); calculateCfgExtSettingsDelta(delta); int drFlags = calculateDescriptorFlags(newCfg, oldCfg); - if(drFlags != 0) + if (drFlags != 0) delta.addChangeFlags(drFlags); } return delta.isEmpty() ? null : delta; } - private void calculateCfgExtSettingsDelta(CProjectDescriptionDelta delta){ - ICConfigurationDescription newDes = (ICConfigurationDescription)delta.getNewSetting(); - ICConfigurationDescription oldDes = (ICConfigurationDescription)delta.getOldSetting(); + private void calculateCfgExtSettingsDelta(CProjectDescriptionDelta delta) { + ICConfigurationDescription newDes = (ICConfigurationDescription) delta.getNewSetting(); + ICConfigurationDescription oldDes = (ICConfigurationDescription) delta.getOldSetting(); ExtSettingsDelta[] deltas = getSettingChange(newDes, oldDes); int flags = 0; int addedRemoved = ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED | ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED; - if(deltas != null ){ + if (deltas != null) { for (ExtSettingsDelta dt : deltas) { ICSettingEntry[][] d = dt.getEntriesDelta(); - if(d[0] != null) + if (d[0] != null) flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_ADDED; - if(d[1] != null) + if (d[1] != null) flags |= ICDescriptionDelta.EXTERNAL_SETTINGS_REMOVED; - if((flags & (addedRemoved)) == addedRemoved) + if ((flags & (addedRemoved)) == addedRemoved) break; } -// delta.setExtSettingsDeltas(deltas); - if(flags != 0) + // delta.setExtSettingsDeltas(deltas); + if (flags != 0) delta.addChangeFlags(flags); } int cfgRefFlags = calcRefChangeFlags(newDes, oldDes); - if(cfgRefFlags != 0) + if (cfgRefFlags != 0) delta.addChangeFlags(cfgRefFlags); } - private int calcRefChangeFlags(ICConfigurationDescription newDes, ICConfigurationDescription oldDes){ + private int calcRefChangeFlags(ICConfigurationDescription newDes, ICConfigurationDescription oldDes) { Map newMap = newDes != null ? newDes.getReferenceInfo() : null; Map oldMap = oldDes != null ? oldDes.getReferenceInfo() : null; int flags = 0; - if(newMap == null || newMap.size() == 0){ - if(oldMap != null && oldMap.size() != 0){ + if (newMap == null || newMap.size() == 0) { + if (oldMap != null && oldMap.size() != 0) { flags = ICDescriptionDelta.CFG_REF_REMOVED; } } else { - if(oldMap == null || oldMap.size() == 0){ + if (oldMap == null || oldMap.size() == 0) { flags = ICDescriptionDelta.CFG_REF_ADDED; } else { boolean stop = false; @@ -1638,18 +1741,18 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { String newProj = newEntry.getKey(); String newCfg = newEntry.getValue(); String oldCfg = oldMap.remove(newProj); - if(!newCfg.equals(oldCfg)){ + if (!newCfg.equals(oldCfg)) { flags |= ICDescriptionDelta.CFG_REF_ADDED; - if(oldCfg != null){ + if (oldCfg != null) { flags |= ICDescriptionDelta.CFG_REF_REMOVED; stop = true; } - if(stop) + if (stop) break; } } - if(!oldMap.isEmpty()) + if (!oldMap.isEmpty()) flags |= ICDescriptionDelta.CFG_REF_REMOVED; } } @@ -1657,17 +1760,16 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return flags; } - - private ExtSettingsDelta[] getSettingChange(ICConfigurationDescription newDes, ICConfigurationDescription oldDes){ - CExternalSetting[] newSettings = newDes != null ? (CExternalSetting[])newDes.getExternalSettings() : null; - CExternalSetting[] oldSettings = oldDes != null ? (CExternalSetting[])oldDes.getExternalSettings() : null; + private ExtSettingsDelta[] getSettingChange(ICConfigurationDescription newDes, ICConfigurationDescription oldDes) { + CExternalSetting[] newSettings = newDes != null ? (CExternalSetting[]) newDes.getExternalSettings() : null; + CExternalSetting[] oldSettings = oldDes != null ? (CExternalSetting[]) oldDes.getExternalSettings() : null; return CExternalSettinsDeltaCalculator.getInstance().getSettingChange(newSettings, oldSettings); } - private CProjectDescriptionDelta createDelta(ICFolderDescription newFo, ICFolderDescription oldFo){ + private CProjectDescriptionDelta createDelta(ICFolderDescription newFo, ICFolderDescription oldFo) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newFo, oldFo); - if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) { ICLanguageSetting newLss[] = newFo.getLanguageSettings(); ICLanguageSetting oldLss[] = oldFo.getLanguageSettings(); List newList = new ArrayList(Arrays.asList(newLss)); @@ -1676,7 +1778,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { for (ICLanguageSetting[] match : matched) { CProjectDescriptionDelta lsDelta = createDelta(match[0], match[1]); - if(lsDelta != null) + if (lsDelta != null) delta.addChild(lsDelta); } @@ -1688,28 +1790,28 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { delta.addChild(createDelta(null, removed)); } -// HashMap oldMap = new HashMap(); -// for(int i = 0; i < oldLss.length; i++){ -// oldMap.put(oldLss[i].getId(), oldLss[i]); -// } + // HashMap oldMap = new HashMap(); + // for(int i = 0; i < oldLss.length; i++){ + // oldMap.put(oldLss[i].getId(), oldLss[i]); + // } -// for(int i = 0; i < newLss.length; i++){ -// ICLanguageSetting oldLs = (ICLanguageSetting)oldMap.remove(newLss[i].getId()); -// CProjectDescriptionDelta lsDelta = createDelta(newLss[i], oldLs); -// if(lsDelta != null) -// delta.addChild(lsDelta); -// } + // for(int i = 0; i < newLss.length; i++){ + // ICLanguageSetting oldLs = (ICLanguageSetting)oldMap.remove(newLss[i].getId()); + // CProjectDescriptionDelta lsDelta = createDelta(newLss[i], oldLs); + // if(lsDelta != null) + // delta.addChild(lsDelta); + // } -// if(!oldMap.isEmpty()){ -// for(Iterator iter = oldMap.values().iterator(); iter.hasNext();){ -// delta.addChild(createDelta(null, (ICLanguageSetting)iter.next())); -// } -// } + // if(!oldMap.isEmpty()){ + // for(Iterator iter = oldMap.values().iterator(); iter.hasNext();){ + // delta.addChild(createDelta(null, (ICLanguageSetting)iter.next())); + // } + // } -// if(!newFo.getPath().equals(oldFo.getPath())) -// delta.addChangeFlags(ICProjectDescriptionDelta.PATH); + // if(!newFo.getPath().equals(oldFo.getPath())) + // delta.addChangeFlags(ICProjectDescriptionDelta.PATH); - if(newFo.isExcluded() != oldFo.isExcluded()) + if (newFo.isExcluded() != oldFo.isExcluded()) delta.addChangeFlags(ICDescriptionDelta.EXCLUDE); } @@ -1717,19 +1819,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } private List sortSettings(List settings1, - List settings2){ + List settings2) { ICLanguageSetting setting1; ICLanguageSetting setting2; List result = new ArrayList(); - for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){ + for (Iterator iter1 = settings1.iterator(); iter1.hasNext();) { setting1 = iter1.next(); - for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){ + for (Iterator iter2 = settings2.iterator(); iter2.hasNext();) { setting2 = iter2.next(); - if(setting2.getId().equals(setting1.getId())){ + if (setting2.getId().equals(setting1.getId())) { iter1.remove(); iter2.remove(); - ICLanguageSetting [] match = new ICLanguageSetting[2]; + ICLanguageSetting[] match = new ICLanguageSetting[2]; match[0] = setting1; match[1] = setting2; result.add(match); @@ -1738,17 +1840,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){ + for (Iterator iter1 = settings1.iterator(); iter1.hasNext();) { setting1 = iter1.next(); String lId = setting1.getLanguageId(); - if(lId != null){ - for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){ + if (lId != null) { + for (Iterator iter2 = settings2.iterator(); iter2.hasNext();) { setting2 = iter2.next(); - if(lId.equals(setting2.getLanguageId())){ + if (lId.equals(setting2.getLanguageId())) { iter1.remove(); iter2.remove(); - ICLanguageSetting [] match = new ICLanguageSetting[2]; + ICLanguageSetting[] match = new ICLanguageSetting[2]; match[0] = setting1; match[1] = setting2; result.add(match); @@ -1758,16 +1860,16 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){ + for (Iterator iter1 = settings1.iterator(); iter1.hasNext();) { setting1 = iter1.next(); String cTypeIds1[] = setting1.getSourceContentTypeIds(); - if(cTypeIds1.length != 0){ - for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){ + if (cTypeIds1.length != 0) { + for (Iterator iter2 = settings2.iterator(); iter2.hasNext();) { setting2 = iter2.next(); - if(Arrays.equals(cTypeIds1, setting2.getSourceContentTypeIds())){ + if (Arrays.equals(cTypeIds1, setting2.getSourceContentTypeIds())) { iter1.remove(); iter2.remove(); - ICLanguageSetting [] match = new ICLanguageSetting[2]; + ICLanguageSetting[] match = new ICLanguageSetting[2]; match[0] = setting1; match[1] = setting2; result.add(match); @@ -1777,18 +1879,18 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - for(Iterator iter1 = settings1.iterator(); iter1.hasNext();){ + for (Iterator iter1 = settings1.iterator(); iter1.hasNext();) { setting1 = iter1.next(); - if(setting1.getSourceContentTypeIds().length == 0){ - String srcExts[] = setting1.getSourceExtensions(); - if(srcExts.length != 0){ - for(Iterator iter2 = settings2.iterator(); iter2.hasNext();){ + if (setting1.getSourceContentTypeIds().length == 0) { + String srcExts[] = setting1.getSourceExtensions(); + if (srcExts.length != 0) { + for (Iterator iter2 = settings2.iterator(); iter2.hasNext();) { setting2 = iter2.next(); - if(setting2.getSourceContentTypeIds().length == 0){ - if(Arrays.equals(srcExts, setting2.getSourceExtensions())){ + if (setting2.getSourceContentTypeIds().length == 0) { + if (Arrays.equals(srcExts, setting2.getSourceExtensions())) { iter1.remove(); iter2.remove(); - ICLanguageSetting [] match = new ICLanguageSetting[2]; + ICLanguageSetting[] match = new ICLanguageSetting[2]; match[0] = setting1; match[1] = setting2; result.add(match); @@ -1802,28 +1904,28 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return result; } - private CProjectDescriptionDelta createDelta(ICFileDescription newFi, ICFileDescription oldFi){ + private CProjectDescriptionDelta createDelta(ICFileDescription newFi, ICFileDescription oldFi) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newFi, oldFi); - if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) { CProjectDescriptionDelta lsDelta = createDelta(newFi.getLanguageSetting(), oldFi.getLanguageSetting()); - if(lsDelta != null) + if (lsDelta != null) delta.addChild(lsDelta); -// if(!newFi.getPath().equals(oldFi.getPath())) -// delta.addChangeFlags(ICProjectDescriptionDelta.PATH); + // if(!newFi.getPath().equals(oldFi.getPath())) + // delta.addChangeFlags(ICProjectDescriptionDelta.PATH); - if(newFi.isExcluded() != oldFi.isExcluded()) + if (newFi.isExcluded() != oldFi.isExcluded()) delta.addChangeFlags(ICDescriptionDelta.EXCLUDE); } return delta.isEmpty() ? null : delta; } - private CProjectDescriptionDelta createDelta(ICLanguageSetting newLs, ICLanguageSetting oldLs){ + private CProjectDescriptionDelta createDelta(ICLanguageSetting newLs, ICLanguageSetting oldLs) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newLs, oldLs); - if(delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) { if (!CDataUtil.objectsEqual(newLs.getLanguageId(), oldLs.getLanguageId())) delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_ID); @@ -1836,11 +1938,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ICLanguageSettingEntry oldEntries[] = oldLs.getSettingEntries(kind); boolean[] change = calculateSettingsChanges(newEntries, oldEntries); - if(change[0]) + if (change[0]) addedKinds |= kind; - if(change[1]) + if (change[1]) removedKinds |= kind; - if(change[2]) + if (change[2]) reorderedKinds |= kind; } delta.setAddedLanguageEntriesKinds(addedKinds); @@ -1850,32 +1952,31 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { String[] newCtIds = newLs.getSourceContentTypeIds(); String[] oldCtIds = oldLs.getSourceContentTypeIds(); - if(!Arrays.equals(newCtIds, oldCtIds)) + if (!Arrays.equals(newCtIds, oldCtIds)) delta.addChangeFlags(ICDescriptionDelta.SOURCE_CONTENT_TYPE); - String[] newExts = newLs.getSourceExtensions(); String[] oldExts = oldLs.getSourceExtensions(); - if(!Arrays.equals(newExts, oldExts)) + if (!Arrays.equals(newExts, oldExts)) delta.addChangeFlags(ICDescriptionDelta.SOURCE_EXTENSIONS); + // newCt = newLs.getHeaderContentType(); + // oldCt = oldLs.getHeaderContentType(); -// newCt = newLs.getHeaderContentType(); -// oldCt = oldLs.getHeaderContentType(); + // if(!compare(newCt, oldCt)) + // delta.addChangeFlags(ICDescriptionDelta.HEADER_CONTENT_TYPE); -// if(!compare(newCt, oldCt)) -// delta.addChangeFlags(ICDescriptionDelta.HEADER_CONTENT_TYPE); - -// newExts = newLs.getHeaderExtensions(); -// oldExts = oldLs.getHeaderExtensions(); -// if(!Arrays.equals(newExts, oldExts)) -// delta.addChangeFlags(ICDescriptionDelta.HEADER_ENTENSIONS); + // newExts = newLs.getHeaderExtensions(); + // oldExts = oldLs.getHeaderExtensions(); + // if(!Arrays.equals(newExts, oldExts)) + // delta.addChangeFlags(ICDescriptionDelta.HEADER_ENTENSIONS); } return delta.isEmpty() ? null : delta; } - private boolean[] calculateSettingsChanges(ICLanguageSettingEntry newEntries[], ICLanguageSettingEntry oldEntries[]) { + private boolean[] calculateSettingsChanges(ICLanguageSettingEntry newEntries[], + ICLanguageSettingEntry oldEntries[]) { boolean result[] = new boolean[3]; // if nothing was known before do not generate any deltas. @@ -1897,7 +1998,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { found = true; break; } - if(!found){ + if (!found) { result[1] = true; break; } @@ -1910,7 +2011,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { found = true; break; } - if(!found){ + if (!found) { result[0] = true; break; } @@ -1933,61 +2034,58 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return result; } -/* public boolean entriesEqual(ICLanguageSettingEntry entries1[], ICLanguageSettingEntry entries2[]){ - if(entries1.length != entries2.length) - return false; - - for(int i = 0; i < entries1.length; i++){ - if(!entries1[i].equals(entries2[i])) - return false; - } - - return true; - } -*/ - private CProjectDescriptionDelta createDelta(ICBuildSetting newBuildSetting, ICBuildSetting oldBuildSetting){ + /* + * public boolean entriesEqual(ICLanguageSettingEntry entries1[], ICLanguageSettingEntry + * entries2[]){ if(entries1.length != entries2.length) return false; + * + * for(int i = 0; i < entries1.length; i++){ if(!entries1[i].equals(entries2[i])) return false; + * } + * + * return true; } + */ + private CProjectDescriptionDelta createDelta(ICBuildSetting newBuildSetting, ICBuildSetting oldBuildSetting) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newBuildSetting, oldBuildSetting); - if(!Arrays.equals(newBuildSetting.getErrorParserIDs(), oldBuildSetting.getErrorParserIDs())) + if (!Arrays.equals(newBuildSetting.getErrorParserIDs(), oldBuildSetting.getErrorParserIDs())) delta.addChangeFlags(ICDescriptionDelta.ERROR_PARSER_IDS); return delta.isEmpty() ? null : delta; } - private CProjectDescriptionDelta createDelta(ICTargetPlatformSetting newTPS, ICTargetPlatformSetting oldTPS){ + private CProjectDescriptionDelta createDelta(ICTargetPlatformSetting newTPS, ICTargetPlatformSetting oldTPS) { CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newTPS, oldTPS); - if(!Arrays.equals(newTPS.getBinaryParserIds(), oldTPS.getBinaryParserIds())) + if (!Arrays.equals(newTPS.getBinaryParserIds(), oldTPS.getBinaryParserIds())) delta.addChangeFlags(ICDescriptionDelta.BINARY_PARSER_IDS); return delta.isEmpty() ? null : delta; } - ICElementDelta[] generateCElementDeltas(ICProject cProject, ICDescriptionDelta projDesDelta){ - if(projDesDelta == null) + ICElementDelta[] generateCElementDeltas(ICProject cProject, ICDescriptionDelta projDesDelta) { + if (projDesDelta == null) return EMPTY_CELEMENT_DELTA; int kind = projDesDelta.getDeltaKind(); - switch(kind){ + switch (kind) { case ICDescriptionDelta.CHANGED: - ICProjectDescription newDes = (ICProjectDescription)projDesDelta.getNewSetting(); - ICProjectDescription oldDes = (ICProjectDescription)projDesDelta.getOldSetting(); -// int flags = projDesDelta.getChangeFlags(); -// ICConfigurationDescription activeCfg = newDes.getActiveConfiguration(); + ICProjectDescription newDes = (ICProjectDescription) projDesDelta.getNewSetting(); + ICProjectDescription oldDes = (ICProjectDescription) projDesDelta.getOldSetting(); + // int flags = projDesDelta.getChangeFlags(); + // ICConfigurationDescription activeCfg = newDes.getActiveConfiguration(); ICConfigurationDescription indexCfg = newDes.getDefaultSettingConfiguration(); -// if(indexCfg != activeCfg){ -// ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta); -// if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ -// indexCfg = activeCfg; -// newDes.setIndexConfiguration(activeCfg); -// } -// } + // if(indexCfg != activeCfg){ + // ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta); + // if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ + // indexCfg = activeCfg; + // newDes.setIndexConfiguration(activeCfg); + // } + // } ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration(); ICDescriptionDelta indexDelta; - if(oldIndexCfg != null && oldIndexCfg.getId().equals(indexCfg.getId())){ + if (oldIndexCfg != null && oldIndexCfg.getId().equals(indexCfg.getId())) { indexDelta = findDelta(indexCfg.getId(), projDesDelta); } else { indexDelta = createDelta(indexCfg, oldIndexCfg); } - if(indexDelta != null){ + if (indexDelta != null) { List list = new ArrayList(); generateCElementDeltasFromCfgDelta(cProject, indexDelta, list); return list.toArray(new ICElementDelta[list.size()]); @@ -2000,18 +2098,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return EMPTY_CELEMENT_DELTA; } - private List generateCElementDeltasFromCfgDelta(ICProject cProject, ICDescriptionDelta cfgDelta, List list){ + private List generateCElementDeltasFromCfgDelta(ICProject cProject, ICDescriptionDelta cfgDelta, + List list) { int kind = cfgDelta.getDeltaKind(); - switch(kind){ + switch (kind) { case ICDescriptionDelta.CHANGED: int descriptionFlags = cfgDelta.getChangeFlags(); int celementFlags = 0; - if((descriptionFlags & ICDescriptionDelta.SOURCE_ADDED) != 0) + if ((descriptionFlags & ICDescriptionDelta.SOURCE_ADDED) != 0) celementFlags |= ICElementDelta.F_ADDED_PATHENTRY_SOURCE; - if((descriptionFlags & ICDescriptionDelta.SOURCE_REMOVED) != 0) + if ((descriptionFlags & ICDescriptionDelta.SOURCE_REMOVED) != 0) celementFlags |= ICElementDelta.F_REMOVED_PATHENTRY_SOURCE; - if(celementFlags != 0){ + if (celementFlags != 0) { CElementDelta cElDelta = new CElementDelta(cProject.getCModel()); cElDelta.changed(cProject, celementFlags); list.add(cElDelta); @@ -2021,7 +2120,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { int type; for (ICDescriptionDelta child : children) { type = child.getSettingType(); - if(type == ICSettingBase.SETTING_FILE || type == ICSettingBase.SETTING_FOLDER){ + if (type == ICSettingBase.SETTING_FILE || type == ICSettingBase.SETTING_FOLDER) { generateCElementDeltasFromResourceDelta(cProject, child, list); } } @@ -2034,36 +2133,39 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } /** - * The method maps {@link ICDescriptionDelta} to {@link CElementDelta} which are added to the {@code list}. - * The delta will indicate modification of CElement for a given resource plus language settings - * if they changed (relative to parent resource description if the resource has no its own). + * The method maps {@link ICDescriptionDelta} to {@link CElementDelta} which are added to the + * {@code list}. The delta will indicate modification of CElement for a given resource plus + * language settings if they changed (relative to parent resource description if the resource + * has no its own). */ - private void generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List list){ + private void generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, + List list) { int kind = delta.getDeltaKind(); ICDescriptionDelta parentDelta = delta.getParent(); ICResourceDescription oldRcDes; ICResourceDescription newRcDes; IPath path; - switch(kind){ + switch (kind) { case ICDescriptionDelta.REMOVED: - oldRcDes = (ICResourceDescription)delta.getOldSetting(); + oldRcDes = (ICResourceDescription) delta.getOldSetting(); path = oldRcDes.getPath(); - newRcDes = ((ICConfigurationDescription)parentDelta.getNewSetting()).getResourceDescription(path, false); + newRcDes = ((ICConfigurationDescription) parentDelta.getNewSetting()).getResourceDescription(path, false); break; case ICDescriptionDelta.ADDED: - newRcDes = (ICResourceDescription)delta.getNewSetting(); + newRcDes = (ICResourceDescription) delta.getNewSetting(); path = newRcDes.getPath(); - oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false); + oldRcDes = ((ICConfigurationDescription) parentDelta.getOldSetting()).getResourceDescription(path, false); break; case ICDescriptionDelta.CHANGED: - newRcDes = (ICResourceDescription)delta.getNewSetting(); + newRcDes = (ICResourceDescription) delta.getNewSetting(); path = newRcDes.getPath(); - oldRcDes = (ICResourceDescription)delta.getOldSetting(); + oldRcDes = (ICResourceDescription) delta.getOldSetting(); break; default: // Not possible - CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.illegalDeltaKind")+kind)); //$NON-NLS-1$ + CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, + SettingsModelMessages.getString("CProjectDescriptionManager.illegalDeltaKind") + kind)); //$NON-NLS-1$ return; } path = path.makeRelative(); @@ -2076,34 +2178,38 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } IResource rc = el.getResource(); - if(rc != null){ + if (rc != null) { CElementDelta ceRcDelta = new CElementDelta(el.getCModel()); ceRcDelta.changed(el, ICElementDelta.F_MODIFIERS); list.add(ceRcDelta); - if(rc.getType() == IResource.FILE){ + if (rc.getType() == IResource.FILE) { String fileName = path.lastSegment(); ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName); ICLanguageSetting oldLS = getLanguageSetting(oldRcDes, fileName); ICDescriptionDelta ld = createDelta(newLS, oldLS); generateCElementDeltasFromLanguageDelta(el, ld, list); } else { - if(newRcDes.getType() != ICSettingBase.SETTING_FOLDER){ - CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+newRcDes)); //$NON-NLS-1$ + if (newRcDes.getType() != ICSettingBase.SETTING_FOLDER) { + CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, + SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription") //$NON-NLS-1$ + + newRcDes)); return; } - ICFolderDescription newFoDes = (ICFolderDescription)newRcDes; + ICFolderDescription newFoDes = (ICFolderDescription) newRcDes; - if(oldRcDes.getType() != ICSettingBase.SETTING_FOLDER){ - CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+oldRcDes)); //$NON-NLS-1$ + if (oldRcDes.getType() != ICSettingBase.SETTING_FOLDER) { + CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, + SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription") //$NON-NLS-1$ + + oldRcDes)); return; } - ICFolderDescription oldFoDes = (ICFolderDescription)oldRcDes; + ICFolderDescription oldFoDes = (ICFolderDescription) oldRcDes; ICDescriptionDelta folderDelta = createDelta(newFoDes, oldFoDes); if (folderDelta != null) { for (ICDescriptionDelta child : folderDelta.getChildren()) { - if(child.getSettingType() == ICSettingBase.SETTING_LANGUAGE){ + if (child.getSettingType() == ICSettingBase.SETTING_LANGUAGE) { generateCElementDeltasFromLanguageDelta(el, child, list); } } @@ -2113,22 +2219,23 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName){ - if(rcDes.getType() == ICSettingBase.SETTING_FILE){ - return ((ICFileDescription)rcDes).getLanguageSetting(); + private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName) { + if (rcDes.getType() == ICSettingBase.SETTING_FILE) { + return ((ICFileDescription) rcDes).getLanguageSetting(); } - return ((ICFolderDescription)rcDes).getLanguageSettingForFile(fileName); + return ((ICFolderDescription) rcDes).getLanguageSettingForFile(fileName); } - private List generateCElementDeltasFromLanguageDelta(ICElement el, ICDescriptionDelta delta, List list){ - if(delta == null) + private List generateCElementDeltasFromLanguageDelta(ICElement el, ICDescriptionDelta delta, + List list) { + if (delta == null) return list; int flags = 0; flags |= calculateEntriesFlags(delta.getAddedEntriesKinds(), true); flags |= calculateEntriesFlags(delta.getRemovedEntriesKinds(), false); flags |= calculateEntriesFlags(delta.getReorderedEntriesKinds(), true); - if(flags != 0){ + if (flags != 0) { CElementDelta cElDelta = new CElementDelta(el.getCModel()); cElDelta.changed(el, flags); list.add(cElDelta); @@ -2136,12 +2243,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return list; } - private int calculateEntriesFlags(int languageDeltaKinds, boolean added){ + private int calculateEntriesFlags(int languageDeltaKinds, boolean added) { int flags = 0; int kindsArray[] = kindsToArray(languageDeltaKinds); for (int element : kindsArray) { - switch(element){ + switch (element) { case ICSettingEntry.INCLUDE_PATH: flags |= ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE; break; @@ -2167,19 +2274,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return flags; } - int[] kindsToArray(int kinds){ + int[] kindsToArray(int kinds) { int allKinds[] = KindBasedStore.getLanguageEntryKinds(); int kindsArray[] = new int[allKinds.length]; int num = 0; for (int kind : allKinds) { - if((kind & kinds) != 0){ + if ((kind & kinds) != 0) { kindsArray[num++] = kind; } } - if(num < allKinds.length){ + if (num < allKinds.length) { int tmp[] = new int[num]; - if(num > 0) + if (num > 0) System.arraycopy(kindsArray, 0, tmp, 0, num); kindsArray = tmp; } @@ -2205,7 +2312,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - public void notifyListeners(CProjectDescriptionEvent event){ + public void notifyListeners(CProjectDescriptionEvent event) { int eventType = event.getEventType(); for (ListenerDescriptor listener : fListeners) { if (listener.handlesEvent(eventType)) @@ -2213,14 +2320,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - void checkRemovedConfigurations(ICDescriptionDelta delta){ - if(delta == null) + void checkRemovedConfigurations(ICDescriptionDelta delta) { + if (delta == null) return; ICDescriptionDelta cfgDeltas[] = delta.getChildren(); for (ICDescriptionDelta cfgDelta : cfgDeltas) { - if(cfgDelta.getDeltaKind() == ICDescriptionDelta.REMOVED){ - CConfigurationDescriptionCache des = (CConfigurationDescriptionCache)cfgDelta.getOldSetting(); + if (cfgDelta.getDeltaKind() == ICDescriptionDelta.REMOVED) { + CConfigurationDescriptionCache des = (CConfigurationDescriptionCache) cfgDelta.getOldSetting(); CConfigurationData data = des.getConfigurationData(); try { removeData(des, data, null); @@ -2235,26 +2342,27 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return getPreferenceConfiguration(buildSystemId, true); } - private void runContextOperations(SettingsContext context, IProgressMonitor monitor){ + private void runContextOperations(SettingsContext context, IProgressMonitor monitor) { IWorkspaceRunnable toRun = context.createOperationRunnable(); - if(toRun != null){ + if (toRun != null) { runWspModification(toRun, monitor); - } else if (monitor != null){ + } else if (monitor != null) { monitor.done(); } } @Override - public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) throws CoreException { + public ICConfigurationDescription getPreferenceConfiguration(String buildSystemId, boolean write) + throws CoreException { ICConfigurationDescription des = getLoaddedPreference(buildSystemId); - if(des == null){ + if (des == null) { try { des = loadPreference(buildSystemId); } catch (CoreException e) { - // CCorePlugin.log(e); + // CCorePlugin.log(e); } - if(des == null){ + if (des == null) { try { des = createNewPreference(buildSystemId); } catch (CoreException e) { @@ -2262,11 +2370,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } - setLoaddedPreference(buildSystemId, (CConfigurationDescriptionCache)des); + setLoaddedPreference(buildSystemId, (CConfigurationDescriptionCache) des); } - if(des != null && write){ + if (des != null && write) { try { - des = createWritablePreference((CConfigurationDescriptionCache)des); + des = createWritablePreference((CConfigurationDescriptionCache) des); } catch (CoreException e) { CCorePlugin.log(e); } @@ -2275,8 +2383,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } @Override - public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException{ - if(!needSavePreference(buildSystemId, des)) + public void setPreferenceConfiguration(String buildSystemId, ICConfigurationDescription des) throws CoreException { + if (!needSavePreference(buildSystemId, des)) return; CConfigurationDescriptionCache cache = createPreferenceCache(des); @@ -2286,12 +2394,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { setLoaddedPreference(buildSystemId, cache); } - private void savePreferenceConfiguration(String buildStystemId, CConfigurationDescriptionCache cache) throws CoreException{ + private void savePreferenceConfiguration(String buildStystemId, CConfigurationDescriptionCache cache) + throws CoreException { ICStorageElement el = cache.getSpecSettings().getRootStorageElement(); saveBuildSystemConfigPreferenceStorage(buildStystemId, el); } - private void saveBuildSystemConfigPreferenceStorage(String buildSystemId, ICStorageElement el) throws CoreException{ + private void saveBuildSystemConfigPreferenceStorage(String buildSystemId, ICStorageElement el) + throws CoreException { ICStorageElement cur = getBuildSystemConfigPreferenceStorage(buildSystemId); ICStorageElement parent = cur.getParent(); parent.removeChild(cur); @@ -2299,8 +2409,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { savePreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, parent); } - private boolean needSavePreference(String buildSystemId, ICConfigurationDescription des){ - if(des.isModified() + private boolean needSavePreference(String buildSystemId, ICConfigurationDescription des) { + if (des.isModified() || !des.isPreferenceConfiguration() || !des.getBuildSystemId().equals(buildSystemId)) return true; @@ -2308,16 +2418,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return false; } - private ICConfigurationDescription createWritablePreference(CConfigurationDescriptionCache cache) throws CoreException{ + private ICConfigurationDescription createWritablePreference(CConfigurationDescriptionCache cache) + throws CoreException { return new CConfigurationDescription(cache, fPrefUpdater); } - private CConfigurationDescriptionCache createPreferenceCache(ICConfigurationDescription des) throws CoreException{ - IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)des; + private CConfigurationDescriptionCache createPreferenceCache(ICConfigurationDescription des) throws CoreException { + IInternalCCfgInfo cfgDes = (IInternalCCfgInfo) des; CConfigurationData baseData = cfgDes.getConfigurationData(false); CConfigurationDescriptionCache baseCache = null; - if(baseData instanceof CConfigurationDescriptionCache){ - baseCache = (CConfigurationDescriptionCache)baseData; + if (baseData instanceof CConfigurationDescriptionCache) { + baseCache = (CConfigurationDescriptionCache) baseData; baseData = baseCache.getConfigurationData(); } CConfigurationSpecSettings settings = cfgDes.getSpecSettings(); @@ -2326,7 +2437,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { rootParent.removeChild(rootEl); ICStorageElement baseRootEl = settings.getRootStorageElement(); rootEl = rootParent.importChild(baseRootEl); - CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, baseCache, cfgDes.getSpecSettings(), null, rootEl); + CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(des, baseData, baseCache, + cfgDes.getSpecSettings(), null, rootEl); SettingsContext context = new SettingsContext(null); cache.applyData(context); cache.doneInitialization(); @@ -2338,40 +2450,42 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { ICStorageElement cfgEl = getBuildSystemConfigPreferenceStorage(buildSystemId, true, false); String id = PREFERENCE_CFG_ID_PREFIX + buildSystemId; - CConfigurationDescription des = new CConfigurationDescription(id, PREFERENCE_CFG_NAME, buildSystemId, cfgEl, fPrefUpdater); + CConfigurationDescription des = new CConfigurationDescription(id, PREFERENCE_CFG_NAME, buildSystemId, cfgEl, + fPrefUpdater); return createPreferenceCache(des); } -// private XmlStorage createBuildSystemCfgPrefStore() throws CoreException{ -// ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, true, false); -// -// XmlStorage store = new XmlStorage((InternalXmlStorageElement)el); -// -// return store; -// } -// -// ICSettingsStorage getBuildSystemCfgPrefStore() throws CoreException{ -// if(fPrefCfgStorage == null){ -// fPrefCfgStorage = createBuildSystemCfgPrefStore(); -// } -// -// return copyStorage(fPrefCfgStorage, false); -// } + // private XmlStorage createBuildSystemCfgPrefStore() throws CoreException{ + // ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, true, false); + // + // XmlStorage store = new XmlStorage((InternalXmlStorageElement)el); + // + // return store; + // } + // + // ICSettingsStorage getBuildSystemCfgPrefStore() throws CoreException{ + // if(fPrefCfgStorage == null){ + // fPrefCfgStorage = createBuildSystemCfgPrefStore(); + // } + // + // return copyStorage(fPrefCfgStorage, false); + // } - ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId) throws CoreException{ + ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId) throws CoreException { return getBuildSystemConfigPreferenceStorage(buildSystemId, true, false); } - private ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId, boolean createIfNotDound, boolean readOnly) throws CoreException{ + private ICStorageElement getBuildSystemConfigPreferenceStorage(String buildSystemId, boolean createIfNotDound, + boolean readOnly) throws CoreException { ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotDound, readOnly); ICStorageElement cfgEl = null; - if(el != null){ + if (el != null) { ICStorageElement children[] = el.getChildren(); for (ICStorageElement child : children) { - if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){ - if(buildSystemId.equals(child.getAttribute(ID))){ + if (PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())) { + if (buildSystemId.equals(child.getAttribute(ID))) { cfgEl = child; break; } @@ -2379,7 +2493,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } - if(cfgEl == null){ + if (cfgEl == null) { cfgEl = el.createChild(PREFERENCE_BUILD_SYSTEM_ELEMENT); cfgEl.setAttribute(ID, buildSystemId); } @@ -2389,14 +2503,14 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return cfgEl; } - private ICConfigurationDescription loadPreference(String buildSystemId) throws CoreException{ + private ICConfigurationDescription loadPreference(String buildSystemId) throws CoreException { ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, false, false); ICStorageElement children[] = el.getChildren(); ICStorageElement cfgEl = null; for (ICStorageElement child : children) { - if(PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())){ - if(buildSystemId.equals(child.getAttribute(ID))){ + if (PREFERENCE_BUILD_SYSTEM_ELEMENT.equals(child.getName())) { + if (buildSystemId.equals(child.getAttribute(ID))) { cfgEl = child; break; } @@ -2409,21 +2523,23 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return cache; } - public ICStorageElement getPreferenceStorage(String prefKey, String storageId, boolean createIfNotDound, boolean readOnly) throws CoreException{ + public ICStorageElement getPreferenceStorage(String prefKey, String storageId, boolean createIfNotDound, + boolean readOnly) throws CoreException { XmlStorage store = getPreferenceStore(prefKey, createIfNotDound, readOnly); return store.getStorage(storageId, createIfNotDound); } - private XmlStorage getPreferenceStore(String prefKey, boolean createIfNotDound, boolean readOnly) throws CoreException{ + private XmlStorage getPreferenceStore(String prefKey, boolean createIfNotDound, boolean readOnly) + throws CoreException { ICStorageElement el = createPreferenceStorage(prefKey, createIfNotDound, readOnly); - XmlStorage store = new XmlStorage((InternalXmlStorageElement)el); + XmlStorage store = new XmlStorage((InternalXmlStorageElement) el); return store; } - public void savePreferenceStorage(String prefKey, String storageId, ICStorageElement el) throws CoreException{ + public void savePreferenceStorage(String prefKey, String storageId, ICStorageElement el) throws CoreException { XmlStorage store = getPreferenceStore(prefKey, true, false); store.importStorage(storageId, el); @@ -2431,124 +2547,127 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { serializePreference(prefKey, rootEl); } - private CConfigurationDescriptionCache getLoaddedPreference(String buildSystemId){ + private CConfigurationDescriptionCache getLoaddedPreference(String buildSystemId) { return fPreferenceMap.get(buildSystemId); } - private void setLoaddedPreference(String buildSystemId, CConfigurationDescriptionCache des){ + private void setLoaddedPreference(String buildSystemId, CConfigurationDescriptionCache des) { fPreferenceMap.put(buildSystemId, des); } - public CConfigBasedDescriptorManager getDescriptorManager(){ + public CConfigBasedDescriptorManager getDescriptorManager() { return fDescriptorManager; } - public CConfigurationData createDefaultConfigData(IProject project, CDataFactory factory) throws CoreException{ + public CConfigurationData createDefaultConfigData(IProject project, CDataFactory factory) throws CoreException { return createDefaultConfigData(project, CDataUtil.genId(DEFAULT_CFG_ID_PREFIX), DEFAULT_CFG_NAME, factory); } - public CConfigurationData createDefaultConfigData(IProject project, String id, String name, CDataFactory factory) throws CoreException{ - if(factory == null) + public CConfigurationData createDefaultConfigData(IProject project, String id, String name, CDataFactory factory) + throws CoreException { + if (factory == null) factory = new CDataFactory(); CConfigurationData data = CDataUtil.createEmptyData(id, name, factory, true); -// CDataUtil. -//// data.initEmptyData(); -// -// CDataUtil.adjustConfig(data, factory); + // CDataUtil. + //// data.initEmptyData(); + // + // CDataUtil.adjustConfig(data, factory); factory.setModified(data, false); return data; } - public boolean isNewStyleIndexCfg(IProject project){ + public boolean isNewStyleIndexCfg(IProject project) { ICProjectDescription des = getProjectDescription(project, false); - if(des != null) + if (des != null) return isNewStyleIndexCfg(des); return false; } - public boolean isNewStyleIndexCfg(ICProjectDescription des){ + public boolean isNewStyleIndexCfg(ICProjectDescription des) { ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration(); - if(cfgDes != null) + if (cfgDes != null) return isNewStyleCfg(cfgDes); return false; } @Override - public boolean isNewStyleProject(IProject project){ + public boolean isNewStyleProject(IProject project) { return isNewStyleProject(getProjectDescription(project, false)); } @Override - public boolean isNewStyleProject(ICProjectDescription des){ - if(des == null) + public boolean isNewStyleProject(ICProjectDescription des) { + if (des == null) return false; return isNewStyleIndexCfg(des); } - public boolean isNewStyleCfg(ICConfigurationDescription cfgDes){ - if(cfgDes == null) + public boolean isNewStyleCfg(ICConfigurationDescription cfgDes) { + if (cfgDes == null) return false; - CConfigurationData data = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false); - if(data instanceof CConfigurationDescriptionCache){ - data = ((CConfigurationDescriptionCache)data).getConfigurationData(); + CConfigurationData data = ((IInternalCCfgInfo) cfgDes).getConfigurationData(false); + if (data instanceof CConfigurationDescriptionCache) { + data = ((CConfigurationDescriptionCache) data).getConfigurationData(); } return data != null && !PathEntryConfigurationDataProvider.isPathEntryData(data); } -// public String[] getContentTypeFileSpecs (IProject project, IContentType type) { -// String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); -// IContentTypeSettings settings = null; -// if (project != null) { -// IScopeContext projectScope = new ProjectScope(project); -// try { -// settings = type.getSettings(projectScope); -// } catch (Exception e) {} -// if (settings != null) { -// String[] specs = settings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); -// if (specs.length > 0) { -// int total = globalSpecs.length + specs.length; -// String[] projSpecs = new String[total]; -// int i=0; -// for (int j=0; j 0) { + // int total = globalSpecs.length + specs.length; + // String[] projSpecs = new String[total]; + // int i=0; + // for (int j=0; j, CLanguageData> createExtSetToLDataMap(IProject project, CLanguageData[] lDatas){ + static private HashMap, CLanguageData> createExtSetToLDataMap(IProject project, + CLanguageData[] lDatas) { HashMap, CLanguageData> map = new HashMap, CLanguageData>(); for (CLanguageData lData : lDatas) { @@ -2560,22 +2679,22 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return map; } - static boolean removeNonCustomSettings(IProject project, CConfigurationData data){ + static boolean removeNonCustomSettings(IProject project, CConfigurationData data) { PathSettingsContainer cont = CDataUtil.createRcDataHolder(data); PathSettingsContainer[] children = cont.getChildren(false); PathSettingsContainer parent; CResourceData childRcData; boolean modified = false; for (PathSettingsContainer child : children) { - childRcData = (CResourceData)child.getValue(); - if(childRcData.getType() == ICSettingBase.SETTING_FOLDER){ + childRcData = (CResourceData) child.getValue(); + if (childRcData.getType() == ICSettingBase.SETTING_FOLDER) { CResourceData parentRcData = null; - for(parent = child.getParentContainer(); - (parentRcData = (CResourceData)parent.getValue()).getType() != ICSettingBase.SETTING_FOLDER; - parent = parent.getParentContainer()) { + for (parent = child.getParentContainer(); (parentRcData = (CResourceData) parent.getValue()) + .getType() != ICSettingBase.SETTING_FOLDER; parent = parent.getParentContainer()) { // no body, this loop is to find the parent } - if(!settingsCustomized(project, (CFolderData)parentRcData, (CFolderData)childRcData, parent.isRoot())){ + if (!settingsCustomized(project, (CFolderData) parentRcData, (CFolderData) childRcData, + parent.isRoot())) { try { data.removeResourceData(childRcData); child.remove(); @@ -2586,7 +2705,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { } } else { parent = child.getParentContainer(); - if(!settingsCustomized(project, (CResourceData)parent.getValue(), (CFileData)childRcData)){ + if (!settingsCustomized(project, (CResourceData) parent.getValue(), (CFileData) childRcData)) { try { data.removeResourceData(childRcData); child.remove(); @@ -2601,44 +2720,45 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return modified; } - static private boolean settingsCustomized(IProject project, CFolderData parent, CFolderData child, boolean isParentRoot){ - if(baseSettingsCustomized(parent, child)) + static private boolean settingsCustomized(IProject project, CFolderData parent, CFolderData child, + boolean isParentRoot) { + if (baseSettingsCustomized(parent, child)) return true; CLanguageData[] childLDatas = child.getLanguageDatas(); CLanguageData[] parentLDatas = parent.getLanguageDatas(); // Note that parent-root can define more languages than regular folder where tools are filtered - if(!isParentRoot && childLDatas.length != parentLDatas.length) + if (!isParentRoot && childLDatas.length != parentLDatas.length) return true; HashMap, CLanguageData> parentMap = createExtSetToLDataMap(project, parentLDatas); HashMap, CLanguageData> childMap = createExtSetToLDataMap(project, childLDatas); for (Map.Entry, CLanguageData> childEntry : childMap.entrySet()) { CLanguageData parentLData = parentMap.get(childEntry.getKey()); - if(parentLData == null) + if (parentLData == null) return true; CLanguageData childLData = childEntry.getValue(); - if(!langDatasEqual(parentLData, childLData)) + if (!langDatasEqual(parentLData, childLData)) return true; } return false; } - static private boolean settingsCustomized(IProject project, CResourceData parent, CFileData child){ - if(baseSettingsCustomized(parent, child)) + static private boolean settingsCustomized(IProject project, CResourceData parent, CFileData child) { + if (baseSettingsCustomized(parent, child)) return true; CLanguageData lData = child.getLanguageData(); - if(parent.getType() == ICSettingBase.SETTING_FOLDER){ - CFolderData foParent = (CFolderData)parent; + if (parent.getType() == ICSettingBase.SETTING_FOLDER) { + CFolderData foParent = (CFolderData) parent; IPath childPath = child.getPath(); String fileName = childPath.lastSegment(); - if(PatternNameMap.isPatternName(fileName)) + if (PatternNameMap.isPatternName(fileName)) return true; CLanguageData parentLangData = CDataUtil.findLanguagDataForFile(fileName, project, foParent); @@ -2646,55 +2766,54 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { return !langDatasEqual(lData, parentLangData); } - CFileData fiParent = (CFileData)parent; + CFileData fiParent = (CFileData) parent; CLanguageData parentLangData = fiParent.getLanguageData(); return !langDatasEqual(lData, parentLangData); } - static boolean langDatasEqual(CLanguageData lData1, CLanguageData lData2){ - if(lData1 == null) + static boolean langDatasEqual(CLanguageData lData1, CLanguageData lData2) { + if (lData1 == null) return lData2 == null; - if(lData2 == null) + if (lData2 == null) return false; int kinds[] = KindBasedStore.getLanguageEntryKinds(); for (int kind : kinds) { ICLanguageSettingEntry entries1[] = lData1.getEntries(kind); ICLanguageSettingEntry entries2[] = lData2.getEntries(kind); - if(!Arrays.equals(entries1, entries2)) + if (!Arrays.equals(entries1, entries2)) return false; } return true; } - private static boolean baseSettingsCustomized(CResourceData parent, CResourceData child){ -// if(parent.isExcluded() != child.isExcluded()) -// return true; + private static boolean baseSettingsCustomized(CResourceData parent, CResourceData child) { + // if(parent.isExcluded() != child.isExcluded()) + // return true; - if(child.hasCustomSettings()) + if (child.hasCustomSettings()) return true; return false; } - @Override public ICProjectDescriptionWorkspacePreferences getProjectDescriptionWorkspacePreferences( boolean write) { - if(fPreferences == null){ + if (fPreferences == null) { try { fPreferences = loadPreferences(); } catch (CoreException e) { } - if(fPreferences == null) - fPreferences = new CProjectDescriptionWorkspacePreferences((ICStorageElement)null, null, true); + if (fPreferences == null) + fPreferences = new CProjectDescriptionWorkspacePreferences((ICStorageElement) null, null, true); } CProjectDescriptionWorkspacePreferences prefs = fPreferences; - if(write) + if (write) prefs = new CProjectDescriptionWorkspacePreferences(prefs, false); return prefs; @@ -2702,26 +2821,26 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { @Override public boolean setProjectDescriptionWorkspacePreferences(ICProjectDescriptionWorkspacePreferences prefs, - boolean updateProjects, - IProgressMonitor monitor) { - if(monitor == null) + boolean updateProjects, + IProgressMonitor monitor) { + if (monitor == null) monitor = new NullProgressMonitor(); boolean changed = false; ICProjectDescriptionWorkspacePreferences oldPrefs = getProjectDescriptionWorkspacePreferences(false); try { do { - if(oldPrefs != prefs){ - if(prefs.getConfigurationRelations() != oldPrefs.getConfigurationRelations()){ + if (oldPrefs != prefs) { + if (prefs.getConfigurationRelations() != oldPrefs.getConfigurationRelations()) { changed = true; break; } } - } while(false); + } while (false); - if(changed){ + if (changed) { CProjectDescriptionWorkspacePreferences basePrefs; - if(prefs instanceof CProjectDescriptionWorkspacePreferences) - basePrefs = (CProjectDescriptionWorkspacePreferences)prefs; + if (prefs instanceof CProjectDescriptionWorkspacePreferences) + basePrefs = (CProjectDescriptionWorkspacePreferences) prefs; else throw new IllegalArgumentException(); @@ -2729,7 +2848,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { storePreferences(fPreferences); - if(updateProjects) + if (updateProjects) updateProjectDescriptions(null, monitor); } } catch (CoreException e) { @@ -2747,7 +2866,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { saveCProjectDescriptionPreferencesElement(el); } - private void saveCProjectDescriptionPreferencesElement(ICStorageElement el) throws CoreException{ + private void saveCProjectDescriptionPreferencesElement(ICStorageElement el) throws CoreException { ICStorageElement cur = getCProjectDescriptionPreferencesElement(true, false); ICStorageElement parent = cur.getParent(); parent.removeChild(cur); @@ -2755,33 +2874,34 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager { savePreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, parent); } - private CProjectDescriptionWorkspacePreferences loadPreferences() throws CoreException{ + private CProjectDescriptionWorkspacePreferences loadPreferences() throws CoreException { ICStorageElement el = getCProjectDescriptionPreferencesElement(false, true); return new CProjectDescriptionWorkspacePreferences(el, null, true); } - private ICStorageElement getCProjectDescriptionPreferencesElement(boolean createIfNotFound, boolean readOnly) throws CoreException{ + private ICStorageElement getCProjectDescriptionPreferencesElement(boolean createIfNotFound, boolean readOnly) + throws CoreException { ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotFound, readOnly); ICStorageElement[] children = el.getChildren(); for (ICStorageElement child : children) { - if(PREFERENCES_ELEMENT.equals(child.getName())) + if (PREFERENCES_ELEMENT.equals(child.getName())) return child; } - if(createIfNotFound) + if (createIfNotFound) return el.createChild(PREFERENCES_ELEMENT); throw ExceptionFactory.createCoreException(SettingsModelMessages.getString("CProjectDescriptionManager.14")); //$NON-NLS-1$ } @Override - public void updateExternalSettingsProviders(String[] ids, IProgressMonitor monitor){ + public void updateExternalSettingsProviders(String[] ids, IProgressMonitor monitor) { ExtensionContainerFactory.updateReferencedProviderIds(ids, monitor); } - boolean isEmptyCreatingDescriptionAllowed(){ + boolean isEmptyCreatingDescriptionAllowed() { return fAllowEmptyCreatingDescription; } - void setEmptyCreatingDescriptionAllowed(boolean allow){ + void setEmptyCreatingDescriptionAllowed(boolean allow) { fAllowEmptyCreatingDescription = allow; } diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index d5e0020806e..c65daa4d019 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -856,5 +856,22 @@ ordering="first"> + + + + + + + + + + diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 8f93d73cbea..9d679229b67 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -92,8 +92,8 @@ import org.osgi.framework.BundleContext; import com.ibm.icu.text.MessageFormat; /** - * CCorePlugin is the life-cycle owner of the core plug-in, and starting point - * for access to many core APIs. + * CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many + * core APIs. * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -103,8 +103,7 @@ public class CCorePlugin extends Plugin { public static final int STATUS_CDTPROJECT_MISMATCH = 2; public static final int CDT_PROJECT_NATURE_ID_MISMATCH = 3; /** - * Status code for core exception that is thrown if a pdom grew larger than - * the supported limit. + * Status code for core exception that is thrown if a pdom grew larger than the supported limit. * * @since 5.2 */ @@ -276,8 +275,7 @@ public class CCorePlugin extends Plugin { } /** - * Returns the shared working copies currently registered for the default - * buffer factory. + * Returns the shared working copies currently registered for the default buffer factory. * * @since 5.1 */ @@ -382,25 +380,21 @@ public class CCorePlugin extends Plugin { pdomManager = new PDOMManager(); final Job post2 = pdomManager.startup(); - // bug 186755, when started after the platform has been started the job - // manager - // is no longer suspended. So we have to start a job at the very end to - // make - // sure we don't trigger a concurrent plug-in activation from within the - // job. + // bug 186755, when started after the platform has been started the job manager + // is no longer suspended. So we have to start a job at the very end to make + // sure we don't trigger a concurrent plug-in activation from within the job. post1.schedule(); post2.schedule(); } /** - * TODO: Add all options here Returns a table of all known configurable - * options with their default values. These options allow to configure the - * behavior of the underlying components. The client may safely use the - * result as a template that they can modify and then pass to + * TODO: Add all options here Returns a table of all known configurable options with their + * default values. These options allow to configure the behavior of the underlying components. + * The client may safely use the result as a template that they can modify and then pass to * setOptions. * - * Helper constants have been defined on CCorePlugin for each of the option - * ID and their possible constant values. + * Helper constants have been defined on CCorePlugin for each of the option ID and their + * possible constant values. * * Note: more options might be added in further releases. * @@ -415,9 +409,8 @@ public class CCorePlugin extends Plugin { * - default: * * - * @return a mutable map containing the default settings of all known - * options (key type: String; value type: - * String) + * @return a mutable map containing the default settings of all known options (key type: + * String; value type: String) * @see #setOptions */ public static HashMap getDefaultOptions() { @@ -446,11 +439,10 @@ public class CCorePlugin extends Plugin { /** * Helper method for returning one option value only. Equivalent to - * (String)CCorePlugin.getOptions().get(optionName) Note that - * it may answer null if this option does not exist. + * (String)CCorePlugin.getOptions().get(optionName) Note that it may answer + * null if this option does not exist. *

- * For a complete description of the configurable options, see - * getDefaultOptions. + * For a complete description of the configurable options, see getDefaultOptions. *

* * @param optionName @@ -471,16 +463,14 @@ public class CCorePlugin extends Plugin { } /** - * Returns the table of the current options. Initially, all options have - * their default values, and this method returns a table that includes all - * known options. + * Returns the table of the current options. Initially, all options have their default values, + * and this method returns a table that includes all known options. *

- * For a complete description of the configurable options, see - * getDefaultOptions. + * For a complete description of the configurable options, see getDefaultOptions. *

* - * @return table of current settings of all options (key type: - * String; value type: String) + * @return table of current settings of all options (key type: String; value type: + * String) * @see CCorePlugin#getDefaultOptions */ public static HashMap getOptions() { @@ -512,18 +502,16 @@ public class CCorePlugin extends Plugin { } /** - * Sets the current table of options. All and only the options explicitly - * included in the given table are remembered; all previous option settings - * are forgotten, including ones not explicitly mentioned. + * Sets the current table of options. All and only the options explicitly included in the given + * table are remembered; all previous option settings are forgotten, including ones not + * explicitly mentioned. *

- * For a complete description of the configurable options, see - * getDefaultOptions. + * For a complete description of the configurable options, see getDefaultOptions. *

* * @param newOptions - * the new options (key type: String; value type: - * String), or null to reset all - * options to their default values + * the new options (key type: String; value type: String), + * or null to reset all options to their default values * @see CCorePlugin#getDefaultOptions */ public static void setOptions(HashMap newOptions) { @@ -550,24 +538,22 @@ public class CCorePlugin extends Plugin { /** * Create CDT console adapter for build console defined as an extension. See - * {@code org.eclipse.cdt.core.CBuildConsole} extension point. If the - * console class is instance of {@link ICConsole} it is initialized with - * context id, name and icon to be shown in the list of consoles in the - * Console view. + * {@code org.eclipse.cdt.core.CBuildConsole} extension point. If the console class is instance + * of {@link ICConsole} it is initialized with context id, name and icon to be shown in the list + * of consoles in the Console view. * * @param extConsoleId * - console id defined in the extension point. * @param contextId - * - context menu id in the Console view. A caller needs to - * define a distinct one for own use. + * - context menu id in the Console view. A caller needs to define a distinct one for + * own use. * @param name - * - name of console to appear in the list of consoles in context - * menu in the Console view. + * - name of console to appear in the list of consoles in context menu in the Console + * view. * @param iconUrl - * - a {@link URL} of the icon for the context menu of the - * Console view. The url is expected to point to an image in - * eclipse OSGi bundle. Here is an example how to retrieve URL: - *
+ * - a {@link URL} of the icon for the context menu of the Console view. The url is + * expected to point to an image in eclipse OSGi bundle. Here is an example how to + * retrieve URL:
* * URL iconUrl = CUIPlugin.getDefault().getBundle().getEntry("icons/obj16/flask.png"); * @@ -604,13 +590,11 @@ public class CCorePlugin extends Plugin { } /** - * Create CDT console adapter. The adapter serves as a bridge between core - * plugin and UI console API in a way that a user can create a UI console - * from plugins having no dependencies to UI. + * Create CDT console adapter. The adapter serves as a bridge between core plugin and UI console + * API in a way that a user can create a UI console from plugins having no dependencies to UI. * * @param id - * - id of the console specified in extension point to - * instantiate console adapter. + * - id of the console specified in extension point to instantiate console adapter. * @return CDT console adapter. */ public IConsole getConsole(String id) { @@ -619,25 +603,23 @@ public class CCorePlugin extends Plugin { /** * Create CDT console adapter for build console. A new instance of class - * {@code org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole} is created - * and initialized with the parameters. + * {@code org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole} is created and initialized + * with the parameters. * * @param contextId - * - context menu id in the Console view. A caller needs to - * define a distinct one for own use. + * - context menu id in the Console view. A caller needs to define a distinct one for + * own use. * @param name - * - name of console to appear in the list of consoles in context - * menu in the Console view. + * - name of console to appear in the list of consoles in context menu in the Console + * view. * @param iconUrl - * - a {@link URL} of the icon for the context menu of the - * Console view. The url is expected to point to an image in - * eclipse OSGi bundle. Here is an example how to retrieve URL: - *
+ * - a {@link URL} of the icon for the context menu of the Console view. The url is + * expected to point to an image in eclipse OSGi bundle. Here is an example how to + * retrieve URL:
* * URL iconUrl = CUIPlugin.getDefault().getBundle().getResource("icons/obj16/flask.png"); *
- * {@code iconUrl} can be null, in that case the default - * image is used. See + * {@code iconUrl} can be null, in that case the default image is used. See * {@code org.eclipse.cdt.internal.ui.buildconsole.BuildConsole(IBuildConsoleManager, String, String, URL)} * * @return CDT console adapter. @@ -657,8 +639,7 @@ public class CCorePlugin extends Plugin { } /** - * @deprecated Use {@link #getDefaultBinaryParserExtensions(IProject)} - * instead. + * @deprecated Use {@link #getDefaultBinaryParserExtensions(IProject)} instead. */ @Deprecated public ICExtensionReference[] getBinaryParserExtensions(IProject project) throws CoreException { @@ -679,8 +660,7 @@ public class CCorePlugin extends Plugin { } /** - * Returns the binary parser extensions for the default settings - * configuration. + * Returns the binary parser extensions for the default settings configuration. * * @since 5.2 */ @@ -794,14 +774,14 @@ public class CCorePlugin extends Plugin { * Please use {@link #getProjectDescription(IProject, boolean)} to fetch the * ICProjectDescription for the project. And use * {@link ICProjectDescription#getConfigurations()} to get an array of - * ICConfigurationDescriptions, which have similar API to ICDescriptor, - * allowing you to store settings and configure extensions at the - * Configuration level rather than at the project level. + * ICConfigurationDescriptions, which have similar API to ICDescriptor, allowing you to store + * settings and configure extensions at the Configuration level rather than at the project + * level. * * @param project * @param create - * @return ICDescriptor or null if create is false and - * no .cdtproject file exists on disk. + * @return ICDescriptor or null if create is false and no .cdtproject file + * exists on disk. * @throws CoreException * @deprecated */ @@ -823,15 +803,13 @@ public class CCorePlugin extends Plugin { } /** - * @deprecated Settings should be set per ICConfigurationDescription rather - * than global to the project. Please use - * {@link #getProjectDescription(IProject, boolean)} to fetch + * @deprecated Settings should be set per ICConfigurationDescription rather than global to the + * project. Please use {@link #getProjectDescription(IProject, boolean)} to fetch * the ICProjectDescription for the project. And use - * {@link ICProjectDescription#getConfigurations()} to get an - * array of ICConfigurationDescriptions, which have similar API - * to ICDescriptor, allowing you to store settings and configure - * extensions at the Configuration level rather than at the - * project level. + * {@link ICProjectDescription#getConfigurations()} to get an array of + * ICConfigurationDescriptions, which have similar API to ICDescriptor, allowing you + * to store settings and configure extensions at the Configuration level rather than + * at the project level. */ @Deprecated public ICDescriptorManager getCDescriptorManager() { @@ -857,7 +835,7 @@ public class CCorePlugin extends Plugin { */ public IProject createCProject(final IProjectDescription description, final IProject projectHandle, IProgressMonitor monitor, final String projectID) - throws CoreException, OperationCanceledException { + throws CoreException, OperationCanceledException { getWorkspace().run(new IWorkspaceRunnable() { @Override @@ -954,9 +932,8 @@ public class CCorePlugin extends Plugin { } /** - * Method convertProjectFromCtoCC converts a C Project to a C++ Project The - * newProject MUST, not be null, already have a C Nature && must NOT already - * have a C++ Nature + * Method convertProjectFromCtoCC converts a C Project to a C++ Project The newProject MUST, not + * be null, already have a C Nature && must NOT already have a C++ Nature * * @param projectHandle * @param monitor @@ -972,9 +949,8 @@ public class CCorePlugin extends Plugin { } /** - * Method to convert a project to a C nature All checks should have been - * done externally (as in the Conversion Wizards). This method blindly does - * the conversion. + * Method to convert a project to a C nature All checks should have been done externally (as in + * the Conversion Wizards). This method blindly does the conversion. */ public void convertProjectToC(IProject projectHandle, IProgressMonitor monitor, String projectID) throws CoreException { @@ -1057,8 +1033,7 @@ public class CCorePlugin extends Plugin { } /** - * @deprecated since CDT 6.1. Use - * {@link ErrorParserManager#getErrorParserAvailableIds()} + * @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserAvailableIds()} * instead * @return array of error parsers ids */ @@ -1070,8 +1045,7 @@ public class CCorePlugin extends Plugin { } /** - * @deprecated since CDT 6.1. Use - * {@link ErrorParserManager#getErrorParserCopy(String)} instead + * @deprecated since CDT 6.1. Use {@link ErrorParserManager#getErrorParserCopy(String)} instead * @param id * - id of error parser * @return array of error parsers @@ -1123,9 +1097,8 @@ public class CCorePlugin extends Plugin { } /** - * Clears cached scanner info provider for the given project so that the - * next call to {@link #getScannerInfoProvider(IProject)} would return an up - * to date scanner info provider. + * Clears cached scanner info provider for the given project so that the next call to + * {@link #getScannerInfoProvider(IProject)} would return an up to date scanner info provider. * * @noreference This method is not intended to be referenced by clients. */ @@ -1141,8 +1114,8 @@ public class CCorePlugin extends Plugin { } /** - * Find {@link IScannerInfoProvider} registered as extension via extension - * point org.eclipse.cdt.core.ScannerInfoProvider2. + * Find {@link IScannerInfoProvider} registered as extension via extension point + * org.eclipse.cdt.core.ScannerInfoProvider2. */ private IScannerInfoProvider getExtensionScannerInfoProvider2(IProject project) throws CoreException { IScannerInfoProvider provider = null; @@ -1182,13 +1155,11 @@ public class CCorePlugin extends Plugin { } /** - * Returns the content type for a filename. The method respects project - * specific content type definitions. The lookup prefers case- sensitive - * matches over the others. + * Returns the content type for a filename. The method respects project specific content type + * definitions. The lookup prefers case- sensitive matches over the others. * * @param project - * a project with possible project specific settings. Can be - * null + * a project with possible project specific settings. Can be null * @param filename * a filename to compute the content type for * @return the content type found or null @@ -1218,8 +1189,7 @@ public class CCorePlugin extends Plugin { private static final String DELTA = CCorePlugin.PLUGIN_ID + "/debug/deltaprocessor"; //$NON-NLS-1$ /** - * Configure the plug-in with respect to option settings defined in - * ".options" file + * Configure the plug-in with respect to option settings defined in ".options" file */ public void configurePluginDebugOptions() { if (CCorePlugin.getDefault().isDebugging()) { @@ -1257,8 +1227,7 @@ public class CCorePlugin extends Plugin { } /** - * @deprecated use {@link ITranslationUnit} or {@link ILanguage} to - * construct ASTs, instead. + * @deprecated use {@link ITranslationUnit} or {@link ILanguage} to construct ASTs, instead. */ @Deprecated public org.eclipse.cdt.core.dom.CDOM getDOM() { @@ -1288,8 +1257,7 @@ public class CCorePlugin extends Plugin { } /** - * Equivalent to - * createProjectDescription(IProject, boolean, false). + * Equivalent to createProjectDescription(IProject, boolean, false). * * @see #createProjectDescription(IProject, boolean, boolean) */ @@ -1304,23 +1272,19 @@ public class CCorePlugin extends Plugin { * @param project * project for which the project description is requested * @param loadIfExists - * if true the method first tries to load and return the project - * description from the settings file (.cproject), if false, the - * stored settings are ignored and the new (empty) project - * description is created + * if true the method first tries to load and return the project description from the + * settings file (.cproject), if false, the stored settings are ignored and the new + * (empty) project description is created * @param creating - * if true the created project description will be contain the - * true "isCdtProjectCreating" state.
- * NOTE: in case the project already contains the project - * description AND its "isCdtProjectCreating" is false the - * resulting description will be created with the false - * "isCdtProjectCreating" state. + * if true the created project description will be contain the true + * "isCdtProjectCreating" state.
+ * NOTE: in case the project already contains the project description AND its + * "isCdtProjectCreating" is false the resulting description will be created with the + * false "isCdtProjectCreating" state. * *
- * NOTE: changes made to the returned project description will - * not be applied until the - * {@link #setProjectDescription(IProject, ICProjectDescription)} - * is called. + * NOTE: changes made to the returned project description will not be applied until + * the {@link #setProjectDescription(IProject, ICProjectDescription)} is called. * @return {@link ICProjectDescription} * @throws CoreException */ @@ -1330,20 +1294,17 @@ public class CCorePlugin extends Plugin { } /** - * Returns the project description associated with this project or null if - * the project does not contain the CDT data associated with it. + * Returns the project description associated with this project or null if the project does not + * contain the CDT data associated with it. * - * This is a convenience method fully equivalent to - * getProjectDescription(project, true) see + * This is a convenience method fully equivalent to getProjectDescription(project, true) see * {@link #getProjectDescription(IProject, boolean)} for more detail. * * @param project - * @return a writable copy of the ICProjectDescription or null if the - * project does not contain the CDT data associated with it.
- * Note: changes to the project description will not be - * reflected/used by the core until the - * {@link #setProjectDescription(IProject, ICProjectDescription)} is - * called. + * @return a writable copy of the ICProjectDescription or null if the project does not contain + * the CDT data associated with it.
+ * Note: changes to the project description will not be reflected/used by the core until + * the {@link #setProjectDescription(IProject, ICProjectDescription)} is called. * * @see #getProjectDescription(IProject, boolean) */ @@ -1352,8 +1313,8 @@ public class CCorePlugin extends Plugin { } /** - * Called to save/apply the project description. The method should be called - * to apply changes made to the project description returned by the + * Called to save/apply the project description. The method should be called to apply changes + * made to the project description returned by the * {@link #getProjectDescription(IProject, boolean)} or * {@link #createProjectDescription(IProject, boolean)} * @@ -1374,40 +1335,37 @@ public class CCorePlugin extends Plugin { } /** - * Returns the project description associated with this project or null if - * the project does not contain the CDT data associated with it. + * Returns the project description associated with this project or null if the project does not + * contain the CDT data associated with it. * * @param project * project for which the description is requested * @param write - * if true, the writable description copy is returned. If false - * the cached read-only description is returned. + * if true, the writable description copy is returned. If false the cached read-only + * description is returned. * *
- * CDT core maintains the cached project description settings. If - * only read access is needed to description, then the read-only - * project description should be obtained. This description - * always operates with cached data and thus it is better to use - * it for performance reasons. All set* calls to the read-only - * description result in the {@link WriteAccessException}. + * CDT core maintains the cached project description settings. If only read access is + * needed to description, then the read-only project description should be obtained. + * This description always operates with cached data and thus it is better to use it + * for performance reasons. All set* calls to the read-only description result in the + * {@link WriteAccessException}. * - * When the writable description is requested, the description - * copy is created. Changes to this description will not be - * reflected/used by the core and the Build System until the - * {@link #setProjectDescription(IProject, ICProjectDescription)} - * is called. + * When the writable description is requested, the description copy is created. + * Changes to this description will not be reflected/used by the core and the Build + * System until the {@link #setProjectDescription(IProject, ICProjectDescription)} is + * called. * - * Each getProjectDescription(project, true) returns a new copy - * of the project description. + * Each getProjectDescription(project, true) returns a new copy of the project + * description. * - * The writable description uses the cached data until the first - * set call after that the description communicates directly to - * the Build System i.e. the implementer of the - * org.eclipse.cdt.core.CConfigurationDataProvider extension This - * ensures the Core<->Build System settings integrity. + * The writable description uses the cached data until the first set call after that + * the description communicates directly to the Build System i.e. the implementer of + * the org.eclipse.cdt.core.CConfigurationDataProvider extension This ensures the + * Core<->Build System settings integrity. * - * @return {@link ICProjectDescription} or null if the project does not - * contain the CDT data associated with it. + * @return {@link ICProjectDescription} or null if the project does not contain the CDT data + * associated with it. */ public ICProjectDescription getProjectDescription(IProject project, boolean write) { return fNewCProjectDescriptionManager.getProjectDescription(project, write); @@ -1417,8 +1375,7 @@ public class CCorePlugin extends Plugin { * Forces the cached data of the specified projects to be re-calculated. * * @param projects - * if null, all projects within the workspace are - * updated + * if null, all projects within the workspace are updated * @param monitor * @throws CoreException */ @@ -1457,8 +1414,7 @@ public class CCorePlugin extends Plugin { // NON-API /** - * @noreference This constructor is not intended to be referenced by - * clients. + * @noreference This constructor is not intended to be referenced by clients. */ public CCorePlugin() { super(); @@ -1476,9 +1432,8 @@ public class CCorePlugin extends Plugin { * Prints a message in the log * * @param severity - * - desired severity of the message in the log, one of - * {@link IStatus#INFO}, {@link IStatus#WARNING} or - * {@link IStatus#ERROR} + * - desired severity of the message in the log, one of {@link IStatus#INFO}, + * {@link IStatus#WARNING} or {@link IStatus#ERROR} * @param msg * - message * @@ -1493,9 +1448,8 @@ public class CCorePlugin extends Plugin { * Prints a message in the log accompanied by stack trace * * @param severity - * - desired severity of the message in the log, one of - * {@link IStatus#INFO}, {@link IStatus#WARNING} or - * {@link IStatus#ERROR} + * - desired severity of the message in the log, one of {@link IStatus#INFO}, + * {@link IStatus#WARNING} or {@link IStatus#ERROR} * @param msg * - message * @@ -1561,9 +1515,8 @@ public class CCorePlugin extends Plugin { } /** - * Returns the preference controlling whether source roots are shown at the - * top of projects or embedded within the resource tree of projects when - * they are not top level folders. + * Returns the preference controlling whether source roots are shown at the top of projects or + * embedded within the resource tree of projects when they are not top level folders. * * @return boolean preference value * @since 5.2 diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs index 3933fad1414..fb6728569bb 100644 --- a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs @@ -79,287 +79,4 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -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 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -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_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -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_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=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 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -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_package=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 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -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_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 -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -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.format_block_comments=true -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_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -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_and_in_type_parameter=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_closing_angle_bracket_in_type_arguments=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 -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -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_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_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=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_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 -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -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_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_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 -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -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_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_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=110 -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_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -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.use_on_off_tags=false -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs index 875055bcc00..c7a604c3d2c 100644 --- a/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs +++ b/core/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.ui.prefs @@ -1,5 +1,4 @@ eclipse.preferences.version=1 -formatter_profile=_CDT formatter_settings_version=12 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=java;javax;org;com;org.eclipse.cdt;org.eclipse.cdt.internal;org.eclipse.cdt.internal.ui; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java index 91851f784b4..bf392a29c85 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java @@ -21,10 +21,12 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -69,8 +71,7 @@ import org.eclipse.cdt.internal.ui.newui.Messages; import org.eclipse.cdt.internal.ui.newui.StatusMessageLine; /** - * This tab presents language settings entries categorized by language - * settings providers. + * This tab presents language settings entries categorized by language settings providers. * * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. @@ -133,17 +134,23 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (entriesParent != null) { overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_PARENT; } - } else if (provider instanceof ILanguageSettingsBroadcastingProvider && (page.isForFile() || page.isForFolder())) { + } else if (provider instanceof ILanguageSettingsBroadcastingProvider + && (page.isForFile() || page.isForFolder())) { // Assuming that the default entries for a resource are always null. // Using that for performance reasons. See note in performDefaults(). - List entriesParent = provider.getSettingEntries(null, null, currentLanguageId); + List entriesParent = provider + .getSettingEntries((ICConfigurationDescription) null, null, currentLanguageId); + if (entriesParent == null) { + entriesParent = provider.getSettingEntries((IBuildConfiguration) null, null, currentLanguageId); + } if (entries != null && !entries.equals(entriesParent)) { overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING; } } ICConfigurationDescription cfgDescription = getConfigurationDescription(); - List initialProviders = initialProvidersMap.get(cfgDescription.getId()); + List initialProviders = initialProvidersMap + .get(cfgDescription.getId()); if (initialProviders != null && !initialProviders.contains(provider)) { overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_EDITED; } @@ -194,7 +201,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { return (Object[]) parentElement; if (parentElement instanceof ILanguageSettingsProvider) { - ILanguageSettingsProvider lsProvider = (ILanguageSettingsProvider)parentElement; + ILanguageSettingsProvider lsProvider = (ILanguageSettingsProvider) parentElement; List entriesList = getSettingEntriesUpResourceTree(lsProvider); if (entriesList == null) { return null; @@ -225,7 +232,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { @Override public boolean hasChildren(Object element) { Object[] children = getChildren(element); - return children!=null && children.length>0; + return children != null && children.length > 0; } @Override @@ -242,7 +249,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { * Shortcut for getting the current resource for the property page. */ private IResource getResource() { - return (IResource)page.getElement(); + return (IResource) page.getElement(); } /** @@ -269,7 +276,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } } if (itemData instanceof ILanguageSettingsProvider) { - provider = (ILanguageSettingsProvider)itemData; + provider = (ILanguageSettingsProvider) itemData; } } @@ -287,7 +294,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { TreeItem item = items[0]; Object itemData = item.getData(); if (itemData instanceof ICLanguageSettingEntry) { - entry = (ICLanguageSettingEntry)itemData; + entry = (ICLanguageSettingEntry) itemData; } } @@ -302,19 +309,28 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { */ private List getSettingEntriesUpResourceTree(ILanguageSettingsProvider provider) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); IResource rc = getResource(); - List entries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, rc, currentLanguageId); + List entries = LanguageSettingsManager + .getSettingEntriesUpResourceTree(provider, config, rc, currentLanguageId); return entries; } /** - * Shortcut for getting setting entries for current context without checking the parent resource. + * Shortcut for getting setting entries for current context without checking the parent + * resource. + * * @return list of setting entries for the current context. */ private List getSettingEntries(ILanguageSettingsProvider provider) { - ICConfigurationDescription cfgDescription = getConfigurationDescription(); IResource rc = getResource(); - return provider.getSettingEntries(cfgDescription, rc, currentLanguageId); + ICConfigurationDescription cfgDescription = getConfigurationDescription(); + List entries = provider.getSettingEntries(cfgDescription, rc, currentLanguageId); + if (entries == null) { + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + entries = provider.getSettingEntries(config, rc, currentLanguageId); + } + return entries; } /** @@ -326,7 +342,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { for (ICConfigurationDescription cfgDescription : cfgDescriptions) { if (cfgDescription instanceof ILanguageSettingsProvidersKeeper) { String cfgId = cfgDescription.getId(); - List initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List initialProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); initialProvidersMap.put(cfgId, initialProviders); } } @@ -412,7 +429,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { @Override public void widgetDefaultSelected(SelectionEvent e) { - if (buttonIsEnabled(BUTTON_EDIT) && treeEntries.getSelection().length>0) + if (buttonIsEnabled(BUTTON_EDIT) && treeEntries.getSelection().length > 0) buttonPressed(BUTTON_EDIT); } }); @@ -423,7 +440,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { * Create sash form. */ private void createSashForm() { - sashFormEntries = new SashForm(usercomp,SWT.HORIZONTAL); + sashFormEntries = new SashForm(usercomp, SWT.HORIZONTAL); GridData gd = new GridData(GridData.FILL_BOTH); gd.horizontalSpan = 2; @@ -443,7 +460,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { * Create check-box to control whether to show built-in entries or not. */ private void createBuiltInsCheckBox() { - builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.FILL_HORIZONTAL); + builtInCheckBox = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, + GridData.FILL_HORIZONTAL); builtInCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { @@ -462,7 +480,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { usercomp.setLayout(new GridLayout()); GridData gd = (GridData) usercomp.getLayoutData(); // Discourage settings entry table from trying to show all its items at once, see bug 264330 - gd.heightHint =1; + gd.heightHint = 1; if (page instanceof LanguageSettingsProvidersPage) { masterPropertyPage = (LanguageSettingsProvidersPage) page; @@ -584,7 +602,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { * Displays warning message - if any - for selected language settings entry. */ private void updateStatusLine() { - IStatus status=null; + IStatus status = null; if (masterPropertyPage.isLanguageSettingsProvidersEnabled()) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); status = LanguageSettingsImages.getStatus(getSelectedEntry(), cfgDescription); @@ -594,12 +612,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { boolean isAllowedEditing = provider instanceof ILanguageSettingsEditableProvider && LanguageSettingsProviderAssociationManager.isAllowedToEditEntries(provider); if (provider != null && !isAllowedEditing) { - status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Entries_Not_Editable); + status = new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, + Messages.LanguageSettingsEntriesTab_Entries_Not_Editable); } } if (status == null || status == Status.OK_STATUS) { if (treeLanguages.getItemCount() <= 0) { - status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages); + status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, + Messages.LanguageSettingsEntriesTab_Cannot_Determine_Languages); } } fStatusLine.setErrorStatus(status); @@ -638,9 +658,9 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } /** - * That method returns exact position of an element in the list. - * Note that {@link List#indexOf(Object)} returns position of the first element - * equals to the given one, not exact element. + * That method returns exact position of an element in the list. Note that + * {@link List#indexOf(Object)} returns position of the first element equals to the given one, + * not exact element. * * @param entries * @param entry @@ -664,7 +684,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { for (TreeItem providerItem : providerItems) { Object providerItemData = providerItem.getData(); if (providerItemData instanceof ILanguageSettingsProvider) { - ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData; + ILanguageSettingsProvider provider = (ILanguageSettingsProvider) providerItemData; if (provider.getId().equals(id)) { return providerItem; } @@ -681,12 +701,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { for (TreeItem providerItem : providerItems) { Object providerItemData = providerItem.getData(); if (providerItemData instanceof ILanguageSettingsProvider) { - ILanguageSettingsProvider provider = (ILanguageSettingsProvider)providerItemData; + ILanguageSettingsProvider provider = (ILanguageSettingsProvider) providerItemData; if (provider.getId().equals(providerId)) { TreeItem[] entryItems = providerItem.getItems(); for (TreeItem entryItem : entryItems) { Object entryItemData = entryItem.getData(); - if (entryItemData==entry) + if (entryItemData == entry) return entryItem; } } @@ -724,7 +744,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { List entries = getEntriesShownToUser(provider); ICLanguageSettingEntry selectedEntry = getSelectedEntry(); int pos = getExactIndex(entries, selectedEntry); - entries.add(pos+1, entry); + entries.add(pos + 1, entry); saveEntries(provider, entries); updateTreeForEntries(providerId, entry); @@ -737,27 +757,34 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { private void saveEntries(ILanguageSettingsProvider provider, List entries) { if (provider instanceof ILanguageSettingsEditableProvider) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); IResource rc = getResource(); if (entries != null && rc != null) { IContainer parent = rc instanceof IProject ? null : rc.getParent(); - List parentEntries = LanguageSettingsManager.getSettingEntriesUpResourceTree(provider, cfgDescription, parent, currentLanguageId); + List parentEntries = LanguageSettingsManager + .getSettingEntriesUpResourceTree(provider, config, parent, currentLanguageId); if (entries.equals(parentEntries)) { // to use parent entries instead entries = null; } } - ((ILanguageSettingsEditableProvider)provider).setSettingEntries(cfgDescription, rc, currentLanguageId, entries); + ((ILanguageSettingsEditableProvider) provider).setSettingEntries(config, rc, currentLanguageId, + entries); } } /** - * Get list of setting entries shown to user. If current resource has no entries assigned the parent - * resource is inspected. + * Get list of setting entries shown to user. If current resource has no entries assigned the + * parent resource is inspected. */ private List getEntriesShownToUser(ILanguageSettingsProvider provider) { - ICConfigurationDescription cfgDescription = getConfigurationDescription(); IResource rc = getResource(); + ICConfigurationDescription cfgDescription = getConfigurationDescription(); List entries = provider.getSettingEntries(cfgDescription, rc, currentLanguageId); + if (entries == null) { + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + entries = provider.getSettingEntries(config, rc, currentLanguageId); + } if (entries == null) { entries = getSettingEntriesUpResourceTree(provider); } @@ -772,11 +799,12 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (selectedProvider instanceof ILanguageSettingsEditableProvider) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); ICLanguageSettingEntry selectedEntry = getSelectedEntry(); - LanguageSettingEntryDialog addDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDescription, selectedEntry, true); + LanguageSettingEntryDialog addDialog = new LanguageSettingEntryDialog(usercomp.getShell(), + cfgDescription, selectedEntry, true); if (addDialog.open()) { ICLanguageSettingEntry settingEntry = addDialog.getEntries()[0]; if (settingEntry != null) { - selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider); + selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider); addEntry(selectedProvider, settingEntry); } } @@ -784,25 +812,27 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } /** - * Return working copy of the provider to edit in current session. If the supplied provider is already - * the working copy return it. If not, create a copy to be edited. + * Return working copy of the provider to edit in current session. If the supplied provider is + * already the working copy return it. If not, create a copy to be edited. */ private ILanguageSettingsEditableProvider getWorkingCopy(ILanguageSettingsEditableProvider provider) { ICConfigurationDescription cfgDescription = getConfigurationDescription(); List initialProviders = initialProvidersMap.get(cfgDescription.getId()); if (initialProviders.contains(provider)) { - List providers = new ArrayList(((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); + List providers = new ArrayList( + ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()); int pos = providers.indexOf(provider); if (pos >= 0) { try { provider = provider.clone(); providers.set(pos, provider); - ((ILanguageSettingsProvidersKeeper) cfgDescription).setLanguageSettingProviders(providers); + ((ILanguageSettingsProvidersKeeper) cfgDescription) + .setLanguageSettingProviders(providers); } catch (CloneNotSupportedException e) { - CUIPlugin.log("Internal Error: cannot clone provider "+provider.getId(), e); //$NON-NLS-1$ + CUIPlugin.log("Internal Error: cannot clone provider " + provider.getId(), e); //$NON-NLS-1$ } } else { - CUIPlugin.log("Internal Error: cannot find provider "+provider.getId(), new Exception()); //$NON-NLS-1$ + CUIPlugin.log("Internal Error: cannot find provider " + provider.getId(), new Exception()); //$NON-NLS-1$ } } return provider; @@ -811,14 +841,16 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Call dialog to edit settings entry. */ - private void performEdit(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { + private void performEdit(ILanguageSettingsProvider selectedProvider, + ICLanguageSettingEntry selectedEntry) { if (selectedProvider instanceof ILanguageSettingsEditableProvider && selectedEntry != null) { ICConfigurationDescription cfgDecsription = getConfigurationDescription(); - LanguageSettingEntryDialog editDialog = new LanguageSettingEntryDialog(usercomp.getShell(), cfgDecsription, selectedEntry); + LanguageSettingEntryDialog editDialog = new LanguageSettingEntryDialog(usercomp.getShell(), + cfgDecsription, selectedEntry); if (editDialog.open()) { ICLanguageSettingEntry newEntry = editDialog.getEntries()[0]; if (newEntry != null) { - selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider); + selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider); replaceEntry(selectedProvider, selectedEntry, newEntry); } } @@ -850,7 +882,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Replace provider's entry and update UI. */ - private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry, ICLanguageSettingEntry newEntry) { + private void replaceEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry oldEntry, + ICLanguageSettingEntry newEntry) { if (provider != null && oldEntry != null && newEntry != null) { String providerId = provider.getId(); @@ -878,9 +911,10 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Clear provider's entries for the given resource or remove one entry depending on selection. */ - private void performDelete(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { + private void performDelete(ILanguageSettingsProvider selectedProvider, + ICLanguageSettingEntry selectedEntry) { if (selectedProvider instanceof ILanguageSettingsEditableProvider) { - selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider); + selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider); if (selectedEntry != null) { deleteEntry(selectedProvider, selectedEntry); } else { @@ -892,7 +926,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Change "Export" flag of provider's entry and update UI. */ - private void exportEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry, boolean isExport) { + private void exportEntry(ILanguageSettingsProvider provider, ICLanguageSettingEntry entry, + boolean isExport) { if (provider instanceof ILanguageSettingsEditableProvider && entry != null) { int flags = entry.getFlags(); if (isExport) { @@ -902,7 +937,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } ICLanguageSettingEntry newEntry = CDataUtil.createEntry(entry, flags); if (newEntry != null) { - provider = getWorkingCopy((ILanguageSettingsEditableProvider)provider); + provider = getWorkingCopy((ILanguageSettingsEditableProvider) provider); replaceEntry(provider, entry, newEntry); } } @@ -915,8 +950,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (provider instanceof ILanguageSettingsEditableProvider) { List entries = getEntriesShownToUser(provider); if (entries.size() > 0) { - provider = getWorkingCopy((ILanguageSettingsEditableProvider)provider); - for (int i = 0; i < entries.size() ; i++) { + provider = getWorkingCopy((ILanguageSettingsEditableProvider) provider); + for (int i = 0; i < entries.size(); i++) { ICLanguageSettingEntry entry = entries.get(i); int flags = entry.getFlags(); if (isExport) { @@ -936,7 +971,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Export or un-export provider's entry or entries. */ - private void performExport(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { + private void performExport(ILanguageSettingsProvider selectedProvider, + ICLanguageSettingEntry selectedEntry) { if (selectedProvider instanceof ILanguageSettingsEditableProvider) { boolean isExport = isExportMode(selectedProvider, selectedEntry); if (selectedEntry != null) { @@ -956,7 +992,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { List entries = getEntriesShownToUser(provider); int pos = getExactIndex(entries, entry); - int newPos = up ? pos-1 : pos+1; + int newPos = up ? pos - 1 : pos + 1; Collections.swap(entries, pos, newPos); saveEntries(provider, entries); @@ -967,9 +1003,10 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Move provider's entry up. */ - private void performMoveUp(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { + private void performMoveUp(ILanguageSettingsProvider selectedProvider, + ICLanguageSettingEntry selectedEntry) { if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) { - selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider); + selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider); moveEntry(selectedProvider, selectedEntry, true); } } @@ -977,9 +1014,10 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Move provider's entry down. */ - private void performMoveDown(ILanguageSettingsProvider selectedProvider, ICLanguageSettingEntry selectedEntry) { + private void performMoveDown(ILanguageSettingsProvider selectedProvider, + ICLanguageSettingEntry selectedEntry) { if (selectedEntry != null && (selectedProvider instanceof ILanguageSettingsEditableProvider)) { - selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider)selectedProvider); + selectedProvider = getWorkingCopy((ILanguageSettingsEditableProvider) selectedProvider); moveEntry(selectedProvider, selectedEntry, false); } } @@ -992,12 +1030,14 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { IResource rc = getResource(); ICConfigurationDescription cfgDescription = getConfigurationDescription(); if (rc != null && cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - List cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); + List cfgProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); for (ILanguageSettingsProvider cfgProvider : cfgProviders) { ILanguageSettingsProvider rawProvider = LanguageSettingsManager.getRawProvider(cfgProvider); if (rawProvider instanceof LanguageSettingsBaseProvider) { // filter out providers incapable of providing entries for this language - List languageIds = ((LanguageSettingsBaseProvider)rawProvider).getLanguageScope(); + List languageIds = ((LanguageSettingsBaseProvider) rawProvider) + .getLanguageScope(); if (languageIds != null && !languageIds.contains(currentLanguageId)) { continue; } @@ -1011,9 +1051,11 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { /** * Re-reads and refreshes the entries tree. * - * @param selectedProviderId - provider of the entry to select after update. - * If the entry is {@code null} the provider itself will be selected. - * @param selectedEntry - entry to select in the tree after update. + * @param selectedProviderId + * - provider of the entry to select after update. If the entry is {@code null} the + * provider itself will be selected. + * @param selectedEntry + * - entry to select in the tree after update. */ private void updateTreeForEntries(String selectedProviderId, ICLanguageSettingEntry selectedEntry) { Object[] expandedElements = treeEntriesViewer.getExpandedElements(); @@ -1031,7 +1073,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { if (provider.getId().equals(selectedProviderId)) { for (int i = 0; i < expandedElements.length; i++) { if (expandedElements[i] instanceof ILanguageSettingsProvider) { - if (((ILanguageSettingsProvider) expandedElements[i]).getId().equals(selectedProviderId)) { + if (((ILanguageSettingsProvider) expandedElements[i]).getId() + .equals(selectedProviderId)) { expandedElements[i] = provider; break; } @@ -1062,17 +1105,19 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { // remove null language when some real ones are defined languageIds.remove(null); } else if (languageIds.isEmpty()) { - // if no languages are defined keep null language as "Unspecified language" + // if no languages are defined keep null language as "Unspecified + // language" languageIds.add(null); } - + // Use a TreeMap to sort the languages by name. // For each name we keep a list of ids in case of name overlap. Map> map = new TreeMap>(); for (String langId : languageIds) { ILanguage language = LanguageManager.getInstance().getLanguage(langId); - String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage; + String langName = language != null ? language.getName() + : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage; if (langName == null || langName.length() == 0) continue; List langIds = map.get(langName); @@ -1082,7 +1127,7 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } langIds.add(langId); } - + for (String langName : map.keySet()) { List langIds = map.get(langName); for (String langId : langIds) { @@ -1170,26 +1215,33 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { return; } + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + boolean changed = false; IResource rc = getResource(); - List oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders(); - List newProviders = new ArrayList(oldProviders.size()); + List oldProviders = ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders(); + List newProviders = new ArrayList( + oldProviders.size()); - // clear entries for a given resource for all languages where applicable - providers: for (ILanguageSettingsProvider provider : oldProviders) { + // clear entries for a given resource for all languages where + // applicable + providers: for (ILanguageSettingsProvider provider : oldProviders) { ILanguageSettingsEditableProvider providerCopy = null; if (provider instanceof ILanguageSettingsEditableProvider) { for (TreeItem langItems : treeLanguages.getItems()) { - String langId = (String)langItems.getData(); - if (provider.getSettingEntries(cfgDescription, rc, langId) != null) { + String langId = (String) langItems.getData(); + if (provider.getSettingEntries(cfgDescription, rc, langId) != null + || provider.getSettingEntries(config, rc, langId) != null) { if (providerCopy == null) { // copy providers to be able to "Cancel" in UI - providerCopy = LanguageSettingsManager.getProviderCopy((ILanguageSettingsEditableProvider) provider, true); + providerCopy = LanguageSettingsManager + .getProviderCopy((ILanguageSettingsEditableProvider) provider, true); if (providerCopy == null) { continue providers; } } - providerCopy.setSettingEntries(cfgDescription, rc, langId, null); + providerCopy.setSettingEntries(config, rc, langId, null); changed = true; } } @@ -1208,12 +1260,15 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { } @Override - protected void performApply(ICResourceDescription srcRcDescription, ICResourceDescription destRcDescription) { + protected void performApply(ICResourceDescription srcRcDescription, + ICResourceDescription destRcDescription) { if (!page.isForPrefs()) { ICConfigurationDescription sd = srcRcDescription.getConfiguration(); ICConfigurationDescription dd = destRcDescription.getConfiguration(); - if (sd instanceof ILanguageSettingsProvidersKeeper && dd instanceof ILanguageSettingsProvidersKeeper) { - List newProviders = ((ILanguageSettingsProvidersKeeper) sd).getLanguageSettingProviders(); + if (sd instanceof ILanguageSettingsProvidersKeeper + && dd instanceof ILanguageSettingsProvidersKeeper) { + List newProviders = ((ILanguageSettingsProvidersKeeper) sd) + .getLanguageSettingProviders(); ((ILanguageSettingsProvidersKeeper) dd).setLanguageSettingProviders(newProviders); } } @@ -1245,7 +1300,8 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab { IResource rc = getResource(); if (rc instanceof IFile) { try { - ILanguage language = LanguageManager.getInstance().getLanguageForFile((IFile)rc, null); + ILanguage language = LanguageManager.getInstance().getLanguageForFile((IFile) rc, + null); return language != null; } catch (CoreException e) { // who cares, not even logging diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java index 1f0c125382e..52fd14ea4d2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CustomBuildSettingsDecorator.java @@ -12,10 +12,12 @@ package org.eclipse.cdt.internal.ui.viewsupport; import java.util.List; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.Adapters; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ILightweightLabelDecorator; @@ -34,15 +36,18 @@ import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.internal.ui.CPluginImages; /** - * Determines if a file or folder got customized build settings and if so decorates with the "wrench" overlay. + * Determines if a file or folder got customized build settings and if so decorates with the + * "wrench" overlay. */ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator { @Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile || element instanceof IFolder) { IResource rc = (IResource) element; - ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault().getProjectDescriptionManager(); - ICProjectDescription prjDescription = projectDescriptionManager.getProjectDescription(rc.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED); + ICProjectDescriptionManager projectDescriptionManager = CoreModel.getDefault() + .getProjectDescriptionManager(); + ICProjectDescription prjDescription = projectDescriptionManager + .getProjectDescription(rc.getProject(), ICProjectDescriptionManager.GET_IF_LOADDED); if (prjDescription != null) { ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration(); if (cfgDescription != null) { @@ -54,23 +59,33 @@ public class CustomBuildSettingsDecorator implements ILightweightLabelDecorator } private static boolean isCustomizedResource(ICConfigurationDescription cfgDescription, IResource rc) { - if (ScannerDiscoveryLegacySupport.isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject()) && cfgDescription instanceof ILanguageSettingsProvidersKeeper) { - IContainer parent = rc.getParent(); - List languages = LanguageSettingsManager.getLanguages(rc, cfgDescription); - for (ILanguageSettingsProvider provider: ((ILanguageSettingsProvidersKeeper) cfgDescription).getLanguageSettingProviders()) { - for (String languageId : languages) { - List list = provider.getSettingEntries(cfgDescription, rc, languageId); - if (list != null) { - List listDefault = provider.getSettingEntries(cfgDescription, parent, languageId); - // != is OK here due as the equal lists will have the same reference in WeakHashSet - if (list != listDefault) - return true; - } + IBuildConfiguration config = Adapters.adapt(cfgDescription, IBuildConfiguration.class); + if (config != null + && ScannerDiscoveryLegacySupport + .isLanguageSettingsProvidersFunctionalityEnabled(rc.getProject()) + && cfgDescription instanceof ILanguageSettingsProvidersKeeper) { + IContainer parent = rc.getParent(); + List languages = LanguageSettingsManager.getLanguages(rc, cfgDescription); + for (ILanguageSettingsProvider provider : ((ILanguageSettingsProvidersKeeper) cfgDescription) + .getLanguageSettingProviders()) { + for (String languageId : languages) { + List list = provider.getSettingEntries(cfgDescription, rc, languageId); + if (list == null) { + list = provider.getSettingEntries(config, rc, languageId); + } + if (list != null) { + List listDefault = provider.getSettingEntries(config, parent, + languageId); + // != is OK here due as the equal lists will have the same reference in WeakHashSet + if (list != listDefault) + return true; } } + } } - ICResourceDescription rcDescription = cfgDescription.getResourceDescription(rc.getProjectRelativePath(), true); + ICResourceDescription rcDescription = cfgDescription + .getResourceDescription(rc.getProjectRelativePath(), true); return rcDescription != null; } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java index 4216f8b1188..878dc1c784b 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePaths.java @@ -18,24 +18,25 @@ import java.util.List; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.utils.spawner.ProcessFactory; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; import org.w3c.dom.Element; import org.w3c.dom.Node; /** - * Discovers and persists the list of Qt include paths for a particular installation of - * Qt. The Qt installation is described by the path to qmake. + * Discovers and persists the list of Qt include paths for a particular + * installation of Qt. The Qt installation is described by the path to qmake. *

- * Qt uses a tool called qmake to generate makefiles for Qt projects. The tool has a - * query mode that can be used to discover information about the Qt installation. Here - * qmake is used to build a list of all installed Qt include paths. + * Qt uses a tool called qmake to generate makefiles for Qt projects. The tool + * has a query mode that can be used to discover information about the Qt + * installation. Here qmake is used to build a list of all installed Qt include + * paths. *

- * These paths are persisted into a file called language-settings.xml in the workspace - * metadata area. + * These paths are persisted into a file called language-settings.xml in the + * workspace metadata area. * * @see QtIncludePathsProvider */ @@ -52,34 +53,34 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { private long qmakeModTime; /** - * The cached data is reloaded when the folder holding the include paths - * is removed. + * The cached data is reloaded when the folder holding the include paths is + * removed. */ private String qtInstallHeadersPath; /** - * The cached data is reloaded when the folder containing the include folders is - * modified. + * The cached data is reloaded when the folder containing the include + * folders is modified. */ private long qtInstallHeadersModTime; - private static final String ATTR_QMAKE = "qmake"; - private static final String ATTR_QMAKE_MOD = "qmakeModification"; - private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS"; - private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification"; + private static final String ATTR_QMAKE = "qmake"; //$NON-NLS-1$ + private static final String ATTR_QMAKE_MOD = "qmakeModification"; //$NON-NLS-1$ + private static final String ATTR_QT_INSTALL_HEADERS = "QT_INSTALL_HEADERS"; //$NON-NLS-1$ + private static final String ATTR_QT_INSTALL_HEADERS_MOD = "qtInstallHeadersModification"; //$NON-NLS-1$ /** - * Create a new instance of the include path wrapper for the Qt installation for - * the given qmake binary. + * Create a new instance of the include path wrapper for the Qt installation + * for the given qmake binary. */ public QtIncludePaths(String qmakePath) { this.qmakePath = qmakePath; } /** - * Create and load an instance of QtIncludePaths from data that was serialized into the - * given XML element. Return null if an instance cannot be loaded or if the installation - * is no longer valid. + * Create and load an instance of QtIncludePaths from data that was + * serialized into the given XML element. Return null if an instance cannot + * be loaded or if the installation is no longer valid. */ public static QtIncludePaths loadFrom(Node node) { if (node.getNodeType() != Node.ELEMENT_NODE) @@ -87,8 +88,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { Element element = (Element) node; String qmakePath = element.getAttribute(ATTR_QMAKE); - if (qmakePath == null - || qmakePath.isEmpty()) + if (qmakePath == null || qmakePath.isEmpty()) return null; QtIncludePaths qtIncludePaths = new QtIncludePaths(qmakePath); @@ -101,18 +101,16 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { } /** - * Return true if the receiver points to a valid Qt installation and false otherwise. - * The installation is considered valid if an executable qmake binary exists at the - * expected location. + * Return true if the receiver points to a valid Qt installation and false + * otherwise. The installation is considered valid if an executable qmake + * binary exists at the expected location. */ public boolean isValid() { - if (qmakePath == null - || qmakePath.isEmpty()) + if (qmakePath == null || qmakePath.isEmpty()) return false; File qmake = new File(qmakePath); - return qmake.exists() - && qmake.canExecute(); + return qmake.exists() && qmake.canExecute(); } @Override @@ -120,8 +118,10 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { if (!(obj instanceof QtIncludePaths)) return super.equals(obj); - // Include paths are equivalent when they point to the same qmake binary. All other - // values are reloaded from that binary and do not need to be directly compared. + // Include paths are equivalent when they point to the same qmake + // binary. All other + // values are reloaded from that binary and do not need to be directly + // compared. QtIncludePaths other = (QtIncludePaths) obj; return qmakePath == null ? other.qmakePath == null : qmakePath.equals(other.qmakePath); } @@ -132,33 +132,32 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { } /** - * Return a current list of the include paths for this Qt installation. Return null if - * no such paths can be found. + * Return a current list of the include paths for this Qt installation. + * Return null if no such paths can be found. *

- * Updates the cached results if needed. If the settings are updated then the new list - * will be serialized into the workspace metadata area. + * Updates the cached results if needed. If the settings are updated then + * the new list will be serialized into the workspace metadata area. */ @Override - public List getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) { + public List getSettingEntries(IBuildConfiguration config, IResource rc, String languageId) { List entries = null; File qmake = new File(qmakePath); - if (!qmake.exists() - || qmakeModTime != qmake.lastModified()) + if (!qmake.exists() || qmakeModTime != qmake.lastModified()) entries = reload(); else { File qtInstallHeadersDir = new File(qtInstallHeadersPath); - if (!qtInstallHeadersDir.exists() - || qtInstallHeadersModTime != qtInstallHeadersDir.lastModified()) + if (!qtInstallHeadersDir.exists() || qtInstallHeadersModTime != qtInstallHeadersDir.lastModified()) entries = reload(); } - // If the cache was not reloaded, then return the previously discovered entries. + // If the cache was not reloaded, then return the previously discovered + // entries. if (entries == null) - return super.getSettingEntries(configDesc, rc, languageId); + return super.getSettingEntries(config, rc, languageId); // Otherwise store, persist, and return the newly discovered values. - setSettingEntries(configDesc, rc, languageId, entries); + setSettingEntries(config, rc, languageId, entries); serializeLanguageSettingsInBackground(null); return entries; } @@ -170,8 +169,10 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS, qtInstallHeadersPath); parentElement.setAttribute(ATTR_QT_INSTALL_HEADERS_MOD, Long.toString(qtInstallHeadersModTime)); - // The parent implementation tries to create a new child node (provider) that is used - // as the part for later entries. This isn't needed in this case, we just want to + // The parent implementation tries to create a new child node (provider) + // that is used + // as the part for later entries. This isn't needed in this case, we + // just want to // use the part that serializes the languages. return parentElement; } @@ -182,25 +183,26 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { qtInstallHeadersPath = element.getAttribute(ATTR_QT_INSTALL_HEADERS); qtInstallHeadersModTime = getLongAttribute(element, ATTR_QT_INSTALL_HEADERS_MOD); - // The parent implementation tries to create a new child node (provider) that is used - // as the part for later entries. This isn't needed in this case, we just want to + // The parent implementation tries to create a new child node (provider) + // that is used + // as the part for later entries. This isn't needed in this case, we + // just want to // use the part that serializes the languages. } /** - * Parse and return the given attribute as a long. Return 0 if the attribute does - * not have a valid value. + * Parse and return the given attribute as a long. Return 0 if the attribute + * does not have a valid value. */ private static long getLongAttribute(Element element, String attr) { String value = element.getAttribute(attr); - if (value == null - || value.isEmpty()) + if (value == null || value.isEmpty()) return 0; try { return Long.parseLong(value); - } catch(NumberFormatException e) { - Activator.log("attribute name:" + attr + " value:" + value, e); + } catch (NumberFormatException e) { + Activator.log("attribute name:" + attr + " value:" + value, e); //$NON-NLS-1$ //$NON-NLS-2$ return 0; } } @@ -209,33 +211,34 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { * Reload and return the entries if possible, return null otherwise. */ private List reload() { - // All keys are reset and then updated as their values are discovered. This allows partial + // All keys are reset and then updated as their values are discovered. + // This allows partial // success to skip over previously calculated values. qmakeModTime = 0; qtInstallHeadersPath = null; qtInstallHeadersModTime = 0; File qmake = new File(qmakePath); - if (!qmake.exists() - || !qmake.canExecute()) + if (!qmake.exists() || !qmake.canExecute()) return Collections.emptyList(); qmakeModTime = qmake.lastModified(); - // Run `qmake -query QT_INSTALL_HEADERS` to get output like "/opt/qt-5.0.0/include". + // Run `qmake -query QT_INSTALL_HEADERS` to get output like + // "/opt/qt-5.0.0/include". BufferedReader reader = null; Process process = null; try { - process = ProcessFactory.getFactory().exec(new String[]{ qmakePath, "-query", "QT_INSTALL_HEADERS" }); + process = ProcessFactory.getFactory().exec(new String[] { qmakePath, "-query", "QT_INSTALL_HEADERS" }); //$NON-NLS-1$ //$NON-NLS-2$ reader = new BufferedReader(new InputStreamReader(process.getInputStream())); qtInstallHeadersPath = reader.readLine(); - } catch(IOException e) { + } catch (IOException e) { Activator.log(e); } finally { try { if (reader != null) reader.close(); - } catch(IOException e) { + } catch (IOException e) { /* ignore */ } finally { if (process != null) @@ -249,12 +252,11 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { File qtInstallHeadersDir = new File(qtInstallHeadersPath); qtInstallHeadersModTime = qtInstallHeadersDir.lastModified(); - if (!qtInstallHeadersDir.exists() - || !qtInstallHeadersDir.canRead() - || !qtInstallHeadersDir.isDirectory()) + if (!qtInstallHeadersDir.exists() || !qtInstallHeadersDir.canRead() || !qtInstallHeadersDir.isDirectory()) return Collections.emptyList(); - // Create an include path entry for all sub-folders in the QT_INSTALL_HEADERS location, including + // Create an include path entry for all sub-folders in the + // QT_INSTALL_HEADERS location, including // the QT_INSTALL_HEADERS folder itself. File[] files = qtInstallHeadersDir.listFiles(new FileFilter() { @Override @@ -265,7 +267,7 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { List entries = new ArrayList(files.length + 1); safeAdd(entries, qtInstallHeadersDir); - for(File file : files) + for (File file : files) safeAdd(entries, file); return entries; @@ -273,8 +275,9 @@ public class QtIncludePaths extends LanguageSettingsSerializableProvider { private static void safeAdd(List entries, File file) { try { - entries.add(new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED)); - } catch(IOException e) { + entries.add( + new CIncludePathEntry(file.getCanonicalPath(), ICSettingEntry.READONLY | ICSettingEntry.RESOLVED)); + } catch (IOException e) { Activator.log(e); } } diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java index fa832c66d79..c9f1e63e8ea 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/QtIncludePathsProvider.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsSerializableProvider; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IResource; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -24,8 +25,8 @@ import org.w3c.dom.NodeList; /** * This provider uses persistent cache to store the include paths for different - * Qt installations. A Qt installation is uniquely identified by the path to - * the qmake binary within the installation. + * Qt installations. A Qt installation is uniquely identified by the path to the + * qmake binary within the installation. *

* This result is shared among all Build Configurations that use the provider * with the same value for the QMAKE environment variable. @@ -33,17 +34,19 @@ import org.w3c.dom.NodeList; public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider { /** - * The provider identifies Qt installations by the absolute path to the qmake binary. The - * include paths relevant to the installations are computed and persisted in {@link QtIncludePaths}. + * The provider identifies Qt installations by the absolute path to the + * qmake binary. The include paths relevant to the installations are + * computed and persisted in {@link QtIncludePaths}. */ private final Map qtInstallHeaders = new HashMap(); /** - * The build configuration stores the path to the qmake binary as an environment variable. + * The build configuration stores the path to the qmake binary as an + * environment variable. */ - private static final String ENVVAR_QMAKE = "QMAKE"; + private static final String ENVVAR_QMAKE = "QMAKE"; //$NON-NLS-1$ - private static final String ELEMENT_QMAKE = "qmake"; + private static final String ELEMENT_QMAKE = "qmake"; //$NON-NLS-1$ @Override public boolean equals(Object obj) { @@ -68,17 +71,19 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider public void loadEntries(Element providerNode) { super.loadEntries(providerNode); - // Find and load all qmake child nodes. There will be one node for each Qt - // installation that has been used. Qt installations that are no longer valid - // are not loaded. This means they will be removed from the file the next time + // Find and load all qmake child nodes. There will be one node for each + // Qt + // installation that has been used. Qt installations that are no longer + // valid + // are not loaded. This means they will be removed from the file the + // next time // that the language setting providers are serialized. NodeList children = providerNode.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node child = children.item(i); if (ELEMENT_QMAKE.equals(child.getNodeName())) { QtIncludePaths qtIncludePaths = QtIncludePaths.loadFrom(child); - if (qtIncludePaths != null - && qtIncludePaths.isValid()) + if (qtIncludePaths != null && qtIncludePaths.isValid()) qtInstallHeaders.put(qtIncludePaths.getQMakePath(), qtIncludePaths); } } @@ -86,14 +91,17 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider @Override public void serializeEntries(Element parent) { - // NOTE: This creates its own XML structure where children of the provider node are qmake nodes. - // Within each qmake node is a list of include paths for that installation. Calling the - // base #serializeEntries here would try to write this instance's (empty) list of settings - // to the file. + // NOTE: This creates its own XML structure where children of the + // provider node are qmake nodes. + // Within each qmake node is a list of include paths for that + // installation. Calling the + // base #serializeEntries here would try to write this instance's + // (empty) list of settings + // to the file. // Each value is serialized into a new element in the XML document. - Document document = parent instanceof Document ? (Document)parent : parent.getOwnerDocument(); - for(QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) { + Document document = parent instanceof Document ? (Document) parent : parent.getOwnerDocument(); + for (QtIncludePaths qtIncludePaths : qtInstallHeaders.values()) { Element child = document.createElement(ELEMENT_QMAKE); qtIncludePaths.serialize(child); parent.appendChild(child); @@ -101,19 +109,24 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider } /** - * The given build configuration's QMAKE environment variable is used to identify the appropriate - * Qt installation. The language settings are then either returned from the previously persisted - * data or loaded, serialized, and returned. + * The given build configuration's QMAKE environment variable is used to + * identify the appropriate Qt installation. The language settings are then + * either returned from the previously persisted data or loaded, serialized, + * and returned. */ @Override - public synchronized List getSettingEntries(ICConfigurationDescription configDesc, IResource rc, String languageId) { + public synchronized List getSettingEntries(IBuildConfiguration config, IResource rc, + String languageId) { // Make sure the requested language is in scope for this provider. if (!getLanguageScope().contains(languageId)) return null; - // The value of the build configuration's QMAKE environment variable is used to select the + // The value of the build configuration's QMAKE environment variable is + // used to select the // right version of qmake. - IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE, configDesc, true); + ICConfigurationDescription configDesc = config.getAdapter(ICConfigurationDescription.class); + IEnvironmentVariable qmake_var = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariable(ENVVAR_QMAKE, + configDesc, true); if (qmake_var == null) return null; @@ -121,13 +134,14 @@ public class QtIncludePathsProvider extends LanguageSettingsSerializableProvider if (qmake == null) return null; - // The path to qmake is used as the key into the in-memory cache of header paths. + // The path to qmake is used as the key into the in-memory cache of + // header paths. QtIncludePaths paths = qtInstallHeaders.get(qmake); if (paths == null) { paths = new QtIncludePaths(qmake); qtInstallHeaders.put(qmake, paths); } - return paths.getSettingEntries(configDesc, null, languageId); + return paths.getSettingEntries(config, null, languageId); } }