Use varargs messages method.
And touch formatter to get saner look.
Change-Id: Iaa48026e9554b289bcb38b84ea60fc81cb6ac322
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java
index 35958ae..1465ef9 100644
--- a/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java
+++ b/core/plugins/org.eclipse.dltk.debug.ui/src/org/eclipse/dltk/debug/ui/launchConfigurations/ScriptLaunchConfigurationTab.java
@@ -104,7 +104,7 @@
* Creates the widgets for specifying a main type.
*
* @param parent
- * the parent composite
+ * the parent composite
*/
protected void createDebugOptionsGroup(Composite parent) {
if (ILaunchManager.DEBUG_MODE.equals(fMode)) {
@@ -226,11 +226,11 @@
* <code>null</code> if none.
*
* @param config
- * working copy
+ * working copy
* @throws CoreException
* @returns resource or <code>null</code>
* @throws CoreException
- * if an exception occurs mapping resource
+ * if an exception occurs mapping resource
*/
protected IResource getResource(ILaunchConfiguration config)
throws CoreException {
@@ -317,7 +317,7 @@
* </p>
*
* @param composite
- * control composite
+ * control composite
*
* @see #createControl(Composite)
*/
@@ -327,7 +327,7 @@
* Performs the sub-class specific configuration tab initialization.
*
* @param config
- * launch configuration
+ * launch configuration
*
* @see #initializeFrom(ILaunchConfiguration)
*/
@@ -342,7 +342,7 @@
* Validate the specified toolkit is valid for the launch configuration
*
* @param toolkit
- * language toolkit
+ * language toolkit
*
* @return <code>true</code> if the toolkit is valid for the launch
* configuration, <code>false</code> otherwise
@@ -365,7 +365,7 @@
* </p>
*
* @param group
- * group composite
+ * group composite
*/
private void addBreakOnFirstLineButton(Composite group) {
breakOnFirstLine = createCheckButton(group,
@@ -383,7 +383,7 @@
* </p>
*
* @param group
- * group composite
+ * group composite
*/
private void addDbgpLoggingButton(Composite group) {
enableLogging = createCheckButton(group,
@@ -463,7 +463,7 @@
* </p>
*
* @param parent
- * the parent composite
+ * the parent composite
*/
protected void createProjectEditor(Composite parent) {
final Composite editParent;
@@ -631,10 +631,10 @@
if (!validateProject(project)) {
String msg = Messages.format(
DLTKLaunchConfigurationsMessages.mainTab_errorDlg_notALangProject,
- new String[] { getLanguageName() });
+ getLanguageName());
String reason = Messages.format(
DLTKLaunchConfigurationsMessages.mainTab_errorDlg_reasonNotALangProject,
- new String[] { getLanguageName() });
+ getLanguageName());
ErrorDialog.openError(getShell(),
DLTKLaunchConfigurationsMessages.mainTab_errorDlg_invalidProject,
msg, DLTKUIStatus.createError(IStatus.ERROR, reason, null));
@@ -649,7 +649,7 @@
* Sets the name of the project associated with the launch configuration
*
* @param name
- * project name
+ * project name
*/
protected final void setProjectName(String name) {
setProjectName(name, new PreferencesLookupDelegate(
@@ -672,7 +672,7 @@
* updates the project text field form the configuration
*
* @param config
- * the configuration we are editing
+ * the configuration we are editing
*/
protected void updateProjectFromConfig(ILaunchConfiguration config) {
String projectName = LaunchConfigurationUtils.getProjectName(config);
diff --git a/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.core.prefs b/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.core.prefs
index 3cc361a..9debb29 100644
--- a/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.core.prefs
@@ -109,8 +109,10 @@
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_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
@@ -119,17 +121,25 @@
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_enum_constants=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_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_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
@@ -149,26 +159,36 @@
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.align_tags_descriptions_grouped=true
+org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_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.indent_parameter_description=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
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.insert_new_line_for_parameter=do not insert
org.eclipse.jdt.core.formatter.comment.line_length=80
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+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=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
@@ -180,7 +200,16 @@
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_enum_constant=insert
+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
@@ -199,7 +228,7 @@
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_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
@@ -228,6 +257,7 @@
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
@@ -246,12 +276,14 @@
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
@@ -275,6 +307,7 @@
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
@@ -302,6 +335,7 @@
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
@@ -330,6 +364,7 @@
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
@@ -339,6 +374,7 @@
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
@@ -348,17 +384,35 @@
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=80
+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.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_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/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.ui.prefs b/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.ui.prefs
index 9f776e8..287577d 100644
--- a/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.ui.prefs
+++ b/core/plugins/org.eclipse.dltk.ui/.settings/org.eclipse.jdt.ui.prefs
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
-formatter_settings_version=11
+formatter_settings_version=14
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyPackageFragmentRootChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyPackageFragmentRootChange.java
index 91161c6..c74bafc 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyPackageFragmentRootChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyPackageFragmentRootChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -21,25 +21,20 @@
public class CopyPackageFragmentRootChange extends ProjectFragmentReorgChange {
- public CopyPackageFragmentRootChange(IProjectFragment root,
- IProject destination, INewNameQuery newNameQuery,
+ public CopyPackageFragmentRootChange(IProjectFragment root, IProject destination, INewNameQuery newNameQuery,
IProjectFragmentManipulationQuery updateBuildpathQuery) {
super(root, destination, newNameQuery, updateBuildpathQuery);
}
@Override
- protected Change doPerformReorg(IPath destinationPath, IProgressMonitor pm)
- throws ModelException {
- getRoot().copy(destinationPath, getResourceUpdateFlags(),
- getUpdateModelFlags(true), null, pm);
+ protected Change doPerformReorg(IPath destinationPath, IProgressMonitor pm) throws ModelException {
+ getRoot().copy(destinationPath, getResourceUpdateFlags(), getUpdateModelFlags(true), null, pm);
return null;
}
@Override
public String getName() {
- String[] keys = { getRoot().getElementName(),
- getDestinationProject().getName() };
- return Messages.format(RefactoringCoreMessages.CopyPackageChange_copy,
- keys);
+ return Messages.format(RefactoringCoreMessages.CopyPackageChange_copy, getRoot().getElementName(),
+ getDestinationProject().getName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyProjectFragmentChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyProjectFragmentChange.java
index e59ce3e..b8975d3 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyProjectFragmentChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyProjectFragmentChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -19,10 +19,10 @@
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.ltk.core.refactoring.Change;
-
public class CopyProjectFragmentChange extends ProjectFragmentReorgChange {
- public CopyProjectFragmentChange(IProjectFragment root, IProject destination, INewNameQuery newNameQuery, IProjectFragmentManipulationQuery updateClasspathQuery) {
+ public CopyProjectFragmentChange(IProjectFragment root, IProject destination, INewNameQuery newNameQuery,
+ IProjectFragmentManipulationQuery updateClasspathQuery) {
super(root, destination, newNameQuery, updateClasspathQuery);
}
@@ -34,7 +34,7 @@
@Override
public String getName() {
- String[] keys= {getRoot().getElementName(), getDestinationProject().getName()};
- return Messages.format(RefactoringCoreMessages.CopyProjectFragmentChange_copy, keys);
+ return Messages.format(RefactoringCoreMessages.CopyProjectFragmentChange_copy, getRoot().getElementName(),
+ getDestinationProject().getName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyResourceChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyResourceChange.java
index 18d365e..a8a8f2a 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyResourceChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyResourceChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -19,10 +19,9 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class CopyResourceChange extends ResourceReorgChange {
- public CopyResourceChange(IResource res, IContainer dest, INewNameQuery newNameQuery){
+ public CopyResourceChange(IResource res, IContainer dest, INewNameQuery newNameQuery) {
super(res, dest, newNameQuery);
}
@@ -36,14 +35,14 @@
}
@Override
- protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException{
+ protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException {
getResource().copy(path, getReorgFlags(), pm);
return null;
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.CopyResourceString_copy,
- new String[]{getResource().getFullPath().toString(), getDestination().getName()});
+ return Messages.format(RefactoringCoreMessages.CopyResourceString_copy, getResource().getFullPath().toString(),
+ getDestination().getName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyScriptFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyScriptFolderChange.java
index e3e51d9..5c4e38d 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyScriptFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopyScriptFolderChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -23,26 +23,22 @@
public class CopyScriptFolderChange extends PackageReorgChange {
- public CopyScriptFolderChange(IScriptFolder pack, IProjectFragment dest,
- INewNameQuery nameQuery) {
+ public CopyScriptFolderChange(IScriptFolder pack, IProjectFragment dest, INewNameQuery nameQuery) {
super(pack, dest, nameQuery);
}
@Override
- protected Change doPerformReorg(IProgressMonitor pm) throws ModelException,
- OperationCanceledException {
+ protected Change doPerformReorg(IProgressMonitor pm) throws ModelException, OperationCanceledException {
getPackage().copy(getDestination(), null, getNewName(), true, pm);
return null;
}
@Override
public String getName() {
- String packageName = ScriptElementLabels.getDefault().getElementLabel(
- getPackage(), ScriptElementLabels.ALL_DEFAULT);
- String destinationName = ScriptElementLabels.getDefault()
- .getElementLabel(getDestination(),
- ScriptElementLabels.ALL_DEFAULT);
- return Messages.format(RefactoringCoreMessages.CopyPackageChange_copy,
- new String[] { packageName, destinationName });
+ String packageName = ScriptElementLabels.getDefault().getElementLabel(getPackage(),
+ ScriptElementLabels.ALL_DEFAULT);
+ String destinationName = ScriptElementLabels.getDefault().getElementLabel(getDestination(),
+ ScriptElementLabels.ALL_DEFAULT);
+ return Messages.format(RefactoringCoreMessages.CopyPackageChange_copy, packageName, destinationName);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopySourceModuleChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopySourceModuleChange.java
index a3126dc..2bc8c95 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopySourceModuleChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/CopySourceModuleChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -18,10 +18,9 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class CopySourceModuleChange extends SourceModuleReorgChange {
- public CopySourceModuleChange(ISourceModule cu, IScriptFolder dest, INewNameQuery newNameQuery){
+ public CopySourceModuleChange(ISourceModule cu, IScriptFolder dest, INewNameQuery newNameQuery) {
super(cu, dest, newNameQuery);
}
@@ -42,7 +41,7 @@
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.CopySourceModuleChange_copy,
- new String[]{getCu().getElementName(), getPackageName(getDestinationPackage())});
+ return Messages.format(RefactoringCoreMessages.CopySourceModuleChange_copy, getCu().getElementName(),
+ getPackageName(getDestinationPackage()));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MovePackageChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MovePackageChange.java
index 8dab287..6c777ca 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MovePackageChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MovePackageChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -16,22 +16,21 @@
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.ltk.core.refactoring.Change;
-
public class MovePackageChange extends ScriptFolderReorgChange {
-
- public MovePackageChange(IScriptFolder pack, IProjectFragment dest){
+
+ public MovePackageChange(IScriptFolder pack, IProjectFragment dest) {
super(pack, dest, null);
}
-
+
@Override
- protected Change doPerformReorg(IProgressMonitor pm) throws ModelException{
+ protected Change doPerformReorg(IProgressMonitor pm) throws ModelException {
getPackage().move(getDestination(), null, getNewName(), true, pm);
return null;
}
-
+
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.MovePackageChange_move,
- new String[]{getPackage().getElementName(), getDestination().getElementName()});
+ return Messages.format(RefactoringCoreMessages.MovePackageChange_move, getPackage().getElementName(),
+ getDestination().getElementName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveProjectFragmentChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveProjectFragmentChange.java
index 8c5fbc1..02b1873 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveProjectFragmentChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveProjectFragmentChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -18,10 +18,10 @@
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.ltk.core.refactoring.Change;
-
public class MoveProjectFragmentChange extends ProjectFragmentReorgChange {
- public MoveProjectFragmentChange(IProjectFragment root, IProject destination, IProjectFragmentManipulationQuery updateClasspathQuery) {
+ public MoveProjectFragmentChange(IProjectFragment root, IProject destination,
+ IProjectFragmentManipulationQuery updateClasspathQuery) {
super(root, destination, null, updateClasspathQuery);
}
@@ -33,7 +33,7 @@
@Override
public String getName() {
- String[] keys= {getRoot().getElementName(), getDestinationProject().getName()};
- return Messages.format(RefactoringCoreMessages.MoveProjectFragmentChange_move, keys);
+ return Messages.format(RefactoringCoreMessages.MoveProjectFragmentChange_move, getRoot().getElementName(),
+ getDestinationProject().getName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveResourceChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveResourceChange.java
index d1954c3..43783d2 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveResourceChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveResourceChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -18,10 +18,9 @@
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class MoveResourceChange extends ResourceReorgChange {
- public MoveResourceChange(IResource res, IContainer dest){
+ public MoveResourceChange(IResource res, IContainer dest) {
super(res, dest, null);
}
@@ -36,15 +35,14 @@
}
@Override
- protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException{
+ protected Change doPerformReorg(IPath path, IProgressMonitor pm) throws CoreException {
getResource().move(path, getReorgFlags(), pm);
return null;
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.MoveResourceChange_move,
- new String[]{getResource().getFullPath().toString(), getDestination().getName()});
+ return Messages.format(RefactoringCoreMessages.MoveResourceChange_move, getResource().getFullPath().toString(),
+ getDestination().getName());
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveScriptFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveScriptFolderChange.java
index 44167b2..8d504fb 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveScriptFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/MoveScriptFolderChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -16,22 +16,21 @@
import org.eclipse.dltk.internal.corext.util.Messages;
import org.eclipse.ltk.core.refactoring.Change;
-
public class MoveScriptFolderChange extends ScriptFolderReorgChange {
- public MoveScriptFolderChange(IScriptFolder pack, IProjectFragment dest){
+ public MoveScriptFolderChange(IScriptFolder pack, IProjectFragment dest) {
super(pack, dest, null);
}
@Override
- protected Change doPerformReorg(IProgressMonitor pm) throws ModelException{
+ protected Change doPerformReorg(IProgressMonitor pm) throws ModelException {
getPackage().move(getDestination(), null, getNewName(), true, pm);
return null;
}
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.MovePackageChange_move,
- new String[]{getPackage().getElementName(), getDestination().getElementName()});
+ return Messages.format(RefactoringCoreMessages.MovePackageChange_move, getPackage().getElementName(),
+ getDestination().getElementName());
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptFolderChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptFolderChange.java
index 7b79776..e291803 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptFolderChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptFolderChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -33,40 +33,41 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public class RenameScriptFolderChange extends AbstractModelElementRenameChange {
private Map fSourceModuleStamps;
private final boolean fRenameSubpackages;
- public RenameScriptFolderChange(RefactoringDescriptor descriptor, IScriptFolder pack, String newName, String comment, boolean renameSubpackages) {
- this(descriptor, pack.getPath(), pack.getElementName(), newName, comment, IResource.NULL_STAMP, null, renameSubpackages);
+ public RenameScriptFolderChange(RefactoringDescriptor descriptor, IScriptFolder pack, String newName,
+ String comment, boolean renameSubpackages) {
+ this(descriptor, pack.getPath(), pack.getElementName(), newName, comment, IResource.NULL_STAMP, null,
+ renameSubpackages);
Assert.isTrue(!pack.isReadOnly(), "package must not be read only"); //$NON-NLS-1$
}
- private RenameScriptFolderChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore,
- Map compilationUnitStamps, boolean renameSubpackages) {
+ private RenameScriptFolderChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName,
+ String newName, String comment, long stampToRestore, Map compilationUnitStamps, boolean renameSubpackages) {
super(descriptor, resourcePath, oldName, newName, comment, stampToRestore);
- fSourceModuleStamps= compilationUnitStamps;
- fRenameSubpackages= renameSubpackages;
+ fSourceModuleStamps = compilationUnitStamps;
+ fRenameSubpackages = renameSubpackages;
}
-
+
@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
- RefactoringStatus result= new RefactoringStatus();
- IModelElement element= (IModelElement)getModifiedElement();
- // don't check for read-only since we don't go through
+ RefactoringStatus result = new RefactoringStatus();
+ IModelElement element = (IModelElement) getModifiedElement();
+ // don't check for read-only since we don't go through
// validate edit.
result.merge(isValid(DIRTY));
if (result.hasFatalError())
return result;
if (element != null && element.exists() && element instanceof IScriptFolder) {
- IScriptFolder pack= (IScriptFolder)element;
+ IScriptFolder pack = (IScriptFolder) element;
if (fRenameSubpackages) {
- IScriptFolder[] allPackages= ModelElementUtil.getPackageAndSubpackages(pack);
+ IScriptFolder[] allPackages = ModelElementUtil.getPackageAndSubpackages(pack);
pm.beginTask("", allPackages.length); //$NON-NLS-1$
- for (int i= 0; i < allPackages.length; i++) {
- // don't check for read-only since we don't go through
+ for (int i = 0; i < allPackages.length; i++) {
+ // don't check for read-only since we don't go through
// validate edit.
checkIfModifiable(result, allPackages[i], DIRTY);
if (result.hasFatalError())
@@ -82,11 +83,11 @@
}
private void isValid(RefactoringStatus result, IScriptFolder pack, IProgressMonitor pm) throws ModelException {
- ISourceModule[] units= pack.getSourceModules();
+ ISourceModule[] units = pack.getSourceModules();
pm.beginTask("", units.length); //$NON-NLS-1$
- for (int i= 0; i < units.length; i++) {
- pm.subTask(Messages.format(
- RefactoringCoreMessages.RenamePackageChange_checking_change, pack.getElementName()));
+ for (int i = 0; i < units.length; i++) {
+ pm.subTask(Messages.format(RefactoringCoreMessages.RenamePackageChange_checking_change,
+ pack.getElementName()));
checkIfModifiable(result, units[i], READ_ONLY | DIRTY);
pm.worked(1);
}
@@ -95,9 +96,9 @@
@Override
protected IPath createNewPath() {
- IScriptFolder oldPackage= getPackage();
- IPath oldPackageName= createPath(oldPackage.getElementName());
- IPath newPackageName= createPath(getNewName());
+ IScriptFolder oldPackage = getPackage();
+ IPath oldPackageName = createPath(oldPackage.getElementName());
+ IPath newPackageName = createPath(getNewName());
return getResourcePath().removeLastSegments(oldPackageName.segmentCount()).append(newPackageName);
}
@@ -106,47 +107,48 @@
}
protected IPath createNewPath(IScriptFolder oldPackage) {
- IPath oldPackagePath= createPath(oldPackage.getElementName());
- IPath newPackagePath= createPath(getNewName(oldPackage));
+ IPath oldPackagePath = createPath(oldPackage.getElementName());
+ IPath newPackagePath = createPath(getNewName(oldPackage));
return oldPackage.getPath().removeLastSegments(oldPackagePath.segmentCount()).append(newPackagePath);
}
-
+
private String getNewName(IScriptFolder subpackage) {
return getNewName() + subpackage.getElementName().substring(getOldName().length());
}
@Override
public String getName() {
- String msg= fRenameSubpackages
- ? RefactoringCoreMessages.RenamePackageChange_name_with_subpackages
+ String msg = fRenameSubpackages ? RefactoringCoreMessages.RenamePackageChange_name_with_subpackages
: RefactoringCoreMessages.RenamePackageChange_name;
- return Messages.format(msg, new String[]{getOldName(), getNewName()});
+ return Messages.format(msg, getOldName(), getNewName());
}
@Override
protected Change createUndoChange(long stampToRestore) throws CoreException {
- IScriptFolder pack= getPackage();
+ IScriptFolder pack = getPackage();
if (pack == null)
return new NullChange();
- Map stamps= new HashMap();
- if (! fRenameSubpackages) {
+ Map stamps = new HashMap();
+ if (!fRenameSubpackages) {
addStamps(stamps, pack.getSourceModules());
} else {
- IScriptFolder[] allPackages= ModelElementUtil.getPackageAndSubpackages(pack);
- for (int i= 0; i < allPackages.length; i++) {
- IScriptFolder currentPackage= allPackages[i];
+ IScriptFolder[] allPackages = ModelElementUtil.getPackageAndSubpackages(pack);
+ for (int i = 0; i < allPackages.length; i++) {
+ IScriptFolder currentPackage = allPackages[i];
addStamps(stamps, currentPackage.getSourceModules());
}
}
- return new RenameScriptFolderChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore, stamps, fRenameSubpackages);
- // Note: This reverse change only works if the renamePackage change did not merge the source package into an existing target.
+ return new RenameScriptFolderChange(null, createNewPath(), getNewName(), getOldName(), getComment(),
+ stampToRestore, stamps, fRenameSubpackages);
+ // Note: This reverse change only works if the renamePackage change did
+ // not merge the source package into an existing target.
}
private void addStamps(Map stamps, ISourceModule[] units) {
- for (int i= 0; i < units.length; i++) {
- IResource resource= units[i].getResource();
- long stamp= IResource.NULL_STAMP;
- if (resource != null && (stamp= resource.getModificationStamp()) != IResource.NULL_STAMP) {
+ for (int i = 0; i < units.length; i++) {
+ IResource resource = units[i].getResource();
+ long stamp = IResource.NULL_STAMP;
+ if (resource != null && (stamp = resource.getModificationStamp()) != IResource.NULL_STAMP) {
stamps.put(resource, Long.valueOf(stamp));
}
}
@@ -154,20 +156,21 @@
@Override
protected void doRename(IProgressMonitor pm) throws CoreException {
- IScriptFolder pack= getPackage();
+ IScriptFolder pack = getPackage();
if (pack == null)
return;
-
- if (! fRenameSubpackages) {
+
+ if (!fRenameSubpackages) {
renamePackage(pack, pm, createNewPath(), getNewName());
} else {
- IScriptFolder[] allPackages= ModelElementUtil.getPackageAndSubpackages(pack);
-
+ IScriptFolder[] allPackages = ModelElementUtil.getPackageAndSubpackages(pack);
+
pm.beginTask("", allPackages.length); //$NON-NLS-1$
try {
- for (int i= 0; i < allPackages.length; i++) {
- IScriptFolder currentPackage= allPackages[i];
- renamePackage(currentPackage, new SubProgressMonitor(pm, 1), createNewPath(currentPackage), getNewName(currentPackage));
+ for (int i = 0; i < allPackages.length; i++) {
+ IScriptFolder currentPackage = allPackages[i];
+ renamePackage(currentPackage, new SubProgressMonitor(pm, 1), createNewPath(currentPackage),
+ getNewName(currentPackage));
}
} finally {
pm.done();
@@ -175,17 +178,18 @@
}
}
- private void renamePackage(IScriptFolder pack, IProgressMonitor pm, IPath newPath, String newName) throws ModelException, CoreException {
+ private void renamePackage(IScriptFolder pack, IProgressMonitor pm, IPath newPath, String newName)
+ throws ModelException, CoreException {
pack.rename(newName, false, pm);
if (fSourceModuleStamps != null) {
- IScriptFolder newPack= (IScriptFolder)DLTKCore.create(
- ResourcesPlugin.getWorkspace().getRoot().getFolder(newPath));
+ IScriptFolder newPack = (IScriptFolder) DLTKCore
+ .create(ResourcesPlugin.getWorkspace().getRoot().getFolder(newPath));
if (newPack.exists()) {
- ISourceModule[] units= newPack.getSourceModules();
- for (int i= 0; i < units.length; i++) {
- IResource resource= units[i].getResource();
+ ISourceModule[] units = newPack.getSourceModules();
+ for (int i = 0; i < units.length; i++) {
+ IResource resource = units[i].getResource();
if (resource != null) {
- Long stamp= (Long)fSourceModuleStamps.get(resource);
+ Long stamp = (Long) fSourceModuleStamps.get(resource);
if (stamp != null) {
resource.revertModificationStamp(stamp.longValue());
}
@@ -196,6 +200,6 @@
}
private IScriptFolder getPackage() {
- return (IScriptFolder)getModifiedElement();
+ return (IScriptFolder) getModifiedElement();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptProjectChange.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptProjectChange.java
index f5bc5f3..8a9006c 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptProjectChange.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/changes/RenameScriptProjectChange.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -27,23 +27,26 @@
import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-
public final class RenameScriptProjectChange extends AbstractModelElementRenameChange {
private boolean fUpdateReferences;
- public RenameScriptProjectChange(RefactoringDescriptor descriptor, IScriptProject project, String newName, String comment, boolean updateReferences) {
- this(descriptor, project.getPath(), project.getElementName(), newName, comment, IResource.NULL_STAMP, updateReferences);
+ public RenameScriptProjectChange(RefactoringDescriptor descriptor, IScriptProject project, String newName,
+ String comment, boolean updateReferences) {
+ this(descriptor, project.getPath(), project.getElementName(), newName, comment, IResource.NULL_STAMP,
+ updateReferences);
Assert.isTrue(!project.isReadOnly(), "should not be read only"); //$NON-NLS-1$
}
- private RenameScriptProjectChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName, String newName, String comment, long stampToRestore, boolean updateReferences) {
+ private RenameScriptProjectChange(RefactoringDescriptor descriptor, IPath resourcePath, String oldName,
+ String newName, String comment, long stampToRestore, boolean updateReferences) {
super(descriptor, resourcePath, oldName, newName, comment);
- fUpdateReferences= updateReferences;
+ fUpdateReferences = updateReferences;
}
private IBuildpathEntry createModifiedEntry(IBuildpathEntry oldEntry) {
- return DLTKCore.newProjectEntry(createNewPath(), oldEntry.getAccessRules(), oldEntry.combineAccessRules(), oldEntry.getExtraAttributes(), oldEntry.isExported());
+ return DLTKCore.newProjectEntry(createNewPath(), oldEntry.getAccessRules(), oldEntry.combineAccessRules(),
+ oldEntry.getExtraAttributes(), oldEntry.isExported());
}
@Override
@@ -53,7 +56,8 @@
@Override
protected Change createUndoChange(long stampToRestore) throws ModelException {
- return new RenameScriptProjectChange(null, createNewPath(), getNewName(), getOldName(), getComment(), stampToRestore, fUpdateReferences);
+ return new RenameScriptProjectChange(null, createNewPath(), getNewName(), getOldName(), getComment(),
+ stampToRestore, fUpdateReferences);
}
@Override
@@ -62,9 +66,9 @@
pm.beginTask(getName(), 2);
if (fUpdateReferences)
modifyBuildpaths(new SubProgressMonitor(pm, 1));
- IProject project= getProject();
+ IProject project = getProject();
if (project != null) {
- IProjectDescription description= project.getDescription();
+ IProjectDescription description = project.getDescription();
description.setName(getNewName());
project.move(description, IResource.FORCE | IResource.SHALLOW, new SubProgressMonitor(pm, 1));
}
@@ -79,11 +83,11 @@
@Override
public String getName() {
- return Messages.format(RefactoringCoreMessages.RenameScriptProjectChange_rename, new String[] { getOldName(), getNewName()});
+ return Messages.format(RefactoringCoreMessages.RenameScriptProjectChange_rename, getOldName(), getNewName());
}
private IProject getProject() {
- IScriptProject jp= getScriptProject();
+ IScriptProject jp = getScriptProject();
if (jp == null)
return null;
return jp.getProject();
@@ -104,23 +108,23 @@
private void modifyBuildpath(IScriptProject referencingProject, IProgressMonitor pm) throws ModelException {
pm.beginTask("", 1); //$NON-NLS-1$
- IBuildpathEntry[] oldEntries= referencingProject.getRawBuildpath();
- IBuildpathEntry[] newEntries= new IBuildpathEntry[oldEntries.length];
- for (int i= 0; i < newEntries.length; i++) {
+ IBuildpathEntry[] oldEntries = referencingProject.getRawBuildpath();
+ IBuildpathEntry[] newEntries = new IBuildpathEntry[oldEntries.length];
+ for (int i = 0; i < newEntries.length; i++) {
if (isOurEntry(oldEntries[i]))
- newEntries[i]= createModifiedEntry(oldEntries[i]);
+ newEntries[i] = createModifiedEntry(oldEntries[i]);
else
- newEntries[i]= oldEntries[i];
+ newEntries[i] = oldEntries[i];
}
referencingProject.setRawBuildpath(newEntries, pm);
pm.done();
}
private void modifyBuildpaths(IProgressMonitor pm) throws ModelException {
- IProject[] referencing= getProject().getReferencingProjects();
+ IProject[] referencing = getProject().getReferencingProjects();
pm.beginTask(RefactoringCoreMessages.RenameScriptProjectChange_update, referencing.length);
- for (int i= 0; i < referencing.length; i++) {
- IScriptProject jp= DLTKCore.create(referencing[i]);
+ for (int i = 0; i < referencing.length; i++) {
+ IScriptProject jp = DLTKCore.create(referencing[i]);
if (jp != null && jp.exists()) {
modifyBuildpath(jp, new SubProgressMonitor(pm, 1));
} else {
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameResourceProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameResourceProcessor.java
index 9859aed..8f80a5c 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameResourceProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameResourceProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -57,9 +57,8 @@
/**
* Creates a new rename resource processor.
- *
- * @param resource
- * the resource, or <code>null</code> if invoked by scripting
+ *
+ * @param resource the resource, or <code>null</code> if invoked by scripting
*/
public RenameResourceProcessor(IResource resource) {
fResource = resource;
@@ -114,8 +113,7 @@
@Override
public Object getNewElement() {
- return ResourcesPlugin.getWorkspace().getRoot()
- .findMember(createNewPath(getNewElementName()));
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(createNewPath(getNewElementName()));
}
public boolean getUpdateReferences() {
@@ -123,58 +121,52 @@
}
@Override
- public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
- SharableParticipants shared) throws CoreException {
- return fRenameModifications.loadParticipants(status, this,
- getAffectedProjectNatures(), shared);
+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared)
+ throws CoreException {
+ return fRenameModifications.loadParticipants(status, this, getAffectedProjectNatures(), shared);
}
// --- Condition checking --------------------------------------------
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
return RefactoringStatus.create(Resources.checkInSync(fResource));
}
@Override
- public RefactoringStatus checkNewElementName(String newName)
- throws ModelException {
+ public RefactoringStatus checkNewElementName(String newName) throws ModelException {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
IContainer c = fResource.getParent();
if (c == null)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenameResourceRefactoring_Internal_Error);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_Internal_Error);
if (c.findMember(newName) != null)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenameResourceRefactoring_alread_exists);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_alread_exists);
if (!c.getFullPath().isValidSegment(newName))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenameResourceRefactoring_invalidName);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenameResourceRefactoring_invalidName);
- RefactoringStatus result = RefactoringStatus.create(
- c.getWorkspace().validateName(newName, fResource.getType()));
+ RefactoringStatus result = RefactoringStatus
+ .create(c.getWorkspace().validateName(newName, fResource.getType()));
if (!result.hasFatalError())
- result.merge(RefactoringStatus.create(c.getWorkspace().validatePath(
- createNewPath(newName), fResource.getType())));
+ result.merge(RefactoringStatus
+ .create(c.getWorkspace().validatePath(createNewPath(newName), fResource.getType())));
return result;
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws ModelException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws ModelException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
fRenameModifications = new RenameModifications();
- fRenameModifications.rename(fResource, new RenameArguments(
- getNewElementName(), getUpdateReferences()));
+ fRenameModifications.rename(fResource, new RenameArguments(getNewElementName(), getUpdateReferences()));
- ResourceChangeChecker checker = context
- .getChecker(ResourceChangeChecker.class);
- IResourceChangeDescriptionFactory deltaFactory = checker
- .getDeltaFactory();
+ ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class);
+ IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
fRenameModifications.buildDelta(deltaFactory);
return new RefactoringStatus();
@@ -184,8 +176,7 @@
}
private String createNewPath(String newName) {
- return fResource.getFullPath().removeLastSegments(1).append(newName)
- .toString();
+ return fResource.getFullPath().removeLastSegments(1).append(newName).toString();
}
// --- changes
@@ -198,28 +189,20 @@
String project = null;
if (fResource.getType() != IResource.PROJECT)
project = fResource.getProject().getName();
- final String header = Messages.format(
- RefactoringCoreMessages.RenameResourceChange_descriptor_description,
- new String[] { fResource.getFullPath().toString(),
- getNewElementName() });
+ final String header = Messages.format(RefactoringCoreMessages.RenameResourceChange_descriptor_description,
+ fResource.getFullPath().toString(), getNewElementName());
final String description = Messages.format(
- RefactoringCoreMessages.RenameResourceChange_descriptor_description_short,
- fResource.getName());
- final String comment = new ScriptRefactoringDescriptorComment(this,
- header).asString();
+ RefactoringCoreMessages.RenameResourceChange_descriptor_description_short, fResource.getName());
+ final String comment = new ScriptRefactoringDescriptorComment(this, header).asString();
final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
- RenameResourceProcessor.ID_RENAME_RESOURCE, project,
- description, comment, arguments,
- RefactoringDescriptor.STRUCTURAL_CHANGE
- | RefactoringDescriptor.MULTI_CHANGE
+ RenameResourceProcessor.ID_RENAME_RESOURCE, project, description, comment, arguments,
+ RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE
| RefactoringDescriptor.BREAKING_CHANGE);
arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
- ScriptRefactoringDescriptor.resourceToHandle(project,
- fResource));
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME,
- getNewElementName());
- return new DynamicValidationStateChange(new RenameResourceChange(
- descriptor, fResource, getNewElementName(), comment));
+ ScriptRefactoringDescriptor.resourceToHandle(project, fResource));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, getNewElementName());
+ return new DynamicValidationStateChange(
+ new RenameResourceChange(descriptor, fResource, getNewElementName(), comment));
} finally {
pm.done();
}
@@ -229,30 +212,26 @@
public RefactoringStatus initialize(final RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
final ScriptRefactoringArguments extended = (ScriptRefactoringArguments) arguments;
- final String handle = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
+ final String handle = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
if (handle != null) {
- fResource = ScriptRefactoringDescriptor
- .handleToResource(extended.getProject(), handle);
+ fResource = ScriptRefactoringDescriptor.handleToResource(extended.getProject(), handle);
if (fResource == null || !fResource.exists())
- return ScriptableRefactoring.createInputFatalStatus(
- fResource, getRefactoring().getName(),
+ return ScriptableRefactoring.createInputFatalStatus(fResource, getRefactoring().getName(),
ID_RENAME_RESOURCE);
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
- final String name = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
+ final String name = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
} else
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
index b6ccb9d..c50eb1a 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptFolderProcessor.java
@@ -72,8 +72,7 @@
private TextChangeManager fChangeManager;
static {
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: RenameScriptFolderProcessor add import manager supprot code here..."); //$NON-NLS-1$
+ System.err.println("TODO: RenameScriptFolderProcessor add import manager supprot code here..."); //$NON-NLS-1$
}
}
// private ImportsManager fImportsManager;
@@ -90,9 +89,8 @@
/**
* Creates a new rename package processor.
*
- * @param fragment
- * the package fragment, or <code>null</code> if invoked
- * by scripting
+ * @param fragment the package fragment, or <code>null</code> if invoked by
+ * scripting
*/
public RenameScriptFolderProcessor(IScriptFolder fragment) {
fPackage = fragment;
@@ -129,34 +127,26 @@
}
@Override
- protected RenameModifications computeRenameModifications()
- throws CoreException {
+ protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
- result.rename(fPackage,
- new RenameArguments(getNewElementName(), getUpdateReferences()),
- fRenameSubpackages);
+ result.rename(fPackage, new RenameArguments(getNewElementName(), getUpdateReferences()), fRenameSubpackages);
return result;
}
@Override
protected IFile[] getChangedFiles() throws CoreException {
Set<IFile> combined = new HashSet<>();
- combined.addAll(Arrays.asList(
- ResourceUtil.getFiles(fChangeManager.getAllSourceModules())));
+ combined.addAll(Arrays.asList(ResourceUtil.getFiles(fChangeManager.getAllSourceModules())));
if (fRenameSubpackages) {
- IScriptFolder[] allPackages = ModelElementUtil
- .getPackageAndSubpackages(fPackage);
+ IScriptFolder[] allPackages = ModelElementUtil.getPackageAndSubpackages(fPackage);
for (int i = 0; i < allPackages.length; i++) {
- combined.addAll(Arrays.asList(ResourceUtil
- .getFiles(allPackages[i].getSourceModules())));
+ combined.addAll(Arrays.asList(ResourceUtil.getFiles(allPackages[i].getSourceModules())));
}
} else {
- combined.addAll(Arrays.asList(
- ResourceUtil.getFiles(fPackage.getSourceModules())));
+ combined.addAll(Arrays.asList(ResourceUtil.getFiles(fPackage.getSourceModules())));
}
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: RenameScriptFolderProcessor Add fQualifiedNameSearchResult suppor code"); //$NON-NLS-1$
+ System.err.println("TODO: RenameScriptFolderProcessor Add fQualifiedNameSearchResult suppor code"); //$NON-NLS-1$
}
// if (fQualifiedNameSearchResult != null)
// combined.addAll(Arrays.asList(fQualifiedNameSearchResult.getAllFiles()));
@@ -252,23 +242,19 @@
}
@Override
- public RefactoringStatus checkNewElementName(String newName)
- throws CoreException {
+ public RefactoringStatus checkNewElementName(String newName) throws CoreException {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
// RefactoringStatus result= Checks.checkPackageName(newName);
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: Add correct package name validation here..."); //$NON-NLS-1$
+ System.err.println("TODO: Add correct package name validation here..."); //$NON-NLS-1$
}
// #replace begin
RefactoringStatus result = new RefactoringStatus();
if ("".equals(newName)) //$NON-NLS-1$
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.Checks_Choose_name);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.Checks_Choose_name);
// #end
if (Checks.isAlreadyNamed(fPackage, newName))
- result.addFatalError(
- RefactoringCoreMessages.RenamePackageRefactoring_another_name);
+ result.addFatalError(RefactoringCoreMessages.RenamePackageRefactoring_another_name);
result.merge(checkPackageInCurrentRoot(newName));
return result;
}
@@ -284,18 +270,16 @@
}
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
return new RefactoringStatus();
}
@Override
- protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws CoreException {
+ protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws CoreException {
try {
pm.beginTask("", 23 + (fUpdateQualifiedNames ? 10 : 0)); //$NON-NLS-1$
- pm.setTaskName(
- RefactoringCoreMessages.RenamePackageRefactoring_checking);
+ pm.setTaskName(RefactoringCoreMessages.RenamePackageRefactoring_checking);
RefactoringStatus result = new RefactoringStatus();
result.merge(checkNewElementName(getNewElementName()));
pm.worked(1);
@@ -303,13 +287,11 @@
pm.worked(2);
if (fPackage.isReadOnly()) {
- String message = Messages.format(
- RefactoringCoreMessages.RenamePackageRefactoring_Packagered_only,
+ String message = Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_Packagered_only,
fPackage.getElementName());
result.addFatalError(message);
} else if (Resources.isReadOnly(fPackage.getResource())) {
- String message = Messages.format(
- RefactoringCoreMessages.RenamePackageRefactoring_resource_read_only,
+ String message = Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_resource_read_only,
fPackage.getElementName());
result.addError(message);
}
@@ -323,27 +305,22 @@
SubProgressMonitor subPm = new SubProgressMonitor(pm, 16);
if (fRenameSubpackages) {
- IScriptFolder[] allSubpackages = ModelElementUtil
- .getPackageAndSubpackages(fPackage);
+ IScriptFolder[] allSubpackages = ModelElementUtil.getPackageAndSubpackages(fPackage);
subPm.beginTask("", allSubpackages.length); //$NON-NLS-1$
for (int i = 0; i < allSubpackages.length; i++) {
- new PackageRenamer(allSubpackages[i], this,
- fChangeManager/* , fImportsManager */).doRename(
- new SubProgressMonitor(subPm, 1), result);
+ new PackageRenamer(allSubpackages[i], this, fChangeManager/* , fImportsManager */)
+ .doRename(new SubProgressMonitor(subPm, 1), result);
}
subPm.done();
} else {
- new PackageRenamer(fPackage, this,
- fChangeManager/* , fImportsManager */).doRename(subPm,
- result);
+ new PackageRenamer(fPackage, this, fChangeManager/* , fImportsManager */).doRename(subPm, result);
}
// fImportsManager.rewriteImports(fChangeManager, new
// SubProgressMonitor(pm, 3));
if (DLTKCore.DEBUG) {
- System.err
- .println("TODO: Add updating of fUpdateQualifiedNames"); //$NON-NLS-1$
+ System.err.println("TODO: Add updating of fUpdateQualifiedNames"); //$NON-NLS-1$
}
// if (fUpdateQualifiedNames)
// computeQualifiedNameMatches(new SubProgressMonitor(pm, 10));
@@ -360,11 +337,10 @@
/*
* returns true if the new name is ok if the specified root. if a package
- * fragment with this name exists and has script resources, then the name is
- * not ok.
+ * fragment with this name exists and has script resources, then the name is not
+ * ok.
*/
- public static boolean isPackageNameOkInRoot(String newName,
- IProjectFragment root) throws CoreException {
+ public static boolean isPackageNameOkInRoot(String newName, IProjectFragment root) throws CoreException {
IScriptFolder pack = root.getScriptFolder(newName);
if (!pack.exists())
return true;
@@ -378,34 +354,28 @@
return true;
}
- private RefactoringStatus checkPackageInCurrentRoot(String newName)
- throws CoreException {
+ private RefactoringStatus checkPackageInCurrentRoot(String newName) throws CoreException {
if (isPackageNameOkInRoot(newName, getProjectFragment())) {
return null;
}
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenamePackageRefactoring_package_exists);
}
private IProjectFragment getProjectFragment() {
return ((IProjectFragment) fPackage.getParent());
}
- private RefactoringStatus checkPackageName(String newName)
- throws CoreException {
+ private RefactoringStatus checkPackageName(String newName) throws CoreException {
RefactoringStatus status = new RefactoringStatus();
- IProjectFragment[] roots = fPackage.getScriptProject()
- .getProjectFragments();
+ IProjectFragment[] roots = fPackage.getScriptProject().getProjectFragments();
Set topLevelTypeNames = getTopLevelTypeNames();
for (int i = 0; i < roots.length; i++) {
if (!isPackageNameOkInRoot(newName, roots[i])) {
- String message = Messages.format(
- RefactoringCoreMessages.RenamePackageRefactoring_aleady_exists,
- new Object[] { getNewElementName(),
- roots[i].getElementName() });
+ String message = Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_aleady_exists,
+ new Object[] { getNewElementName(), roots[i].getElementName() });
status.merge(RefactoringStatus.createWarningStatus(message));
- status.merge(checkTypeNameConflicts(roots[i], newName,
- topLevelTypeNames));
+ status.merge(checkTypeNameConflicts(roots[i], newName, topLevelTypeNames));
}
}
return status;
@@ -420,8 +390,7 @@
return result;
}
- private static Collection getTopLevelTypeNames(ISourceModule iSourceModule)
- throws CoreException {
+ private static Collection getTopLevelTypeNames(ISourceModule iSourceModule) throws CoreException {
IType[] types = iSourceModule.getTypes();
List result = new ArrayList(types.length);
for (int i = 0; i < types.length; i++) {
@@ -430,8 +399,8 @@
return result;
}
- private RefactoringStatus checkTypeNameConflicts(IProjectFragment root,
- String newName, Set topLevelTypeNames) throws CoreException {
+ private RefactoringStatus checkTypeNameConflicts(IProjectFragment root, String newName, Set topLevelTypeNames)
+ throws CoreException {
IScriptFolder otherPack = root.getScriptFolder(newName);
if (fPackage.equals(otherPack))
return null;
@@ -443,8 +412,7 @@
return result;
}
- private RefactoringStatus checkTypeNameConflicts(
- ISourceModule iSourceModule, Set topLevelTypeNames)
+ private RefactoringStatus checkTypeNameConflicts(ISourceModule iSourceModule, Set topLevelTypeNames)
throws CoreException {
RefactoringStatus result = new RefactoringStatus();
IType[] types = iSourceModule.getTypes();
@@ -453,11 +421,8 @@
String name = types[i].getElementName();
if (topLevelTypeNames.contains(name)) {
Object[] keys = { packageName, name };
- String msg = Messages.format(
- RefactoringCoreMessages.RenamePackageRefactoring_contains_type,
- keys);
- RefactoringStatusContext context = ScriptStatusContext
- .create(types[i]);
+ String msg = Messages.format(RefactoringCoreMessages.RenamePackageRefactoring_contains_type, keys);
+ RefactoringStatusContext context = ScriptStatusContext.create(types[i]);
result.addError(msg, context);
}
}
@@ -467,53 +432,37 @@
@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
try {
- monitor.beginTask(
- RefactoringCoreMessages.RenamePackageRefactoring_creating_change,
- 1);
+ monitor.beginTask(RefactoringCoreMessages.RenamePackageRefactoring_creating_change, 1);
final Map arguments = new HashMap();
String project = null;
IScriptProject scriptProject = fPackage.getScriptProject();
if (scriptProject != null)
project = scriptProject.getElementName();
final int flags = ScriptRefactoringDescriptor.ARCHIVE_IMPORTABLE
- | ScriptRefactoringDescriptor.ARCHIVE_REFACTORABLE
- | RefactoringDescriptor.STRUCTURAL_CHANGE
+ | ScriptRefactoringDescriptor.ARCHIVE_REFACTORABLE | RefactoringDescriptor.STRUCTURAL_CHANGE
| RefactoringDescriptor.MULTI_CHANGE;
final String description = Messages.format(
RefactoringCoreMessages.RenamePackageProcessor_descriptor_description_short,
fPackage.getElementName());
- final String header = Messages.format(
- RefactoringCoreMessages.RenamePackageProcessor_descriptor_description,
- new String[] { fPackage.getElementName(),
- getNewElementName() });
- final ScriptRefactoringDescriptorComment comment = new ScriptRefactoringDescriptorComment(
- this, header);
+ final String header = Messages.format(RefactoringCoreMessages.RenamePackageProcessor_descriptor_description,
+ fPackage.getElementName(), getNewElementName());
+ final ScriptRefactoringDescriptorComment comment = new ScriptRefactoringDescriptorComment(this, header);
if (fRenameSubpackages)
- comment.addSetting(
- RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages);
- final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
- ID_RENAME_PACKAGE, project, description, comment.asString(),
- arguments, flags);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
- descriptor.elementToHandle(fPackage));
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME,
- getNewElementName());
+ comment.addSetting(RefactoringCoreMessages.RenamePackageProcessor_rename_subpackages);
+ final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(ID_RENAME_PACKAGE, project,
+ description, comment.asString(), arguments, flags);
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor.elementToHandle(fPackage));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, getNewElementName());
if (fFilePatterns != null && !"".equals(fFilePatterns)) //$NON-NLS-1$
arguments.put(ATTRIBUTE_PATTERNS, fFilePatterns);
- arguments.put(ATTRIBUTE_REFERENCES,
- Boolean.valueOf(fUpdateReferences).toString());
- arguments.put(ATTRIBUTE_QUALIFIED,
- Boolean.valueOf(fUpdateQualifiedNames).toString());
- arguments.put(ATTRIBUTE_TEXTUAL_MATCHES,
- Boolean.valueOf(fUpdateTextualMatches).toString());
- arguments.put(ATTRIBUTE_HIERARCHICAL,
- Boolean.valueOf(fRenameSubpackages).toString());
- final DynamicValidationRefactoringChange result = new DynamicValidationRefactoringChange(
- descriptor,
+ arguments.put(ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
+ arguments.put(ATTRIBUTE_QUALIFIED, Boolean.valueOf(fUpdateQualifiedNames).toString());
+ arguments.put(ATTRIBUTE_TEXTUAL_MATCHES, Boolean.valueOf(fUpdateTextualMatches).toString());
+ arguments.put(ATTRIBUTE_HIERARCHICAL, Boolean.valueOf(fRenameSubpackages).toString());
+ final DynamicValidationRefactoringChange result = new DynamicValidationRefactoringChange(descriptor,
RefactoringCoreMessages.RenamePackageRefactoring_change_name);
result.addAll(fChangeManager.getAllChanges());
- result.add(new RenameScriptFolderChange(null, fPackage,
- getNewElementName(), comment.asString(),
+ result.add(new RenameScriptFolderChange(null, fPackage, getNewElementName(), comment.asString(),
fRenameSubpackages));
monitor.worked(1);
return result;
@@ -525,8 +474,7 @@
}
@Override
- public Change postCreateChange(Change[] participantChanges,
- IProgressMonitor pm) throws CoreException {
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
// if (fQualifiedNameSearchResult != null) {
// try {
// return
@@ -541,8 +489,7 @@
public String getNewPackageName(String oldSubPackageName) {
String oldPackageName = getPackage().getElementName();
- return getNewElementName()
- + oldSubPackageName.substring(oldPackageName.length());
+ return getNewElementName() + oldSubPackageName.substring(oldPackageName.length());
}
private static class PackageRenamer {
@@ -552,8 +499,8 @@
// private final ImportsManager fImportsManager;
/**
- * references to fPackage (can include star imports which also import
- * namesake package fragments)
+ * references to fPackage (can include star imports which also import namesake
+ * package fragments)
*/
// private SearchResultGroup[] fOccurrences;
@@ -566,8 +513,7 @@
* - from fOccurrences (without namesakes): may have shared star import
* (star-import not updated here, but for fOccurrences)
* <p>
- * - from fPackage: may have unimported references to types of namesake
- * packages
+ * - from fPackage: may have unimported references to types of namesake packages
* <p>
* - both: may have unused imports of namesake packages.
* <p>
@@ -584,11 +530,9 @@
*/
// private List fReferencesToTypesInPackage;
- public PackageRenamer(IScriptFolder pack,
- RenameScriptFolderProcessor processor,
+ public PackageRenamer(IScriptFolder pack, RenameScriptFolderProcessor processor,
TextChangeManager textChangeManager/*
- * , ImportsManager
- * importsManager
+ * , ImportsManager importsManager
*/) {
fPackage = pack;
fProcessor = processor;
@@ -596,13 +540,11 @@
// fImportsManager= importsManager;
}
- void doRename(IProgressMonitor pm, RefactoringStatus result)
- throws CoreException {
+ void doRename(IProgressMonitor pm, RefactoringStatus result) throws CoreException {
pm.beginTask("", //$NON-NLS-1$
16 + (fProcessor.getUpdateTextualMatches() ? 10 : 0));
if (fProcessor.getUpdateReferences()) {
- pm.setTaskName(
- RefactoringCoreMessages.RenamePackageRefactoring_searching);
+ pm.setTaskName(RefactoringCoreMessages.RenamePackageRefactoring_searching);
// fOccurrences= getReferences(new SubProgressMonitor(pm, 4),
// result);
// fReferencesToTypesInNamesakes=
@@ -611,8 +553,7 @@
// fReferencesToTypesInPackage=
// getReferencesToTypesInPackage(new SubProgressMonitor(pm, 4),
// result);
- pm.setTaskName(
- RefactoringCoreMessages.RenamePackageRefactoring_checking);
+ pm.setTaskName(RefactoringCoreMessages.RenamePackageRefactoring_checking);
result.merge(analyzeAffectedSourceModules());
pm.worked(1);
} else {
@@ -628,18 +569,15 @@
else
pm.worked(3);
- if (fProcessor.getUpdateTextualMatches()
- && fPackage.equals(fProcessor.getPackage())) {
- pm.subTask(
- RefactoringCoreMessages.RenamePackageRefactoring_searching_text);
+ if (fProcessor.getUpdateTextualMatches() && fPackage.equals(fProcessor.getPackage())) {
+ pm.subTask(RefactoringCoreMessages.RenamePackageRefactoring_searching_text);
// addTextMatches(new SubProgressMonitor(pm, 10));
}
pm.done();
}
- private RefactoringStatus analyzeAffectedSourceModules()
- throws CoreException {
+ private RefactoringStatus analyzeAffectedSourceModules() throws CoreException {
// TODO: also for both fReferencesTo...; only check each CU once!
RefactoringStatus result = new RefactoringStatus();
// fOccurrences= Checks.excludeSourceModules(fOccurrences, result);
@@ -650,8 +588,7 @@
return result;
}
- private void addReferenceUpdates(IProgressMonitor pm)
- throws CoreException {
+ private void addReferenceUpdates(IProgressMonitor pm) throws CoreException {
if (DLTKCore.DEBUG) {
System.err.println("TODO: Add search support code."); //$NON-NLS-1$
}
@@ -693,70 +630,59 @@
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
final ScriptRefactoringArguments extended = (ScriptRefactoringArguments) arguments;
- final String handle = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
+ final String handle = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
if (handle != null) {
- final IModelElement element = ScriptRefactoringDescriptor
- .handleToElement(extended.getProject(), handle, false);
- if (element == null || !element.exists() || element
- .getElementType() != IModelElement.SCRIPT_FOLDER) {
- return ScriptableRefactoring.createInputFatalStatus(element,
- getRefactoring().getName(), ID_RENAME_PACKAGE);
+ final IModelElement element = ScriptRefactoringDescriptor.handleToElement(extended.getProject(), handle,
+ false);
+ if (element == null || !element.exists() || element.getElementType() != IModelElement.SCRIPT_FOLDER) {
+ return ScriptableRefactoring.createInputFatalStatus(element, getRefactoring().getName(),
+ ID_RENAME_PACKAGE);
}
fPackage = (IScriptFolder) element;
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
- final String name = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
+ final String name = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
final String patterns = extended.getAttribute(ATTRIBUTE_PATTERNS);
if (patterns != null && !"".equals(patterns)) //$NON-NLS-1$
fFilePatterns = patterns;
else
fFilePatterns = ""; //$NON-NLS-1$
- final String references = extended
- .getAttribute(ATTRIBUTE_REFERENCES);
+ final String references = extended.getAttribute(ATTRIBUTE_REFERENCES);
if (references != null) {
fUpdateReferences = Boolean.valueOf(references).booleanValue();
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_REFERENCES));
- final String matches = extended
- .getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REFERENCES));
+ final String matches = extended.getAttribute(ATTRIBUTE_TEXTUAL_MATCHES);
if (matches != null) {
fUpdateTextualMatches = Boolean.valueOf(matches).booleanValue();
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_TEXTUAL_MATCHES));
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ATTRIBUTE_TEXTUAL_MATCHES));
final String qualified = extended.getAttribute(ATTRIBUTE_QUALIFIED);
if (qualified != null) {
- fUpdateQualifiedNames = Boolean.valueOf(qualified)
- .booleanValue();
+ fUpdateQualifiedNames = Boolean.valueOf(qualified).booleanValue();
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_QUALIFIED));
- final String hierarchical = extended
- .getAttribute(ATTRIBUTE_HIERARCHICAL);
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_QUALIFIED));
+ final String hierarchical = extended.getAttribute(ATTRIBUTE_HIERARCHICAL);
if (hierarchical != null) {
- fRenameSubpackages = Boolean.valueOf(hierarchical)
- .booleanValue();
+ fRenameSubpackages = Boolean.valueOf(hierarchical).booleanValue();
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_HIERARCHICAL));
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_HIERARCHICAL));
} else
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
index b15351e..d1b9245 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/rename/RenameScriptProjectProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -44,8 +44,7 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
-public class RenameScriptProjectProcessor extends ScriptRenameProcessor
- implements IReferenceUpdating {
+public class RenameScriptProjectProcessor extends ScriptRenameProcessor implements IReferenceUpdating {
private static final String ID_RENAME_SCRIPT_PROJECT = "org.eclipse.dltk.ui.rename.script.project"; //$NON-NLS-1$
private static final String ATTRIBUTE_REFERENCES = "references"; //$NON-NLS-1$
@@ -57,10 +56,8 @@
/**
* Creates a new renamescriptproject processor.
- *
- * @param project
- * thescriptproject, or <code>null</code> if invoked by
- * scripting
+ *
+ * @param project thescriptproject, or <code>null</code> if invoked by scripting
*/
public RenameScriptProjectProcessor(IScriptProject project) {
fProject = project;
@@ -96,25 +93,20 @@
@Override
public Object getNewElement() throws CoreException {
- IPath newPath = fProject.getPath().removeLastSegments(1)
- .append(getNewElementName());
- return DLTKCore.create(
- ResourcesPlugin.getWorkspace().getRoot().findMember(newPath));
+ IPath newPath = fProject.getPath().removeLastSegments(1).append(getNewElementName());
+ return DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot().findMember(newPath));
}
@Override
- protected RenameModifications computeRenameModifications()
- throws CoreException {
+ protected RenameModifications computeRenameModifications() throws CoreException {
RenameModifications result = new RenameModifications();
- result.rename(fProject, new RenameArguments(getNewElementName(),
- getUpdateReferences()));
+ result.rename(fProject, new RenameArguments(getNewElementName(), getUpdateReferences()));
return result;
}
@Override
protected IFile[] getChangedFiles() throws CoreException {
- IFile projectFile = fProject.getProject()
- .getFile(IScriptProjectFilenames.PROJECT_FILENAME);
+ IFile projectFile = fProject.getProject().getFile(IScriptProjectFilenames.PROJECT_FILENAME);
if (projectFile != null && projectFile.exists()) {
return new IFile[] { projectFile };
}
@@ -146,38 +138,35 @@
}
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
return new RefactoringStatus();
}
@Override
- public RefactoringStatus checkNewElementName(String newName)
- throws CoreException {
+ public RefactoringStatus checkNewElementName(String newName) throws CoreException {
Assert.isNotNull(newName, "new name"); //$NON-NLS-1$
- RefactoringStatus result = RefactoringStatus.create(ResourcesPlugin
- .getWorkspace().validateName(newName, IResource.PROJECT));
+ RefactoringStatus result = RefactoringStatus
+ .create(ResourcesPlugin.getWorkspace().validateName(newName, IResource.PROJECT));
if (result.hasFatalError())
return result;
if (projectNameAlreadyExists(newName))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenameScriptProjectRefactoring_already_exists);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenameScriptProjectRefactoring_already_exists);
if (projectFolderAlreadyExists(newName))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.RenameScriptProjectProcessor_folder_already_exists);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.RenameScriptProjectProcessor_folder_already_exists);
return new RefactoringStatus();
}
@Override
- protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws CoreException {
+ protected RefactoringStatus doCheckFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws CoreException {
pm.beginTask("", 1); //$NON-NLS-1$
try {
if (isReadOnly()) {
- String message = Messages.format(
- RefactoringCoreMessages.RenameScriptProjectRefactoring_read_only,
+ String message = Messages.format(RefactoringCoreMessages.RenameScriptProjectRefactoring_read_only,
fProject.getElementName());
return RefactoringStatus.createErrorStatus(message);
}
@@ -192,14 +181,11 @@
}
private boolean projectNameAlreadyExists(String newName) {
- return ResourcesPlugin.getWorkspace().getRoot().getProject(newName)
- .exists();
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(newName).exists();
}
- private boolean projectFolderAlreadyExists(String newName)
- throws CoreException {
- boolean isNotInWorkpace = fProject.getProject().getDescription()
- .getLocationURI() != null;
+ private boolean projectFolderAlreadyExists(String newName) throws CoreException {
+ boolean isNotInWorkpace = fProject.getProject().getDescription().getLocationURI() != null;
if (isNotInWorkpace)
return false; // projects outside of the workspace are not renamed
URI locationURI = fProject.getProject().getLocationURI();
@@ -219,26 +205,18 @@
RefactoringCoreMessages.RenameScriptProjectProcessor_descriptor_description_short,
fProject.getElementName());
final String header = Messages.format(
- RefactoringCoreMessages.RenameScriptProjectChange_descriptor_description,
- new String[] { fProject.getElementName(),
- getNewElementName() });
- final String comment = new ScriptRefactoringDescriptorComment(this,
- header).asString();
- final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
- RenameScriptProjectProcessor.ID_RENAME_SCRIPT_PROJECT, null,
- description, comment, arguments,
- RefactoringDescriptor.STRUCTURAL_CHANGE
- | RefactoringDescriptor.MULTI_CHANGE
- | RefactoringDescriptor.BREAKING_CHANGE);
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT,
- descriptor.elementToHandle(fProject));
- arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME,
+ RefactoringCoreMessages.RenameScriptProjectChange_descriptor_description, fProject.getElementName(),
getNewElementName());
- arguments.put(ATTRIBUTE_REFERENCES,
- Boolean.valueOf(fUpdateReferences).toString());
- return new DynamicValidationStateChange(
- new RenameScriptProjectChange(descriptor, fProject,
- getNewElementName(), comment, fUpdateReferences));
+ final String comment = new ScriptRefactoringDescriptorComment(this, header).asString();
+ final ScriptRefactoringDescriptor descriptor = new ScriptRefactoringDescriptor(
+ RenameScriptProjectProcessor.ID_RENAME_SCRIPT_PROJECT, null, description, comment, arguments,
+ RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE
+ | RefactoringDescriptor.BREAKING_CHANGE);
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT, descriptor.elementToHandle(fProject));
+ arguments.put(ScriptRefactoringDescriptor.ATTRIBUTE_NAME, getNewElementName());
+ arguments.put(ATTRIBUTE_REFERENCES, Boolean.valueOf(fUpdateReferences).toString());
+ return new DynamicValidationStateChange(new RenameScriptProjectChange(descriptor, fProject,
+ getNewElementName(), comment, fUpdateReferences));
} finally {
pm.done();
}
@@ -248,41 +226,35 @@
public RefactoringStatus initialize(RefactoringArguments arguments) {
if (arguments instanceof ScriptRefactoringArguments) {
final ScriptRefactoringArguments extended = (ScriptRefactoringArguments) arguments;
- final String handle = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
+ final String handle = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_INPUT);
if (handle != null) {
- final IModelElement element = ScriptRefactoringDescriptor
- .handleToElement(extended.getProject(), handle, false);
- if (element == null || !element.exists() || element
- .getElementType() != IModelElement.SCRIPT_PROJECT) {
- return ScriptableRefactoring.createInputFatalStatus(element,
- getRefactoring().getName(),
+ final IModelElement element = ScriptRefactoringDescriptor.handleToElement(extended.getProject(), handle,
+ false);
+ if (element == null || !element.exists() || element.getElementType() != IModelElement.SCRIPT_PROJECT) {
+ return ScriptableRefactoring.createInputFatalStatus(element, getRefactoring().getName(),
ID_RENAME_SCRIPT_PROJECT);
}
fProject = (IScriptProject) element;
} else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
- final String name = extended
- .getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_INPUT));
+ final String name = extended.getAttribute(ScriptRefactoringDescriptor.ATTRIBUTE_NAME);
if (name != null && !"".equals(name)) //$NON-NLS-1$
setNewElementName(name);
else
- return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
- final String references = extended
- .getAttribute(ATTRIBUTE_REFERENCES);
+ return RefactoringStatus.createFatalErrorStatus(
+ Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
+ ScriptRefactoringDescriptor.ATTRIBUTE_NAME));
+ final String references = extended.getAttribute(ATTRIBUTE_REFERENCES);
if (references != null) {
fUpdateReferences = Boolean.valueOf(references).booleanValue();
} else
return RefactoringStatus.createFatalErrorStatus(Messages.format(
- RefactoringCoreMessages.InitializableRefactoring_argument_not_exist,
- ATTRIBUTE_REFERENCES));
+ RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, ATTRIBUTE_REFERENCES));
} else
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.InitializableRefactoring_inacceptable_arguments);
return new RefactoringStatus();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
index 5177ad5..d8a7ce3 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
@@ -77,18 +77,17 @@
// private
}
- public static ICopyPolicy createCopyPolicy(IResource[] resources,
- IModelElement[] modelElements) throws ModelException {
+ public static ICopyPolicy createCopyPolicy(IResource[] resources, IModelElement[] modelElements)
+ throws ModelException {
return (ICopyPolicy) createReorgPolicy(true, resources, modelElements);
}
- public static IMovePolicy createMovePolicy(IResource[] resources,
- IModelElement[] modelElements) throws ModelException {
+ public static IMovePolicy createMovePolicy(IResource[] resources, IModelElement[] modelElements)
+ throws ModelException {
return (IMovePolicy) createReorgPolicy(false, resources, modelElements);
}
- private static IReorgPolicy createReorgPolicy(boolean copy,
- IResource[] selectedResources,
+ private static IReorgPolicy createReorgPolicy(boolean copy, IResource[] selectedResources,
IModelElement[] selectedScriptElements) throws ModelException {
final IReorgPolicy NO;
if (copy)
@@ -96,11 +95,10 @@
else
NO = new NoMovePolicy();
- ActualSelectionComputer selectionComputer = new ActualSelectionComputer(
- selectedScriptElements, selectedResources);
+ ActualSelectionComputer selectionComputer = new ActualSelectionComputer(selectedScriptElements,
+ selectedResources);
IResource[] resources = selectionComputer.getActualResourcesToReorg();
- IModelElement[] modelElements = selectionComputer
- .getActualScriptElementsToReorg();
+ IModelElement[] modelElements = selectionComputer.getActualScriptElementsToReorg();
if (false) {
System.out.println("createReorgPolicy():"); //$NON-NLS-1$
@@ -108,77 +106,55 @@
System.out.println(" elements: " + Arrays.asList(modelElements)); //$NON-NLS-1$
}
- if (isNothingToReorg(resources, modelElements)
- || containsNull(resources) || containsNull(modelElements)
- || ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.SCRIPT_PROJECT)
- || ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.SCRIPT_MODEL)
- || ReorgUtils.hasElementsOfType(resources,
- IResource.PROJECT | IResource.ROOT)
+ if (isNothingToReorg(resources, modelElements) || containsNull(resources) || containsNull(modelElements)
+ || ReorgUtils.hasElementsOfType(modelElements, IModelElement.SCRIPT_PROJECT)
+ || ReorgUtils.hasElementsOfType(modelElements, IModelElement.SCRIPT_MODEL)
+ || ReorgUtils.hasElementsOfType(resources, IResource.PROJECT | IResource.ROOT)
|| !haveCommonParent(resources, modelElements))
return NO;
- if (ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.SCRIPT_FOLDER)) {
- if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
- modelElements, IModelElement.SCRIPT_FOLDER))
+ if (ReorgUtils.hasElementsOfType(modelElements, IModelElement.SCRIPT_FOLDER)) {
+ if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(modelElements, IModelElement.SCRIPT_FOLDER))
return NO;
if (copy) {
- return new CopyPackagesPolicy(
- ArrayTypeConverter.toPackageArray(modelElements));
+ return new CopyPackagesPolicy(ArrayTypeConverter.toPackageArray(modelElements));
}
- return new MovePackagesPolicy(
- ArrayTypeConverter.toPackageArray(modelElements));
+ return new MovePackagesPolicy(ArrayTypeConverter.toPackageArray(modelElements));
}
- if (ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.PROJECT_FRAGMENT)) {
- if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(
- modelElements, IModelElement.PROJECT_FRAGMENT))
+ if (ReorgUtils.hasElementsOfType(modelElements, IModelElement.PROJECT_FRAGMENT)) {
+ if (resources.length != 0 || ReorgUtils.hasElementsNotOfType(modelElements, IModelElement.PROJECT_FRAGMENT))
return NO;
if (copy) {
- return new CopyProjectFragmentsPolicy(ArrayTypeConverter
- .toProjectFragmentArray(modelElements));
+ return new CopyProjectFragmentsPolicy(ArrayTypeConverter.toProjectFragmentArray(modelElements));
}
- return new MoveProjectFragmentsPolicy(
- ArrayTypeConverter.toProjectFragmentArray(modelElements));
+ return new MoveProjectFragmentsPolicy(ArrayTypeConverter.toProjectFragmentArray(modelElements));
}
- if (ReorgUtils.hasElementsOfType(resources,
- IResource.FILE | IResource.FOLDER)
- || ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.SOURCE_MODULE)) {
- if (ReorgUtils.hasElementsNotOfType(modelElements,
- IModelElement.SOURCE_MODULE))
+ if (ReorgUtils.hasElementsOfType(resources, IResource.FILE | IResource.FOLDER)
+ || ReorgUtils.hasElementsOfType(modelElements, IModelElement.SOURCE_MODULE)) {
+ if (ReorgUtils.hasElementsNotOfType(modelElements, IModelElement.SOURCE_MODULE))
return NO;
- if (ReorgUtils.hasElementsNotOfType(resources,
- IResource.FILE | IResource.FOLDER))
+ if (ReorgUtils.hasElementsNotOfType(resources, IResource.FILE | IResource.FOLDER))
return NO;
if (copy) {
- return new CopyFilesFoldersAndCusPolicy(
- ReorgUtils.getFiles(resources),
- ReorgUtils.getFolders(resources),
- ArrayTypeConverter.toCuArray(modelElements));
+ return new CopyFilesFoldersAndCusPolicy(ReorgUtils.getFiles(resources),
+ ReorgUtils.getFolders(resources), ArrayTypeConverter.toCuArray(modelElements));
}
- return new MoveFilesFoldersAndCusPolicy(
- ReorgUtils.getFiles(resources),
- ReorgUtils.getFolders(resources),
+ return new MoveFilesFoldersAndCusPolicy(ReorgUtils.getFiles(resources), ReorgUtils.getFolders(resources),
ArrayTypeConverter.toCuArray(modelElements));
}
if (hasElementsSmallerThanCuOrClassFile(modelElements)) {
// assertions guaranteed by common parent
Assert.isTrue(resources.length == 0);
- Assert.isTrue(!ReorgUtils.hasElementsOfType(modelElements,
- IModelElement.SOURCE_MODULE));
+ Assert.isTrue(!ReorgUtils.hasElementsOfType(modelElements, IModelElement.SOURCE_MODULE));
Assert.isTrue(!hasElementsLargerThanCuOrClassFile(modelElements));
if (copy) {
return new CopySubCuElementsPolicy(modelElements);
}
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
+ System.err.println("TODO: ReorgPolicyFactory: Add MoveSubCuElementsPolicy support"); //$NON-NLS-1$
}
// return new MoveSubCuElementsPolicy(modelElements);
}
@@ -193,8 +169,7 @@
return false;
}
- private static boolean hasElementsSmallerThanCuOrClassFile(
- IModelElement[] modelElements) {
+ private static boolean hasElementsSmallerThanCuOrClassFile(IModelElement[] modelElements) {
for (int i = 0; i < modelElements.length; i++) {
if (ReorgUtils.isInsideSourceModule(modelElements[i]))
return true;
@@ -204,8 +179,7 @@
return false;
}
- private static boolean hasElementsLargerThanCuOrClassFile(
- IModelElement[] modelElements) {
+ private static boolean hasElementsLargerThanCuOrClassFile(IModelElement[] modelElements) {
for (int i = 0; i < modelElements.length; i++) {
if (!ReorgUtils.isInsideSourceModule(modelElements[i])
// && ! ReorgUtils.isInsideClassFile(modelElements[i])
@@ -215,13 +189,11 @@
return false;
}
- private static boolean haveCommonParent(IResource[] resources,
- IModelElement[] modelElements) {
+ private static boolean haveCommonParent(IResource[] resources, IModelElement[] modelElements) {
return new ParentChecker(resources, modelElements).haveCommonParent();
}
- private static boolean isNothingToReorg(IResource[] resources,
- IModelElement[] modelElements) {
+ private static boolean isNothingToReorg(IResource[] resources, IModelElement[] modelElements) {
return resources.length + modelElements.length == 0;
}
@@ -231,8 +203,7 @@
private IModelElement fScriptElementDestination;
@Override
- public final RefactoringStatus setDestination(IResource destination)
- throws ModelException {
+ public final RefactoringStatus setDestination(IResource destination) throws ModelException {
Assert.isNotNull(destination);
resetDestinations();
fResourceDestination = destination;
@@ -240,19 +211,16 @@
}
@Override
- public final RefactoringStatus setDestination(IModelElement destination)
- throws ModelException {
+ public final RefactoringStatus setDestination(IModelElement destination) throws ModelException {
Assert.isNotNull(destination);
resetDestinations();
fScriptElementDestination = destination;
return verifyDestination(destination);
}
- protected abstract RefactoringStatus verifyDestination(
- IModelElement destination) throws ModelException;
+ protected abstract RefactoringStatus verifyDestination(IModelElement destination) throws ModelException;
- protected abstract RefactoringStatus verifyDestination(
- IResource destination) throws ModelException;
+ protected abstract RefactoringStatus verifyDestination(IResource destination) throws ModelException;
@Override
public boolean canChildrenBeDestinations(IModelElement modelElement) {
@@ -293,50 +261,41 @@
return new IFile[0];
}
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
return null;
}
@Override
- public final RefactoringParticipant[] loadParticipants(
- RefactoringStatus status, RefactoringProcessor processor,
- String[] natures, SharableParticipants shared)
- throws CoreException {
+ public final RefactoringParticipant[] loadParticipants(RefactoringStatus status, RefactoringProcessor processor,
+ String[] natures, SharableParticipants shared) throws CoreException {
RefactoringModifications modifications = getModifications();
if (modifications != null) {
- return modifications.loadParticipants(status, processor,
- natures, shared);
+ return modifications.loadParticipants(status, processor, natures, shared);
}
return new RefactoringParticipant[0];
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
Assert.isNotNull(reorgQueries);
- ResourceChangeChecker checker = context
- .getChecker(ResourceChangeChecker.class);
+ ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class);
IFile[] allModifiedFiles = getAllModifiedFiles();
RefactoringModifications modifications = getModifications();
- IResourceChangeDescriptionFactory deltaFactory = checker
- .getDeltaFactory();
+ IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
for (int i = 0; i < allModifiedFiles.length; i++) {
deltaFactory.change(allModifiedFiles[i]);
}
if (modifications != null) {
modifications.buildDelta(deltaFactory);
- modifications.buildValidateEdits(
- context.getChecker(ValidateEditChecker.class));
+ modifications.buildValidateEdits(context.getChecker(ValidateEditChecker.class));
}
return new RefactoringStatus();
}
@Override
public boolean hasAllInputSet() {
- return fScriptElementDestination != null
- || fResourceDestination != null;
+ return fScriptElementDestination != null || fResourceDestination != null;
}
@Override
@@ -407,8 +366,7 @@
IResource[] resources = getResources();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
- if (!resource.exists() || resource.isPhantom()
- || !resource.isAccessible())
+ if (!resource.exists() || resource.isPhantom() || !resource.isAccessible())
return false;
}
@@ -422,94 +380,79 @@
}
}
- private static abstract class FilesFoldersAndCusReorgPolicy
- extends ReorgPolicy {
+ private static abstract class FilesFoldersAndCusReorgPolicy extends ReorgPolicy {
private ISourceModule[] fCus;
private IFolder[] fFolders;
private IFile[] fFiles;
- public FilesFoldersAndCusReorgPolicy(IFile[] files, IFolder[] folders,
- ISourceModule[] cus) {
+ public FilesFoldersAndCusReorgPolicy(IFile[] files, IFolder[] folders, ISourceModule[] cus) {
fFiles = files;
fFolders = folders;
fCus = cus;
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
Assert.isNotNull(modelElement);
if (!modelElement.exists())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_doesnotexist0);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_doesnotexist0);
if (modelElement instanceof IScriptModel)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
if (modelElement.isReadOnly())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_readonly);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_readonly);
if (!modelElement.isStructureKnown())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_structure);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_structure);
if (modelElement instanceof IOpenable) {
IOpenable openable = (IOpenable) modelElement;
if (!openable.isConsistent())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_inconsistent);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_inconsistent);
}
if (modelElement instanceof IProjectFragment) {
IProjectFragment root = (IProjectFragment) modelElement;
if (root.isArchive())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_archive);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_archive);
if (root.isExternal())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_external);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_external);
}
if (ReorgUtils.isInsideSourceModule(modelElement)) {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot);
}
IContainer destinationAsContainer = getDestinationAsContainer();
- if (destinationAsContainer == null
- || isChildOfOrEqualToAnyFolder(destinationAsContainer))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
+ if (destinationAsContainer == null || isChildOfOrEqualToAnyFolder(destinationAsContainer))
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
- if (containsLinkedResources() && !ReorgUtils
- .canBeDestinationForLinkedResources(modelElement))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_linked);
+ if (containsLinkedResources() && !ReorgUtils.canBeDestinationForLinkedResources(modelElement))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_linked);
return new RefactoringStatus();
}
@Override
- protected RefactoringStatus verifyDestination(IResource resource)
- throws ModelException {
+ protected RefactoringStatus verifyDestination(IResource resource) throws ModelException {
Assert.isNotNull(resource);
if (!resource.exists() || resource.isPhantom())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_phantom);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_phantom);
if (!resource.isAccessible())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_inaccessible);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_inaccessible);
Assert.isTrue(resource.getType() != IResource.ROOT);
if (isChildOfOrEqualToAnyFolder(resource))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_not_this_resource);
- if (containsLinkedResources()
- && !ReorgUtils.canBeDestinationForLinkedResources(resource))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_linked);
+ if (containsLinkedResources() && !ReorgUtils.canBeDestinationForLinkedResources(resource))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_linked);
return new RefactoringStatus();
}
@@ -517,8 +460,7 @@
private boolean isChildOfOrEqualToAnyFolder(IResource resource) {
for (int i = 0; i < fFolders.length; i++) {
IFolder folder = fFolders[i];
- if (folder.equals(resource)
- || ParentChecker.isDescendantOf(resource, folder))
+ if (folder.equals(resource) || ParentChecker.isDescendantOf(resource, folder))
return true;
}
return false;
@@ -586,16 +528,13 @@
}
protected final IScriptFolder getDestinationAsScriptFolder() {
- IScriptFolder javaAsPackage = getScriptDestinationAsScriptFolder(
- getScriptElementDestination());
+ IScriptFolder javaAsPackage = getScriptDestinationAsScriptFolder(getScriptElementDestination());
if (javaAsPackage != null)
return javaAsPackage;
- return getResourceDestinationAsScriptFolder(
- getResourceDestination());
+ return getResourceDestinationAsScriptFolder(getResourceDestination());
}
- private static IScriptFolder getScriptDestinationAsScriptFolder(
- IModelElement scriptDest) {
+ private static IScriptFolder getScriptDestinationAsScriptFolder(IModelElement scriptDest) {
if (scriptDest == null || !scriptDest.exists())
return null;
if (scriptDest instanceof IScriptFolder)
@@ -604,24 +543,19 @@
return ((IProjectFragment) scriptDest).getScriptFolder(""); //$NON-NLS-1$
if (scriptDest instanceof IScriptProject) {
try {
- IProjectFragment root = ReorgUtils
- .getCorrespondingProjectFragment(
- (IScriptProject) scriptDest);
+ IProjectFragment root = ReorgUtils.getCorrespondingProjectFragment((IScriptProject) scriptDest);
if (root != null)
return root.getScriptFolder(""); //$NON-NLS-1$
} catch (ModelException e) {
// fall through
}
}
- return (IScriptFolder) scriptDest
- .getAncestor(IModelElement.SCRIPT_FOLDER);
+ return (IScriptFolder) scriptDest.getAncestor(IModelElement.SCRIPT_FOLDER);
}
- private static IScriptFolder getResourceDestinationAsScriptFolder(
- IResource resource) {
+ private static IScriptFolder getResourceDestinationAsScriptFolder(IResource resource) {
if (resource instanceof IFile)
- return getScriptDestinationAsScriptFolder(
- DLTKCore.create(resource.getParent()));
+ return getScriptDestinationAsScriptFolder(DLTKCore.create(resource.getParent()));
return null;
}
@@ -636,8 +570,7 @@
}
protected boolean containsLinkedResources() {
- return ReorgUtils.containsLinkedResources(fFiles)
- || ReorgUtils.containsLinkedResources(fFolders)
+ return ReorgUtils.containsLinkedResources(fFiles) || ReorgUtils.containsLinkedResources(fFolders)
|| ReorgUtils.containsLinkedResources(fCus);
}
@@ -654,11 +587,9 @@
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
- RefactoringStatus status = super.checkFinalConditions(pm, context,
- reorgQueries);
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
+ RefactoringStatus status = super.checkFinalConditions(pm, context, reorgQueries);
confirmOverwritting(reorgQueries);
return status;
}
@@ -674,8 +605,7 @@
} else {
IContainer destinationAsContainer = getDestinationAsContainer();
if (destinationAsContainer != null)
- oh.confirmOverwritting(reorgQueries,
- destinationAsContainer);
+ oh.confirmOverwritting(reorgQueries, destinationAsContainer);
}
fFiles = oh.getFilesWithoutUnconfirmedOnes();
fFolders = oh.getFoldersWithoutUnconfirmedOnes();
@@ -692,17 +622,14 @@
}
@Override
- protected final RefactoringStatus verifyDestination(
- IResource destination) throws ModelException {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_no_resource);
+ protected final RefactoringStatus verifyDestination(IResource destination) throws ModelException {
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_no_resource);
}
protected final ISourceModule getSourceCu() {
// all have a common parent, so all must be in the same cu
// we checked before that the array in not null and not empty
- return (ISourceModule) fScriptElements[0]
- .getAncestor(IModelElement.SOURCE_MODULE);
+ return (ISourceModule) fScriptElements[0].getAncestor(IModelElement.SOURCE_MODULE);
}
@Override
@@ -719,12 +646,10 @@
return getDestinationCu(getScriptElementDestination());
}
- protected static final ISourceModule getDestinationCu(
- IModelElement destination) {
+ protected static final ISourceModule getDestinationCu(IModelElement destination) {
if (destination instanceof ISourceModule)
return (ISourceModule) destination;
- return (ISourceModule) destination
- .getAncestor(IModelElement.SOURCE_MODULE);
+ return (ISourceModule) destination.getAncestor(IModelElement.SOURCE_MODULE);
}
// private static ISourceModule getEnclosingCu(IModelElement
@@ -757,39 +682,32 @@
}
@Override
- protected RefactoringStatus verifyDestination(IModelElement destination)
- throws ModelException {
+ protected RefactoringStatus verifyDestination(IModelElement destination) throws ModelException {
return recursiveVerifyDestination(destination);
}
- private RefactoringStatus recursiveVerifyDestination(
- IModelElement destination) throws ModelException {
+ private RefactoringStatus recursiveVerifyDestination(IModelElement destination) throws ModelException {
Assert.isNotNull(destination);
if (!destination.exists())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_doesnotexist1);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_doesnotexist1);
if (destination instanceof IScriptModel)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
- if (!(destination instanceof ISourceModule)
- && !ReorgUtils.isInsideSourceModule(destination))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
+ if (!(destination instanceof ISourceModule) && !ReorgUtils.isInsideSourceModule(destination))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot);
ISourceModule destinationCu = getDestinationCu(destination);
Assert.isNotNull(destinationCu);
if (destinationCu.isReadOnly())// the resource read-onliness is
// handled by validateEdit
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot_modify);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot_modify);
switch (destination.getElementType()) {
case IModelElement.SOURCE_MODULE:
- int[] types0 = new int[] { IModelElement.FIELD,
- IModelElement.METHOD };
+ int[] types0 = new int[] { IModelElement.FIELD, IModelElement.METHOD };
if (ReorgUtils.hasElementsOfType(getScriptElements(), types0))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot);
break;
// case IModelElement.PACKAGE_DECLARATION:
// return
@@ -843,8 +761,7 @@
}
}
- private static abstract class ProjectFragmentsReorgPolicy
- extends ReorgPolicy {
+ private static abstract class ProjectFragmentsReorgPolicy extends ReorgPolicy {
private IProjectFragment[] fProjectFragments;
@@ -873,8 +790,7 @@
return false;
for (int i = 0; i < fProjectFragments.length; i++) {
if (!(ReorgUtils.isSourceFolder(fProjectFragments[i])
- || (fProjectFragments[i].isArchive()
- && !fProjectFragments[i].isExternal())))
+ || (fProjectFragments[i].isArchive() && !fProjectFragments[i].isExternal())))
return false;
}
if (ReorgUtils.containsLinkedResources(fProjectFragments))
@@ -900,8 +816,7 @@
@Override
public boolean canElementBeDestination(IModelElement modelElement) {
- return modelElement
- .getElementType() == IModelElement.SCRIPT_PROJECT;
+ return modelElement.getElementType() == IModelElement.SCRIPT_PROJECT;
}
@Override
@@ -911,31 +826,24 @@
@Override
protected RefactoringStatus verifyDestination(IResource resource) {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
Assert.isNotNull(modelElement);
if (!modelElement.exists())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
if (modelElement instanceof IScriptModel)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
- if (!(modelElement instanceof IScriptProject
- || modelElement instanceof IProjectFragment))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
+ if (!(modelElement instanceof IScriptProject || modelElement instanceof IProjectFragment))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2proj);
if (modelElement.isReadOnly())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_src2writable);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2writable);
if (ReorgUtils.isProjectFragment(modelElement.getScriptProject()))
// TODO: adapt message to archives:
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_src2nosrc);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_src2nosrc);
return new RefactoringStatus();
}
@@ -943,8 +851,7 @@
return getDestinationAsScriptProject(getScriptElementDestination());
}
- private IScriptProject getDestinationAsScriptProject(
- IModelElement modelElementDestination) {
+ private IScriptProject getDestinationAsScriptProject(IModelElement modelElementDestination) {
if (modelElementDestination == null) {
return null;
}
@@ -956,11 +863,9 @@
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
- RefactoringStatus status = super.checkFinalConditions(pm, context,
- reorgQueries);
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
+ RefactoringStatus status = super.checkFinalConditions(pm, context, reorgQueries);
confirmOverwritting(reorgQueries);
return status;
}
@@ -999,8 +904,7 @@
@Override
public boolean canEnable() throws ModelException {
for (int i = 0; i < fScriptFolders.length; i++) {
- if (ModelElementUtil.isDefaultPackage(fScriptFolders[i])
- || fScriptFolders[i].isReadOnly())
+ if (ModelElementUtil.isDefaultPackage(fScriptFolders[i]) || fScriptFolders[i].isReadOnly())
return false;
}
if (ReorgUtils.containsLinkedResources(fScriptFolders))
@@ -1010,14 +914,11 @@
@Override
protected RefactoringStatus verifyDestination(IResource resource) {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_packages);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_packages);
}
- protected IProjectFragment getDestinationAsProjectFragment()
- throws ModelException {
- return getDestinationAsProjectFragment(
- getScriptElementDestination());
+ protected IProjectFragment getDestinationAsProjectFragment() throws ModelException {
+ return getDestinationAsProjectFragment(getScriptElementDestination());
}
@Override
@@ -1054,8 +955,7 @@
return false;
}
- private IProjectFragment getDestinationAsProjectFragment(
- IModelElement modelElement) throws ModelException {
+ private IProjectFragment getDestinationAsProjectFragment(IModelElement modelElement) throws ModelException {
if (modelElement == null)
return null;
@@ -1069,41 +969,32 @@
}
if (modelElement instanceof IScriptProject)
- return ReorgUtils.getCorrespondingProjectFragment(
- (IScriptProject) modelElement);
+ return ReorgUtils.getCorrespondingProjectFragment((IScriptProject) modelElement);
return null;
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
Assert.isNotNull(modelElement);
if (!modelElement.exists())
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_cannot1);
if (modelElement instanceof IScriptModel)
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
- IProjectFragment destRoot = getDestinationAsProjectFragment(
- modelElement);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_jmodel);
+ IProjectFragment destRoot = getDestinationAsProjectFragment(modelElement);
if (!ReorgUtils.isSourceFolder(destRoot))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_packages);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_packages);
return new RefactoringStatus();
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
- RefactoringStatus refactoringStatus = super.checkFinalConditions(pm,
- context, reorgQueries);
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
+ RefactoringStatus refactoringStatus = super.checkFinalConditions(pm, context, reorgQueries);
confirmOverwritting(reorgQueries);
return refactoringStatus;
}
- private void confirmOverwritting(IReorgQueries reorgQueries)
- throws ModelException {
+ private void confirmOverwritting(IReorgQueries reorgQueries) throws ModelException {
OverwriteHelper oh = new OverwriteHelper();
oh.setPackages(fScriptFolders);
IProjectFragment destRoot = getDestinationAsProjectFragment();
@@ -1112,8 +1003,7 @@
}
}
- private static class CopySubCuElementsPolicy extends SubCuElementReorgPolicy
- implements ICopyPolicy {
+ private static class CopySubCuElementsPolicy extends SubCuElementReorgPolicy implements ICopyPolicy {
private CopyModifications fModifications;
private ReorgExecutionLog fReorgExecutionLog;
@@ -1127,15 +1017,13 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new CopyModifications();
fReorgExecutionLog = new ReorgExecutionLog();
- CopyArguments args = new CopyArguments(
- getScriptElementDestination(), fReorgExecutionLog);
+ CopyArguments args = new CopyArguments(getScriptElementDestination(), fReorgExecutionLog);
IModelElement[] modelElements = getScriptElements();
for (int i = 0; i < modelElements.length; i++) {
fModifications.copy(modelElements[i], args, null);
@@ -1144,11 +1032,9 @@
}
@Override
- public Change createChange(IProgressMonitor pm,
- INewNameQueries copyQueries) throws ModelException {
+ public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) throws ModelException {
if (DLTKCore.DEBUG) {
- System.err.println(
- "ReorgPolicyFactory:createChange return null."); //$NON-NLS-1$
+ System.err.println("ReorgPolicyFactory:createChange return null."); //$NON-NLS-1$
}
return null;
// try {
@@ -1187,18 +1073,15 @@
@Override
public IFile[] getAllModifiedFiles() {
- return ReorgUtils.getFiles(new IResource[] {
- ReorgUtils.getResource(getDestinationCu()) });
+ return ReorgUtils.getFiles(new IResource[] { ReorgUtils.getResource(getDestinationCu()) });
}
}
- private static class CopyFilesFoldersAndCusPolicy
- extends FilesFoldersAndCusReorgPolicy implements ICopyPolicy {
+ private static class CopyFilesFoldersAndCusPolicy extends FilesFoldersAndCusReorgPolicy implements ICopyPolicy {
private CopyModifications fModifications;
private ReorgExecutionLog fReorgExecutionLog;
- CopyFilesFoldersAndCusPolicy(IFile[] files, IFolder[] folders,
- ISourceModule[] cus) {
+ CopyFilesFoldersAndCusPolicy(IFile[] files, IFolder[] folders, ISourceModule[] cus) {
super(files, folders, cus);
}
@@ -1208,16 +1091,13 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new CopyModifications();
fReorgExecutionLog = new ReorgExecutionLog();
- CopyArguments jArgs = new CopyArguments(getDestination(),
- fReorgExecutionLog);
- CopyArguments rArgs = new CopyArguments(getDestinationAsContainer(),
- fReorgExecutionLog);
+ CopyArguments jArgs = new CopyArguments(getDestination(), fReorgExecutionLog);
+ CopyArguments rArgs = new CopyArguments(getDestinationAsContainer(), fReorgExecutionLog);
ISourceModule[] cus = getCus();
for (int i = 0; i < cus.length; i++) {
fModifications.copy(cus[i], jArgs, rArgs);
@@ -1237,15 +1117,13 @@
}
@Override
- public Change createChange(IProgressMonitor pm,
- INewNameQueries copyQueries) {
+ public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
IFile[] file = getFiles();
IFolder[] folders = getFolders();
ISourceModule[] cus = getCus();
pm.beginTask("", cus.length + file.length + folders.length); //$NON-NLS-1$
NewNameProposer nameProposer = new NewNameProposer();
- CompositeChange composite = new DynamicValidationStateChange(
- RefactoringCoreMessages.ReorgPolicy_copy);
+ CompositeChange composite = new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_copy);
composite.markAsSynthetic();
for (int i = 0; i < cus.length; i++) {
composite.add(createChange(cus[i], nameProposer, copyQueries));
@@ -1260,42 +1138,34 @@
if (pm.isCanceled())
throw new OperationCanceledException();
for (int i = 0; i < folders.length; i++) {
- composite.add(
- createChange(folders[i], nameProposer, copyQueries));
+ composite.add(createChange(folders[i], nameProposer, copyQueries));
pm.worked(1);
}
pm.done();
return composite;
}
- private Change createChange(ISourceModule unit,
- NewNameProposer nameProposer, INewNameQueries copyQueries) {
+ private Change createChange(ISourceModule unit, NewNameProposer nameProposer, INewNameQueries copyQueries) {
IScriptFolder pack = getDestinationAsScriptFolder();
if (pack != null)
return copyCuToPackage(unit, pack, nameProposer, copyQueries);
IContainer container = getDestinationAsContainer();
- return copyFileToContainer(unit, container, nameProposer,
- copyQueries);
+ return copyFileToContainer(unit, container, nameProposer, copyQueries);
}
- private static Change copyFileToContainer(ISourceModule cu,
- IContainer dest, NewNameProposer nameProposer,
+ private static Change copyFileToContainer(ISourceModule cu, IContainer dest, NewNameProposer nameProposer,
INewNameQueries copyQueries) {
IResource resource = ReorgUtils.getResource(cu);
- return createCopyResourceChange(resource, nameProposer, copyQueries,
- dest);
+ return createCopyResourceChange(resource, nameProposer, copyQueries, dest);
}
- private Change createChange(IResource resource,
- NewNameProposer nameProposer, INewNameQueries copyQueries) {
+ private Change createChange(IResource resource, NewNameProposer nameProposer, INewNameQueries copyQueries) {
IContainer dest = getDestinationAsContainer();
- return createCopyResourceChange(resource, nameProposer, copyQueries,
- dest);
+ return createCopyResourceChange(resource, nameProposer, copyQueries, dest);
}
- private static Change createCopyResourceChange(IResource resource,
- NewNameProposer nameProposer, INewNameQueries copyQueries,
- IContainer destination) {
+ private static Change createCopyResourceChange(IResource resource, NewNameProposer nameProposer,
+ INewNameQueries copyQueries, IContainer destination) {
if (resource == null || destination == null)
return new NullChange();
INewNameQuery nameQuery;
@@ -1303,45 +1173,37 @@
if (name == null)
nameQuery = copyQueries.createNullQuery();
else
- nameQuery = copyQueries.createNewResourceNameQuery(resource,
- name);
+ nameQuery = copyQueries.createNewResourceNameQuery(resource, name);
return new CopyResourceChange(resource, destination, nameQuery);
}
- private static Change copyCuToPackage(ISourceModule cu,
- IScriptFolder dest, NewNameProposer nameProposer,
+ private static Change copyCuToPackage(ISourceModule cu, IScriptFolder dest, NewNameProposer nameProposer,
INewNameQueries copyQueries) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource res = ReorgUtils.getResource(cu);
if (res != null && res.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
- return copyFileToContainer(cu,
- (IContainer) ResourceUtil.getResource(dest),
- nameProposer, copyQueries);
+ return copyFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest), nameProposer,
+ copyQueries);
}
String newName = nameProposer.createNewName(cu, dest);
- Change simpleCopy = new CopySourceModuleChange(cu, dest,
- copyQueries.createStaticQuery(newName));
+ Change simpleCopy = new CopySourceModuleChange(cu, dest, copyQueries.createStaticQuery(newName));
if (newName == null || newName.equals(cu.getElementName()))
return simpleCopy;
try {
- IPath newPath = ResourceUtil.getResource(cu).getParent()
- .getFullPath().append(newName);
- INewNameQuery nameQuery = copyQueries
- .createNewSourceModuleNameQuery(cu, newName);
- return new CreateCopyOfSourceModuleChange(newPath,
- cu.getSource(), cu, nameQuery);
+ IPath newPath = ResourceUtil.getResource(cu).getParent().getFullPath().append(newName);
+ INewNameQuery nameQuery = copyQueries.createNewSourceModuleNameQuery(cu, newName);
+ return new CreateCopyOfSourceModuleChange(newPath, cu.getSource(), cu, nameQuery);
} catch (CoreException e) {
return simpleCopy; // fallback - no ui here
}
}
}
- private static class CopyProjectFragmentsPolicy
- extends ProjectFragmentsReorgPolicy implements ICopyPolicy {
+ private static class CopyProjectFragmentsPolicy extends ProjectFragmentsReorgPolicy implements ICopyPolicy {
private CopyModifications fModifications;
private ReorgExecutionLog fReorgExecutionLog;
@@ -1355,17 +1217,14 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new CopyModifications();
fReorgExecutionLog = new ReorgExecutionLog();
- CopyArguments javaArgs = new CopyArguments(
- getDestinationScriptProject(), fReorgExecutionLog);
- CopyArguments resourceArgs = new CopyArguments(
- getDestinationScriptProject().getProject(),
+ CopyArguments javaArgs = new CopyArguments(getDestinationScriptProject(), fReorgExecutionLog);
+ CopyArguments resourceArgs = new CopyArguments(getDestinationScriptProject().getProject(),
fReorgExecutionLog);
IProjectFragment[] roots = getRoots();
for (int i = 0; i < roots.length; i++) {
@@ -1375,8 +1234,7 @@
}
@Override
- public Change createChange(IProgressMonitor pm,
- INewNameQueries copyQueries) {
+ public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
NewNameProposer nameProposer = new NewNameProposer();
IProjectFragment[] roots = getProjectFragments();
pm.beginTask("", roots.length); //$NON-NLS-1$
@@ -1386,36 +1244,30 @@
IScriptProject destination = getDestinationScriptProject();
Assert.isNotNull(destination);
for (int i = 0; i < roots.length; i++) {
- composite.add(createChange(roots[i], destination, nameProposer,
- copyQueries));
+ composite.add(createChange(roots[i], destination, nameProposer, copyQueries));
pm.worked(1);
}
pm.done();
return composite;
}
- private Change createChange(IProjectFragment root,
- IScriptProject destination, NewNameProposer nameProposer,
+ private Change createChange(IProjectFragment root, IScriptProject destination, NewNameProposer nameProposer,
INewNameQueries copyQueries) {
IResource res = root.getResource();
IProject destinationProject = destination.getProject();
- String newName = nameProposer.createNewName(res,
- destinationProject);
+ String newName = nameProposer.createNewName(res, destinationProject);
INewNameQuery nameQuery;
if (newName == null)
nameQuery = copyQueries.createNullQuery();
else
- nameQuery = copyQueries.createNewProjectFragmentNameQuery(root,
- newName);
+ nameQuery = copyQueries.createNewProjectFragmentNameQuery(root, newName);
// TODO sounds wrong that this change works on IProjects
// TODO fix the query problem
- return new CopyProjectFragmentChange(root, destinationProject,
- nameQuery, null);
+ return new CopyProjectFragmentChange(root, destinationProject, nameQuery, null);
}
}
- private static class CopyPackagesPolicy extends PackagesReorgPolicy
- implements ICopyPolicy {
+ private static class CopyPackagesPolicy extends PackagesReorgPolicy implements ICopyPolicy {
private CopyModifications fModifications;
private ReorgExecutionLog fReorgExecutionLog;
@@ -1429,18 +1281,15 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new CopyModifications();
fReorgExecutionLog = new ReorgExecutionLog();
IProjectFragment destination = getDestinationAsProjectFragment();
- CopyArguments javaArgs = new CopyArguments(destination,
- fReorgExecutionLog);
- CopyArguments resourceArgs = new CopyArguments(
- destination.getResource(), fReorgExecutionLog);
+ CopyArguments javaArgs = new CopyArguments(destination, fReorgExecutionLog);
+ CopyArguments resourceArgs = new CopyArguments(destination.getResource(), fReorgExecutionLog);
IScriptFolder[] packages = getPackages();
for (int i = 0; i < packages.length; i++) {
fModifications.copy(packages[i], javaArgs, resourceArgs);
@@ -1449,8 +1298,7 @@
}
@Override
- public Change createChange(IProgressMonitor pm,
- INewNameQueries newNameQueries) throws ModelException {
+ public Change createChange(IProgressMonitor pm, INewNameQueries newNameQueries) throws ModelException {
NewNameProposer nameProposer = new NewNameProposer();
IScriptFolder[] fragments = getPackages();
pm.beginTask("", fragments.length); //$NON-NLS-1$
@@ -1459,16 +1307,14 @@
composite.markAsSynthetic();
IProjectFragment root = getDestinationAsProjectFragment();
for (int i = 0; i < fragments.length; i++) {
- composite.add(createChange(fragments[i], root, nameProposer,
- newNameQueries));
+ composite.add(createChange(fragments[i], root, nameProposer, newNameQueries));
pm.worked(1);
}
pm.done();
return composite;
}
- private Change createChange(IScriptFolder pack,
- IProjectFragment destination, NewNameProposer nameProposer,
+ private Change createChange(IScriptFolder pack, IProjectFragment destination, NewNameProposer nameProposer,
INewNameQueries copyQueries) {
String newName = nameProposer.createNewName(pack, destination);
IDLTKLanguageToolkit tk = null;
@@ -1477,31 +1323,27 @@
if (newName != null) {
newPath = newPath.append(newName);
}
- if (newName == null
- || (tk != null && tk.validateSourcePackage(newPath,
- EnvironmentManager.getEnvironment(destination)))) {
+ if (newName == null || (tk != null
+ && tk.validateSourcePackage(newPath, EnvironmentManager.getEnvironment(destination)))) {
INewNameQuery nameQuery;
if (newName == null) {
nameQuery = copyQueries.createNullQuery();
} else {
- nameQuery = copyQueries.createNewPackageNameQuery(pack,
- newName);
+ nameQuery = copyQueries.createNewPackageNameQuery(pack, newName);
}
return new CopyScriptFolderChange(pack, destination, nameQuery);
}
if (destination.getResource() instanceof IContainer) {
IContainer dest = (IContainer) destination.getResource();
IResource res = pack.getResource();
- INewNameQuery nameQuery = copyQueries
- .createNewResourceNameQuery(res, newName);
+ INewNameQuery nameQuery = copyQueries.createNewResourceNameQuery(res, newName);
return new CopyResourceChange(res, dest, nameQuery);
}
return new NullChange();
}
}
- private static class NoCopyPolicy extends ReorgPolicy
- implements ICopyPolicy {
+ private static class NoCopyPolicy extends ReorgPolicy implements ICopyPolicy {
@Override
public boolean canEnable() throws ModelException {
return false;
@@ -1513,22 +1355,17 @@
}
@Override
- protected RefactoringStatus verifyDestination(IResource resource)
- throws ModelException {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_noCopying);
+ protected RefactoringStatus verifyDestination(IResource resource) throws ModelException {
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_noCopying);
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_noCopying);
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_noCopying);
}
@Override
- public Change createChange(IProgressMonitor pm,
- INewNameQueries copyQueries) {
+ public Change createChange(IProgressMonitor pm, INewNameQueries copyQueries) {
return new NullChange();
}
@@ -1546,8 +1383,7 @@
private static class NewNameProposer {
private final Set fAutoGeneratedNewNames = new HashSet(2);
- public String createNewName(ISourceModule cu,
- IScriptFolder destination) {
+ public String createNewName(ISourceModule cu, IScriptFolder destination) {
if (isNewNameOk(destination, cu.getElementName()))
return null;
if (!ReorgUtils.isParentInWorkspaceOrOnDisk(cu, destination))
@@ -1556,16 +1392,11 @@
while (true) {
String newName;
if (i == 1)
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_cu_copyOf1,
- cu.getElementName());
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_cu_copyOf1, cu.getElementName());
else
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_cu_copyOfMore,
- new String[] { String.valueOf(i),
- cu.getElementName() });
- if (isNewNameOk(destination, newName)
- && !fAutoGeneratedNewNames.contains(newName)) {
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_cu_copyOfMore, String.valueOf(i),
+ cu.getElementName());
+ if (isNewNameOk(destination, newName) && !fAutoGeneratedNewNames.contains(newName)) {
fAutoGeneratedNewNames.add(newName);
return removeTrailingScript(newName);
}
@@ -1576,8 +1407,7 @@
private static String removeTrailingScript(String name) {
// return DLTKCore.removeScriptLikeExtension(name);
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: ReorgPolicyFactory add removeScriptLikeExtension code..."); //$NON-NLS-1$
+ System.err.println("TODO: ReorgPolicyFactory add removeScriptLikeExtension code..."); //$NON-NLS-1$
}
return name;
}
@@ -1591,15 +1421,11 @@
while (true) {
String newName;
if (i == 1)
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_resource_copyOf1,
- res.getName());
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_resource_copyOf1, res.getName());
else
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_resource_copyOfMore,
- new String[] { String.valueOf(i), res.getName() });
- if (isNewNameOk(destination, newName)
- && !fAutoGeneratedNewNames.contains(newName)) {
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_resource_copyOfMore,
+ String.valueOf(i), res.getName());
+ if (isNewNameOk(destination, newName) && !fAutoGeneratedNewNames.contains(newName)) {
fAutoGeneratedNewNames.add(newName);
return newName;
}
@@ -1607,8 +1433,7 @@
}
}
- public String createNewName(IScriptFolder pack,
- IProjectFragment destination) {
+ public String createNewName(IScriptFolder pack, IProjectFragment destination) {
if (isNewNameOk(destination, pack.getElementName()))
return null;
if (!ReorgUtils.isParentInWorkspaceOrOnDisk(pack, destination))
@@ -1617,16 +1442,12 @@
while (true) {
String newName;
if (i == 1)
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_package_copyOf1,
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_package_copyOf1,
pack.getElementName());
else
- newName = Messages.format(
- RefactoringCoreMessages.CopyRefactoring_package_copyOfMore,
- new String[] { String.valueOf(i),
- pack.getElementName() });
- if (isNewNameOk(destination, newName)
- && !fAutoGeneratedNewNames.contains(newName)) {
+ newName = Messages.format(RefactoringCoreMessages.CopyRefactoring_package_copyOfMore,
+ String.valueOf(i), pack.getElementName());
+ if (isNewNameOk(destination, newName) && !fAutoGeneratedNewNames.contains(newName)) {
fAutoGeneratedNewNames.add(newName);
return newName;
}
@@ -1638,19 +1459,16 @@
return !dest.getSourceModule(newName).exists();
}
- private static boolean isNewNameOk(IContainer container,
- String newName) {
+ private static boolean isNewNameOk(IContainer container, String newName) {
return container.findMember(newName) == null;
}
- private static boolean isNewNameOk(IProjectFragment root,
- String newName) {
+ private static boolean isNewNameOk(IProjectFragment root, String newName) {
return !root.getScriptFolder(newName).exists();
}
}
- private static class MoveProjectFragmentsPolicy
- extends ProjectFragmentsReorgPolicy implements IMovePolicy {
+ private static class MoveProjectFragmentsPolicy extends ProjectFragmentsReorgPolicy implements IMovePolicy {
private MoveModifications fModifications;
@@ -1659,20 +1477,17 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new MoveModifications();
IScriptProject destination = getDestinationScriptProject();
- boolean updateReferences = canUpdateReferences()
- && getUpdateReferences();
+ boolean updateReferences = canUpdateReferences() && getUpdateReferences();
if (destination != null) {
IProjectFragment[] roots = getProjectFragments();
for (int i = 0; i < roots.length; i++) {
- fModifications.move(roots[i],
- new MoveArguments(destination, updateReferences));
+ fModifications.move(roots[i], new MoveArguments(destination, updateReferences));
}
}
return fModifications;
@@ -1696,37 +1511,30 @@
}
@Override
- public Change postCreateChange(Change[] participantChanges,
- IProgressMonitor pm) throws CoreException {
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
return null;
}
- private Change createChange(IProjectFragment root,
- IScriptProject destination) {
+ private Change createChange(IProjectFragment root, IScriptProject destination) {
// /XXX fix the query
- return new MoveProjectFragmentChange(root, destination.getProject(),
- null);
+ return new MoveProjectFragmentChange(root, destination.getProject(), null);
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
- RefactoringStatus superStatus = super.verifyDestination(
- modelElement);
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
+ RefactoringStatus superStatus = super.verifyDestination(modelElement);
if (superStatus.hasFatalError())
return superStatus;
IScriptProject scriptProject = getDestinationScriptProject();
if (isParentOfAny(scriptProject, getProjectFragments()))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_element2parent);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_element2parent);
return superStatus;
}
- private static boolean isParentOfAny(IScriptProject scriptProject,
- IProjectFragment[] roots) {
+ private static boolean isParentOfAny(IScriptProject scriptProject, IProjectFragment[] roots) {
for (int i = 0; i < roots.length; i++) {
- if (ReorgUtils.isParentInWorkspaceOrOnDisk(roots[i],
- scriptProject))
+ if (ReorgUtils.isParentInWorkspaceOrOnDisk(roots[i], scriptProject))
return true;
}
return false;
@@ -1741,14 +1549,12 @@
if (roots[i].isReadOnly() && !(roots[i].isArchive())) {
IResource res = roots[i].getResource();
if (res != null) {
- final ResourceAttributes attributes = roots[i]
- .getResource().getResourceAttributes();
+ final ResourceAttributes attributes = roots[i].getResource().getResourceAttributes();
if (attributes == null || attributes.isReadOnly())
return false;
} else {
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: Add correct code of copy external folders in..."); //$NON-NLS-1$
+ System.err.println("TODO: Add correct code of copy external folders in..."); //$NON-NLS-1$
}
return false;
}
@@ -1758,12 +1564,10 @@
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
try {
- RefactoringStatus status = super.checkFinalConditions(pm,
- context, reorgQueries);
+ RefactoringStatus status = super.checkFinalConditions(pm, context, reorgQueries);
confirmMovingReadOnly(reorgQueries);
return status;
} catch (ModelException e) {
@@ -1773,10 +1577,9 @@
}
}
- private void confirmMovingReadOnly(IReorgQueries reorgQueries)
- throws CoreException {
- if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(
- getScriptElements(), getResources(), reorgQueries))
+ private void confirmMovingReadOnly(IReorgQueries reorgQueries) throws CoreException {
+ if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(getScriptElements(), getResources(),
+ reorgQueries))
throw new OperationCanceledException(); // saying' no' to this
// one is like
// cancelling the whole
@@ -1784,8 +1587,7 @@
}
@Override
- public ICreateTargetQuery getCreateTargetQuery(
- ICreateTargetQueries createQueries) {
+ public ICreateTargetQuery getCreateTargetQuery(ICreateTargetQueries createQueries) {
return null;
}
@@ -1795,8 +1597,7 @@
}
}
- private static class MovePackagesPolicy extends PackagesReorgPolicy
- implements IMovePolicy {
+ private static class MovePackagesPolicy extends PackagesReorgPolicy implements IMovePolicy {
private MoveModifications fModifications;
MovePackagesPolicy(IScriptFolder[] ScriptFolders) {
@@ -1804,40 +1605,34 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
fModifications = new MoveModifications();
- boolean updateReferences = canUpdateReferences()
- && getUpdateReferences();
+ boolean updateReferences = canUpdateReferences() && getUpdateReferences();
IScriptFolder[] packages = getPackages();
IProjectFragment scriptDestination = getDestinationAsProjectFragment();
for (int i = 0; i < packages.length; i++) {
- fModifications.move(packages[i],
- new MoveArguments(scriptDestination, updateReferences));
+ fModifications.move(packages[i], new MoveArguments(scriptDestination, updateReferences));
}
return fModifications;
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
- RefactoringStatus superStatus = super.verifyDestination(
- modelElement);
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
+ RefactoringStatus superStatus = super.verifyDestination(modelElement);
if (superStatus.hasFatalError())
return superStatus;
IProjectFragment root = getDestinationAsProjectFragment();
if (isParentOfAny(root, getPackages()))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_package2parent);
+ return RefactoringStatus
+ .createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_package2parent);
return superStatus;
}
- private static boolean isParentOfAny(IProjectFragment root,
- IScriptFolder[] fragments) {
+ private static boolean isParentOfAny(IProjectFragment root, IScriptFolder[] fragments) {
for (int i = 0; i < fragments.length; i++) {
IScriptFolder fragment = fragments[i];
if (ReorgUtils.isParentInWorkspaceOrOnDisk(fragment, root))
@@ -1850,8 +1645,7 @@
public Change createChange(IProgressMonitor pm) throws ModelException {
IScriptFolder[] fragments = getPackages();
pm.beginTask("", fragments.length); //$NON-NLS-1$
- CompositeChange result = new DynamicValidationStateChange(
- RefactoringCoreMessages.ReorgPolicy_move_package);
+ CompositeChange result = new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move_package);
result.markAsSynthetic();
IProjectFragment root = getDestinationAsProjectFragment();
for (int i = 0; i < fragments.length; i++) {
@@ -1865,23 +1659,19 @@
}
@Override
- public Change postCreateChange(Change[] participantChanges,
- IProgressMonitor pm) throws CoreException {
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
return null;
}
- private Change createChange(IScriptFolder pack,
- IProjectFragment destination) {
+ private Change createChange(IScriptFolder pack, IProjectFragment destination) {
return new MoveScriptFolderChange(pack, destination);
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
try {
- RefactoringStatus status = super.checkFinalConditions(pm,
- context, reorgQueries);
+ RefactoringStatus status = super.checkFinalConditions(pm, context, reorgQueries);
confirmMovingReadOnly(reorgQueries);
return status;
} catch (ModelException e) {
@@ -1891,10 +1681,9 @@
}
}
- private void confirmMovingReadOnly(IReorgQueries reorgQueries)
- throws CoreException {
- if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(
- getScriptElements(), getResources(), reorgQueries))
+ private void confirmMovingReadOnly(IReorgQueries reorgQueries) throws CoreException {
+ if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(getScriptElements(), getResources(),
+ reorgQueries))
throw new OperationCanceledException(); // saying' no' to this
// one is like
// cancelling the whole
@@ -1902,8 +1691,7 @@
}
@Override
- public ICreateTargetQuery getCreateTargetQuery(
- ICreateTargetQueries createQueries) {
+ public ICreateTargetQuery getCreateTargetQuery(ICreateTargetQueries createQueries) {
return null;
}
@@ -1913,8 +1701,7 @@
}
}
- private static class MoveFilesFoldersAndCusPolicy
- extends FilesFoldersAndCusReorgPolicy implements IMovePolicy {
+ private static class MoveFilesFoldersAndCusPolicy extends FilesFoldersAndCusReorgPolicy implements IMovePolicy {
private boolean fUpdateReferences;
private boolean fUpdateQualifiedNames;
@@ -1923,8 +1710,7 @@
private TextChangeManager fChangeManager;
private MoveModifications fModifications;
- MoveFilesFoldersAndCusPolicy(IFile[] files, IFolder[] folders,
- ISourceModule[] cus) {
+ MoveFilesFoldersAndCusPolicy(IFile[] files, IFolder[] folders, ISourceModule[] cus) {
super(files, folders, cus);
fUpdateReferences = true;
fUpdateQualifiedNames = false;
@@ -1932,8 +1718,7 @@
}
@Override
- protected RefactoringModifications getModifications()
- throws CoreException {
+ protected RefactoringModifications getModifications() throws CoreException {
if (fModifications != null)
return fModifications;
@@ -1948,86 +1733,66 @@
// don't use fUpdateReferences directly since it is only valid if
// canUpdateReferences is true
- boolean updateReferenes = canUpdateReferences()
- && getUpdateReferences();
+ boolean updateReferenes = canUpdateReferences() && getUpdateReferences();
if (unitDestination != null) {
ISourceModule[] units = getCus();
for (int i = 0; i < units.length; i++) {
- fModifications.move(units[i], new MoveArguments(
- unitDestination, updateReferenes));
+ fModifications.move(units[i], new MoveArguments(unitDestination, updateReferenes));
}
}
if (container != null) {
IFile[] files = getFiles();
for (int i = 0; i < files.length; i++) {
- fModifications.move(files[i],
- new MoveArguments(container, updateReferenes));
+ fModifications.move(files[i], new MoveArguments(container, updateReferenes));
}
IFolder[] folders = getFolders();
for (int i = 0; i < folders.length; i++) {
- fModifications.move(folders[i],
- new MoveArguments(container, updateReferenes));
+ fModifications.move(folders[i], new MoveArguments(container, updateReferenes));
}
}
return fModifications;
}
@Override
- protected RefactoringStatus verifyDestination(IModelElement destination)
- throws ModelException {
- RefactoringStatus superStatus = super.verifyDestination(
- destination);
+ protected RefactoringStatus verifyDestination(IModelElement destination) throws ModelException {
+ RefactoringStatus superStatus = super.verifyDestination(destination);
if (superStatus.hasFatalError())
return superStatus;
- Object commonParent = new ParentChecker(getResources(),
- getScriptElements()).getCommonParent();
+ Object commonParent = new ParentChecker(getResources(), getScriptElements()).getCommonParent();
if (destination.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
IContainer destinationAsContainer = getDestinationAsContainer();
- if (destinationAsContainer != null
- && destinationAsContainer.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ if (destinationAsContainer != null && destinationAsContainer.equals(commonParent))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
IScriptFolder destinationAsPackage = getDestinationAsScriptFolder();
- if (destinationAsPackage != null
- && destinationAsPackage.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ if (destinationAsPackage != null && destinationAsPackage.equals(commonParent))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
return superStatus;
}
@Override
- protected RefactoringStatus verifyDestination(IResource destination)
- throws ModelException {
- RefactoringStatus superStatus = super.verifyDestination(
- destination);
+ protected RefactoringStatus verifyDestination(IResource destination) throws ModelException {
+ RefactoringStatus superStatus = super.verifyDestination(destination);
if (superStatus.hasFatalError())
return superStatus;
Object commonParent = getCommonParent();
if (destination.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
IContainer destinationAsContainer = getDestinationAsContainer();
- if (destinationAsContainer != null
- && destinationAsContainer.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ if (destinationAsContainer != null && destinationAsContainer.equals(commonParent))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
IModelElement destinationContainerAsPackage = getDestinationContainerAsScriptElement();
- if (destinationContainerAsPackage != null
- && destinationContainerAsPackage.equals(commonParent))
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_parent);
+ if (destinationContainerAsPackage != null && destinationContainerAsPackage.equals(commonParent))
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_parent);
return superStatus;
}
private Object getCommonParent() {
- return new ParentChecker(getResources(), getScriptElements())
- .getCommonParent();
+ return new ParentChecker(getResources(), getScriptElements()).getCommonParent();
}
@Override
@@ -2039,11 +1804,9 @@
}
@Override
- public Change postCreateChange(Change[] participantChanges,
- IProgressMonitor pm) throws CoreException {
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO: ReorgPolicyFactory Add QualifiedNameSearchResult "); //$NON-NLS-1$
+ System.err.println("TODO: ReorgPolicyFactory Add QualifiedNameSearchResult "); //$NON-NLS-1$
}
// if (fQualifiedNameSearchResult != null) {
// return
@@ -2054,33 +1817,28 @@
// }
}
- private Change createReferenceUpdatingMoveChange(IProgressMonitor pm)
- throws ModelException {
+ private Change createReferenceUpdatingMoveChange(IProgressMonitor pm) throws ModelException {
pm.beginTask("", 2 + (fUpdateQualifiedNames ? 1 : 0)); //$NON-NLS-1$
try {
- CompositeChange composite = new DynamicValidationStateChange(
- RefactoringCoreMessages.ReorgPolicy_move);
+ CompositeChange composite = new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
composite.markAsSynthetic();
// XX workaround for bug 13558
// <workaround>
if (fChangeManager == null) {
- fChangeManager = createChangeManager(
- new SubProgressMonitor(pm, 1),
- new RefactoringStatus()); // TODO: non-CU matches
+ fChangeManager = createChangeManager(new SubProgressMonitor(pm, 1), new RefactoringStatus()); // TODO:
+ // non-CU
+ // matches
// silently dropped
- RefactoringStatus status = Checks
- .validateModifiesFiles(getAllModifiedFiles(), null);
+ RefactoringStatus status = Checks.validateModifiesFiles(getAllModifiedFiles(), null);
if (status.hasFatalError())
fChangeManager = new TextChangeManager();
}
// </workaround>
- composite.merge(new CompositeChange(
- RefactoringCoreMessages.MoveRefactoring_reorganize_elements,
+ composite.merge(new CompositeChange(RefactoringCoreMessages.MoveRefactoring_reorganize_elements,
fChangeManager.getAllChanges()));
- Change fileMove = createSimpleMoveChange(
- new SubProgressMonitor(pm, 1));
+ Change fileMove = createSimpleMoveChange(new SubProgressMonitor(pm, 1));
if (fileMove instanceof CompositeChange) {
composite.merge(((CompositeChange) fileMove));
} else {
@@ -2092,8 +1850,8 @@
}
}
- private TextChangeManager createChangeManager(IProgressMonitor pm,
- RefactoringStatus status) throws ModelException {
+ private TextChangeManager createChangeManager(IProgressMonitor pm, RefactoringStatus status)
+ throws ModelException {
pm.beginTask("", 1);//$NON-NLS-1$
try {
if (!fUpdateReferences)
@@ -2117,8 +1875,7 @@
}
private Change createSimpleMoveChange(IProgressMonitor pm) {
- CompositeChange result = new DynamicValidationStateChange(
- RefactoringCoreMessages.ReorgPolicy_move);
+ CompositeChange result = new DynamicValidationStateChange(RefactoringCoreMessages.ReorgPolicy_move);
result.markAsSynthetic();
IFile[] files = getFiles();
IFolder[] folders = getFolders();
@@ -2154,21 +1911,18 @@
return moveFileToContainer(cu, container);
}
- private static Change moveCuToPackage(ISourceModule cu,
- IScriptFolder dest) {
+ private static Change moveCuToPackage(ISourceModule cu, IScriptFolder dest) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource resource = ResourceUtil.getResource(cu);
if (resource != null && resource.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
- return moveFileToContainer(cu,
- (IContainer) ResourceUtil.getResource(dest));
+ return moveFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest));
}
return new MoveSourceModuleChange(cu, dest);
}
- private static Change moveFileToContainer(ISourceModule cu,
- IContainer dest) {
+ private static Change moveFileToContainer(ISourceModule cu, IContainer dest) {
return new MoveResourceChange(ResourceUtil.getResource(cu), dest);
}
@@ -2179,25 +1933,21 @@
return new MoveResourceChange(res, destinationAsContainer);
}
- private void computeQualifiedNameMatches(IProgressMonitor pm)
- throws ModelException {
+ private void computeQualifiedNameMatches(IProgressMonitor pm) throws ModelException {
if (!fUpdateQualifiedNames)
return;
IScriptFolder destination = getDestinationAsScriptFolder();
if (destination != null) {
ISourceModule[] cus = getCus();
pm.beginTask("", cus.length); //$NON-NLS-1$
- pm.subTask(
- RefactoringCoreMessages.MoveRefactoring_scanning_qualified_names);
+ pm.subTask(RefactoringCoreMessages.MoveRefactoring_scanning_qualified_names);
for (int i = 0; i < cus.length; i++) {
ISourceModule cu = cus[i];
IType[] types = cu.getTypes();
- IProgressMonitor typesMonitor = new SubProgressMonitor(pm,
- 1);
+ IProgressMonitor typesMonitor = new SubProgressMonitor(pm, 1);
typesMonitor.beginTask("", types.length); //$NON-NLS-1$
for (int j = 0; j < types.length; j++) {
- handleType(types[j], destination,
- new SubProgressMonitor(typesMonitor, 1));
+ handleType(types[j], destination, new SubProgressMonitor(typesMonitor, 1));
if (typesMonitor.isCanceled())
throw new OperationCanceledException();
}
@@ -2207,8 +1957,7 @@
pm.done();
}
- private void handleType(IType type, IScriptFolder destination,
- IProgressMonitor pm) {
+ private void handleType(IType type, IScriptFolder destination, IProgressMonitor pm) {
if (DLTKCore.DEBUG) {
System.err.println("TODO: Add QualifiedNameFinder support..."); //$NON-NLS-1$
}
@@ -2219,19 +1968,16 @@
}
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context, IReorgQueries reorgQueries)
- throws CoreException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context,
+ IReorgQueries reorgQueries) throws CoreException {
try {
pm.beginTask("", fUpdateQualifiedNames ? 7 : 3); //$NON-NLS-1$
RefactoringStatus result = new RefactoringStatus();
confirmMovingReadOnly(reorgQueries);
- fChangeManager = createChangeManager(
- new SubProgressMonitor(pm, 2), result);
+ fChangeManager = createChangeManager(new SubProgressMonitor(pm, 2), result);
if (fUpdateQualifiedNames)
computeQualifiedNameMatches(new SubProgressMonitor(pm, 4));
- result.merge(super.checkFinalConditions(
- new SubProgressMonitor(pm, 1), context, reorgQueries));
+ result.merge(super.checkFinalConditions(new SubProgressMonitor(pm, 1), context, reorgQueries));
return result;
} catch (ModelException e) {
throw e;
@@ -2242,10 +1988,9 @@
}
}
- private void confirmMovingReadOnly(IReorgQueries reorgQueries)
- throws CoreException {
- if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(
- getScriptElements(), getResources(), reorgQueries))
+ private void confirmMovingReadOnly(IReorgQueries reorgQueries) throws CoreException {
+ if (!ReadOnlyResourceFinder.confirmMoveOfReadOnlyElements(getScriptElements(), getResources(),
+ reorgQueries))
throw new OperationCanceledException(); // saying' no' to this
// one is like
// cancelling the whole
@@ -2255,8 +2000,7 @@
@Override
public IFile[] getAllModifiedFiles() {
Set result = new HashSet();
- result.addAll(Arrays.asList(ResourceUtil
- .getFiles(fChangeManager.getAllSourceModules())));
+ result.addAll(Arrays.asList(ResourceUtil.getFiles(fChangeManager.getAllSourceModules())));
// result.addAll(Arrays.asList(fQualifiedNameSearchResult.
// getAllFiles()));
if (getDestinationAsScriptFolder() != null && getUpdateReferences())
@@ -2266,8 +2010,7 @@
@Override
public boolean hasAllInputSet() {
- return super.hasAllInputSet() && !canUpdateReferences()
- && !canUpdateQualifiedNames();
+ return super.hasAllInputSet() && !canUpdateReferences() && !canUpdateQualifiedNames();
}
@Override
@@ -2295,15 +2038,13 @@
@Override
public boolean canEnableQualifiedNameUpdating() {
- return getCus().length > 0
- && !ModelElementUtil.isDefaultPackage(getCommonParent());
+ return getCus().length > 0 && !ModelElementUtil.isDefaultPackage(getCommonParent());
}
@Override
public boolean canUpdateQualifiedNames() {
IScriptFolder pack = getDestinationAsScriptFolder();
- return (canEnableQualifiedNameUpdating() && pack != null
- && !pack.isRootFolder());
+ return (canEnableQualifiedNameUpdating() && pack != null && !pack.isRootFolder());
}
@Override
@@ -2328,8 +2069,7 @@
}
@Override
- public ICreateTargetQuery getCreateTargetQuery(
- ICreateTargetQueries createQueries) {
+ public ICreateTargetQuery getCreateTargetQuery(ICreateTargetQueries createQueries) {
return createQueries.createNewPackageQuery();
}
@@ -2339,20 +2079,15 @@
}
}
- private static class NoMovePolicy extends ReorgPolicy
- implements IMovePolicy {
+ private static class NoMovePolicy extends ReorgPolicy implements IMovePolicy {
@Override
- protected RefactoringStatus verifyDestination(IResource resource)
- throws ModelException {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_noMoving);
+ protected RefactoringStatus verifyDestination(IResource resource) throws ModelException {
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_noMoving);
}
@Override
- protected RefactoringStatus verifyDestination(
- IModelElement modelElement) throws ModelException {
- return RefactoringStatus.createFatalErrorStatus(
- RefactoringCoreMessages.ReorgPolicyFactory_noMoving);
+ protected RefactoringStatus verifyDestination(IModelElement modelElement) throws ModelException {
+ return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ReorgPolicyFactory_noMoving);
}
@Override
@@ -2361,8 +2096,7 @@
}
@Override
- public Change postCreateChange(Change[] participantChanges,
- IProgressMonitor pm) throws CoreException {
+ public Change postCreateChange(Change[] participantChanges, IProgressMonitor pm) throws CoreException {
return null;
}
@@ -2382,8 +2116,7 @@
}
@Override
- public ICreateTargetQuery getCreateTargetQuery(
- ICreateTargetQueries createQueries) {
+ public ICreateTargetQuery getCreateTargetQuery(ICreateTargetQueries createQueries) {
return null;
}
@@ -2397,14 +2130,12 @@
private final IResource[] fResources;
private final IModelElement[] fScriptElements;
- public ActualSelectionComputer(IModelElement[] modelElements,
- IResource[] resources) {
+ public ActualSelectionComputer(IModelElement[] modelElements, IResource[] resources) {
fScriptElements = modelElements;
fResources = resources;
}
- public IModelElement[] getActualScriptElementsToReorg()
- throws ModelException {
+ public IModelElement[] getActualScriptElementsToReorg() throws ModelException {
List result = new ArrayList();
for (int i = 0; i < fScriptElements.length; i++) {
IModelElement element = fScriptElements[i];
@@ -2415,22 +2146,18 @@
if (element instanceof IType) {
IType type = (IType) element;
ISourceModule cu = type.getSourceModule();
- if (cu != null && type.getDeclaringType() == null
- && cu.exists() && cu.getTypes().length == 1
+ if (cu != null && type.getDeclaringType() == null && cu.exists() && cu.getTypes().length == 1
&& !result.contains(cu))
result.add(cu);
else if (!result.contains(type))
result.add(type);
- } else if (element instanceof IScriptFolder
- && !element.isReadOnly()
- && element.getResource() != null) {
+ } else if (element instanceof IScriptFolder && !element.isReadOnly() && element.getResource() != null) {
// skip
} else if (!result.contains(element)) {
result.add(element);
}
}
- return (IModelElement[]) result
- .toArray(new IModelElement[result.size()]);
+ return (IModelElement[]) result.toArray(new IModelElement[result.size()]);
}
public IResource[] getActualResourcesToReorg() {
@@ -2440,8 +2167,7 @@
if (fResources[i] == null)
continue;
IModelElement element = DLTKCore.create(fResources[i]);
- if (element == null || !element.exists()
- || !modelElementSet.contains(element))
+ if (element == null || !element.exists() || !modelElementSet.contains(element))
if (!result.contains(fResources[i]))
result.add(fResources[i]);
}
@@ -2449,8 +2175,7 @@
IModelElement element = fScriptElements[i];
if (element == null)
continue;
- if (element.getElementType() == IModelElement.SCRIPT_FOLDER
- && !element.isReadOnly()) {
+ if (element.getElementType() == IModelElement.SCRIPT_FOLDER && !element.isReadOnly()) {
IResource resource = element.getResource();
if (resource != null) {
if (!result.contains(resource))
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
index c80b88d..f796933 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ReorgUtils.java
@@ -53,13 +53,11 @@
}
public static boolean isProject(Object element) {
- return (element instanceof IScriptProject)
- || (element instanceof IProject);
+ return (element instanceof IScriptProject) || (element instanceof IProject);
}
public static boolean isInsideSourceModule(IModelElement element) {
- return !(element instanceof ISourceModule)
- && hasAncestorOfType(element, IModelElement.SOURCE_MODULE);
+ return !(element instanceof ISourceModule) && hasAncestorOfType(element, IModelElement.SOURCE_MODULE);
}
public static boolean hasAncestorOfType(IModelElement element, int type) {
@@ -69,8 +67,7 @@
public static ISourceModule getSourceModule(IModelElement modelElement) {
if (modelElement instanceof ISourceModule)
return (ISourceModule) modelElement;
- return (ISourceModule) modelElement
- .getAncestor(IModelElement.SOURCE_MODULE);
+ return (ISourceModule) modelElement.getAncestor(IModelElement.SOURCE_MODULE);
}
public static boolean isDeletedFromEditor(IModelElement elem) {
@@ -94,13 +91,13 @@
public static String getName(IModelElement element) throws ModelException {
String pattern = createNamePattern(element);
- String[] args = createNameArguments(element);
+ Object[] args = createNameArguments(element);
return Messages.format(pattern, args);
}
public static String getName(IResource resource) {
String pattern = createNamePattern(resource);
- String[] args = createNameArguments(resource);
+ Object[] args = createNameArguments(resource);
return Messages.format(pattern, args);
}
@@ -122,8 +119,7 @@
}
}
- private static String createNamePattern(IModelElement element)
- throws ModelException {
+ private static String createNamePattern(IModelElement element) throws ModelException {
switch (element.getElementType()) {
case IModelElement.SOURCE_MODULE:
if (element instanceof ExternalSourceModule) {
@@ -165,13 +161,11 @@
}
}
- private static String[] createNameArguments(IModelElement element)
- throws ModelException {
+ private static String[] createNameArguments(IModelElement element) throws ModelException {
switch (element.getElementType()) {
case IModelElement.SOURCE_MODULE:
if (element instanceof ExternalSourceModule) {
- return new String[] { ((ExternalSourceModule) element)
- .getFullPath().toString() };
+ return new String[] { ((ExternalSourceModule) element).getFullPath().toString() };
}
return new String[] { element.getElementName() };
case IModelElement.FIELD:
@@ -203,11 +197,9 @@
}
}
- public static boolean isSourceFolder(IModelElement modelElement)
- throws ModelException {
+ public static boolean isSourceFolder(IModelElement modelElement) throws ModelException {
return (modelElement instanceof IProjectFragment)
- && ((IProjectFragment) modelElement)
- .getKind() == IProjectFragment.K_SOURCE;
+ && ((IProjectFragment) modelElement).getKind() == IProjectFragment.K_SOURCE;
}
public static IResource[] getResources(List elements) {
@@ -242,8 +234,7 @@
Collection<IResource> result = new ArrayList<>(resources.length);
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
- if (resource != null && !result.contains(resource)
- && !resource.isLinked())
+ if (resource != null && !result.contains(resource) && !resource.isLinked())
result.add(resource);
}
return result.toArray(new IResource[result.size()]);
@@ -273,8 +264,7 @@
return result;
}
- public static List getElementsOfType(IModelElement[] modelElements,
- int type) {
+ public static List getElementsOfType(IModelElement[] modelElements, int type) {
List result = new ArrayList(modelElements.length);
for (int i = 0; i < modelElements.length; i++) {
if (isOfType(modelElements[i], type))
@@ -295,17 +285,14 @@
return (flags & flag) != 0;
}
- public static IModelElement[] setMinus(IModelElement[] setToRemoveFrom,
- IModelElement[] elementsToRemove) {
- Set<IModelElement> setMinus = new HashSet<>(
- setToRemoveFrom.length - setToRemoveFrom.length);
+ public static IModelElement[] setMinus(IModelElement[] setToRemoveFrom, IModelElement[] elementsToRemove) {
+ Set<IModelElement> setMinus = new HashSet<>(setToRemoveFrom.length - setToRemoveFrom.length);
setMinus.addAll(Arrays.asList(setToRemoveFrom));
setMinus.removeAll(Arrays.asList(elementsToRemove));
return setMinus.toArray(new IModelElement[setMinus.size()]);
}
- public static IModelElement[] union(IModelElement[] set1,
- IModelElement[] set2) {
+ public static IModelElement[] union(IModelElement[] set1, IModelElement[] set2) {
List<IModelElement> union = new ArrayList<>(set1.length + set2.length);// use
// lists
// to
@@ -336,10 +323,8 @@
}
}
- public static IResource[] setMinus(IResource[] setToRemoveFrom,
- IResource[] elementsToRemove) {
- Set<IResource> setMinus = new HashSet<>(
- setToRemoveFrom.length - setToRemoveFrom.length);
+ public static IResource[] setMinus(IResource[] setToRemoveFrom, IResource[] elementsToRemove) {
+ Set<IResource> setMinus = new HashSet<>(setToRemoveFrom.length - setToRemoveFrom.length);
setMinus.addAll(Arrays.asList(setToRemoveFrom));
setMinus.removeAll(Arrays.asList(elementsToRemove));
return setMinus.toArray(new IResource[setMinus.size()]);
@@ -355,8 +340,7 @@
return resources.toArray(new IModelElement[resources.size()]);
}
- public static ISourceModule[] getSourceModules(
- IModelElement[] modelElements) {
+ public static ISourceModule[] getSourceModules(IModelElement[] modelElements) {
ISourceModule[] result = new ISourceModule[modelElements.length];
for (int i = 0; i < modelElements.length; i++) {
result[i] = getSourceModule(modelElements[i]);
@@ -375,8 +359,8 @@
return result.toArray(new IWorkingSet[result.size()]);
}
- public static void splitIntoModelElementsAndResources(Object[] elements,
- List modelElementResult, List resourceResult) {
+ public static void splitIntoModelElementsAndResources(Object[] elements, List modelElementResult,
+ List resourceResult) {
for (int i = 0; i < elements.length; i++) {
Object element = elements[i];
if (element instanceof IModelElement) {
@@ -392,8 +376,7 @@
}
}
- public static boolean containsElementOrParent(Set elements,
- IModelElement element) {
+ public static boolean containsElementOrParent(Set elements, IModelElement element) {
if (elements.contains(element))
return true;
IModelElement parent = element.getParent();
@@ -405,8 +388,7 @@
return false;
}
- public static boolean containsElementOrParent(Set elements,
- IResource element) {
+ public static boolean containsElementOrParent(Set elements, IResource element) {
if (elements.contains(element))
return true;
IResource parent = element.getParent();
@@ -422,8 +404,7 @@
return false;
}
- public static boolean hasElementsNotOfType(IResource[] resources,
- int typeMask) {
+ public static boolean hasElementsNotOfType(IResource[] resources, int typeMask) {
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource != null && !isOfType(resource, typeMask))
@@ -432,8 +413,7 @@
return false;
}
- public static boolean hasElementsNotOfType(IModelElement[] modelElements,
- int type) {
+ public static boolean hasElementsNotOfType(IModelElement[] modelElements, int type) {
for (int i = 0; i < modelElements.length; i++) {
IModelElement element = modelElements[i];
if (element != null && !isOfType(element, type))
@@ -442,40 +422,34 @@
return false;
}
- public static boolean canBeDestinationForLinkedResources(
- IResource resource) {
+ public static boolean canBeDestinationForLinkedResources(IResource resource) {
return resource.isAccessible() && resource instanceof IProject;
}
- public static boolean canBeDestinationForLinkedResources(
- IModelElement modelElement) {
+ public static boolean canBeDestinationForLinkedResources(IModelElement modelElement) {
if (modelElement instanceof IProjectFragment) {
- return isProjectFragmentCorrespondingToProject(
- (IProjectFragment) modelElement);
+ return isProjectFragmentCorrespondingToProject((IProjectFragment) modelElement);
} else if (modelElement instanceof IScriptProject) {
return true;// XXX ???
} else
return false;
}
- private static boolean isProjectFragmentCorrespondingToProject(
- IProjectFragment root) {
+ private static boolean isProjectFragmentCorrespondingToProject(IProjectFragment root) {
return root.getResource() instanceof IProject;
}
public static boolean isArchiveOrExterrnalMember(IModelElement[] elements) {
for (int i = 0; i < elements.length; i++) {
IModelElement element = elements[i];
- IProjectFragment root = (IProjectFragment) element
- .getAncestor(IModelElement.PROJECT_FRAGMENT);
+ IProjectFragment root = (IProjectFragment) element.getAncestor(IModelElement.PROJECT_FRAGMENT);
if (root != null && (root.isArchive() || root.isExternal()))
return true;
}
return false;
}
- public static boolean hasElementsOfType(IModelElement[] modelElements,
- int type) {
+ public static boolean hasElementsOfType(IModelElement[] modelElements, int type) {
for (int i = 0; i < modelElements.length; i++) {
IModelElement element = modelElements[i];
if (element != null && isOfType(element, type))
@@ -484,8 +458,7 @@
return false;
}
- public static boolean hasElementsOfType(IModelElement[] modelElements,
- int[] types) {
+ public static boolean hasElementsOfType(IModelElement[] modelElements, int[] types) {
for (int i = 0; i < types.length; i++) {
if (hasElementsOfType(modelElements, types[i]))
return true;
@@ -493,8 +466,7 @@
return false;
}
- public static boolean hasElementsOfType(IResource[] resources,
- int typeMask) {
+ public static boolean hasElementsOfType(IResource[] resources, int typeMask) {
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource != null && isOfType(resource, typeMask))
@@ -522,8 +494,7 @@
return (IFolder[]) result.toArray(new IFolder[result.size()]);
}
- public static IProjectFragment getCorrespondingProjectFragment(
- IScriptProject p) throws ModelException {
+ public static IProjectFragment getCorrespondingProjectFragment(IScriptProject p) throws ModelException {
IProjectFragment[] roots = p.getProjectFragments();
for (int i = 0; i < roots.length; i++) {
if (isProjectFragmentCorrespondingToProject(roots[i]))
@@ -540,8 +511,7 @@
return false;
}
- public static boolean containsLinkedResources(
- IModelElement[] modelElements) {
+ public static boolean containsLinkedResources(IModelElement[] modelElements) {
for (int i = 0; i < modelElements.length; i++) {
IResource res = getResource(modelElements[i]);
if (res != null && res.isLinked())
@@ -550,13 +520,11 @@
return false;
}
- public static boolean isProjectFragment(IScriptProject scriptProject)
- throws ModelException {
+ public static boolean isProjectFragment(IScriptProject scriptProject) throws ModelException {
return getCorrespondingProjectFragment(scriptProject) != null;
}
- public static boolean areEqualInWorkspaceOrOnDisk(IResource r1,
- IResource r2) {
+ public static boolean areEqualInWorkspaceOrOnDisk(IResource r1, IResource r2) {
if (r1 == null || r2 == null)
return false;
if (r1.equals(r2))
@@ -568,8 +536,7 @@
return r1Location.equals(r2Location);
}
- public static boolean isParentInWorkspaceOrOnDisk(IScriptFolder pack,
- IProjectFragment root) {
+ public static boolean isParentInWorkspaceOrOnDisk(IScriptFolder pack, IProjectFragment root) {
if (pack == null)
return false;
IModelElement packParent = pack.getParent();
@@ -579,12 +546,10 @@
return true;
IResource packageResource = ResourceUtil.getResource(pack);
IResource packageRootResource = ResourceUtil.getResource(root);
- return isParentInWorkspaceOrOnDisk(packageResource,
- packageRootResource);
+ return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
- public static boolean isParentInWorkspaceOrOnDisk(IProjectFragment root,
- IScriptProject scriptProject) {
+ public static boolean isParentInWorkspaceOrOnDisk(IProjectFragment root, IScriptProject scriptProject) {
if (root == null)
return false;
IModelElement rootParent = root.getParent();
@@ -594,12 +559,10 @@
return true;
IResource packageResource = ResourceUtil.getResource(root);
IResource packageRootResource = ResourceUtil.getResource(scriptProject);
- return isParentInWorkspaceOrOnDisk(packageResource,
- packageRootResource);
+ return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
- public static boolean isParentInWorkspaceOrOnDisk(ISourceModule cu,
- IScriptFolder dest) {
+ public static boolean isParentInWorkspaceOrOnDisk(ISourceModule cu, IScriptFolder dest) {
if (cu == null)
return false;
IModelElement cuParent = cu.getParent();
@@ -612,8 +575,7 @@
return isParentInWorkspaceOrOnDisk(cuResource, packageResource);
}
- public static boolean isParentInWorkspaceOrOnDisk(IResource res,
- IResource maybeParent) {
+ public static boolean isParentInWorkspaceOrOnDisk(IResource res, IResource maybeParent) {
if (res == null)
return false;
return areEqualInWorkspaceOrOnDisk(res.getParent(), maybeParent);
diff --git a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ScriptDeleteProcessor.java b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ScriptDeleteProcessor.java
index 82b005f..bbddb53 100644
--- a/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ScriptDeleteProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/core refactoring/org/eclipse/dltk/internal/corext/refactoring/reorg/ScriptDeleteProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -60,8 +60,7 @@
import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
-public final class ScriptDeleteProcessor extends DeleteProcessor
- implements ICommentProvider {
+public final class ScriptDeleteProcessor extends DeleteProcessor implements ICommentProvider {
private boolean fWasCanceled;
private Object[] fElements;
@@ -79,8 +78,7 @@
public ScriptDeleteProcessor(Object[] elements) {
fElements = elements;
fResources = RefactoringAvailabilityTester.getResources(elements);
- fScriptElements = RefactoringAvailabilityTester
- .getScriptElements(elements);
+ fScriptElements = RefactoringAvailabilityTester.getScriptElements(elements);
fDeleteSubPackages = false;
fWasCanceled = false;
}
@@ -104,8 +102,7 @@
return false;
}
for (int i = 0; i < fScriptElements.length; i++) {
- if (!RefactoringAvailabilityTester
- .isDeleteAvailable(fScriptElements[i]))
+ if (!RefactoringAvailabilityTester.isDeleteAvailable(fScriptElements[i]))
return false;
}
return true;
@@ -136,17 +133,14 @@
}
@Override
- public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
- SharableParticipants shared) throws CoreException {
- return fDeleteModifications.loadParticipants(status, this,
- getAffectedProjectNatures(), shared);
+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants shared)
+ throws CoreException {
+ return fDeleteModifications.loadParticipants(status, this, getAffectedProjectNatures(), shared);
}
private String[] getAffectedProjectNatures() throws CoreException {
- String[] jNatures = ScriptProcessors
- .computeAffectedNaturs(fScriptElements);
- String[] rNatures = ResourceProcessors
- .computeAffectedNatures(fResources);
+ String[] jNatures = ScriptProcessors.computeAffectedNaturs(fScriptElements);
+ String[] rNatures = ResourceProcessors.computeAffectedNatures(fResources);
Set<String> result = new HashSet<>();
result.addAll(Arrays.asList(jNatures));
result.addAll(Arrays.asList(rNatures));
@@ -203,16 +197,13 @@
* checkActivation(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
- throws CoreException {
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
Assert.isNotNull(fDeleteQueries);// must be set before checking
// activation
RefactoringStatus result = new RefactoringStatus();
- result.merge(RefactoringStatus.create(
- Resources.checkInSync(ReorgUtils.getNotLinked(fResources))));
+ result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotLinked(fResources))));
IResource[] javaResources = ReorgUtils.getResources(fScriptElements);
- result.merge(RefactoringStatus.create(
- Resources.checkInSync(ReorgUtils.getNotLinked(javaResources))));
+ result.merge(RefactoringStatus.create(Resources.checkInSync(ReorgUtils.getNotLinked(javaResources))));
for (int i = 0; i < fScriptElements.length; i++) {
// IModelElement element= fScriptElements[i];
// if (element instanceof IType && ((IType)element).isAnonymous()) {
@@ -233,8 +224,8 @@
* org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
- CheckConditionsContext context) throws CoreException {
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
+ throws CoreException {
pm.beginTask(RefactoringCoreMessages.DeleteRefactoring_1, 1);
try {
fWasCanceled = false;
@@ -243,8 +234,8 @@
recalculateElementsToDelete();
TextChangeManager manager = new TextChangeManager();
- fDeleteChange = DeleteChangeCreator.createDeleteChange(manager,
- fResources, fScriptElements, getProcessorName());
+ fDeleteChange = DeleteChangeCreator.createDeleteChange(manager, fResources, fScriptElements,
+ getProcessorName());
checkDirtySourceModules(result);
checkDirtyResources(result);
fDeleteModifications = new DeleteModifications();
@@ -252,10 +243,8 @@
fDeleteModifications.delete(fScriptElements);
fDeleteModifications.postProcess();
- ResourceChangeChecker checker = context
- .getChecker(ResourceChangeChecker.class);
- IResourceChangeDescriptionFactory deltaFactory = checker
- .getDeltaFactory();
+ ResourceChangeChecker checker = context.getChecker(ResourceChangeChecker.class);
+ IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
fDeleteModifications.buildDelta(deltaFactory);
IFile[] files = getBuildpathFiles();
for (int i = 0; i < files.length; i++) {
@@ -278,8 +267,7 @@
}
}
- private void checkDirtySourceModules(RefactoringStatus result)
- throws CoreException {
+ private void checkDirtySourceModules(RefactoringStatus result) throws CoreException {
if (fScriptElements == null || fScriptElements.length == 0)
return;
for (int je = 0; je < fScriptElements.length; je++) {
@@ -287,8 +275,7 @@
if (element instanceof ISourceModule) {
checkDirtySourceModule(result, (ISourceModule) element);
} else if (element instanceof IScriptFolder) {
- ISourceModule[] units = ((IScriptFolder) element)
- .getSourceModules();
+ ISourceModule[] units = ((IScriptFolder) element).getSourceModules();
for (int u = 0; u < units.length; u++) {
checkDirtySourceModule(result, units[u]);
}
@@ -296,16 +283,14 @@
}
}
- private void checkDirtySourceModule(RefactoringStatus result,
- ISourceModule cunit) {
+ private void checkDirtySourceModule(RefactoringStatus result, ISourceModule cunit) {
IResource resource = cunit.getResource();
if (resource == null || resource.getType() != IResource.FILE)
return;
checkDirtyFile(result, (IFile) resource);
}
- private void checkDirtyResources(final RefactoringStatus result)
- throws CoreException {
+ private void checkDirtyResources(final RefactoringStatus result) throws CoreException {
for (int i = 0; i < fResources.length; i++) {
IResource resource = fResources[i];
resource.accept((IResourceVisitor) visitedResource -> {
@@ -320,16 +305,14 @@
private void checkDirtyFile(RefactoringStatus result, IFile file) {
if (file == null || !file.exists())
return;
- ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager()
- .getTextFileBuffer(file.getFullPath(), LocationKind.NORMALIZE);
+ ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(),
+ LocationKind.NORMALIZE);
if (buffer != null && buffer.isDirty()) {
if (buffer.isStateValidated() && buffer.isSynchronized()) {
- result.addWarning(Messages.format(
- RefactoringCoreMessages.ScriptDeleteProcessor_unsaved_changes,
+ result.addWarning(Messages.format(RefactoringCoreMessages.ScriptDeleteProcessor_unsaved_changes,
file.getFullPath().toString()));
} else {
- result.addFatalError(Messages.format(
- RefactoringCoreMessages.ScriptDeleteProcessor_unsaved_changes,
+ result.addFatalError(Messages.format(RefactoringCoreMessages.ScriptDeleteProcessor_unsaved_changes,
file.getFullPath().toString()));
}
}
@@ -338,54 +321,40 @@
/*
* The set of elements that will eventually be deleted may be very different
* from the set originally selected - there may be fewer, more or different
- * elements. This method is used to calculate the set of elements that will
- * be deleted - if necessary, it asks the user.
+ * elements. This method is used to calculate the set of elements that will be
+ * deleted - if necessary, it asks the user.
*/
private void recalculateElementsToDelete() throws CoreException {
// the sequence is critical here
if (fDeleteSubPackages) /*
- * add subpackages first, to allow removing
- * elements with parents in selection etc.
+ * add subpackages first, to allow removing elements with parents in selection
+ * etc.
*/
addSubPackages();
removeElementsWithParentsInSelection(); /*
- * ask before adding empty cus -
- * you don't want to ask if you,
- * for example delete the
- * package, in which the cus
- * live
+ * ask before adding empty cus - you don't want to ask if you, for
+ * example delete the package, in which the cus live
*/
removeUnconfirmedFoldersThatContainSourceFolders(); /*
- * a selected folder
- * may be a parent
- * of a source
- * folder we must
- * inform the user
- * about it and ask
- * if ok to delete
- * the folder
+ * a selected folder may be a parent of a source folder we
+ * must inform the user about it and ask if ok to delete the
+ * folder
*/
removeUnconfirmedReferencedArchives();
addEmptySourceModulesToDelete();
removeScriptElementsChildrenOfScriptElements();/*
- * because adding cus
- * may create elements
- * (types in cus) whose
- * parents are in
- * selection
+ * because adding cus may create elements (types in cus) whose
+ * parents are in selection
*/
confirmDeletingReadOnly(); /*
- * after empty cus - you want to ask for all
- * cus that are to be deleted
+ * after empty cus - you want to ask for all cus that are to be deleted
*/
addDeletableParentPackagesOnPackageDeletion(); /*
- * do not change the
- * sequence in
- * fScriptElements after
- * this method
+ * do not change the sequence in fScriptElements after this
+ * method
*/
}
@@ -401,15 +370,13 @@
for (int i = 0; i < fScriptElements.length; i++) {
if (fScriptElements[i] instanceof IScriptFolder) {
modelElements.addAll(
- Arrays.asList(ModelElementUtil.getPackageAndSubpackages(
- (IScriptFolder) fScriptElements[i])));
+ Arrays.asList(ModelElementUtil.getPackageAndSubpackages((IScriptFolder) fScriptElements[i])));
} else {
modelElements.add(fScriptElements[i]);
}
}
- fScriptElements = modelElements
- .toArray(new IModelElement[modelElements.size()]);
+ fScriptElements = modelElements.toArray(new IModelElement[modelElements.size()]);
}
/**
@@ -417,12 +384,10 @@
*
* @throws CoreException
*/
- private void addDeletableParentPackagesOnPackageDeletion()
- throws CoreException {
+ private void addDeletableParentPackagesOnPackageDeletion() throws CoreException {
- final List/* <IScriptFolder */ initialPackagesToDelete = ReorgUtils
- .getElementsOfType(fScriptElements,
- IModelElement.SCRIPT_FOLDER);
+ final List/* <IScriptFolder */ initialPackagesToDelete = ReorgUtils.getElementsOfType(fScriptElements,
+ IModelElement.SCRIPT_FOLDER);
if (initialPackagesToDelete.size() == 0)
return;
@@ -445,25 +410,19 @@
// new package list in the right sequence
final List<IScriptFolder> allFragmentsToDelete = new ArrayList<>();
- for (Iterator outerIter = initialPackagesToDelete.iterator(); outerIter
- .hasNext();) {
- final IScriptFolder currentScriptFolder = (IScriptFolder) outerIter
- .next();
+ for (Iterator outerIter = initialPackagesToDelete.iterator(); outerIter.hasNext();) {
+ final IScriptFolder currentScriptFolder = (IScriptFolder) outerIter.next();
// The package will at least be cleared
allFragmentsToDelete.add(currentScriptFolder);
- if (canRemoveCompletely(currentScriptFolder,
- initialPackagesToDelete)) {
+ if (canRemoveCompletely(currentScriptFolder, initialPackagesToDelete)) {
- final IScriptFolder parent = ModelElementUtil
- .getParentSubpackage(currentScriptFolder);
- if (parent != null
- && !initialPackagesToDelete.contains(parent)) {
+ final IScriptFolder parent = ModelElementUtil.getParentSubpackage(currentScriptFolder);
+ if (parent != null && !initialPackagesToDelete.contains(parent)) {
final List/* <IScriptFolder> */ emptyParents = new ArrayList();
- addDeletableParentPackages(parent, initialPackagesToDelete,
- deletedChildren, emptyParents);
+ addDeletableParentPackages(parent, initialPackagesToDelete, deletedChildren, emptyParents);
// Add parents in the right sequence (inner to outer)
allFragmentsToDelete.addAll(emptyParents);
@@ -476,8 +435,7 @@
for (int i = 0; i < fScriptElements.length; i++) {
if (!(fScriptElements[i] instanceof IScriptFolder)) {
// remove children of deleted packages
- final IScriptFolder frag = (IScriptFolder) fScriptElements[i]
- .getAncestor(IModelElement.SCRIPT_FOLDER);
+ final IScriptFolder frag = (IScriptFolder) fScriptElements[i].getAncestor(IModelElement.SCRIPT_FOLDER);
if (!allFragmentsToDelete.contains(frag))
modelElements.add(fScriptElements[i]);
}
@@ -495,23 +453,19 @@
resources.add(fResources[i]);
}
- fScriptElements = modelElements
- .toArray(new IModelElement[modelElements.size()]);
+ fScriptElements = modelElements.toArray(new IModelElement[modelElements.size()]);
fResources = resources.toArray(new IResource[resources.size()]);
}
/**
- * Returns true if this initially selected package is really deletable (if
- * it has non-selected subpackages, it may only be cleared).
+ * Returns true if this initially selected package is really deletable (if it
+ * has non-selected subpackages, it may only be cleared).
*
*/
- private boolean canRemoveCompletely(IScriptFolder pack,
- List packagesToDelete) throws ModelException {
- final IScriptFolder[] subPackages = ModelElementUtil
- .getPackageAndSubpackages(pack);
+ private boolean canRemoveCompletely(IScriptFolder pack, List packagesToDelete) throws ModelException {
+ final IScriptFolder[] subPackages = ModelElementUtil.getPackageAndSubpackages(pack);
for (int i = 0; i < subPackages.length; i++) {
- if (!(subPackages[i].equals(pack))
- && !(packagesToDelete.contains(subPackages[i])))
+ if (!(subPackages[i].equals(pack)) && !(packagesToDelete.contains(subPackages[i])))
return false;
}
return true;
@@ -519,26 +473,24 @@
/**
* Adds deletable parent packages of the fragment "frag" to the list
- * "deletableParentPackages"; also adds the resources of those packages to
- * the set "resourcesToDelete".
+ * "deletableParentPackages"; also adds the resources of those packages to the
+ * set "resourcesToDelete".
*
*/
- private void addDeletableParentPackages(IScriptFolder frag,
- List initialPackagesToDelete, Set resourcesToDelete,
+ private void addDeletableParentPackages(IScriptFolder frag, List initialPackagesToDelete, Set resourcesToDelete,
List deletableParentPackages) throws CoreException {
if (frag.getResource().isLinked()) {
final IConfirmQuery query = fDeleteQueries.createYesNoQuery(
- RefactoringCoreMessages.ScriptDeleteProcessor_confirm_linked_folder_delete,
- false, IReorgQueries.CONFIRM_DELETE_LINKED_PARENT);
- if (!query.confirm(Messages.format(
- RefactoringCoreMessages.ScriptDeleteProcessor_delete_linked_folder_question,
- new String[] { frag.getResource().getName() })))
+ RefactoringCoreMessages.ScriptDeleteProcessor_confirm_linked_folder_delete, false,
+ IReorgQueries.CONFIRM_DELETE_LINKED_PARENT);
+ if (!query.confirm(
+ Messages.format(RefactoringCoreMessages.ScriptDeleteProcessor_delete_linked_folder_question,
+ frag.getResource().getName())))
return;
}
- final IResource[] children = (((IContainer) frag.getResource()))
- .members();
+ final IResource[] children = (((IContainer) frag.getResource())).members();
for (int i = 0; i < children.length; i++) {
// Child must be a package fragment already in the list,
// or a resource which is deleted as well.
@@ -550,16 +502,14 @@
final IScriptFolder parent = ModelElementUtil.getParentSubpackage(frag);
if (parent != null && !initialPackagesToDelete.contains(parent))
- addDeletableParentPackages(parent, initialPackagesToDelete,
- resourcesToDelete, deletableParentPackages);
+ addDeletableParentPackages(parent, initialPackagesToDelete, resourcesToDelete, deletableParentPackages);
}
// ask for confirmation of deletion of all package fragment roots that are
// on buildpaths of other projects
private void removeUnconfirmedReferencedArchives() throws ModelException {
String queryTitle = RefactoringCoreMessages.DeleteRefactoring_2;
- IConfirmQuery query = fDeleteQueries.createYesYesToAllNoNoToAllQuery(
- queryTitle, true,
+ IConfirmQuery query = fDeleteQueries.createYesYesToAllNoNoToAllQuery(queryTitle, true,
IReorgQueries.CONFIRM_DELETE_REFERENCED_ARCHIVES);
removeUnconfirmedReferencedProjectFragments(query);
removeUnconfirmedReferencedArchiveFiles(query);
@@ -576,23 +526,19 @@
IScriptProject project = DLTKCore.create(resource.getProject());
if (project == null || !project.exists())
continue;
- IProjectFragment root = project
- .findProjectFragment(resource.getFullPath());
+ IProjectFragment root = project.findProjectFragment(resource.getFullPath());
if (root == null)
continue;
List referencingProjects = new ArrayList(1);
referencingProjects.add(root.getScriptProject());
- referencingProjects.addAll(Arrays
- .asList(ModelElementUtil.getReferencingProjects(root)));
+ referencingProjects.addAll(Arrays.asList(ModelElementUtil.getReferencingProjects(root)));
if (skipDeletingReferencedRoot(query, root, referencingProjects))
filesToSkip.add((IFile) resource);
}
- removeFromSetToDelete(
- filesToSkip.toArray(new IFile[filesToSkip.size()]));
+ removeFromSetToDelete(filesToSkip.toArray(new IFile[filesToSkip.size()]));
}
- private void removeUnconfirmedReferencedProjectFragments(
- IConfirmQuery query)
+ private void removeUnconfirmedReferencedProjectFragments(IConfirmQuery query)
throws ModelException, OperationCanceledException {
List<IModelElement> rootsToSkip = new ArrayList<>(0);
for (int i = 0; i < fScriptElements.length; i++) {
@@ -600,32 +546,24 @@
if (!(element instanceof IProjectFragment))
continue;
IProjectFragment root = (IProjectFragment) element;
- List referencingProjects = Arrays
- .asList(ModelElementUtil.getReferencingProjects(root));
+ List referencingProjects = Arrays.asList(ModelElementUtil.getReferencingProjects(root));
if (skipDeletingReferencedRoot(query, root, referencingProjects))
rootsToSkip.add(root);
}
- removeFromSetToDelete(
- rootsToSkip.toArray(new IModelElement[rootsToSkip.size()]));
+ removeFromSetToDelete(rootsToSkip.toArray(new IModelElement[rootsToSkip.size()]));
}
- private static boolean skipDeletingReferencedRoot(IConfirmQuery query,
- IProjectFragment root, List referencingProjects)
- throws OperationCanceledException {
- if (referencingProjects.isEmpty() || root == null || !root.exists()
- || !root.isArchive())
+ private static boolean skipDeletingReferencedRoot(IConfirmQuery query, IProjectFragment root,
+ List referencingProjects) throws OperationCanceledException {
+ if (referencingProjects.isEmpty() || root == null || !root.exists() || !root.isArchive())
return false;
- String question = Messages.format(
- RefactoringCoreMessages.DeleteRefactoring_3,
- root.getElementName());
+ String question = Messages.format(RefactoringCoreMessages.DeleteRefactoring_3, root.getElementName());
return !query.confirm(question, referencingProjects.toArray());
}
- private void removeUnconfirmedFoldersThatContainSourceFolders()
- throws CoreException {
+ private void removeUnconfirmedFoldersThatContainSourceFolders() throws CoreException {
String queryTitle = RefactoringCoreMessages.DeleteRefactoring_4;
- IConfirmQuery query = fDeleteQueries.createYesYesToAllNoNoToAllQuery(
- queryTitle, true,
+ IConfirmQuery query = fDeleteQueries.createYesYesToAllNoNoToAllQuery(queryTitle, true,
IReorgQueries.CONFIRM_DELETE_FOLDERS_CONTAINING_SOURCE_FOLDERS);
List<IResource> foldersToSkip = new ArrayList<>(0);
for (int i = 0; i < fResources.length; i++) {
@@ -633,20 +571,16 @@
if (resource instanceof IFolder) {
IFolder folder = (IFolder) resource;
if (containsSourceFolder(folder)) {
- String question = Messages.format(
- RefactoringCoreMessages.DeleteRefactoring_5,
- folder.getName());
+ String question = Messages.format(RefactoringCoreMessages.DeleteRefactoring_5, folder.getName());
if (!query.confirm(question))
foldersToSkip.add(folder);
}
}
}
- removeFromSetToDelete(
- foldersToSkip.toArray(new IResource[foldersToSkip.size()]));
+ removeFromSetToDelete(foldersToSkip.toArray(new IResource[foldersToSkip.size()]));
}
- private static boolean containsSourceFolder(IFolder folder)
- throws CoreException {
+ private static boolean containsSourceFolder(IFolder folder) throws CoreException {
IResource[] subFolders = folder.members();
for (int i = 0; i < subFolders.length; i++) {
if (!(subFolders[i] instanceof IFolder))
@@ -663,16 +597,14 @@
}
private void removeElementsWithParentsInSelection() {
- ParentChecker parentUtil = new ParentChecker(fResources,
- fScriptElements);
+ ParentChecker parentUtil = new ParentChecker(fResources, fScriptElements);
parentUtil.removeElementsWithAncestorsOnList(false);
fScriptElements = parentUtil.getScriptElements();
fResources = parentUtil.getResources();
}
private void removeScriptElementsChildrenOfScriptElements() {
- ParentChecker parentUtil = new ParentChecker(fResources,
- fScriptElements);
+ ParentChecker parentUtil = new ParentChecker(fResources, fScriptElements);
parentUtil.removeElementsWithAncestorsOnList(true);
fScriptElements = parentUtil.getScriptElements();
}
@@ -707,8 +639,7 @@
}
private void removeFromSetToDelete(IModelElement[] elementsToNotDelete) {
- fScriptElements = ReorgUtils.setMinus(fScriptElements,
- elementsToNotDelete);
+ fScriptElements = ReorgUtils.setMinus(fScriptElements, elementsToNotDelete);
}
// private static IField[] getFields(IModelElement[] elements){
@@ -722,8 +653,7 @@
// ----------- read-only confirmation business ------
private void confirmDeletingReadOnly() throws CoreException {
- if (!ReadOnlyResourceFinder.confirmDeleteOfReadOnlyElements(
- fScriptElements, fResources, fDeleteQueries))
+ if (!ReadOnlyResourceFinder.confirmDeleteOfReadOnlyElements(fScriptElements, fResources, fDeleteQueries))
throw new OperationCanceledException(); // saying 'no' to this one
// is like cancelling the
// whole operation
@@ -732,8 +662,7 @@
// ----------- empty source modules related method
private void addEmptySourceModulesToDelete() throws ModelException {
Set<ISourceModule> modulesToEmpty = getCusToEmpty();
- addToSetToDelete(modulesToEmpty
- .toArray(new ISourceModule[modulesToEmpty.size()]));
+ addToSetToDelete(modulesToEmpty.toArray(new ISourceModule[modulesToEmpty.size()]));
}
private Set<ISourceModule> getCusToEmpty() throws ModelException {
@@ -742,10 +671,8 @@
IModelElement element = fScriptElements[i];
ISourceModule module = ReorgUtils.getSourceModule(element);
if (module != null && !result.contains(module)) {
- IDLTKLanguageToolkit toolkit = DLTKLanguageManager
- .getLanguageToolkit(module);
- if (toolkit != null && toolkit
- .get(DLTKFeatures.DELETE_MODULE_WITHOUT_TOP_LEVEL_TYPES)
+ IDLTKLanguageToolkit toolkit = DLTKLanguageManager.getLanguageToolkit(module);
+ if (toolkit != null && toolkit.get(DLTKFeatures.DELETE_MODULE_WITHOUT_TOP_LEVEL_TYPES)
&& willHaveAllTopLevelTypesDeleted(module)) {
result.add(module);
}
@@ -754,8 +681,7 @@
return result;
}
- private boolean willHaveAllTopLevelTypesDeleted(ISourceModule cu)
- throws ModelException {
+ private boolean willHaveAllTopLevelTypesDeleted(ISourceModule cu) throws ModelException {
Set elementSet = new HashSet(Arrays.asList(fScriptElements));
IType[] topLevelTypes = cu.getTypes();
for (int i = 0; i < topLevelTypes.length; i++) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
index af4c218..7f9a397 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyLabelProvider.java
@@ -25,18 +25,14 @@
//
// private static final long TEXTFLAGS= DEFAULT_TEXTFLAGS | FULLY_QUALIFIED | ScriptElementLabels.P_POST_QUALIFIED | ScriptElementLabels.P_COMPRESSED;// | ScriptElementLabels.M_FULLY_QUALIFIED | ScriptElementLabels.PREPEND_ROOT_PATH;
// private static final int IMAGEFLAGS= DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS;
- private static final long TEXTFLAGS = DEFAULT_TEXTFLAGS
- | ScriptElementLabels.ALL_POST_QUALIFIED
- | ScriptElementLabels.P_COMPRESSED | ScriptElementLabels.APPEND_FILE
- | ScriptElementLabels.APPEND_ROOT_PATH;
- private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS
- | ScriptElementImageProvider.SMALL_ICONS;
+ private static final long TEXTFLAGS = DEFAULT_TEXTFLAGS | ScriptElementLabels.ALL_POST_QUALIFIED
+ | ScriptElementLabels.P_COMPRESSED | ScriptElementLabels.APPEND_FILE | ScriptElementLabels.APPEND_ROOT_PATH;
+ private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS;
private ILabelDecorator fDecorator;
CallHierarchyLabelProvider() {
- super(TEXTFLAGS, IMAGEFLAGS,
- DLTKUIPlugin.getDefault().getPreferenceStore());
+ super(TEXTFLAGS, IMAGEFLAGS, DLTKUIPlugin.getDefault().getPreferenceStore());
fDecorator = new CallHierarchyLabelDecorator();
}
@@ -47,9 +43,7 @@
MethodWrapper methodWrapper = (MethodWrapper) element;
if (methodWrapper.getMember() != null) {
- result = fDecorator.decorateImage(
- super.getImage(methodWrapper.getMember()),
- methodWrapper);
+ result = fDecorator.decorateImage(super.getImage(methodWrapper.getMember()), methodWrapper);
}
} else if (isPendingUpdate(element)) {
return null;
@@ -85,14 +79,11 @@
private String getElementLabel(MethodWrapper methodWrapper) {
String label = super.getText(methodWrapper.getMember());
- Collection callLocations = methodWrapper.getMethodCall()
- .getCallLocations();
+ Collection callLocations = methodWrapper.getMethodCall().getCallLocations();
if ((callLocations != null) && (callLocations.size() > 1)) {
- return Messages.format(
- CallHierarchyMessages.CallHierarchyLabelProvider_matches,
- new String[] { label,
- String.valueOf(callLocations.size()) });
+ return Messages.format(CallHierarchyMessages.CallHierarchyLabelProvider_matches, label,
+ String.valueOf(callLocations.size()));
}
return label;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyUI.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyUI.java
index 384b7b3..1fc7144 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyUI.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyUI.java
@@ -5,7 +5,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
+
* (report 36180: Callers/Callees view)
*******************************************************************************/
package org.eclipse.dltk.internal.ui.callhierarchy;
@@ -46,238 +46,234 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.texteditor.ITextEditor;
-
public class CallHierarchyUI {
- private static final int DEFAULT_MAX_CALL_DEPTH= 10;
- private static final String PREF_MAX_CALL_DEPTH = "PREF_MAX_CALL_DEPTH"; //$NON-NLS-1$
+ private static final int DEFAULT_MAX_CALL_DEPTH = 10;
+ private static final String PREF_MAX_CALL_DEPTH = "PREF_MAX_CALL_DEPTH"; //$NON-NLS-1$
- private static CallHierarchyUI fgInstance;
+ private static CallHierarchyUI fgInstance;
- private CallHierarchyUI() {
- // Do nothing
- }
+ private CallHierarchyUI() {
+ // Do nothing
+ }
- public static CallHierarchyUI getDefault() {
- if (fgInstance == null) {
- fgInstance = new CallHierarchyUI();
- }
+ public static CallHierarchyUI getDefault() {
+ if (fgInstance == null) {
+ fgInstance = new CallHierarchyUI();
+ }
- return fgInstance;
- }
+ return fgInstance;
+ }
- /**
- * Returns the maximum tree level allowed
- * @return int
- */
- public int getMaxCallDepth() {
- int maxCallDepth;
-
- IPreferenceStore settings = DLTKUIPlugin.getDefault().getPreferenceStore();
- maxCallDepth = settings.getInt(PREF_MAX_CALL_DEPTH);
- if (maxCallDepth < 1 || maxCallDepth > 99) {
- maxCallDepth= DEFAULT_MAX_CALL_DEPTH;
- }
+ /**
+ * Returns the maximum tree level allowed
+ *
+ * @return int
+ */
+ public int getMaxCallDepth() {
+ int maxCallDepth;
- return maxCallDepth;
- }
+ IPreferenceStore settings = DLTKUIPlugin.getDefault().getPreferenceStore();
+ maxCallDepth = settings.getInt(PREF_MAX_CALL_DEPTH);
+ if (maxCallDepth < 1 || maxCallDepth > 99) {
+ maxCallDepth = DEFAULT_MAX_CALL_DEPTH;
+ }
- public void setMaxCallDepth(int maxCallDepth) {
- IPreferenceStore settings = DLTKUIPlugin.getDefault().getPreferenceStore();
- settings.setValue(PREF_MAX_CALL_DEPTH, maxCallDepth);
- }
-
- public static void jumpToMember(IModelElement element) {
- if (element != null) {
- try {
- IEditorPart methodEditor = EditorUtility.openInEditor(element, true);
- EditorUtility.revealInEditor(methodEditor, element);
- } catch (ModelException e) {
- DLTKUIPlugin.log(e);
- } catch (PartInitException e) {
- DLTKUIPlugin.log(e);
- }
- }
- }
+ return maxCallDepth;
+ }
- public static void jumpToLocation(CallLocation callLocation) {
- try {
- IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(),
- false);
+ public void setMaxCallDepth(int maxCallDepth) {
+ IPreferenceStore settings = DLTKUIPlugin.getDefault().getPreferenceStore();
+ settings.setValue(PREF_MAX_CALL_DEPTH, maxCallDepth);
+ }
- if (methodEditor instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) methodEditor;
- editor.selectAndReveal(callLocation.getStart(),
- (callLocation.getEnd() - callLocation.getStart()));
- }
- } catch (ModelException e) {
- DLTKUIPlugin.log(e);
- } catch (PartInitException e) {
- DLTKUIPlugin.log(e);
- }
- }
+ public static void jumpToMember(IModelElement element) {
+ if (element != null) {
+ try {
+ IEditorPart methodEditor = EditorUtility.openInEditor(element, true);
+ EditorUtility.revealInEditor(methodEditor, element);
+ } catch (ModelException e) {
+ DLTKUIPlugin.log(e);
+ } catch (PartInitException e) {
+ DLTKUIPlugin.log(e);
+ }
+ }
+ }
- /**
- * @return <code>true</code> iff no error occurred while trying to
- * open the editor, <code>false</code> iff an error dialog was raised.
- */
- public static boolean openInEditor(Object element, Shell shell, String title) {
- CallLocation callLocation= CallHierarchy.getCallLocation(element);
-
- try {
- IModelElement enclosingMember;
- int selectionStart;
+ public static void jumpToLocation(CallLocation callLocation) {
+ try {
+ IEditorPart methodEditor = EditorUtility.openInEditor(callLocation.getMember(), false);
+
+ if (methodEditor instanceof ITextEditor) {
+ ITextEditor editor = (ITextEditor) methodEditor;
+ editor.selectAndReveal(callLocation.getStart(), (callLocation.getEnd() - callLocation.getStart()));
+ }
+ } catch (ModelException e) {
+ DLTKUIPlugin.log(e);
+ } catch (PartInitException e) {
+ DLTKUIPlugin.log(e);
+ }
+ }
+
+ /**
+ * @return <code>true</code> iff no error occurred while trying to open the
+ * editor, <code>false</code> iff an error dialog was raised.
+ */
+ public static boolean openInEditor(Object element, Shell shell, String title) {
+ CallLocation callLocation = CallHierarchy.getCallLocation(element);
+
+ try {
+ IModelElement enclosingMember;
+ int selectionStart;
int selectionLength;
-
- if (callLocation != null) {
- enclosingMember= callLocation.getMember();
- selectionStart= callLocation.getStart();
- selectionLength= callLocation.getEnd() - selectionStart;
- } else if (element instanceof MethodWrapper) {
- enclosingMember= ((MethodWrapper) element).getMember();
- ISourceRange selectionRange= null;
- if( enclosingMember instanceof IMember ) {
- selectionRange = ((IMember)enclosingMember).getNameRange();
- }
- if (selectionRange == null && enclosingMember instanceof IMember)
- selectionRange= ((IMember)enclosingMember).getSourceRange();
- if (selectionRange == null)
- return true;
- selectionStart= selectionRange.getOffset();
- selectionLength= selectionRange.getLength();
- } else {
- return true;
- }
-
- boolean activateOnOpen = OpenStrategy.activateOnOpen();
+
+ if (callLocation != null) {
+ enclosingMember = callLocation.getMember();
+ selectionStart = callLocation.getStart();
+ selectionLength = callLocation.getEnd() - selectionStart;
+ } else if (element instanceof MethodWrapper) {
+ enclosingMember = ((MethodWrapper) element).getMember();
+ ISourceRange selectionRange = null;
+ if (enclosingMember instanceof IMember) {
+ selectionRange = ((IMember) enclosingMember).getNameRange();
+ }
+ if (selectionRange == null && enclosingMember instanceof IMember)
+ selectionRange = ((IMember) enclosingMember).getSourceRange();
+ if (selectionRange == null)
+ return true;
+ selectionStart = selectionRange.getOffset();
+ selectionLength = selectionRange.getLength();
+ } else {
+ return true;
+ }
+
+ boolean activateOnOpen = OpenStrategy.activateOnOpen();
IEditorPart methodEditor = EditorUtility.openInEditor(enclosingMember, activateOnOpen);
- if (methodEditor instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) methodEditor;
+ if (methodEditor instanceof ITextEditor) {
+ ITextEditor editor = (ITextEditor) methodEditor;
editor.selectAndReveal(selectionStart, selectionLength);
- }
- return true;
- } catch (ModelException e) {
- DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(),
- IDLTKStatusConstants.INTERNAL_ERROR,
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message, e));
+ }
+ return true;
+ } catch (ModelException e) {
+ DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), IDLTKStatusConstants.INTERNAL_ERROR,
+ CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message, e));
- ErrorDialog.openError(shell, title,
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message,
- e.getStatus());
- return false;
- } catch (PartInitException x) {
- String name;
- if (callLocation != null)
- name= callLocation.getCalledMember().getElementName();
- else if (element instanceof MethodWrapper)
- name= ((MethodWrapper) element).getName();
- else
- name= ""; //$NON-NLS-1$
- MessageDialog.openError(shell, title,
- Messages.format(
- CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_messageArgs,
- new String[] { name, x.getMessage() }));
- return false;
- }
- }
+ ErrorDialog.openError(shell, title, CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_message,
+ e.getStatus());
+ return false;
+ } catch (PartInitException x) {
+ String name;
+ if (callLocation != null)
+ name = callLocation.getCalledMember().getElementName();
+ else if (element instanceof MethodWrapper)
+ name = ((MethodWrapper) element).getName();
+ else
+ name = ""; //$NON-NLS-1$
+ MessageDialog.openError(shell, title, Messages.format(
+ CallHierarchyMessages.CallHierarchyUI_open_in_editor_error_messageArgs, name, x.getMessage()));
+ return false;
+ }
+ }
- public static IEditorPart isOpenInEditor(Object elem) {
- IModelElement modelElement= null;
- if (elem instanceof MethodWrapper) {
- modelElement= ((MethodWrapper) elem).getMember();
- } else if (elem instanceof CallLocation) {
- modelElement= ((CallLocation) elem).getCalledMember();
- }
- if (modelElement != null) {
- return EditorUtility.isOpenInEditor(modelElement);
- }
- return null;
- }
+ public static IEditorPart isOpenInEditor(Object elem) {
+ IModelElement modelElement = null;
+ if (elem instanceof MethodWrapper) {
+ modelElement = ((MethodWrapper) elem).getMember();
+ } else if (elem instanceof CallLocation) {
+ modelElement = ((CallLocation) elem).getCalledMember();
+ }
+ if (modelElement != null) {
+ return EditorUtility.isOpenInEditor(modelElement);
+ }
+ return null;
+ }
- /**
- * Converts the input to a possible input candidates
- */
- public static IModelElement[] getCandidates(Object input) {
- if (!(input instanceof IModelElement)) {
- return null;
- }
- IModelElement elem= (IModelElement) input;
- if (elem.getElementType() == IModelElement.METHOD) {
- return new IModelElement[] { elem };
- }
- return null;
- }
-
- public static CallHierarchyViewPart open(IModelElement[] candidates, IWorkbenchWindow window, String partID) {
- Assert.isTrue(candidates != null && candidates.length != 0);
-
- IModelElement input= null;
- if (candidates.length > 1) {
- String title= CallHierarchyMessages.CallHierarchyUI_selectionDialog_title;
- String message= CallHierarchyMessages.CallHierarchyUI_selectionDialog_message;
- input= OpenActionUtil.selectModelElement(candidates, window.getShell(), title, message);
- } else {
- input= candidates[0];
- }
- if (input == null)
- return null;
-
- return openInViewPart(window, input, partID);
- }
+ /**
+ * Converts the input to a possible input candidates
+ */
+ public static IModelElement[] getCandidates(Object input) {
+ if (!(input instanceof IModelElement)) {
+ return null;
+ }
+ IModelElement elem = (IModelElement) input;
+ if (elem.getElementType() == IModelElement.METHOD) {
+ return new IModelElement[] { elem };
+ }
+ return null;
+ }
- private static void openEditor(Object input, boolean activate) throws PartInitException, ModelException {
- IEditorPart part= EditorUtility.openInEditor(input, activate);
- if (input instanceof IModelElement)
- EditorUtility.revealInEditor(part, (IModelElement) input);
- }
-
- private static CallHierarchyViewPart openInViewPart(IWorkbenchWindow window, IModelElement input, String partID) {
- IWorkbenchPage page= window.getActivePage();
- try {
- CallHierarchyViewPart result= (CallHierarchyViewPart)page.showView(partID);
- result.setMethod((IMethod)input);
- openEditor(input, false);
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CallHierarchyMessages.CallHierarchyUI_error_open_view, e.getMessage());
- }
- return null;
- }
-
- /**
- * Converts an ISelection (containing MethodWrapper instances) to an ISelection
- * with the MethodWrapper's replaced by their corresponding IMembers. If the selection
- * contains elements which are not MethodWrapper instances or not already IMember instances
- * they are discarded.
- * @param selection The selection to convert.
- * @return An ISelection containing IMember's in place of MethodWrapper instances.
- */
- static ISelection convertSelection(ISelection selection) {
- if (selection.isEmpty()) {
- return selection;
- }
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) selection;
- List modelElements= new ArrayList();
- for (Iterator iter= structuredSelection.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof MethodWrapper) {
- IModelElement member= ((MethodWrapper)element).getMember();
- if (member != null) {
- modelElements.add(member);
- }
- } else if (element instanceof IMember) {
- modelElements.add(element);
- } else if (element instanceof CallLocation) {
- IModelElement member = ((CallLocation) element).getMember();
- modelElements.add(member);
- }
- }
- return new StructuredSelection(modelElements);
- }
- return StructuredSelection.EMPTY;
- }
+ public static CallHierarchyViewPart open(IModelElement[] candidates, IWorkbenchWindow window, String partID) {
+ Assert.isTrue(candidates != null && candidates.length != 0);
+
+ IModelElement input = null;
+ if (candidates.length > 1) {
+ String title = CallHierarchyMessages.CallHierarchyUI_selectionDialog_title;
+ String message = CallHierarchyMessages.CallHierarchyUI_selectionDialog_message;
+ input = OpenActionUtil.selectModelElement(candidates, window.getShell(), title, message);
+ } else {
+ input = candidates[0];
+ }
+ if (input == null)
+ return null;
+
+ return openInViewPart(window, input, partID);
+ }
+
+ private static void openEditor(Object input, boolean activate) throws PartInitException, ModelException {
+ IEditorPart part = EditorUtility.openInEditor(input, activate);
+ if (input instanceof IModelElement)
+ EditorUtility.revealInEditor(part, (IModelElement) input);
+ }
+
+ private static CallHierarchyViewPart openInViewPart(IWorkbenchWindow window, IModelElement input, String partID) {
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ CallHierarchyViewPart result = (CallHierarchyViewPart) page.showView(partID);
+ result.setMethod((IMethod) input);
+ openEditor(input, false);
+ return result;
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, window.getShell(), CallHierarchyMessages.CallHierarchyUI_error_open_view,
+ e.getMessage());
+ }
+ return null;
+ }
+
+ /**
+ * Converts an ISelection (containing MethodWrapper instances) to an ISelection
+ * with the MethodWrapper's replaced by their corresponding IMembers. If the
+ * selection contains elements which are not MethodWrapper instances or not
+ * already IMember instances they are discarded.
+ *
+ * @param selection The selection to convert.
+ * @return An ISelection containing IMember's in place of MethodWrapper
+ * instances.
+ */
+ static ISelection convertSelection(ISelection selection) {
+ if (selection.isEmpty()) {
+ return selection;
+ }
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ List modelElements = new ArrayList();
+ for (Iterator iter = structuredSelection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof MethodWrapper) {
+ IModelElement member = ((MethodWrapper) element).getMember();
+ if (member != null) {
+ modelElements.add(member);
+ }
+ } else if (element instanceof IMember) {
+ modelElements.add(element);
+ } else if (element instanceof CallLocation) {
+ IModelElement member = ((CallLocation) element).getMember();
+ modelElements.add(member);
+ }
+ }
+ return new StructuredSelection(modelElements);
+ }
+ return StructuredSelection.EMPTY;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
index f7902c3..0476179 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
@@ -91,11 +91,9 @@
* selected method.
*
*/
-public class CallHierarchyViewPart extends ViewPart
- implements ICallHierarchyViewPart, ISelectionChangedListener {
+public class CallHierarchyViewPart extends ViewPart implements ICallHierarchyViewPart, ISelectionChangedListener {
- private class CallHierarchySelectionProvider
- extends SelectionProviderMediator {
+ private class CallHierarchySelectionProvider extends SelectionProviderMediator {
public CallHierarchySelectionProvider(StructuredViewer[] viewers) {
super(viewers, null);
@@ -114,8 +112,7 @@
private static final String DIALOGSTORE_VIEWORIENTATION = "CallHierarchyViewPart.orientation"; //$NON-NLS-1$
private static final String DIALOGSTORE_CALL_MODE = "CallHierarchyViewPart.call_mode"; //$NON-NLS-1$
/**
- * The key to be used is
- * <code>DIALOGSTORE_RATIO + fCurrentOrientation</code>.
+ * The key to be used is <code>DIALOGSTORE_RATIO + fCurrentOrientation</code>.
*/
private static final String DIALOGSTORE_RATIO = "CallHierarchyViewPart.ratio"; //$NON-NLS-1$
@@ -196,8 +193,7 @@
updateHistoryEntries();
}
- return (IMethod[]) fMethodHistory
- .toArray(new IMethod[fMethodHistory.size()]);
+ return (IMethod[]) fMethodHistory.toArray(new IMethod[fMethodHistory.size()]);
}
/**
@@ -249,16 +245,12 @@
/**
* called from ToggleOrientationAction.
*
- * @param orientation
- * VIEW_ORIENTATION_HORIZONTAL or
- * VIEW_ORIENTATION_VERTICAL
+ * @param orientation VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
*/
void setOrientation(int orientation) {
if (fCurrentOrientation != orientation) {
- if ((fLocationViewer != null)
- && !fLocationViewer.getControl().isDisposed()
- && (fHierarchyLocationSplitter != null)
- && !fHierarchyLocationSplitter.isDisposed()) {
+ if ((fLocationViewer != null) && !fLocationViewer.getControl().isDisposed()
+ && (fHierarchyLocationSplitter != null) && !fHierarchyLocationSplitter.isDisposed()) {
if (orientation == CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
setShowCallDetails(false);
} else {
@@ -267,8 +259,7 @@
}
boolean horizontal = orientation == CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL;
- fHierarchyLocationSplitter.setOrientation(
- horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
+ fHierarchyLocationSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
}
fHierarchyLocationSplitter.layout();
@@ -284,28 +275,23 @@
private void updateCheckedState() {
for (int i = 0; i < fToggleOrientationActions.length; i++) {
- fToggleOrientationActions[i]
- .setChecked(fOrientation == fToggleOrientationActions[i]
- .getOrientation());
+ fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
}
}
/**
* called from ToggleCallModeAction.
*
- * @param mode
- * CALL_MODE_CALLERS or CALL_MODE_CALLEES
+ * @param mode CALL_MODE_CALLERS or CALL_MODE_CALLEES
*/
void setCallMode(int mode) {
if (fCurrentCallMode != mode) {
for (int i = 0; i < fToggleCallModeActions.length; i++) {
- fToggleCallModeActions[i].setChecked(
- mode == fToggleCallModeActions[i].getMode());
+ fToggleCallModeActions[i].setChecked(mode == fToggleCallModeActions[i].getMode());
}
fCurrentCallMode = mode;
- fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_CALL_MODE,
- mode);
+ fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_CALL_MODE, mode);
updateView();
}
@@ -326,35 +312,27 @@
addDropAdapters(fLocationViewer);
// dnd on empty hierarchy
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE
- | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(
- new Transfer[] { LocalSelectionTransfer.getTransfer() });
- dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this,
- fCallHierarchyViewer));
+ DropTarget dropTarget = new DropTarget(fPagebook,
+ DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+ dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() });
+ dropTarget.addDropListener(new CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer));
}
private void addDropAdapters(StructuredViewer viewer) {
- Transfer[] transfers = new Transfer[] {
- LocalSelectionTransfer.getTransfer() };
- int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK
- | DND.DROP_DEFAULT;
+ Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer() };
+ int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
TransferDropTargetListener[] dropListeners = new TransferDropTargetListener[] {
new CallHierarchyTransferDropAdapter(this, viewer) };
- viewer.addDropSupport(ops, transfers,
- new DelegatingDropAdapter(dropListeners));
+ viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
}
private void addDragAdapters(StructuredViewer viewer) {
int ops = DND.DROP_COPY | DND.DROP_LINK;
- Transfer[] transfers = new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance() };
+ Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer(), ResourceTransfer.getInstance() };
TransferDragSourceListener[] dragListeners = new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(viewer),
- new ResourceTransferDragAdapter(viewer) };
+ new SelectionTransferDragAdapter(viewer), new ResourceTransferDragAdapter(viewer) };
// viewer.addDragSupport(ops, transfers, new
// DLTKViewerDragAdapter(viewer, dragListeners));
}
@@ -371,10 +349,8 @@
createLocationViewer(fHierarchyLocationSplitter);
// Page 2: Nothing selected
- fNoHierarchyShownLabel = new Label(fPagebook,
- SWT.TOP + SWT.LEFT + SWT.WRAP);
- fNoHierarchyShownLabel
- .setText(CallHierarchyMessages.CallHierarchyViewPart_empty); //
+ fNoHierarchyShownLabel = new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
+ fNoHierarchyShownLabel.setText(CallHierarchyMessages.CallHierarchyViewPart_empty); //
initDragAndDrop();
@@ -387,17 +363,13 @@
}
fSelectionProviderMediator = new CallHierarchySelectionProvider(
- new StructuredViewer[] { fCallHierarchyViewer,
- fLocationViewer });
+ new StructuredViewer[] { fCallHierarchyViewer, fLocationViewer });
- IStatusLineManager slManager = getViewSite().getActionBars()
- .getStatusLineManager();
- fSelectionProviderMediator
- .addSelectionChangedListener(new StatusBarUpdater(slManager));
+ IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager();
+ fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
getSite().setSelectionProvider(fSelectionProviderMediator);
- fCallHierarchyViewer.initContextMenu(
- menu -> fillCallHierarchyViewerContextMenu(menu), getSite(),
+ fCallHierarchyViewer.initContextMenu(menu -> fillCallHierarchyViewerContextMenu(menu), getSite(),
fSelectionProviderMediator);
fClipboard = new Clipboard(parent.getDisplay());
@@ -414,32 +386,26 @@
}
restoreSplitterRatio();
addPartListener();
- IContextService ctxService = getSite()
- .getService(IContextService.class);
+ IContextService ctxService = getSite().getService(IContextService.class);
if (ctxService != null) {
- fContextActivation = ctxService
- .activateContext(DLTKUIPlugin.CONTEXT_VIEWS);
+ fContextActivation = ctxService.activateContext(DLTKUIPlugin.CONTEXT_VIEWS);
}
}
private void restoreSplitterRatio() {
- String ratio = fDialogSettings.get(
- CallHierarchyViewPart.DIALOGSTORE_RATIO + fCurrentOrientation);
+ String ratio = fDialogSettings.get(CallHierarchyViewPart.DIALOGSTORE_RATIO + fCurrentOrientation);
if (ratio == null) {
return;
}
int intRatio = Integer.parseInt(ratio);
- fHierarchyLocationSplitter
- .setWeights(new int[] { intRatio, 1000 - intRatio });
+ fHierarchyLocationSplitter.setWeights(new int[] { intRatio, 1000 - intRatio });
}
private void saveSplitterRatio() {
- if (fHierarchyLocationSplitter != null
- && !fHierarchyLocationSplitter.isDisposed()) {
+ if (fHierarchyLocationSplitter != null && !fHierarchyLocationSplitter.isDisposed()) {
int[] weigths = fHierarchyLocationSplitter.getWeights();
int ratio = (weigths[0] * 1000) / (weigths[0] + weigths[1]);
- String key = CallHierarchyViewPart.DIALOGSTORE_RATIO
- + fCurrentOrientation;
+ String key = CallHierarchyViewPart.DIALOGSTORE_RATIO + fCurrentOrientation;
fDialogSettings.put(key, ratio);
}
}
@@ -456,16 +422,14 @@
@Override
public void partClosed(IWorkbenchPartReference partRef) {
- if (CallHierarchyViewPart.ID_CALL_HIERARCHY
- .equals(partRef.getId())) {
+ if (CallHierarchyViewPart.ID_CALL_HIERARCHY.equals(partRef.getId())) {
saveViewSettings();
}
}
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
- if (CallHierarchyViewPart.ID_CALL_HIERARCHY
- .equals(partRef.getId())) {
+ if (CallHierarchyViewPart.ID_CALL_HIERARCHY.equals(partRef.getId())) {
saveViewSettings();
}
}
@@ -491,8 +455,7 @@
protected void saveViewSettings() {
saveSplitterRatio();
- fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION,
- fOrientation);
+ fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION, fOrientation);
}
private void addResizeListener(Composite parent) {
@@ -510,8 +473,7 @@
void computeOrientation() {
saveSplitterRatio();
- fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION,
- fOrientation);
+ fDialogSettings.put(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION, fOrientation);
if (fOrientation != CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
setOrientation(fOrientation);
} else {
@@ -521,11 +483,9 @@
Point size = fParent.getSize();
if (size.x != 0 && size.y != 0) {
if (size.x > size.y) {
- setOrientation(
- CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL);
+ setOrientation(CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL);
} else {
- setOrientation(
- CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL);
+ setOrientation(CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL);
}
}
}
@@ -550,8 +510,7 @@
int mode;
try {
- mode = fDialogSettings
- .getInt(CallHierarchyViewPart.DIALOGSTORE_CALL_MODE);
+ mode = fDialogSettings.getInt(CallHierarchyViewPart.DIALOGSTORE_CALL_MODE);
if ((mode < 0) || (mode > 1)) {
mode = CallHierarchyViewPart.CALL_MODE_CALLERS;
@@ -570,8 +529,7 @@
private void initOrientation() {
try {
- fOrientation = fDialogSettings
- .getInt(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION);
+ fOrientation = fDialogSettings.getInt(CallHierarchyViewPart.DIALOGSTORE_VIEWORIENTATION);
if ((fOrientation < 0) || (fOrientation > 3)) {
fOrientation = CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC;
@@ -596,8 +554,7 @@
viewMenu.add(new Separator());
- MenuManager layoutSubMenu = new MenuManager(
- CallHierarchyMessages.CallHierarchyViewPart_layout_menu);
+ MenuManager layoutSubMenu = new MenuManager(CallHierarchyMessages.CallHierarchyViewPart_layout_menu);
for (int i = 0; i < fToggleOrientationActions.length; i++) {
layoutSubMenu.add(fToggleOrientationActions[i]);
}
@@ -610,8 +567,7 @@
@Override
public void dispose() {
if (fContextActivation != null) {
- IContextService ctxService = getSite()
- .getService(IContextService.class);
+ IContextService ctxService = getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
@@ -633,8 +589,7 @@
}
/**
- * Goes to the selected entry, without updating the order of history
- * entries.
+ * Goes to the selected entry, without updating the order of history entries.
*/
public void gotoHistoryEntry(IMethod entry) {
if (fMethodHistory.contains(entry)) {
@@ -646,8 +601,7 @@
* (non-Javadoc) Method declared on IViewPart.
*/
@Override
- public void init(IViewSite site, IMemento memento)
- throws PartInitException {
+ public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
fMemento = memento;
}
@@ -687,10 +641,8 @@
* @param selection
*/
private void methodSelectionChanged(ISelection selection) {
- if (selection instanceof IStructuredSelection
- && ((IStructuredSelection) selection).size() == 1) {
- Object selectedElement = ((IStructuredSelection) selection)
- .getFirstElement();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) {
+ Object selectedElement = ((IStructuredSelection) selection).getFirstElement();
if (selectedElement instanceof MethodWrapper) {
MethodWrapper methodWrapper = (MethodWrapper) selectedElement;
@@ -720,8 +672,7 @@
CallLocation callLocation = CallHierarchy.getCallLocation(elem);
if (callLocation != null) {
- IEditorPart editorPart = CallHierarchyUI
- .isOpenInEditor(callLocation);
+ IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(callLocation);
if (editorPart != null) {
getSite().getPage().bringToTop(editorPart);
@@ -729,15 +680,13 @@
if (editorPart instanceof ITextEditor) {
ITextEditor editor = (ITextEditor) editorPart;
editor.selectAndReveal(callLocation.getStart(),
- (callLocation.getEnd()
- - callLocation.getStart()));
+ (callLocation.getEnd() - callLocation.getStart()));
}
}
} else {
IEditorPart editorPart = CallHierarchyUI.isOpenInEditor(elem);
getSite().getPage().bringToTop(editorPart);
- EditorUtility.revealInEditor(editorPart,
- ((MethodWrapper) elem).getMember());
+ EditorUtility.revealInEditor(editorPart, ((MethodWrapper) elem).getMember());
}
} else if (elem instanceof IModelElement) {
IEditorPart editorPart = EditorUtility.isOpenInEditor(elem);
@@ -771,8 +720,7 @@
* Returns the current selection.
*/
protected ISelection getSelection() {
- StructuredViewer viewerInFocus = fSelectionProviderMediator
- .getViewerInFocus();
+ StructuredViewer viewerInFocus = fSelectionProviderMediator.getViewerInFocus();
if (viewerInFocus != null) {
return viewerInFocus.getSelection();
}
@@ -782,8 +730,7 @@
protected void fillLocationViewerContextMenu(IMenuManager menu) {
DLTKUIPlugin.createStandardGroups(menu);
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW,
- fOpenLocationAction);
+ menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fOpenLocationAction);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
}
@@ -809,8 +756,7 @@
private MethodWrapper getCalleeRoot() {
if (fCalleeRoot == null) {
- fCalleeRoot = CallHierarchy.getDefault()
- .getCalleeRoot(fShownMethod);
+ fCalleeRoot = CallHierarchy.getDefault().getCalleeRoot(fShownMethod);
}
return fCalleeRoot;
@@ -822,16 +768,14 @@
private MethodWrapper getCallerRoot() {
if (fCallerRoot == null) {
- fCallerRoot = CallHierarchy.getDefault()
- .getCallerRoot(fShownMethod);
+ fCallerRoot = CallHierarchy.getDefault().getCallerRoot(fShownMethod);
}
return fCallerRoot;
}
/**
- * Adds the entry if new. Inserted at the beginning of the history entries
- * list.
+ * Adds the entry if new. Inserted at the beginning of the history entries list.
*/
private void addHistoryEntry(IModelElement entry) {
if (fMethodHistory.contains(entry)) {
@@ -850,8 +794,7 @@
fLocationViewer.getControl().addKeyListener(createKeyListener());
- fLocationViewer.initContextMenu(
- menu -> fillLocationViewerContextMenu(menu),
+ fLocationViewer.initContextMenu(menu -> fillLocationViewerContextMenu(menu),
CallHierarchyViewPart.ID_CALL_HIERARCHY, getSite());
}
@@ -875,12 +818,10 @@
DLTKUIPlugin.createStandardGroups(menu);
menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshAction);
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW,
- new Separator(CallHierarchyViewPart.GROUP_FOCUS));
+ menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(CallHierarchyViewPart.GROUP_FOCUS));
if (fFocusOnSelectionAction.canActionBeAdded()) {
- menu.appendToGroup(CallHierarchyViewPart.GROUP_FOCUS,
- fFocusOnSelectionAction);
+ menu.appendToGroup(CallHierarchyViewPart.GROUP_FOCUS, fFocusOnSelectionAction);
}
if (fCopyAction.canActionBeAdded()) {
menu.appendToGroup(CallHierarchyViewPart.GROUP_FOCUS, fCopyAction);
@@ -925,42 +866,32 @@
fLocationViewer.addOpenListener(event -> fOpenLocationAction.run());
fFocusOnSelectionAction = new FocusOnSelectionAction(this);
- fCopyAction = new CopyCallHierarchyAction(this, fClipboard,
- fCallHierarchyViewer);
- fSearchScopeActions = new SearchScopeActionGroup(this,
- fDialogSettings) {
+ fCopyAction = new CopyCallHierarchyAction(this, fClipboard, fCallHierarchyViewer);
+ fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings) {
@Override
protected IDLTKLanguageToolkit getLangaugeToolkit() {
return getMethodLanguageToolkit();
}
};
- fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
- fCallHierarchyViewer);
+ fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, fCallHierarchyViewer);
fHistoryDropDownAction = new HistoryDropDownAction(this);
fHistoryDropDownAction.setEnabled(false);
fCancelSearchAction = new CancelSearchAction(this);
setCancelEnabled(false);
fToggleOrientationActions = new ToggleOrientationAction[] {
- new ToggleOrientationAction(this,
- CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL),
- new ToggleOrientationAction(this,
- CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL),
- new ToggleOrientationAction(this,
- CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC),
- new ToggleOrientationAction(this,
- CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) };
+ new ToggleOrientationAction(this, CallHierarchyViewPart.VIEW_ORIENTATION_VERTICAL),
+ new ToggleOrientationAction(this, CallHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL),
+ new ToggleOrientationAction(this, CallHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC),
+ new ToggleOrientationAction(this, CallHierarchyViewPart.VIEW_ORIENTATION_SINGLE) };
fToggleCallModeActions = new ToggleCallModeAction[] {
- new ToggleCallModeAction(this,
- CallHierarchyViewPart.CALL_MODE_CALLERS),
- new ToggleCallModeAction(this,
- CallHierarchyViewPart.CALL_MODE_CALLEES) };
- fActionGroups = new CompositeActionGroup(
- new ActionGroup[] { new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this), new CCPActionGroup(this),
- // new GenerateActionGroup(this),
- new RefactorActionGroup(this, null),
- // new DLTKSearchActionGroup(this),
- fSearchScopeActions, fFiltersActionGroup });
+ new ToggleCallModeAction(this, CallHierarchyViewPart.CALL_MODE_CALLERS),
+ new ToggleCallModeAction(this, CallHierarchyViewPart.CALL_MODE_CALLEES) };
+ fActionGroups = new CompositeActionGroup(new ActionGroup[] { new OpenEditorActionGroup(this),
+ new OpenViewActionGroup(this), new CCPActionGroup(this),
+ // new GenerateActionGroup(this),
+ new RefactorActionGroup(this, null),
+ // new DLTKSearchActionGroup(this),
+ fSearchScopeActions, fFiltersActionGroup });
}
protected IDLTKLanguageToolkit getMethodLanguageToolkit() {
@@ -974,16 +905,13 @@
if (fShowCallDetails) {
fHierarchyLocationSplitter.setMaximizedControl(null);
} else {
- fHierarchyLocationSplitter
- .setMaximizedControl(fCallHierarchyViewer.getControl());
+ fHierarchyLocationSplitter.setMaximizedControl(fCallHierarchyViewer.getControl());
}
}
private void updateLocationsView(MethodWrapper methodWrapper) {
- if (methodWrapper != null
- && methodWrapper.getMethodCall().hasCallLocations()) {
- fLocationViewer
- .setInput(methodWrapper.getMethodCall().getCallLocations());
+ if (methodWrapper != null && methodWrapper.getMethodCall().hasCallLocations()) {
+ fLocationViewer.setInput(methodWrapper.getMethodCall().getCallLocations());
} else {
fLocationViewer.clearViewer();
}
@@ -1010,18 +938,15 @@
CallHierarchy.getDefault().setSearchScope(getSearchScope());
- String elementName = ScriptElementLabels.getDefault()
- .getElementLabel(fShownMethod,
- ScriptElementLabels.ALL_DEFAULT);
+ String elementName = ScriptElementLabels.getDefault().getElementLabel(fShownMethod,
+ ScriptElementLabels.ALL_DEFAULT);
String scopeDescription = fSearchScopeActions.getFullDescription();
- String[] args = new String[] { elementName, scopeDescription };
+ Object[] args = new String[] { elementName, scopeDescription };
// set input to null so that setSorter does not cause a refresh on
// the old contents:
fCallHierarchyViewer.setInput(null);
if (fCurrentCallMode == CallHierarchyViewPart.CALL_MODE_CALLERS) {
- setContentDescription(Messages.format(
- CallHierarchyMessages.CallHierarchyViewPart_callsToMethod,
- args));
+ setContentDescription(Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMethod, args));
fCallHierarchyViewer.setComparator(new ViewerComparator()); // bug
// 111423:
// sort
@@ -1030,23 +955,20 @@
// alphabetically
fCallHierarchyViewer.setMethodWrapper(getCallerRoot());
} else {
- setContentDescription(Messages.format(
- CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod,
- args));
+ setContentDescription(
+ Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod, args));
fCallHierarchyViewer.setComparator(null);
fCallHierarchyViewer.setMethodWrapper(getCalleeRoot());
}
}
}
- static CallHierarchyViewPart findAndShowCallersView(
- IWorkbenchPartSite site) {
+ static CallHierarchyViewPart findAndShowCallersView(IWorkbenchPartSite site) {
IWorkbenchPage workbenchPage = site.getPage();
CallHierarchyViewPart callersView = null;
try {
- callersView = (CallHierarchyViewPart) workbenchPage
- .showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
+ callersView = (CallHierarchyViewPart) workbenchPage.showView(CallHierarchyViewPart.ID_CALL_HIERARCHY);
} catch (PartInitException e) {
DLTKUIPlugin.log(e);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeActionGroup.java
index 43831a8..bb7febe 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchScopeActionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -52,8 +52,7 @@
private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction;
private SelectWorkingSetAction fSelectWorkingSetAction;
- public SearchScopeActionGroup(CallHierarchyViewPart view,
- IDialogSettings dialogSettings) {
+ public SearchScopeActionGroup(CallHierarchyViewPart view, IDialogSettings dialogSettings) {
this.fView = view;
this.fDialogSettings = dialogSettings;
createActions();
@@ -81,8 +80,7 @@
protected void setActiveWorkingSets(IWorkingSet[] sets) {
if (sets != null) {
fSelectedWorkingSetNames = getWorkingSetNames(sets);
- fSelectedAction = new SearchScopeWorkingSetAction(this, sets,
- getScopeDescription(sets));
+ fSelectedAction = new SearchScopeWorkingSetAction(this, sets, getScopeDescription(sets));
} else {
fSelectedWorkingSetNames = null;
fSelectedAction = null;
@@ -111,8 +109,7 @@
}
Set<IWorkingSet> workingSets = new HashSet<>(2);
for (int j = 0; j < workingSetNames.length; j++) {
- IWorkingSet workingSet = getWorkingSetManager()
- .getWorkingSet(workingSetNames[j]);
+ IWorkingSet workingSet = getWorkingSetManager().getWorkingSet(workingSetNames[j]);
if (workingSet != null) {
workingSets.add(workingSet);
}
@@ -124,19 +121,15 @@
/**
* Sets the new search scope type.
*
- * @param newSelection
- * New action which should be the checked one
- * @param ignoreUnchecked
- * Ignores actions which are unchecked (necessary since both the
- * old and the new action fires).
+ * @param newSelection New action which should be the checked one
+ * @param ignoreUnchecked Ignores actions which are unchecked (necessary since
+ * both the old and the new action fires).
*/
- protected void setSelected(SearchScopeAction newSelection,
- boolean ignoreUnchecked) {
+ protected void setSelected(SearchScopeAction newSelection, boolean ignoreUnchecked) {
if (!ignoreUnchecked || newSelection.isChecked()) {
if (newSelection instanceof SearchScopeWorkingSetAction) {
fSelectedWorkingSetNames = getWorkingSetNames(
- ((SearchScopeWorkingSetAction) newSelection)
- .getWorkingSets());
+ ((SearchScopeWorkingSetAction) newSelection).getWorkingSets());
} else {
fSelectedWorkingSetNames = null;
}
@@ -148,8 +141,7 @@
}
fDialogSettings.put(DIALOGSTORE_SCOPE_TYPE, getSearchScopeType());
- fDialogSettings.put(DIALOGSTORE_SELECTED_WORKING_SET,
- fSelectedWorkingSetNames);
+ fDialogSettings.put(DIALOGSTORE_SELECTED_WORKING_SET, fSelectedWorkingSetNames);
}
}
@@ -158,8 +150,7 @@
}
protected IWorkingSetManager getWorkingSetManager() {
- IWorkingSetManager workingSetManager = PlatformUI.getWorkbench()
- .getWorkingSetManager();
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
return workingSetManager;
}
@@ -182,8 +173,7 @@
public void fillContextMenu(IMenuManager menu) {
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- MenuManager javaSearchMM = new MenuManager(
- CallHierarchyMessages.SearchScopeActionGroup_searchScope,
+ MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.SearchScopeActionGroup_searchScope,
IContextMenuConstants.GROUP_SEARCH);
javaSearchMM.setRemoveAllWhenShown(true);
@@ -194,8 +184,7 @@
}
private Action[] getActions() {
- List<Action> actions = new ArrayList<>(
- SearchUtil.LRU_WORKINGSET_LIST_SIZE + 4);
+ List<Action> actions = new ArrayList<>(SearchUtil.LRU_WORKINGSET_LIST_SIZE + 4);
addAction(actions, fSearchScopeWorkspaceAction);
addAction(actions, fSearchScopeProjectAction);
addAction(actions, fSearchScopeHierarchyAction);
@@ -205,8 +194,8 @@
while (iter.hasNext()) {
IWorkingSet[] workingSets = (IWorkingSet[]) iter.next();
String description = SearchUtil.toString(workingSets);
- SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(
- this, workingSets, description);
+ SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(this, workingSets,
+ description);
if (isSelectedWorkingSet(workingSets)) {
workingSetAction.setChecked(true);
@@ -268,18 +257,15 @@
} catch (NumberFormatException e) {
searchScopeType = SEARCH_SCOPE_TYPE_WORKSPACE;
}
- String[] workingSetNames = fDialogSettings
- .getArray(DIALOGSTORE_SELECTED_WORKING_SET);
- setSelected(getSearchScopeAction(searchScopeType, workingSetNames),
- false);
+ String[] workingSetNames = fDialogSettings.getArray(DIALOGSTORE_SELECTED_WORKING_SET);
+ setSelected(getSearchScopeAction(searchScopeType, workingSetNames), false);
}
public void saveState(IMemento memento) {
int type = getSearchScopeType();
memento.putInteger(TAG_SEARCH_SCOPE_TYPE, type);
if (type == SEARCH_SCOPE_TYPE_WORKING_SET) {
- memento.putInteger(TAG_WORKING_SET_COUNT,
- fSelectedWorkingSetNames.length);
+ memento.putInteger(TAG_WORKING_SET_COUNT, fSelectedWorkingSetNames.length);
for (int i = 0; i < fSelectedWorkingSetNames.length; i++) {
String workingSetName = fSelectedWorkingSetNames[i];
memento.putString(TAG_SELECTED_WORKING_SET + i, workingSetName);
@@ -292,24 +278,19 @@
Integer scopeType = memento.getInteger(TAG_SEARCH_SCOPE_TYPE);
if (scopeType != null) {
if (scopeType.intValue() == SEARCH_SCOPE_TYPE_WORKING_SET) {
- Integer workingSetCount = memento
- .getInteger(TAG_WORKING_SET_COUNT);
+ Integer workingSetCount = memento.getInteger(TAG_WORKING_SET_COUNT);
if (workingSetCount != null) {
workingSetNames = new String[workingSetCount.intValue()];
for (int i = 0; i < workingSetCount.intValue(); i++) {
- workingSetNames[i] = memento
- .getString(TAG_SELECTED_WORKING_SET + i);
+ workingSetNames[i] = memento.getString(TAG_SELECTED_WORKING_SET + i);
}
}
}
- setSelected(
- getSearchScopeAction(scopeType.intValue(), workingSetNames),
- false);
+ setSelected(getSearchScopeAction(scopeType.intValue(), workingSetNames), false);
}
}
- private SearchScopeAction getSearchScopeAction(int searchScopeType,
- String[] workingSetNames) {
+ private SearchScopeAction getSearchScopeAction(int searchScopeType, String[] workingSetNames) {
switch (searchScopeType) {
case SEARCH_SCOPE_TYPE_WORKSPACE:
return fSearchScopeWorkspaceAction;
@@ -320,8 +301,7 @@
case SEARCH_SCOPE_TYPE_WORKING_SET:
IWorkingSet[] workingSets = getWorkingSets(workingSetNames);
if (workingSets != null && workingSets.length > 0) {
- return new SearchScopeWorkingSetAction(this, workingSets,
- getScopeDescription(workingSets));
+ return new SearchScopeWorkingSetAction(this, workingSets, getScopeDescription(workingSets));
}
return null;
}
@@ -336,8 +316,7 @@
}
private String getScopeDescription(IWorkingSet[] workingSets) {
- return Messages.format(CallHierarchyMessages.WorkingSetScope,
- new String[] { SearchUtil.toString(workingSets) });
+ return Messages.format(CallHierarchyMessages.WorkingSetScope, SearchUtil.toString(workingSets));
}
/**
@@ -349,8 +328,7 @@
* currently selected working sets
*/
private boolean isSelectedWorkingSet(IWorkingSet[] workingSets) {
- if (fSelectedWorkingSetNames != null
- && fSelectedWorkingSetNames.length == workingSets.length) {
+ if (fSelectedWorkingSetNames != null && fSelectedWorkingSetNames.length == workingSets.length) {
Set<String> workingSetNames = new HashSet<>(workingSets.length);
for (int i = 0; i < workingSets.length; i++) {
workingSetNames.add(workingSets[i].getName());
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchUtil.java
index b113fa9..ada867b 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/SearchUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -38,8 +38,7 @@
/**
* Updates the LRU list of working sets.
*
- * @param workingSets
- * the workings sets to be added to the LRU list
+ * @param workingSets the workings sets to be added to the LRU list
*/
public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
if (workingSets == null || workingSets.length < 1)
@@ -58,8 +57,7 @@
String[] names = new String[workingSets.length];
for (int j = 0; j < workingSets.length; j++)
names[j] = workingSets[j].getName();
- SearchUtil.fgSettingsStore
- .put(SearchUtil.STORE_LRU_WORKING_SET_NAMES + i, names);
+ SearchUtil.fgSettingsStore.put(SearchUtil.STORE_LRU_WORKING_SET_NAMES + i, names);
i++;
}
}
@@ -72,13 +70,11 @@
}
static void restoreState() {
- SearchUtil.fgLRUWorkingSets = new LRUWorkingSetsList(
- SearchUtil.LRU_WORKINGSET_LIST_SIZE);
- SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault()
- .getDialogSettings().getSection(SearchUtil.DIALOG_SETTINGS_KEY);
+ SearchUtil.fgLRUWorkingSets = new LRUWorkingSetsList(SearchUtil.LRU_WORKINGSET_LIST_SIZE);
+ SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault().getDialogSettings()
+ .getSection(SearchUtil.DIALOG_SETTINGS_KEY);
if (SearchUtil.fgSettingsStore == null)
- SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault()
- .getDialogSettings()
+ SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault().getDialogSettings()
.addNewSection(SearchUtil.DIALOG_SETTINGS_KEY);
boolean foundLRU = false;
@@ -88,8 +84,7 @@
if (lruWorkingSetNames != null) {
Set<IWorkingSet> workingSets = new HashSet<>(2);
for (int j = 0; j < lruWorkingSetNames.length; j++) {
- IWorkingSet workingSet = PlatformUI.getWorkbench()
- .getWorkingSetManager()
+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager()
.getWorkingSet(lruWorkingSetNames[j]);
if (workingSet != null) {
workingSets.add(workingSet);
@@ -97,8 +92,7 @@
}
foundLRU = true;
if (!workingSets.isEmpty())
- SearchUtil.fgLRUWorkingSets.add(workingSets
- .toArray(new IWorkingSet[workingSets.size()]));
+ SearchUtil.fgLRUWorkingSets.add(workingSets.toArray(new IWorkingSet[workingSets.size()]));
}
}
if (!foundLRU)
@@ -107,27 +101,22 @@
}
private static void restoreFromOldFormat() {
- SearchUtil.fgLRUWorkingSets = new LRUWorkingSetsList(
- SearchUtil.LRU_WORKINGSET_LIST_SIZE);
- SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault()
- .getDialogSettings().getSection(SearchUtil.DIALOG_SETTINGS_KEY);
+ SearchUtil.fgLRUWorkingSets = new LRUWorkingSetsList(SearchUtil.LRU_WORKINGSET_LIST_SIZE);
+ SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault().getDialogSettings()
+ .getSection(SearchUtil.DIALOG_SETTINGS_KEY);
if (SearchUtil.fgSettingsStore == null)
- SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault()
- .getDialogSettings()
+ SearchUtil.fgSettingsStore = DLTKUIPlugin.getDefault().getDialogSettings()
.addNewSection(SearchUtil.DIALOG_SETTINGS_KEY);
boolean foundLRU = false;
- String[] lruWorkingSetNames = SearchUtil.fgSettingsStore
- .getArray(SearchUtil.STORE_LRU_WORKING_SET_NAMES);
+ String[] lruWorkingSetNames = SearchUtil.fgSettingsStore.getArray(SearchUtil.STORE_LRU_WORKING_SET_NAMES);
if (lruWorkingSetNames != null) {
for (int i = lruWorkingSetNames.length - 1; i >= 0; i--) {
- IWorkingSet workingSet = PlatformUI.getWorkbench()
- .getWorkingSetManager()
+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager()
.getWorkingSet(lruWorkingSetNames[i]);
if (workingSet != null) {
foundLRU = true;
- SearchUtil.fgLRUWorkingSets
- .add(new IWorkingSet[] { workingSet });
+ SearchUtil.fgLRUWorkingSets.add(new IWorkingSet[] { workingSet });
}
}
}
@@ -144,9 +133,8 @@
for (int i = 0; i < workingSets.length; i++) {
String workingSetName = workingSets[i].getLabel();
if (firstFound)
- result = Messages.format(
- CallHierarchyMessages.SearchUtil_workingSetConcatenation,
- new String[] { result, workingSetName });
+ result = Messages.format(CallHierarchyMessages.SearchUtil_workingSetConcatenation, result,
+ workingSetName);
else {
result = workingSetName;
firstFound = true;
@@ -157,25 +145,24 @@
}
/**
- * This helper method with Object as parameter is needed to prevent the
- * loading of the Search plug-in: the Interpreter verifies the method call
- * and hence loads the types used in the method signature, eventually
- * triggering the loading of a plug-in (in this case ISearchQuery results in
- * Search plug-in being loaded).
+ * This helper method with Object as parameter is needed to prevent the loading
+ * of the Search plug-in: the Interpreter verifies the method call and hence
+ * loads the types used in the method signature, eventually triggering the
+ * loading of a plug-in (in this case ISearchQuery results in Search plug-in
+ * being loaded).
*/
public static void runQueryInBackground(Object query) {
NewSearchUI.runQueryInBackground((ISearchQuery) query);
}
/**
- * This helper method with Object as parameter is needed to prevent the
- * loading of the Search plug-in: the Interpreter verifies the method call
- * and hence loads the types used in the method signature, eventually
- * triggering the loading of a plug-in (in this case ISearchQuery results in
- * Search plug-in being loaded).
+ * This helper method with Object as parameter is needed to prevent the loading
+ * of the Search plug-in: the Interpreter verifies the method call and hence
+ * loads the types used in the method signature, eventually triggering the
+ * loading of a plug-in (in this case ISearchQuery results in Search plug-in
+ * being loaded).
*/
- public static IStatus runQueryInForeground(IRunnableContext context,
- Object query) {
+ public static IStatus runQueryInForeground(IRunnableContext context, Object query) {
return NewSearchUI.runQueryInForeground(context, (ISearchQuery) query);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/MethodSelectionDialog2.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/MethodSelectionDialog2.java
index 0f3d606..fa36d96 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/MethodSelectionDialog2.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/MethodSelectionDialog2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -79,12 +79,9 @@
if (text == null || text.length() == 0) {
getShell().setText(fTitle);
} else {
- getShell()
- .setText(
- Messages
- .format(
- DLTKUIMessages.TypeSelectionDialog2_title_format,
- new String[] { fTitle, text }));
+ getShell().setText(Messages.format(
+ DLTKUIMessages.TypeSelectionDialog2_title_format,
+ fTitle, text));
}
}
}
@@ -265,8 +262,7 @@
ScriptElementLabels.ROOT_QUALIFIED);
String message = Messages.format(
DLTKUIMessages.TypeSelectionDialog_dialogMessage,
- new String[] { typeInfo.getFullyQualifiedName(),
- containerName });
+ typeInfo.getFullyQualifiedName(), containerName);
MessageDialog.openError(getShell(), title, message);
history.remove(typeInfo);
setResult(null);
@@ -279,8 +275,8 @@
setResult(result);
}
- private void ensureConsistency() throws InvocationTargetException,
- InterruptedException {
+ private void ensureConsistency()
+ throws InvocationTargetException, InterruptedException {
// we only have to ensure history consistency here since the search
// engine
// takes care of working copies.
@@ -296,14 +292,14 @@
OpenMethodHistory history = OpenMethodHistory
.getInstance(fToolkit);
if (fgFirstTime || history.isEmpty()) {
- monitor
- .beginTask(
- DLTKUIMessages.TypeSelectionDialog_progress_consistency,
- 100);
+ monitor.beginTask(
+ DLTKUIMessages.TypeSelectionDialog_progress_consistency,
+ 100);
if (history.needConsistencyCheck()) {
- refreshSearchIndices(new SubProgressMonitor(monitor, 90));
- history.checkConsistency(new SubProgressMonitor(
- monitor, 10));
+ refreshSearchIndices(
+ new SubProgressMonitor(monitor, 90));
+ history.checkConsistency(
+ new SubProgressMonitor(monitor, 10));
} else {
refreshSearchIndices(monitor);
}
@@ -324,16 +320,21 @@
private void refreshSearchIndices(IProgressMonitor monitor)
throws InvocationTargetException {
try {
- new SearchEngine().searchAllTypeNames(
- null,
- 0, // make sure we search a concrete name. This is
- // faster according to Kent
+ new SearchEngine().searchAllTypeNames(null, 0, // make sure
+ // we search
+ // a
+ // concrete
+ // name.
+ // This is
+ // faster
+ // according
+ // to Kent
"_______________".toCharArray(), //$NON-NLS-1$
SearchPattern.R_EXACT_MATCH
| SearchPattern.R_CASE_SENSITIVE,
- IDLTKSearchConstants.FIELD, SearchEngine
- .createWorkspaceScope(fToolkit
- .getCoreToolkit()),
+ IDLTKSearchConstants.FIELD,
+ SearchEngine.createWorkspaceScope(
+ fToolkit.getCoreToolkit()),
new NopTypeNameRequestor(),
IDLTKSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
monitor);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TypeSelectionDialog2.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TypeSelectionDialog2.java
index 5261b05..72f3852 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TypeSelectionDialog2.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/TypeSelectionDialog2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -84,22 +84,18 @@
if (text == null || text.length() == 0) {
getShell().setText(fTitle);
} else {
- getShell().setText(Messages.format(
- DLTKUIMessages.TypeSelectionDialog2_title_format,
- new String[] { fTitle, text }));
+ getShell().setText(Messages.format(DLTKUIMessages.TypeSelectionDialog2_title_format, fTitle, text));
}
}
}
- public TypeSelectionDialog2(Shell parent, boolean multi,
- IRunnableContext context, IDLTKSearchScope scope, int elementKinds,
- IDLTKUILanguageToolkit toolkit) {
+ public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IDLTKSearchScope scope,
+ int elementKinds, IDLTKUILanguageToolkit toolkit) {
this(parent, multi, context, scope, elementKinds, null, toolkit);
}
- public TypeSelectionDialog2(Shell parent, boolean multi,
- IRunnableContext context, IDLTKSearchScope scope, int elementKinds,
- TypeSelectionExtension extension, IDLTKUILanguageToolkit toolkit) {
+ public TypeSelectionDialog2(Shell parent, boolean multi, IRunnableContext context, IDLTKSearchScope scope,
+ int elementKinds, TypeSelectionExtension extension, IDLTKUILanguageToolkit toolkit) {
super(parent);
setShellStyle(getShellStyle() | SWT.RESIZE);
fMultipleSelection = multi;
@@ -150,9 +146,8 @@
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
- fContent = new TypeSelectionComponent(area, SWT.NONE, getMessage(),
- fMultipleSelection, fScope, fElementKind, fInitialFilter,
- new TitleLabel(), fExtension, this.fToolkit);
+ fContent = new TypeSelectionComponent(area, SWT.NONE, getMessage(), fMultipleSelection, fScope, fElementKind,
+ fInitialFilter, new TitleLabel(), fExtension, this.fToolkit);
GridData gd = new GridData(GridData.FILL_BOTH);
fContent.setLayoutData(gd);
fContent.addSelectionListener(new SelectionListener() {
@@ -178,8 +173,7 @@
protected void handleWidgetSelected(TypeNameMatch[] selection) {
IStatus status = null;
if (selection.length == 0) {
- status = new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(),
- IStatus.ERROR, "", null); //$NON-NLS-1$
+ status = new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), IStatus.ERROR, "", null); //$NON-NLS-1$
} else {
if (fValidator != null) {
List<IType> jElements = new ArrayList<>();
@@ -188,10 +182,8 @@
if (type != null) {
jElements.add(type);
} else {
- status = new Status(IStatus.ERROR,
- DLTKUIPlugin.getPluginId(), IStatus.ERROR,
- Messages.format(
- DLTKUIMessages.TypeSelectionDialog_error_type_doesnot_exist,
+ status = new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), IStatus.ERROR,
+ Messages.format(DLTKUIMessages.TypeSelectionDialog_error_type_doesnot_exist,
selection[i].getFullyQualifiedName()),
null);
break;
@@ -201,8 +193,7 @@
status = fValidator.validate(jElements.toArray());
}
} else {
- status = new Status(IStatus.OK, DLTKUIPlugin.getPluginId(),
- IStatus.OK, "", null); //$NON-NLS-1$
+ status = new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
}
}
updateStatus(status);
@@ -213,8 +204,7 @@
try {
ensureConsistency();
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e,
- DLTKUIMessages.TypeSelectionDialog_error3Title,
+ ExceptionHandler.handle(e, DLTKUIMessages.TypeSelectionDialog_error3Title,
DLTKUIMessages.TypeSelectionDialog_error3Message);
return CANCEL;
} catch (InterruptedException e) {
@@ -224,14 +214,12 @@
if (fInitialFilter == null) {
IWorkbenchWindow window = DLTKUIPlugin.getActiveWorkbenchWindow();
if (window != null) {
- ISelection selection = window.getSelectionService()
- .getSelection();
+ ISelection selection = window.getSelectionService().getSelection();
if (selection instanceof ITextSelection) {
String text = ((ITextSelection) selection).getText();
setInitialFilter(text);
} else if (selection instanceof IStructuredSelection) {
- Object object = ((IStructuredSelection) selection)
- .getFirstElement();
+ Object object = ((IStructuredSelection) selection).getFirstElement();
if (object instanceof IModelElement) {
IModelElement element = (IModelElement) object;
String text = element.getElementName();
@@ -299,14 +287,10 @@
} else {
String title = DLTKUIMessages.TypeSelectionDialog_errorTitle;
IProjectFragment root = typeInfo.getProjectFragment();
- ScriptElementLabels labels = this.fToolkit
- .getScriptElementLabels();
- String containerName = labels.getElementLabel(root,
- ScriptElementLabels.ROOT_QUALIFIED);
- String message = Messages.format(
- DLTKUIMessages.TypeSelectionDialog_dialogMessage,
- new String[] { typeInfo.getFullyQualifiedName(),
- containerName });
+ ScriptElementLabels labels = this.fToolkit.getScriptElementLabels();
+ String containerName = labels.getElementLabel(root, ScriptElementLabels.ROOT_QUALIFIED);
+ String message = Messages.format(DLTKUIMessages.TypeSelectionDialog_dialogMessage,
+ typeInfo.getFullyQualifiedName(), containerName);
MessageDialog.openError(getShell(), title, message);
history.remove(typeInfo);
setResult(null);
@@ -319,15 +303,13 @@
setResult(result);
}
- private void ensureConsistency()
- throws InvocationTargetException, InterruptedException {
+ private void ensureConsistency() throws InvocationTargetException, InterruptedException {
// we only have to ensure history consistency here since the search
// engine
// takes care of working copies.
class ConsistencyRunnable implements IRunnableWithProgress {
@Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (fgFirstTime) {
// Join the initialize after load job.
IJobManager manager = Job.getJobManager();
@@ -335,14 +317,10 @@
}
OpenTypeHistory history = OpenTypeHistory.getInstance(fToolkit);
if (fgFirstTime || history.isEmpty()) {
- monitor.beginTask(
- DLTKUIMessages.TypeSelectionDialog_progress_consistency,
- 100);
+ monitor.beginTask(DLTKUIMessages.TypeSelectionDialog_progress_consistency, 100);
if (history.needConsistencyCheck()) {
- refreshSearchIndices(
- new SubProgressMonitor(monitor, 90));
- history.checkConsistency(
- new SubProgressMonitor(monitor, 10));
+ refreshSearchIndices(new SubProgressMonitor(monitor, 90));
+ history.checkConsistency(new SubProgressMonitor(monitor, 10));
} else {
refreshSearchIndices(monitor);
}
@@ -355,25 +333,18 @@
public boolean needsExecution() {
OpenTypeHistory history = OpenTypeHistory.getInstance(fToolkit);
- return fgFirstTime || history.isEmpty()
- || history.needConsistencyCheck();
+ return fgFirstTime || history.isEmpty() || history.needConsistencyCheck();
}
- private void refreshSearchIndices(IProgressMonitor monitor)
- throws InvocationTargetException {
+ private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
try {
new SearchEngine().searchAllTypeNames(null, 0,
// make sure we search a concrete name. This is
// faster according to Kent
"_______________".toCharArray(), //$NON-NLS-1$
- SearchPattern.R_EXACT_MATCH
- | SearchPattern.R_CASE_SENSITIVE,
- IDLTKSearchConstants.FIELD,
- SearchEngine.createWorkspaceScope(
- fToolkit.getCoreToolkit()),
- new NopTypeNameRequestor(),
- IDLTKSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- monitor);
+ SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, IDLTKSearchConstants.FIELD,
+ SearchEngine.createWorkspaceScope(fToolkit.getCoreToolkit()), new NopTypeNameRequestor(),
+ IDLTKSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
} catch (ModelException e) {
throw new InvocationTargetException(e);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/EditorUtility.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/EditorUtility.java
index a7fa12d..50564a1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/EditorUtility.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/EditorUtility.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -80,18 +80,16 @@
public class EditorUtility {
/**
- * Returns the DLTK project for a given editor input or <code>null</code> if
- * no corresponding DLTK project exists.
+ * Returns the DLTK project for a given editor input or <code>null</code> if no
+ * corresponding DLTK project exists.
*
- * @param input
- * the editor input
+ * @param input the editor input
* @return the corresponding DLTK project
*/
public static IScriptProject getScriptProject(IEditorInput input) {
IScriptProject dProject = null;
if (input instanceof IFileEditorInput) {
- IProject project = ((IFileEditorInput) input).getFile()
- .getProject();
+ IProject project = ((IFileEditorInput) input).getFile().getProject();
if (project != null) {
dProject = DLTKCore.create(project);
if (!dProject.exists())
@@ -112,24 +110,20 @@
/**
* Returns the given editor's input as model element.
*
- * @param editor
- * the editor
- * @param primaryOnly
- * if <code>true</code> only primary working copies will be
- * returned
+ * @param editor the editor
+ * @param primaryOnly if <code>true</code> only primary working copies will be
+ * returned
* @return the given editor's input as model element or <code>null</code> if
* none
*/
- public static ISourceModule getEditorInputModelElement(IEditorPart editor,
- boolean primaryOnly) {
+ public static ISourceModule getEditorInputModelElement(IEditorPart editor, boolean primaryOnly) {
IEditorInput editorInput = editor.getEditorInput();
if (editorInput == null)
return null;
ISourceModule je = DLTKUIPlugin.getEditorInputModelElement(editorInput);
if (je != null || primaryOnly)
return je;
- return DLTKUIPlugin.getDefault().getWorkingCopyManager()
- .getWorkingCopy(editorInput, primaryOnly);
+ return DLTKUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, primaryOnly);
}
/**
@@ -139,8 +133,7 @@
*
* @return the IEditorPart or null if wrong element type or opening failed
*/
- public static IEditorPart openInEditor(Object inputElement)
- throws ModelException, PartInitException {
+ public static IEditorPart openInEditor(Object inputElement) throws ModelException, PartInitException {
return openInEditor(inputElement, true);
}
@@ -149,8 +142,8 @@
*
* @return the IEditorPart or null if wrong element type or opening failed
*/
- public static IEditorPart openInEditor(Object inputElement,
- boolean activate) throws ModelException, PartInitException {
+ public static IEditorPart openInEditor(Object inputElement, boolean activate)
+ throws ModelException, PartInitException {
if (inputElement instanceof IFile) {
return openInEditor((IFile) inputElement, activate);
} else if (inputElement instanceof DelegatedOpen) {
@@ -162,8 +155,7 @@
if (inputElement instanceof IModelElement) {
// first try to get it from the system.
String editorId = null;
- IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager
- .getLanguageToolkit((IModelElement) inputElement);
+ IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager.getLanguageToolkit((IModelElement) inputElement);
if (toolkit != null) {
editorId = toolkit.getEditorId(inputElement);
}
@@ -175,24 +167,21 @@
return openInEditor(input, editorId, activate);
}
} else
- return openInEditor(input, getEditorID(input, inputElement),
- activate);
+ return openInEditor(input, getEditorID(input, inputElement), activate);
}
if (inputElement instanceof IModelElement) {
IModelElement modelElement = (IModelElement) inputElement;
- ISourceModule cu = (ISourceModule) (modelElement)
- .getAncestor(IModelElement.SOURCE_MODULE);
+ ISourceModule cu = (ISourceModule) (modelElement).getAncestor(IModelElement.SOURCE_MODULE);
if (cu != null) {
/*
- * Support for non-primary or RSE working copy. Try to reveal it
- * in the active editor.
+ * Support for non-primary or RSE working copy. Try to reveal it in the active
+ * editor.
*/
IWorkbenchPage page = DLTKUIPlugin.getActivePage();
if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor != null) {
- IModelElement editorCU = EditorUtility
- .getEditorInputModelElement(editor, false);
+ IModelElement editorCU = EditorUtility.getEditorInputModelElement(editor, false);
if (editorCU == cu) {
EditorUtility.revealInEditor(editor, modelElement);
return editor;
@@ -208,14 +197,11 @@
IEditorDescriptor editorDescriptor;
try {
if (input instanceof IFileEditorInput) {
- editorDescriptor = IDE.getEditorDescriptor(
- ((IFileEditorInput) input).getFile(), true, false);
+ editorDescriptor = IDE.getEditorDescriptor(((IFileEditorInput) input).getFile(), true, false);
} else if (input instanceof ExternalStorageEditorInput) {
- editorDescriptor = IDE.getEditorDescriptor(input.getName(),
- true, false);
+ editorDescriptor = IDE.getEditorDescriptor(input.getName(), true, false);
} else {
- editorDescriptor = IDE.getEditorDescriptor(input.getName(),
- true, false);
+ editorDescriptor = IDE.getEditorDescriptor(input.getName(), true, false);
}
} catch (PartInitException e) {
@@ -255,8 +241,7 @@
if (input instanceof IFile)
return new FileEditorInput((IFile) input);
if (DLTKCore.DEBUG) {
- System.err.println(
- "Add archive entry and external source folder editor input.."); //$NON-NLS-1$
+ System.err.println("Add archive entry and external source folder editor input.."); //$NON-NLS-1$
}
if (input instanceof IStorage) {
return new ExternalStorageEditorInput((IStorage) input);
@@ -306,8 +291,7 @@
* @param lineNumber
* @throws CoreException
*/
- public static void revealInEditor(IEditorPart editorPart, int lineNumber)
- throws CoreException {
+ public static void revealInEditor(IEditorPart editorPart, int lineNumber) throws CoreException {
if (editorPart instanceof ITextEditor && lineNumber >= 0) {
final ITextEditor textEditor = (ITextEditor) editorPart;
final IDocumentProvider provider = textEditor.getDocumentProvider();
@@ -335,8 +319,7 @@
/**
* Selects and reveals the given offset and length in the given editor part.
*/
- public static void revealInEditor(IEditorPart editor, final int offset,
- final int length) {
+ public static void revealInEditor(IEditorPart editor, final int offset, final int length) {
if (editor instanceof ITextEditor) {
((ITextEditor) editor).selectAndReveal(offset, length);
return;
@@ -348,15 +331,12 @@
final IGotoMarker gotoMarkerTarget = (IGotoMarker) editor;
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
@Override
- protected void execute(IProgressMonitor monitor)
- throws CoreException {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
IMarker marker = null;
try {
- marker = ((IFileEditorInput) input).getFile()
- .createMarker(IMarker.TEXT);
+ marker = ((IFileEditorInput) input).getFile().createMarker(IMarker.TEXT);
marker.setAttribute(IMarker.CHAR_START, offset);
- marker.setAttribute(IMarker.CHAR_END,
- offset + length);
+ marker.setAttribute(IMarker.CHAR_END, offset + length);
gotoMarkerTarget.gotoMarker(marker);
} finally {
if (marker != null)
@@ -373,8 +353,7 @@
// canceled"); //$NON-NLS-1$
}
} else if (input instanceof ExternalStorageEditorInput) {
- System.err.println(
- "TODO: Add external storage editor input reveal..."); //$NON-NLS-1$
+ System.err.println("TODO: Add external storage editor input reveal..."); //$NON-NLS-1$
}
return;
}
@@ -382,21 +361,18 @@
* Workaround: send out a text selection XXX: Needs to be improved, see
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
*/
- if (editor != null
- && editor.getEditorSite().getSelectionProvider() != null) {
+ if (editor != null && editor.getEditorSite().getSelectionProvider() != null) {
IEditorSite site = editor.getEditorSite();
if (site == null)
return;
- ISelectionProvider provider = editor.getEditorSite()
- .getSelectionProvider();
+ ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
if (provider == null)
return;
provider.setSelection(new TextSelection(offset, length));
}
}
- private static IEditorPart openInEditor(IFile file, boolean activate)
- throws PartInitException {
+ private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
if (file != null) {
IWorkbenchPage p = DLTKUIPlugin.getActivePage();
if (p != null) {
@@ -408,13 +384,12 @@
return null;
}
- private static IEditorPart openInEditor(IEditorInput input, String editorID,
- boolean activate) throws PartInitException {
+ private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate)
+ throws PartInitException {
if (input != null) {
IWorkbenchPage p = DLTKUIPlugin.getActivePage();
if (p != null) {
- IEditorPart editorPart = p.openEditor(input, editorID,
- activate);
+ IEditorPart editorPart = p.openEditor(input, editorID, activate);
initializeHighlightRange(editorPart);
return editorPart;
}
@@ -425,8 +400,7 @@
private static void initializeHighlightRange(IEditorPart editorPart) {
if (editorPart instanceof ITextEditor) {
IAction toggleAction = editorPart.getEditorSite().getActionBars()
- .getGlobalActionHandler(
- ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
+ .getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
boolean enable = toggleAction != null;
// if (enable && editorPart instanceof Editor)
// enable=
@@ -434,18 +408,15 @@
// PreferenceConstants.EDITOR_SHOW_SEGMENTS);
// else
if (DLTKCore.DEBUG) {
- System.err.println(
- "Add initializeHighlightRange support of preferences."); //$NON-NLS-1$
+ System.err.println("Add initializeHighlightRange support of preferences."); //$NON-NLS-1$
}
- enable = enable && toggleAction.isEnabled()
- && toggleAction.isChecked();
+ enable = enable && toggleAction.isEnabled() && toggleAction.isChecked();
if (enable) {
if (toggleAction instanceof TextEditorAction) {
// Reset the action
((TextEditorAction) toggleAction).setEditor(null);
// Restore the action
- ((TextEditorAction) toggleAction)
- .setEditor((ITextEditor) editorPart);
+ ((TextEditorAction) toggleAction).setEditor((ITextEditor) editorPart);
} else {
// Un-check
toggleAction.run();
@@ -459,8 +430,7 @@
/**
* Tests if a CU is currently shown in an editor
*
- * @return the IEditorPart if shown, null if element is not open in an
- * editor
+ * @return the IEditorPart if shown, null if element is not open in an editor
*/
public static IEditorPart isOpenInEditor(Object inputElement) {
IEditorInput input = getEditorInput(inputElement);
@@ -498,8 +468,7 @@
}
/**
- * If the current active editor edits ascriptelement return it, else return
- * null
+ * If the current active editor edits ascriptelement return it, else return null
*/
public static IModelElement getActiveEditorModelInput() {
IWorkbenchPage page = DLTKUIPlugin.getActivePage();
@@ -519,30 +488,25 @@
* Appends to modifier string of the given SWT modifier bit to the given
* modifierString.
*
- * @param modifierString
- * the modifier string
- * @param modifier
- * an int with SWT modifier bit
+ * @param modifierString the modifier string
+ * @param modifier an int with SWT modifier bit
* @return the concatenated modifier string
*
*/
- private static String appendModifierString(String modifierString,
- int modifier) {
+ private static String appendModifierString(String modifierString, int modifier) {
if (modifierString == null)
modifierString = ""; //$NON-NLS-1$
String newModifierString = Action.findModifierString(modifier);
if (modifierString.length() == 0)
return newModifierString;
- return Messages.format(
- DLTKEditorMessages.EditorUtility_concatModifierStrings,
- new String[] { modifierString, newModifierString });
+ return Messages.format(DLTKEditorMessages.EditorUtility_concatModifierStrings, modifierString,
+ newModifierString);
}
/**
* Returns the modifier string for the given SWT modifier modifier bits.
*
- * @param stateMask
- * the SWT modifier bits
+ * @param stateMask the SWT modifier bits
* @return the modifier string
*
*/
@@ -564,8 +528,7 @@
* Maps the localized modifier name to a code in the same manner as
* #findModifier.
*
- * @param modifierName
- * the modifier name
+ * @param modifierName the modifier name
* @return the SWT modifier bit, or <code>0</code> if no match was found
*
*/
@@ -579,31 +542,25 @@
return SWT.SHIFT;
if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
return SWT.ALT;
- if (modifierName
- .equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
+ if (modifierName.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
return SWT.COMMAND;
return 0;
}
/**
- * Return the regions of all lines which have changed in the given buffer
- * since the last save occurred. Each region in the result spans over the
- * size of at least one line. If successive lines have changed a region
- * spans over the size of all successive lines. The regions include line
- * delimiters.
+ * Return the regions of all lines which have changed in the given buffer since
+ * the last save occurred. Each region in the result spans over the size of at
+ * least one line. If successive lines have changed a region spans over the size
+ * of all successive lines. The regions include line delimiters.
*
- * @param buffer
- * the buffer to compare contents from
- * @param monitor
- * to report progress to
+ * @param buffer the buffer to compare contents from
+ * @param monitor to report progress to
* @return the regions of the changed lines
- * @throws CoreException
- * if something goes wrong
+ * @throws CoreException if something goes wrong
* @since 3.0
*/
- public static IRegion[] calculateChangedLineRegions(
- final ITextFileBuffer buffer, final IProgressMonitor monitor)
+ public static IRegion[] calculateChangedLineRegions(final ITextFileBuffer buffer, final IProgressMonitor monitor)
throws CoreException {
final IRegion[][] result = new IRegion[1][];
final IStatus[] errorStatus = new IStatus[] { Status.OK_STATUS };
@@ -613,71 +570,56 @@
@Override
public void handleException(Throwable exception) {
- DLTKUIPlugin.log(new Status(IStatus.ERROR,
- DLTKUIPlugin.PLUGIN_ID,
- IDLTKStatusConstants.EDITOR_CHANGED_REGION_CALCULATION,
- exception.getLocalizedMessage(), exception));
+ DLTKUIPlugin.log(new Status(IStatus.ERROR, DLTKUIPlugin.PLUGIN_ID,
+ IDLTKStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, exception.getLocalizedMessage(),
+ exception));
String msg = DLTKEditorMessages.CompilationUnitDocumentProvider_error_calculatingChangedRegions;
- errorStatus[0] = new Status(IStatus.ERROR,
- DLTKUIPlugin.PLUGIN_ID,
- IDLTKStatusConstants.EDITOR_CHANGED_REGION_CALCULATION,
- msg, exception);
+ errorStatus[0] = new Status(IStatus.ERROR, DLTKUIPlugin.PLUGIN_ID,
+ IDLTKStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, msg, exception);
result[0] = null;
}
@Override
public void run() throws Exception {
monitor.beginTask(
- DLTKEditorMessages.CompilationUnitDocumentProvider_calculatingChangedRegions_message,
- 20);
+ DLTKEditorMessages.CompilationUnitDocumentProvider_calculatingChangedRegions_message, 20);
IFileStore fileStore = buffer.getFileStore();
- ITextFileBufferManager fileBufferManager = FileBuffers
- .createTextFileBufferManager();
- fileBufferManager.connectFileStore(fileStore,
- getSubProgressMonitor(monitor, 15));
+ ITextFileBufferManager fileBufferManager = FileBuffers.createTextFileBufferManager();
+ fileBufferManager.connectFileStore(fileStore, getSubProgressMonitor(monitor, 15));
try {
IDocument currentDocument = buffer.getDocument();
- IDocument oldDocument = ((ITextFileBuffer) fileBufferManager
- .getFileStoreFileBuffer(fileStore))
- .getDocument();
+ IDocument oldDocument = ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore))
+ .getDocument();
- result[0] = getChangedLineRegions(oldDocument,
- currentDocument);
+ result[0] = getChangedLineRegions(oldDocument, currentDocument);
} finally {
- fileBufferManager.disconnectFileStore(fileStore,
- getSubProgressMonitor(monitor, 5));
+ fileBufferManager.disconnectFileStore(fileStore, getSubProgressMonitor(monitor, 5));
monitor.done();
}
}
/**
- * Return regions of all lines which differ comparing
- * <code>oldDocument</code>s content with
- * <code>currentDocument</code>s content. Successive lines are
+ * Return regions of all lines which differ comparing <code>oldDocument</code>s
+ * content with <code>currentDocument</code>s content. Successive lines are
* merged into one region.
*
- * @param oldDocument
- * a document containing the old content
- * @param currentDocument
- * a document containing the current content
+ * @param oldDocument a document containing the old content
+ * @param currentDocument a document containing the current content
* @return the changed regions
- * @throws BadLocationException
- * if fetching the line information fails
+ * @throws BadLocationException if fetching the line information fails
*/
- private IRegion[] getChangedLineRegions(IDocument oldDocument,
- IDocument currentDocument) throws BadLocationException {
+ private IRegion[] getChangedLineRegions(IDocument oldDocument, IDocument currentDocument)
+ throws BadLocationException {
/*
- * Do not change the type of those local variables. We use
- * Object here in order to prevent loading of the Compare
- * plug-in at load time of this class.
+ * Do not change the type of those local variables. We use Object here in order
+ * to prevent loading of the Compare plug-in at load time of this class.
*/
Object leftSide = new LineComparator(oldDocument);
Object rightSide = new LineComparator(currentDocument);
- RangeDifference[] differences = RangeDifferencer
- .findDifferences((IRangeComparator) leftSide,
- (IRangeComparator) rightSide);
+ RangeDifference[] differences = RangeDifferencer.findDifferences((IRangeComparator) leftSide,
+ (IRangeComparator) rightSide);
// It holds that:
// 1. Ranges are sorted:
@@ -692,23 +634,18 @@
ArrayList<IRegion> regions = new ArrayList<>();
for (int i = 0; i < differences.length; i++) {
RangeDifference curr = differences[i];
- if (curr.kind() == RangeDifference.CHANGE
- && curr.rightLength() > 0) {
+ if (curr.kind() == RangeDifference.CHANGE && curr.rightLength() > 0) {
int startLine = curr.rightStart();
int endLine = curr.rightEnd() - 1;
- IRegion startLineRegion = currentDocument
- .getLineInformation(startLine);
+ IRegion startLineRegion = currentDocument.getLineInformation(startLine);
if (startLine == endLine) {
regions.add(startLineRegion);
} else {
- IRegion endLineRegion = currentDocument
- .getLineInformation(endLine);
+ IRegion endLineRegion = currentDocument.getLineInformation(endLine);
int startOffset = startLineRegion.getOffset();
- int endOffset = endLineRegion.getOffset()
- + endLineRegion.getLength();
- regions.add(new Region(startOffset,
- endOffset - startOffset));
+ int endOffset = endLineRegion.getOffset() + endLineRegion.getLength();
+ regions.add(new Region(startOffset, endOffset - startOffset));
}
}
}
@@ -725,21 +662,16 @@
}
/**
- * Creates and returns a new sub-progress monitor for the given parent
- * monitor.
+ * Creates and returns a new sub-progress monitor for the given parent monitor.
*
- * @param monitor
- * the parent progress monitor
- * @param ticks
- * the number of work ticks allocated from the parent monitor
+ * @param monitor the parent progress monitor
+ * @param ticks the number of work ticks allocated from the parent monitor
* @return the new sub-progress monitor
* @since 3.0
*/
- private static IProgressMonitor getSubProgressMonitor(
- IProgressMonitor monitor, int ticks) {
+ private static IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
if (monitor != null)
- return new SubProgressMonitor(monitor, ticks,
- SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+ return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
return new NullProgressMonitor();
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
index 212378d..fbfd113 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
@@ -135,9 +135,8 @@
* view the corresponding editor is activated.
*/
-public class ScriptExplorerPart extends ViewPart implements ISetSelectionTarget,
- IMenuListener, IShowInTarget, IScriptExplorerViewPart,
- IPropertyChangeListener, IViewPartInputProvider {
+public class ScriptExplorerPart extends ViewPart implements ISetSelectionTarget, IMenuListener, IShowInTarget,
+ IScriptExplorerViewPart, IPropertyChangeListener, IViewPartInputProvider {
private static final String PERF_CREATE_PART_CONTROL = "org.eclipse.dltk.ui/perf/explorer/createPartControl"; //$NON-NLS-1$
private static final String PERF_MAKE_ACTIONS = "org.eclipse.dltk.ui/perf/explorer/makeActions"; //$NON-NLS-1$
@@ -251,21 +250,18 @@
@Override
protected boolean evaluateExpandableWithFilters(Object parent) {
- if (parent instanceof IScriptProject
- || parent instanceof ISourceModule
+ if (parent instanceof IScriptProject || parent instanceof ISourceModule
|| parent instanceof BuildPathContainer) {
return false;
}
- if (parent instanceof IProjectFragment
- && ((IProjectFragment) parent).isArchive()) {
+ if (parent instanceof IProjectFragment && ((IProjectFragment) parent).isArchive()) {
return false;
}
return true;
}
@Override
- protected boolean isFiltered(Object object, Object parent,
- ViewerFilter[] filters) {
+ protected boolean isFiltered(Object object, Object parent, ViewerFilter[] filters) {
// if (object instanceof PackageFragmentRootContainer) {
// return !hasFilteredChildren(object);
// }
@@ -278,8 +274,8 @@
}
/*
- * Checks if a filtered object in essential (i.e. is a parent that
- * should not be removed).
+ * Checks if a filtered object in essential (i.e. is a parent that should not be
+ * removed).
*/
private boolean isEssential(Object object) {
try {
@@ -296,13 +292,11 @@
}
@Override
- protected void handleInvalidSelection(ISelection invalidSelection,
- ISelection newSelection) {
+ protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
IStructuredSelection is = (IStructuredSelection) invalidSelection;
List ns = null;
if (newSelection instanceof IStructuredSelection) {
- ns = new ArrayList(
- ((IStructuredSelection) newSelection).toList());
+ ns = new ArrayList(((IStructuredSelection) newSelection).toList());
} else {
ns = new ArrayList();
}
@@ -338,8 +332,7 @@
*/
@Override
protected Object[] addAditionalProblemParents(Object[] elements) {
- if (getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS
- && elements != null) {
+ if (getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS && elements != null) {
return fWorkingSetModel.addWorkingSets(elements);
}
return elements;
@@ -359,14 +352,12 @@
}
@Override
- protected void setSelectionToWidget(ISelection selection,
- boolean reveal) {
+ protected void setSelectionToWidget(ISelection selection, boolean reveal) {
if (true) {
super.setSelectionToWidget(selection, reveal);
return;
}
- if (!fInPreserveSelection
- || !(selection instanceof ITreeSelection)) {
+ if (!fInPreserveSelection || !(selection instanceof ITreeSelection)) {
super.setSelectionToWidget(selection, reveal);
return;
}
@@ -381,14 +372,11 @@
for (Iterator iter = toRestore.iterator(); iter.hasNext();) {
Object element = iter.next();
TreePath[] pathsToRestore = toRestore.getPathsFor(element);
- CustomHashtable currentParents = createRootAccessedMap(
- contentProvider.getTreePaths(element));
+ CustomHashtable currentParents = createRootAccessedMap(contentProvider.getTreePaths(element));
for (int i = 0; i < pathsToRestore.length; i++) {
TreePath path = pathsToRestore[i];
Object root = path.getFirstSegment();
- if (root != null
- && path.equals((TreePath) currentParents.get(root),
- getComparer())) {
+ if (root != null && path.equals((TreePath) currentParents.get(root), getComparer())) {
pathsToSelect.add(path);
}
}
@@ -403,8 +391,7 @@
Widget current = getTree();
int last = size - 1;
Object segment;
- for (int i = 0; i < size && current != null
- && (segment = path.getSegment(i)) != null; i++) {
+ for (int i = 0; i < size && current != null && (segment = path.getSegment(i)) != null; i++) {
internalExpandToLevel(current, 1);
current = internalFindChild(current, segment);
if (i == last && current != null) {
@@ -412,8 +399,7 @@
}
}
}
- getTree().setSelection((TreeItem[]) toSelect
- .toArray(new TreeItem[toSelect.size()]));
+ getTree().setSelection((TreeItem[]) toSelect.toArray(new TreeItem[toSelect.size()]));
}
private Widget internalFindChild(Widget parent, Object element) {
@@ -445,28 +431,23 @@
fPostSelectionListener = event -> handlePostSelectionChanged(event);
// exception: initialize from preference
- fDialogSettings = DLTKUIPlugin.getDefault()
- .getDialogSettingsSection(getClass().getName());
+ fDialogSettings = DLTKUIPlugin.getDefault().getDialogSettingsSection(getClass().getName());
// on by default
- fShowLibrariesNode = fDialogSettings
- .get(ScriptExplorerPart.TAG_GROUP_LIBRARIES) == null
- || fDialogSettings
- .getBoolean(ScriptExplorerPart.TAG_GROUP_LIBRARIES);
+ fShowLibrariesNode = fDialogSettings.get(ScriptExplorerPart.TAG_GROUP_LIBRARIES) == null
+ || fDialogSettings.getBoolean(ScriptExplorerPart.TAG_GROUP_LIBRARIES);
- fLinkingEnabled = fDialogSettings
- .getBoolean(ScriptExplorerPart.TAG_LINK_EDITOR);
+ fLinkingEnabled = fDialogSettings.getBoolean(ScriptExplorerPart.TAG_LINK_EDITOR);
try {
- fIsCurrentLayoutFlat = fDialogSettings.getInt(
- ScriptExplorerPart.TAG_LAYOUT) == ScriptExplorerPart.FLAT_LAYOUT;
+ fIsCurrentLayoutFlat = fDialogSettings
+ .getInt(ScriptExplorerPart.TAG_LAYOUT) == ScriptExplorerPart.FLAT_LAYOUT;
} catch (NumberFormatException e) {
fIsCurrentLayoutFlat = getDefaultPackageLayout() == FLAT_LAYOUT;
}
try {
- fRootMode = fDialogSettings
- .getInt(ScriptExplorerPart.TAG_ROOT_MODE);
+ fRootMode = fDialogSettings.getInt(ScriptExplorerPart.TAG_ROOT_MODE);
} catch (NumberFormatException e) {
fRootMode = ScriptExplorerPart.PROJECTS_AS_ROOTS;
}
@@ -478,16 +459,13 @@
}
@Override
- public void init(IViewSite site, IMemento memento)
- throws PartInitException {
+ public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
if (memento == null) {
- String persistedMemento = fDialogSettings
- .get(ScriptExplorerPart.TAG_MEMENTO);
+ String persistedMemento = fDialogSettings.get(ScriptExplorerPart.TAG_MEMENTO);
if (persistedMemento != null) {
try {
- memento = XMLMemento
- .createReadRoot(new StringReader(persistedMemento));
+ memento = XMLMemento.createReadRoot(new StringReader(persistedMemento));
} catch (WorkbenchException e) {
// don't do anything. Simply don't restore the settings
}
@@ -506,8 +484,7 @@
private void restoreRootMode(IMemento memento) {
Integer value = memento.getInteger(ScriptExplorerPart.TAG_ROOT_MODE);
- fRootMode = value == null ? ScriptExplorerPart.PROJECTS_AS_ROOTS
- : value.intValue();
+ fRootMode = value == null ? ScriptExplorerPart.PROJECTS_AS_ROOTS : value.intValue();
if (fRootMode != ScriptExplorerPart.PROJECTS_AS_ROOTS
&& fRootMode != ScriptExplorerPart.WORKING_SETS_AS_ROOTS) {
fRootMode = ScriptExplorerPart.PROJECTS_AS_ROOTS;
@@ -517,20 +494,17 @@
private void restoreLayoutState(IMemento memento) {
Integer layoutState = memento.getInteger(ScriptExplorerPart.TAG_LAYOUT);
if (layoutState != null) {
- fIsCurrentLayoutFlat = layoutState
- .intValue() == ScriptExplorerPart.FLAT_LAYOUT;
+ fIsCurrentLayoutFlat = layoutState.intValue() == ScriptExplorerPart.FLAT_LAYOUT;
}
// on by default
- Integer groupLibraries = memento
- .getInteger(ScriptExplorerPart.TAG_GROUP_LIBRARIES);
- fShowLibrariesNode = groupLibraries == null
- || groupLibraries.intValue() != 0;
+ Integer groupLibraries = memento.getInteger(ScriptExplorerPart.TAG_GROUP_LIBRARIES);
+ fShowLibrariesNode = groupLibraries == null || groupLibraries.intValue() != 0;
}
/**
- * Returns the package explorer part of the active perspective. If there
- * isn't any package explorer part <code>null</code> is returned.
+ * Returns the package explorer part of the active perspective. If there isn't
+ * any package explorer part <code>null</code> is returned.
*/
public static ScriptExplorerPart getFromActivePerspective() {
IWorkbenchPage activePage = DLTKUIPlugin.getActivePage();
@@ -545,14 +519,13 @@
}
/**
- * Makes the package explorer part visible in the active perspective. If
- * there isn't a package explorer part registered <code>null</code> is
- * returned. Otherwise the opened view part is returned.
+ * Makes the package explorer part visible in the active perspective. If there
+ * isn't a package explorer part registered <code>null</code> is returned.
+ * Otherwise the opened view part is returned.
*/
public static ScriptExplorerPart openInActivePerspective() {
try {
- return (ScriptExplorerPart) DLTKUIPlugin.getActivePage()
- .showView(DLTKUIPlugin.ID_SCRIPT_EXPLORER);
+ return (ScriptExplorerPart) DLTKUIPlugin.getActivePage().showView(DLTKUIPlugin.ID_SCRIPT_EXPLORER);
} catch (PartInitException pe) {
return null;
}
@@ -561,8 +534,7 @@
@Override
public void dispose() {
if (fContextActivation != null) {
- IContextService ctxService = getSite()
- .getService(IContextService.class);
+ IContextService ctxService = getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
@@ -572,8 +544,7 @@
StringWriter writer = new StringWriter();
try {
memento.save(writer);
- fDialogSettings.put(ScriptExplorerPart.TAG_MEMENTO,
- writer.getBuffer().toString());
+ fDialogSettings.put(ScriptExplorerPart.TAG_MEMENTO, writer.getBuffer().toString());
} catch (IOException e) {
// don't do anything. Simply don't store the settings
}
@@ -590,8 +561,7 @@
// didn't
// register
- DLTKUIPlugin.getDefault().getPreferenceStore()
- .removePropertyChangeListener(this);
+ DLTKUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
// if (fViewer != null) {
// fViewer.removeTreeListener(fExpansionListener);
// }
@@ -600,8 +570,7 @@
fActionSet.dispose();
}
if (fFilterUpdater != null) {
- ResourcesPlugin.getWorkspace()
- .removeResourceChangeListener(fFilterUpdater);
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
}
if (fWorkingSetModel != null) {
fWorkingSetModel.dispose();
@@ -618,8 +587,7 @@
@Override
public void createPartControl(Composite parent) {
- final PerformanceStats stats = PerformanceStats
- .getStats(ScriptExplorerPart.PERF_CREATE_PART_CONTROL, this);
+ final PerformanceStats stats = PerformanceStats.getStats(ScriptExplorerPart.PERF_CREATE_PART_CONTROL, this);
stats.startRun();
fViewer = createViewer(parent);
@@ -629,8 +597,7 @@
setProviders();
- DLTKUIPlugin.getDefault().getPreferenceStore()
- .addPropertyChangeListener(this);
+ DLTKUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
@@ -655,16 +622,14 @@
fViewer.addPostSelectionChangedListener(fPostSelectionListener);
- fViewer.addDoubleClickListener(
- event -> fActionSet.handleDoubleClick(event));
+ fViewer.addDoubleClickListener(event -> fActionSet.handleDoubleClick(event));
fViewer.addOpenListener(event -> {
fActionSet.handleOpen(event);
fLastOpenSelection = event.getSelection();
});
- IStatusLineManager slManager = getViewSite().getActionBars()
- .getStatusLineManager();
+ IStatusLineManager slManager = getViewSite().getActionBars().getStatusLineManager();
fViewer.addSelectionChangedListener(new StatusBarUpdater(slManager));
// fViewer.addTreeListener(fExpansionListener);
@@ -675,19 +640,16 @@
updateTitle();
fFilterUpdater = new FilterUpdater(fViewer);
- ResourcesPlugin.getWorkspace()
- .addResourceChangeListener(fFilterUpdater);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
// Sync'ing the package explorer has to be done here. It can't be done
// when restoring the link state since the package explorers input isn't
// set yet.
setLinkingEnabled(isLinkingEnabled());
- IContextService ctxService = getSite()
- .getService(IContextService.class);
+ IContextService ctxService = getSite().getService(IContextService.class);
if (ctxService != null) {
- fContextActivation = ctxService
- .activateContext(DLTKUIPlugin.CONTEXT_VIEWS);
+ fContextActivation = ctxService.activateContext(DLTKUIPlugin.CONTEXT_VIEWS);
}
stats.endRun();
}
@@ -705,8 +667,7 @@
*
*/
protected ProblemTreeViewer createViewer(Composite composite) {
- return new PackageExplorerProblemTreeViewer(composite,
- SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ return new PackageExplorerProblemTreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
/**
@@ -729,8 +690,7 @@
fLabelProvider = createLabelProvider();
fLabelProvider.setIsFlatLayout(fIsCurrentLayoutFlat);
- fDecoratingLabelProvider = new StyledDecoratingModelLabelProvider(
- fLabelProvider, false, fIsCurrentLayoutFlat);
+ fDecoratingLabelProvider = new StyledDecoratingModelLabelProvider(fLabelProvider, false, fIsCurrentLayoutFlat);
fViewer.setLabelProvider(fDecoratingLabelProvider);
// problem decoration provided by PackageLabelProvider
}
@@ -782,8 +742,7 @@
}
};
}
- return new WorkingSetAwareContentProvider(showCUChildren,
- fWorkingSetModel) {
+ return new WorkingSetAwareContentProvider(showCUChildren, fWorkingSetModel) {
@Override
protected IPreferenceStore getPreferenceStore() {
return DLTKUIPlugin.getDefault().getPreferenceStore();
@@ -793,8 +752,7 @@
protected ScriptExplorerLabelProvider createLabelProvider() {
- final IPreferenceStore store = DLTKUIPlugin.getDefault()
- .getPreferenceStore();
+ final IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
return new ScriptExplorerLabelProvider(fContentProvider, store);
}
@@ -845,8 +803,7 @@
return (T) getShowInSource();
}
if (key == IShowInTargetList.class) {
- return (T) (IShowInTargetList) () -> new String[] {
- IPageLayout.ID_RES_NAV };
+ return (T) (IShowInTargetList) () -> new String[] { IPageLayout.ID_RES_NAV };
}
// if (key == IContextProvider.class) {
// return ScriptUIHelp.getHelpContextProvider(this,
@@ -891,16 +848,13 @@
return result;
}
if (result.length() == 0) {
- return Messages.format(ScriptMessages.PackageExplorer_toolTip,
- new String[] { fWorkingSetLabel });
+ return Messages.format(ScriptMessages.PackageExplorer_toolTip, fWorkingSetLabel);
}
- return Messages.format(ScriptMessages.PackageExplorer_toolTip2,
- new String[] { result, fWorkingSetLabel });
+ return Messages.format(ScriptMessages.PackageExplorer_toolTip2, result, fWorkingSetLabel);
}
// Working set mode. During initialization element and
// action set can be null.
- if (element != null && !(element instanceof IWorkingSet)
- && !(element instanceof WorkingSetModel)
+ if (element != null && !(element instanceof IWorkingSet) && !(element instanceof WorkingSetModel)
&& fActionSet != null) {
FrameList frameList = fActionSet.getFrameList();
int index = frameList.getCurrentIndex();
@@ -917,8 +871,7 @@
index--;
}
if (ws != null) {
- return Messages.format(ScriptMessages.PackageExplorer_toolTip3,
- new String[] { ws.getLabel(), result });
+ return Messages.format(ScriptMessages.PackageExplorer_toolTip3, ws.getLabel(), result);
}
return result;
}
@@ -933,11 +886,6 @@
return getToolTipText(fViewer.getInput());
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- */
@Override
public void setFocus() {
fViewer.getTree().setFocus();
@@ -950,11 +898,6 @@
// ---- Action handling
// ----------------------------------------------------------
- /*
- * (non-Javadoc)
- *
- * @see IMenuListener#menuAboutToShow(IMenuManager)
- */
@Override
public void menuAboutToShow(IMenuManager menu) {
DLTKUIPlugin.createStandardGroups(menu);
@@ -966,14 +909,12 @@
private void makeActions() {
- final PerformanceStats stats = PerformanceStats
- .getStats(ScriptExplorerPart.PERF_MAKE_ACTIONS, this);
+ final PerformanceStats stats = PerformanceStats.getStats(ScriptExplorerPart.PERF_MAKE_ACTIONS, this);
stats.startRun();
fActionSet = getActionGroup();
if (fWorkingSetModel != null) {
- fActionSet.getWorkingSetActionGroup()
- .setWorkingSetModel(fWorkingSetModel);
+ fActionSet.getWorkingSetActionGroup().setWorkingSetModel(fWorkingSetModel);
}
stats.endRun();
@@ -1019,13 +960,6 @@
fLastOpenSelection = null;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.part.ISetSelectionTarget#selectReveal(org.eclipse.jface
- * .viewers.ISelection)
- */
@Override
public void selectReveal(final ISelection selection) {
Control ctrl = getTreeViewer().getControl();
@@ -1061,8 +995,7 @@
if (original instanceof ISourceModule) {
ISourceModule cu = (ISourceModule) original;
IScriptProject javaProject = cu.getScriptProject();
- if (javaProject != null && javaProject.exists()
- && !javaProject.isOnBuildpath(cu)) {
+ if (javaProject != null && javaProject.exists() && !javaProject.isOnBuildpath(cu)) {
// could be a working copy of a .java file that is not on
// classpath
IResource resource = cu.getResource();
@@ -1115,8 +1048,7 @@
/**
* Links to editor (if option enabled)
*
- * @param selection
- * the selection
+ * @param selection the selection
*/
private void linkToEditor(IStructuredSelection selection) {
// ignore selection changes if the package explorer is not the active
@@ -1165,25 +1097,21 @@
}
private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(ScriptExplorerPart.TAG_LINK_EDITOR,
- fLinkingEnabled ? 1 : 0);
+ memento.putInteger(ScriptExplorerPart.TAG_LINK_EDITOR, fLinkingEnabled ? 1 : 0);
}
private void saveLayoutState(IMemento memento) {
if (memento != null) {
memento.putInteger(ScriptExplorerPart.TAG_LAYOUT, getLayoutAsInt());
- memento.putInteger(ScriptExplorerPart.TAG_GROUP_LIBRARIES,
- fShowLibrariesNode ? 1 : 0);
+ memento.putInteger(ScriptExplorerPart.TAG_GROUP_LIBRARIES, fShowLibrariesNode ? 1 : 0);
}
}
private void saveDialogSettings() {
- fDialogSettings.put(ScriptExplorerPart.TAG_GROUP_LIBRARIES,
- fShowLibrariesNode);
+ fDialogSettings.put(ScriptExplorerPart.TAG_GROUP_LIBRARIES, fShowLibrariesNode);
fDialogSettings.put(ScriptExplorerPart.TAG_LAYOUT, getLayoutAsInt());
fDialogSettings.put(ScriptExplorerPart.TAG_ROOT_MODE, fRootMode);
- fDialogSettings.put(ScriptExplorerPart.TAG_LINK_EDITOR,
- fLinkingEnabled);
+ fDialogSettings.put(ScriptExplorerPart.TAG_LINK_EDITOR, fLinkingEnabled);
}
private int getLayoutAsInt() {
@@ -1218,11 +1146,10 @@
}
/**
- * An editor has been activated. Set the selection in this Packages Viewer
- * to be the editor's input, if linking is enabled.
+ * An editor has been activated. Set the selection in this Packages Viewer to be
+ * the editor's input, if linking is enabled.
*
- * @param editor
- * the activated editor
+ * @param editor the activated editor
*/
protected void editorActivated(IEditorPart editor) {
IEditorInput editorInput = editor.getEditorInput();
@@ -1271,8 +1198,7 @@
return false;
}
- IEditorInput selectionAsInput = EditorUtility
- .getEditorInput(selection.getFirstElement());
+ IEditorInput selectionAsInput = EditorUtility.getEditorInput(selection.getFirstElement());
return input.equals(selectionAsInput);
}
@@ -1293,12 +1219,10 @@
fViewer.reveal(element);
} else {
try {
- fViewer.removePostSelectionChangedListener(
- fPostSelectionListener);
+ fViewer.removePostSelectionChangedListener(fPostSelectionListener);
fViewer.setSelection(newSelection, true);
- while (element != null
- && fViewer.getSelection().isEmpty()) {
+ while (element != null && fViewer.getSelection().isEmpty()) {
// Try to select parent in case element is filtered
element = getParent(element);
if (element != null) {
@@ -1307,8 +1231,7 @@
}
}
} finally {
- fViewer.addPostSelectionChangedListener(
- fPostSelectionListener);
+ fViewer.addPostSelectionChangedListener(fPostSelectionListener);
}
}
return true;
@@ -1344,8 +1267,7 @@
else if (input instanceof ExternalStorageEditorInput)
return ((ExternalStorageEditorInput) input).getStorage();
else if (input instanceof FileStoreEditorInput) {
- ISourceModule module = DLTKUIPlugin
- .resolveSourceModule((FileStoreEditorInput) input);
+ ISourceModule module = DLTKUIPlugin.resolveSourceModule((FileStoreEditorInput) input);
if (module != null) {
return module;
}
@@ -1379,8 +1301,8 @@
}
/**
- * Updates the title text and title tool tip. Called whenever the input of
- * the viewer changes.
+ * Updates the title text and title tool tip. Called whenever the input of the
+ * viewer changes.
*/
void updateTitle() {
Object input = fViewer.getInput();
@@ -1388,8 +1310,8 @@
setContentDescription(""); //$NON-NLS-1$
setTitleToolTip(""); //$NON-NLS-1$
} else {
- String inputText = ScriptElementLabels.getDefault().getTextLabel(
- input, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
+ String inputText = ScriptElementLabels.getDefault().getTextLabel(input,
+ AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
setContentDescription(inputText);
setTitleToolTip(getToolTipText(input));
}
@@ -1403,21 +1325,17 @@
boolean refreshViewer = false;
- if (PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN
- .equals(event.getProperty())) {
+ if (PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN.equals(event.getProperty())) {
fActionSet.updateActionBars(getViewSite().getActionBars());
- boolean showCUChildren = DLTKUIPlugin.getDefault()
- .getPreferenceStore().getBoolean(
- PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN);
- ((StandardModelElementContentProvider) fViewer.getContentProvider())
- .setProvideMembers(showCUChildren);
+ boolean showCUChildren = DLTKUIPlugin.getDefault().getPreferenceStore()
+ .getBoolean(PreferenceConstants.SHOW_SOURCE_MODULE_CHILDREN);
+ ((StandardModelElementContentProvider) fViewer.getContentProvider()).setProvideMembers(showCUChildren);
refreshViewer = true;
}
if (DLTKCore.DEBUG) {
- System.err.println(
- "Add members order preference cach support here..."); //$NON-NLS-1$
+ System.err.println("Add members order preference cach support here..."); //$NON-NLS-1$
}
// } else if
// (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty()
@@ -1447,8 +1365,7 @@
public void collapseAll() {
try {
fViewer.getControl().setRedraw(false);
- fViewer.collapseToLevel(getViewPartInput(),
- AbstractTreeViewer.ALL_LEVELS);
+ fViewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
} finally {
fViewer.getControl().setRedraw(true);
}
@@ -1484,8 +1401,7 @@
Object input = context.getInput();
if (input instanceof IEditorInput) {
Object elementOfInput = getInputFromEditor((IEditorInput) input);
- return elementOfInput != null
- && (tryToReveal(elementOfInput) == IStatus.OK);
+ return elementOfInput != null && (tryToReveal(elementOfInput) == IStatus.OK);
}
return false;
@@ -1495,8 +1411,7 @@
* Returns the <code>IShowInSource</code> for this view.
*/
protected IShowInSource getShowInSource() {
- return () -> new ShowInContext(getTreeViewer().getInput(),
- getTreeViewer().getSelection());
+ return () -> new ShowInContext(getTreeViewer().getInput(), getTreeViewer().getSelection());
}
@Override
@@ -1536,33 +1451,23 @@
return IStatus.OK;
}
- WorkingSetFilterActionGroup workingSetGroup = fActionSet
- .getWorkingSetActionGroup().getFilterGroup();
+ WorkingSetFilterActionGroup workingSetGroup = fActionSet.getWorkingSetActionGroup().getFilterGroup();
if (workingSetGroup != null) {
IWorkingSet workingSet = workingSetGroup.getWorkingSet();
- if (workingSetGroup.isFiltered(getVisibleParent(element),
- element)) {
+ if (workingSetGroup.isFiltered(getVisibleParent(element), element)) {
String message;
if (element instanceof IModelElement) {
- IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager
- .getLanguageToolkit((IModelElement) element);
- ScriptElementLabels labels = toolkit
- .getScriptElementLabels();
- String elementLabel = labels.getElementLabel(
- (IModelElement) element,
+ IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager.getLanguageToolkit((IModelElement) element);
+ ScriptElementLabels labels = toolkit.getScriptElementLabels();
+ String elementLabel = labels.getElementLabel((IModelElement) element,
ScriptElementLabels.ALL_DEFAULT);
- message = Messages.format(
- ScriptMessages.PackageExplorer_notFound,
- new String[] { elementLabel,
- workingSet.getLabel() });
- } else {
- message = Messages.format(
- ScriptMessages.PackageExplorer_notFound,
+ message = Messages.format(ScriptMessages.PackageExplorer_notFound, elementLabel,
workingSet.getLabel());
+ } else {
+ message = Messages.format(ScriptMessages.PackageExplorer_notFound, workingSet.getLabel());
}
if (MessageDialog.openQuestion(getSite().getShell(),
- ScriptMessages.PackageExplorer_filteredDialog_title,
- message)) {
+ ScriptMessages.PackageExplorer_filteredDialog_title, message)) {
workingSetGroup.setWorkingSet(null, true);
if (revealElementOrParent(element)) {
return IStatus.OK;
@@ -1573,29 +1478,21 @@
}
}
// try to remove filters
- CustomFiltersActionGroup filterGroup = fActionSet
- .getCustomFilterActionGroup();
+ CustomFiltersActionGroup filterGroup = fActionSet.getCustomFilterActionGroup();
String[] currentFilters = filterGroup.internalGetEnabledFilterIds();
- String[] newFilters = filterGroup.removeFiltersFor(
- getVisibleParent(element), element,
+ String[] newFilters = filterGroup.removeFiltersFor(getVisibleParent(element), element,
getTreeViewer().getContentProvider());
if (currentFilters.length > newFilters.length) {
String message;
if (element instanceof IModelElement) {
- IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager
- .getLanguageToolkit((IModelElement) element);
+ IDLTKUILanguageToolkit toolkit = DLTKUILanguageManager.getLanguageToolkit((IModelElement) element);
ScriptElementLabels labels = toolkit.getScriptElementLabels();
- String elementLabel = labels.getElementLabel(
- (IModelElement) element,
- ScriptElementLabels.ALL_DEFAULT);
- message = Messages.format(
- ScriptMessages.PackageExplorer_removeFilters,
- elementLabel);
+ String elementLabel = labels.getElementLabel((IModelElement) element, ScriptElementLabels.ALL_DEFAULT);
+ message = Messages.format(ScriptMessages.PackageExplorer_removeFilters, elementLabel);
} else {
message = ScriptMessages.PackageExplorer_removeFilters;
}
- if (MessageDialog.openQuestion(getSite().getShell(),
- ScriptMessages.PackageExplorer_filteredDialog_title,
+ if (MessageDialog.openQuestion(getSite().getShell(), ScriptMessages.PackageExplorer_filteredDialog_title,
message)) {
filterGroup.setFilters(newFilters);
if (revealElementOrParent(element)) {
@@ -1609,8 +1506,7 @@
while (action.getFrameList().getCurrentIndex() > 0) {
// only try to go up if there is a parent frame
// fix for bug# 63769 Endless loop after Show in Package Explorer
- if (action.getFrameList().getSource()
- .getFrame(IFrameSource.PARENT_FRAME, 0) == null) {
+ if (action.getFrameList().getSource().getFrame(IFrameSource.PARENT_FRAME, 0) == null) {
break;
}
action.run();
@@ -1679,21 +1575,16 @@
fRootMode = newMode;
saveDialogSettings();
- if (getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS
- && fWorkingSetModel == null) {
+ if (getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS && fWorkingSetModel == null) {
createWorkingSetModel();
if (fActionSet != null) {
- fActionSet.getWorkingSetActionGroup()
- .setWorkingSetModel(fWorkingSetModel);
+ fActionSet.getWorkingSetActionGroup().setWorkingSetModel(fWorkingSetModel);
}
}
- IStructuredSelection selection = new StructuredSelection(
- (fViewer.getStructuredSelection()).toArray());
+ IStructuredSelection selection = new StructuredSelection((fViewer.getStructuredSelection()).toArray());
Object input = fViewer.getInput();
- boolean isRootInputChange = DLTKCore
- .create(ResourcesPlugin.getWorkspace().getRoot()).equals(input)
- || (fWorkingSetModel != null && fWorkingSetModel.equals(input))
- || input instanceof IWorkingSet;
+ boolean isRootInputChange = DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot()).equals(input)
+ || (fWorkingSetModel != null && fWorkingSetModel.equals(input)) || input instanceof IWorkingSet;
try {
fViewer.getControl().setRedraw(false);
if (isRootInputChange) {
@@ -1709,8 +1600,7 @@
} finally {
fViewer.getControl().setRedraw(true);
}
- if (isRootInputChange
- && getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS
+ if (isRootInputChange && getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS
&& fWorkingSetModel.needsConfiguration()) {
configWorkingSet();
fWorkingSetModel.configured();
@@ -1719,8 +1609,7 @@
}
protected void configWorkingSet() {
- ConfigureWorkingSetAction action = new ConfigureWorkingSetAction(
- getSite());
+ ConfigureWorkingSetAction action = new ConfigureWorkingSetAction(getSite());
action.setWorkingSetModel(fWorkingSetModel);
action.run();
}
@@ -1752,8 +1641,7 @@
return null;
}
- return fActionSet.getWorkingSetActionGroup().getFilterGroup()
- .getWorkingSet();
+ return fActionSet.getWorkingSetActionGroup().getFilterGroup().getWorkingSet();
}
public WorkingSetModel getWorkingSetModel() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchParticipantDescriptor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchParticipantDescriptor.java
index b08bd1c..2687a01 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchParticipantDescriptor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchParticipantDescriptor.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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.dltk.internal.ui.search;
@@ -18,8 +17,6 @@
import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.dltk.ui.search.IQueryParticipant;
-/**
- */
public class SearchParticipantDescriptor {
private static final String CLASS = "class"; //$NON-NLS-1$
private static final String NATURE = "nature"; //$NON-NLS-1$
@@ -36,43 +33,33 @@
/**
* checks whether a participant has all the proper attributes.
- *
+ *
* @return returns a status describing the result of the validation
*/
protected IStatus checkSyntax() {
if (fConfigurationElement.getAttribute(ID) == null) {
String format = SearchMessages.SearchParticipant_error_noID;
- String message = Messages
- .format(format,
- new String[] { fConfigurationElement
- .getDeclaringExtension()
- .getUniqueIdentifier() });
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
- message, null);
+ String message = Messages.format(format,
+ fConfigurationElement.getDeclaringExtension().getUniqueIdentifier());
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, null);
}
if (fConfigurationElement.getAttribute(LANGUAGE) == null) {
String format = SearchMessages.SearchParticipant_error_noLanguage;
- String message = Messages.format(format,
- new String[] { fConfigurationElement.getAttribute(ID) });
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
- message, null);
+ String message = Messages.format(format, fConfigurationElement.getAttribute(ID));
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, null);
}
if (fConfigurationElement.getAttribute(NATURE) == null) {
String format = SearchMessages.SearchParticipant_error_noNature;
- String message = Messages.format(format,
- new String[] { fConfigurationElement.getAttribute(ID) });
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
- message, null);
+ String message = Messages.format(format, fConfigurationElement.getAttribute(ID));
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, null);
}
if (fConfigurationElement.getAttribute(CLASS) == null) {
String format = SearchMessages.SearchParticipant_error_noClass;
- String message = Messages.format(format,
- new String[] { fConfigurationElement.getAttribute(ID) });
- return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
- message, null);
+ String message = Messages.format(format, fConfigurationElement.getAttribute(ID));
+ return new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0, message, null);
}
return Status.OK_STATUS;
}
@@ -91,11 +78,9 @@
protected IQueryParticipant create() throws CoreException {
try {
- return (IQueryParticipant) fConfigurationElement
- .createExecutableExtension(CLASS);
+ return (IQueryParticipant) fConfigurationElement.createExecutableExtension(CLASS);
} catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR,
- DLTKUIPlugin.getPluginId(), 0,
+ throw new CoreException(new Status(IStatus.ERROR, DLTKUIPlugin.getPluginId(), 0,
SearchMessages.SearchParticipant_error_classCast, e));
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchUtil.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchUtil.java
index 5343385..c0086fa 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchUtil.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/SearchUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -49,33 +49,31 @@
}
/**
- * This helper method with Object as parameter is needed to prevent the
- * loading of the Search plug-in: the Interpreter verifies the method call
- * and hence loads the types used in the method signature, eventually
- * triggering the loading of a plug-in (in this case ISearchQuery results in
- * Search plug-in being loaded).
+ * This helper method with Object as parameter is needed to prevent the loading
+ * of the Search plug-in: the Interpreter verifies the method call and hence
+ * loads the types used in the method signature, eventually triggering the
+ * loading of a plug-in (in this case ISearchQuery results in Search plug-in
+ * being loaded).
*/
public static void runQueryInBackground(Object query) {
NewSearchUI.runQueryInBackground((ISearchQuery) query);
}
/**
- * This helper method with Object as parameter is needed to prevent the
- * loading of the Search plug-in: the Interpreter verifies the method call
- * and hence loads the types used in the method signature, eventually
- * triggering the loading of a plug-in (in this case ISearchQuery results in
- * Search plug-in being loaded).
+ * This helper method with Object as parameter is needed to prevent the loading
+ * of the Search plug-in: the Interpreter verifies the method call and hence
+ * loads the types used in the method signature, eventually triggering the
+ * loading of a plug-in (in this case ISearchQuery results in Search plug-in
+ * being loaded).
*/
- public static IStatus runQueryInForeground(IRunnableContext context,
- Object query) {
+ public static IStatus runQueryInForeground(IRunnableContext context, Object query) {
return NewSearchUI.runQueryInForeground(context, (ISearchQuery) query);
}
/**
* Returns the compilation unit for the givenscriptelement.
*
- * @param element
- * thescriptelement whose compilation unit is searched for
+ * @param element thescriptelement whose compilation unit is searched for
* @return the compilation unit of the givenscriptelement
*/
static ISourceModule findSourceModule(IModelElement element) {
@@ -92,9 +90,8 @@
for (int i = 0; i < workingSets.length; i++) {
String workingSetLabel = workingSets[i].getLabel();
if (firstFound)
- result = Messages.format(
- SearchMessages.SearchUtil_workingSetConcatenation,
- new String[] { result, workingSetLabel });
+ result = Messages.format(SearchMessages.SearchUtil_workingSetConcatenation, result,
+ workingSetLabel);
else {
result = workingSetLabel;
firstFound = true;
@@ -109,8 +106,7 @@
/**
* Updates the LRU list of working sets.
*
- * @param workingSets
- * the workings sets to be added to the LRU list
+ * @param workingSets the workings sets to be added to the LRU list
*/
public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
if (workingSets == null || workingSets.length < 1)
@@ -147,13 +143,11 @@
boolean foundLRU = false;
for (int i = LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) {
- String[] lruWorkingSetNames = settingsStore
- .getArray(STORE_LRU_WORKING_SET_NAMES + i);
+ String[] lruWorkingSetNames = settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES + i);
if (lruWorkingSetNames != null) {
Set<IWorkingSet> workingSets = new HashSet<>(2);
for (int j = 0; j < lruWorkingSetNames.length; j++) {
- IWorkingSet workingSet = PlatformUI.getWorkbench()
- .getWorkingSetManager()
+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager()
.getWorkingSet(lruWorkingSetNames[j]);
if (workingSet != null) {
workingSets.add(workingSet);
@@ -161,8 +155,7 @@
}
foundLRU = true;
if (!workingSets.isEmpty())
- fgLRUWorkingSets.add(workingSets
- .toArray(new IWorkingSet[workingSets.size()]));
+ fgLRUWorkingSets.add(workingSets.toArray(new IWorkingSet[workingSets.size()]));
}
}
if (!foundLRU)
@@ -171,11 +164,9 @@
}
private static IDialogSettings getDialogStoreSection() {
- IDialogSettings settingsStore = DLTKUIPlugin.getDefault()
- .getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
+ IDialogSettings settingsStore = DLTKUIPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
if (settingsStore == null)
- settingsStore = DLTKUIPlugin.getDefault().getDialogSettings()
- .addNewSection(DIALOG_SETTINGS_KEY);
+ settingsStore = DLTKUIPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
return settingsStore;
}
@@ -184,12 +175,10 @@
IDialogSettings settingsStore = getDialogStoreSection();
boolean foundLRU = false;
- String[] lruWorkingSetNames = settingsStore
- .getArray(STORE_LRU_WORKING_SET_NAMES);
+ String[] lruWorkingSetNames = settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES);
if (lruWorkingSetNames != null) {
for (int i = lruWorkingSetNames.length - 1; i >= 0; i--) {
- IWorkingSet workingSet = PlatformUI.getWorkbench()
- .getWorkingSetManager()
+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager()
.getWorkingSet(lruWorkingSetNames[i]);
if (workingSet != null) {
foundLRU = true;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
index 1b90c0c..2444a74 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/HierarchyInformationControl.java
@@ -47,8 +47,7 @@
*
* @since 3.0
*/
-public abstract class HierarchyInformationControl
- extends AbstractInformationControl {
+public abstract class HierarchyInformationControl extends AbstractInformationControl {
private TypeHierarchyLifeCycle fLifeCycle;
private HierarchyLabelProvider fLabelProvider;
@@ -62,10 +61,8 @@
private MethodOverrideTester fMethodOverrideTester;
- public HierarchyInformationControl(Shell parent, int shellStyle,
- int treeStyle) {
- super(parent, shellStyle, treeStyle,
- IScriptEditorActionDefinitionIds.OPEN_HIERARCHY, true);
+ public HierarchyInformationControl(Shell parent, int shellStyle, int treeStyle) {
+ super(parent, shellStyle, treeStyle, IScriptEditorActionDefinitionIds.OPEN_HIERARCHY, true);
fOtherExpandedElements = null;
fDoFilter = true;
fMethodOverrideTester = null;
@@ -76,11 +73,9 @@
fKeyAdapter = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
- int accelerator = SWTKeySupport
- .convertEventToUnmodifiedAccelerator(e);
- KeySequence keySequence = KeySequence.getInstance(
- SWTKeySupport.convertAcceleratorToKeyStroke(
- accelerator));
+ int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
+ KeySequence keySequence = KeySequence
+ .getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
KeySequence[] sequences = getInvokingCommandKeySequences();
if (sequences == null)
return;
@@ -124,10 +119,8 @@
TreeViewer treeViewer = new TreeViewer(tree);
treeViewer.addFilter(new ViewerFilter() {
@Override
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- return element instanceof IType
- || element instanceof CumulativeType;
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return element instanceof IType || element instanceof CumulativeType;
}
});
@@ -136,18 +129,15 @@
treeViewer.setComparator(new HierarchyViewerSorter(fLifeCycle));
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
- fLabelProvider = new HierarchyLabelProvider(fLifeCycle,
- getPreferenceStore());
+ fLabelProvider = new HierarchyLabelProvider(fLifeCycle, getPreferenceStore());
fLabelProvider.setFilter(new ViewerFilter() {
@Override
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
return hasFocusMethod((IType) element);
}
});
- fLabelProvider.setTextFlags(ScriptElementLabels.ALL_DEFAULT
- | ScriptElementLabels.T_POST_QUALIFIED);
+ fLabelProvider.setTextFlags(ScriptElementLabels.ALL_DEFAULT | ScriptElementLabels.T_POST_QUALIFIED);
fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
treeViewer.setLabelProvider(fLabelProvider);
@@ -185,27 +175,21 @@
}
- private IMethod findMethod(IMethod filterMethod, IType typeToFindIn)
- throws ModelException {
+ private IMethod findMethod(IMethod filterMethod, IType typeToFindIn) throws ModelException {
IType filterType = filterMethod.getDeclaringType();
ITypeHierarchy hierarchy = fLifeCycle.getHierarchy();
- boolean filterOverrides = ScriptModelUtil.isSuperType(hierarchy,
- typeToFindIn, filterType);
+ boolean filterOverrides = ScriptModelUtil.isSuperType(hierarchy, typeToFindIn, filterType);
IType focusType = filterOverrides ? filterType : typeToFindIn;
- if (fMethodOverrideTester == null
- || !fMethodOverrideTester.getFocusType().equals(focusType)) {
- fMethodOverrideTester = new MethodOverrideTester(focusType,
- hierarchy);
+ if (fMethodOverrideTester == null || !fMethodOverrideTester.getFocusType().equals(focusType)) {
+ fMethodOverrideTester = new MethodOverrideTester(focusType, hierarchy);
}
if (filterOverrides) {
- return fMethodOverrideTester
- .findOverriddenMethodInType(typeToFindIn, filterMethod);
+ return fMethodOverrideTester.findOverriddenMethodInType(typeToFindIn, filterMethod);
}
- return fMethodOverrideTester.findOverridingMethodInType(typeToFindIn,
- filterMethod);
+ return fMethodOverrideTester.findOverridingMethodInType(typeToFindIn, filterMethod);
}
@Override
@@ -241,9 +225,8 @@
input = elem.getParent().getParent();
break;
default:
- DLTKUIPlugin.logErrorMessage(
- "Element unsupported by the hierarchy: " //$NON-NLS-1$
- + elem.getClass());
+ DLTKUIPlugin.logErrorMessage("Element unsupported by the hierarchy: " //$NON-NLS-1$
+ + elem.getClass());
input = null;
}
} catch (ModelException e) {
@@ -252,31 +235,26 @@
super.setTitleText(getHeaderLabel(locked == null ? input : locked));
try {
- fLifeCycle.ensureRefreshedTypeHierarchy(input,
- DLTKUIPlugin.getActiveWorkbenchWindow());
+ fLifeCycle.ensureRefreshedTypeHierarchy(input, DLTKUIPlugin.getActiveWorkbenchWindow());
} catch (InvocationTargetException e1) {
input = null;
} catch (InterruptedException e1) {
dispose();
return;
}
- IMember[] memberFilter = locked != null ? new IMember[] { locked }
- : null;
+ IMember[] memberFilter = locked != null ? new IMember[] { locked } : null;
- TraditionalHierarchyContentProvider contentProvider = new TraditionalHierarchyContentProvider(
- fLifeCycle);
+ TraditionalHierarchyContentProvider contentProvider = new TraditionalHierarchyContentProvider(fLifeCycle);
contentProvider.setMemberFilter(memberFilter);
getTreeViewer().setContentProvider(contentProvider);
- fOtherContentProvider = new SuperTypeHierarchyContentProvider(
- fLifeCycle);
+ fOtherContentProvider = new SuperTypeHierarchyContentProvider(fLifeCycle);
fOtherContentProvider.setMemberFilter(memberFilter);
fFocus = locked;
Object[] topLevelObjects = contentProvider.getElements(fLifeCycle);
- if (topLevelObjects.length > 0 && contentProvider
- .getChildren(topLevelObjects[0]).length > 40) {
+ if (topLevelObjects.length > 0 && contentProvider.getChildren(topLevelObjects[0]).length > 40) {
fDoFilter = false;
} else {
getTreeViewer().addFilter(new NamePatternFilter());
@@ -306,8 +284,7 @@
treeViewer.getTree().setRedraw(false);
Object[] expandedElements = treeViewer.getExpandedElements();
- TypeHierarchyContentProvider contentProvider = (TypeHierarchyContentProvider) treeViewer
- .getContentProvider();
+ TypeHierarchyContentProvider contentProvider = (TypeHierarchyContentProvider) treeViewer.getContentProvider();
treeViewer.setContentProvider(fOtherContentProvider);
treeViewer.refresh();
@@ -327,18 +304,12 @@
private String getHeaderLabel(IModelElement input) {
if (input instanceof IMethod) {
- String[] args = { input.getParent().getElementName(),
- ScriptElementLabels.getDefault().getElementLabel(input,
- ScriptElementLabels.ALL_DEFAULT) };
- return Messages.format(
- TypeHierarchyMessages.HierarchyInformationControl_methodhierarchy_label,
- args);
+ Object[] args = { input.getParent().getElementName(),
+ ScriptElementLabels.getDefault().getElementLabel(input, ScriptElementLabels.ALL_DEFAULT) };
+ return Messages.format(TypeHierarchyMessages.HierarchyInformationControl_methodhierarchy_label, args);
} else if (input != null) {
- String arg = ScriptElementLabels.getDefault().getElementLabel(input,
- ScriptElementLabels.DEFAULT_QUALIFIED);
- return Messages.format(
- TypeHierarchyMessages.HierarchyInformationControl_hierarchy_label,
- arg);
+ String arg = ScriptElementLabels.getDefault().getElementLabel(input, ScriptElementLabels.DEFAULT_QUALIFIED);
+ return Messages.format(TypeHierarchyMessages.HierarchyInformationControl_hierarchy_label, arg);
} else {
return ""; //$NON-NLS-1$
}
@@ -352,13 +323,10 @@
keyName = sequences[0].format();
if (fOtherContentProvider instanceof TraditionalHierarchyContentProvider) {
- return Messages.format(
- TypeHierarchyMessages.HierarchyInformationControl_toggle_traditionalhierarchy_label,
+ return Messages.format(TypeHierarchyMessages.HierarchyInformationControl_toggle_traditionalhierarchy_label,
keyName);
}
- return Messages.format(
- TypeHierarchyMessages.HierarchyInformationControl_toggle_superhierarchy_label,
- keyName);
+ return Messages.format(TypeHierarchyMessages.HierarchyInformationControl_toggle_superhierarchy_label, keyName);
}
@Override
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesDialog.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesDialog.java
index 52c50f2..0781ee2 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesDialog.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/AccessRulesDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -46,10 +46,9 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-
public class AccessRulesDialog extends StatusDialog {
- public static final int SWITCH_PAGE= 10;
+ public static final int SWITCH_PAGE = 10;
private final ListDialogField fAccessRulesList;
private final SelectionButtonDialogField fCombineRulesCheckbox;
@@ -58,48 +57,43 @@
private final IScriptProject fProject;
private final boolean fParentCanSwitchPage;
- private static final int IDX_ADD= 0;
- private static final int IDX_EDIT= 1;
- private static final int IDX_UP= 3;
- private static final int IDX_DOWN= 4;
- private static final int IDX_REMOVE= 6;
+ private static final int IDX_ADD = 0;
+ private static final int IDX_EDIT = 1;
+ private static final int IDX_UP = 3;
+ private static final int IDX_DOWN = 4;
+ private static final int IDX_REMOVE = 6;
-
- public AccessRulesDialog(Shell parent, BPListElement entryToEdit, IScriptProject project, boolean parentCanSwitchPage) {
+ public AccessRulesDialog(Shell parent, BPListElement entryToEdit, IScriptProject project,
+ boolean parentCanSwitchPage) {
super(parent);
setShellStyle(getShellStyle() | SWT.RESIZE);
- fCurrElement= entryToEdit;
- fProject= project; // can be null
+ fCurrElement = entryToEdit;
+ fProject = project; // can be null
setTitle(NewWizardMessages.AccessRulesDialog_title);
- fAccessRulesList= createListContents(entryToEdit);
+ fAccessRulesList = createListContents(entryToEdit);
- fCombineRulesCheckbox= new SelectionButtonDialogField(SWT.CHECK);
+ fCombineRulesCheckbox = new SelectionButtonDialogField(SWT.CHECK);
fCombineRulesCheckbox.setLabelText(NewWizardMessages.AccessRulesDialog_combine_label);
- fCombineRulesCheckbox.setSelection(Boolean.TRUE.equals(entryToEdit.getAttribute(BPListElement.COMBINE_ACCESSRULES)));
+ fCombineRulesCheckbox
+ .setSelection(Boolean.TRUE.equals(entryToEdit.getAttribute(BPListElement.COMBINE_ACCESSRULES)));
- fParentCanSwitchPage= parentCanSwitchPage;
+ fParentCanSwitchPage = parentCanSwitchPage;
}
-
private ListDialogField createListContents(BPListElement entryToEdit) {
- String label= NewWizardMessages.AccessRulesDialog_rules_label;
- String[] buttonLabels= new String[] {
- NewWizardMessages.AccessRulesDialog_rules_add,
- NewWizardMessages.AccessRulesDialog_rules_edit,
- null,
- NewWizardMessages.AccessRulesDialog_rules_up,
- NewWizardMessages.AccessRulesDialog_rules_down,
- null,
- NewWizardMessages.AccessRulesDialog_rules_remove
- };
+ String label = NewWizardMessages.AccessRulesDialog_rules_label;
+ String[] buttonLabels = new String[] { NewWizardMessages.AccessRulesDialog_rules_add,
+ NewWizardMessages.AccessRulesDialog_rules_edit, null, NewWizardMessages.AccessRulesDialog_rules_up,
+ NewWizardMessages.AccessRulesDialog_rules_down, null,
+ NewWizardMessages.AccessRulesDialog_rules_remove };
- TypeRestrictionAdapter adapter= new TypeRestrictionAdapter();
- AccessRulesLabelProvider labelProvider= new AccessRulesLabelProvider();
+ TypeRestrictionAdapter adapter = new TypeRestrictionAdapter();
+ AccessRulesLabelProvider labelProvider = new AccessRulesLabelProvider();
- ListDialogField patternList= new ListDialogField(adapter, buttonLabels, labelProvider);
+ ListDialogField patternList = new ListDialogField(adapter, buttonLabels, labelProvider);
patternList.setDialogFieldListener(adapter);
patternList.setLabelText(label);
@@ -108,9 +102,9 @@
patternList.setDownButtonIndex(IDX_DOWN);
patternList.enableButton(IDX_EDIT, false);
- IAccessRule[] rules= (IAccessRule[]) entryToEdit.getAttribute(BPListElement.ACCESSRULES);
- ArrayList elements= new ArrayList(rules.length);
- for (int i= 0; i < rules.length; i++) {
+ IAccessRule[] rules = (IAccessRule[]) entryToEdit.getAttribute(BPListElement.ACCESSRULES);
+ ArrayList elements = new ArrayList(rules.length);
+ for (int i = 0; i < rules.length; i++) {
elements.add(rules[i]);
}
patternList.setElements(elements);
@@ -118,77 +112,74 @@
return patternList;
}
-
@Override
protected Control createDialogArea(Composite parent) {
- Composite composite= (Composite) super.createDialogArea(parent);
+ Composite composite = (Composite) super.createDialogArea(parent);
- int maxLabelSize= 0;
- GC gc= new GC(composite);
+ int maxLabelSize = 0;
+ GC gc = new GC(composite);
try {
- maxLabelSize= gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_ACCESSIBLE)).x;
- int len2= gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_DISCOURAGED)).x;
+ maxLabelSize = gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_ACCESSIBLE)).x;
+ int len2 = gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_DISCOURAGED)).x;
if (len2 > maxLabelSize) {
- maxLabelSize= len2;
+ maxLabelSize = len2;
}
- int len3= gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_NON_ACCESSIBLE)).x;
+ int len3 = gc.textExtent(AccessRulesLabelProvider.getResolutionLabel(IAccessRule.K_NON_ACCESSIBLE)).x;
if (len3 > maxLabelSize) {
- maxLabelSize= len3;
+ maxLabelSize = len3;
}
} finally {
gc.dispose();
}
- ColumnLayoutData[] columnDta= new ColumnLayoutData[] {
- new ColumnPixelData(maxLabelSize + 40),
- new ColumnWeightData(1),
- };
+ ColumnLayoutData[] columnDta = new ColumnLayoutData[] { new ColumnPixelData(maxLabelSize + 40),
+ new ColumnWeightData(1), };
fAccessRulesList.setTableColumns(new ListDialogField.ColumnsDescription(columnDta, null, false));
-
- Composite inner= new Composite(composite, SWT.NONE);
+ Composite inner = new Composite(composite, SWT.NONE);
inner.setFont(composite.getFont());
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
inner.setLayout(layout);
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
- Label description= new Label(inner, SWT.WRAP);
+ Label description = new Label(inner, SWT.WRAP);
description.setText(getDescriptionString());
- GridData data= new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
- data.widthHint= convertWidthInCharsToPixels(70);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ data.widthHint = convertWidthInCharsToPixels(70);
description.setLayoutData(data);
fAccessRulesList.doFillIntoGrid(inner, 3);
LayoutUtil.setHorizontalSpan(fAccessRulesList.getLabelControl(null), 2);
- data= (GridData) fAccessRulesList.getListControl(null).getLayoutData();
- data.grabExcessHorizontalSpace= true;
- data.heightHint= SWT.DEFAULT;
+ data = (GridData) fAccessRulesList.getListControl(null).getLayoutData();
+ data.grabExcessHorizontalSpace = true;
+ data.heightHint = SWT.DEFAULT;
if (fCurrElement.getEntryKind() == IBuildpathEntry.BPE_PROJECT) {
fCombineRulesCheckbox.doFillIntoGrid(inner, 2);
}
if (fProject != null) {
- String forbiddenSeverity= fProject.getOption(DLTKCore.COMPILER_PB_FORBIDDEN_REFERENCE, true);
- String discouragedSeverity= fProject.getOption(DLTKCore.COMPILER_PB_DISCOURAGED_REFERENCE, true);
- String[] args= { getLocalizedString(discouragedSeverity), getLocalizedString(forbiddenSeverity) };
+ String forbiddenSeverity = fProject.getOption(DLTKCore.COMPILER_PB_FORBIDDEN_REFERENCE, true);
+ String discouragedSeverity = fProject.getOption(DLTKCore.COMPILER_PB_DISCOURAGED_REFERENCE, true);
+ Object[] args = { getLocalizedString(discouragedSeverity), getLocalizedString(forbiddenSeverity) };
- FormToolkit toolkit= new FormToolkit(parent.getDisplay());
+ FormToolkit toolkit = new FormToolkit(parent.getDisplay());
toolkit.setBackground(null);
try {
FormText text = toolkit.createFormText(composite, true);
text.setFont(inner.getFont());
if (fParentCanSwitchPage) {
// with link
- text.setText(Messages.format(NewWizardMessages.AccessRulesDialog_severity_info_with_link, args), true, false);
+ text.setText(Messages.format(NewWizardMessages.AccessRulesDialog_severity_info_with_link, args),
+ true, false);
text.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
@@ -197,10 +188,11 @@
});
} else {
// no link
- text.setText(Messages.format(NewWizardMessages.AccessRulesDialog_severity_info_no_link, args), true, false);
+ text.setText(Messages.format(NewWizardMessages.AccessRulesDialog_severity_info_no_link, args), true,
+ false);
}
- data= new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
- data.widthHint= convertWidthInCharsToPixels(70);
+ data = new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1);
+ data.widthHint = convertWidthInCharsToPixels(70);
text.setLayoutData(data);
} catch (IllegalArgumentException e) {
DLTKUIPlugin.log(e); // invalid string
@@ -213,8 +205,10 @@
}
final void doErrorWarningLinkPressed() {
- if (fParentCanSwitchPage && MessageDialog.openQuestion(getShell(), NewWizardMessages.AccessRulesDialog_switch_dialog_title, NewWizardMessages.AccessRulesDialog_switch_dialog_message)) {
- setReturnCode(SWITCH_PAGE);
+ if (fParentCanSwitchPage
+ && MessageDialog.openQuestion(getShell(), NewWizardMessages.AccessRulesDialog_switch_dialog_title,
+ NewWizardMessages.AccessRulesDialog_switch_dialog_message)) {
+ setReturnCode(SWITCH_PAGE);
close();
}
}
@@ -231,29 +225,29 @@
private String getDescriptionString() {
String desc;
- String name= fCurrElement.getPath().lastSegment();
- if( name.startsWith(IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
+ String name = fCurrElement.getPath().lastSegment();
+ if (name.startsWith(IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
name = ScriptElementLabels.BUILTINS_FRAGMENT;
}
switch (fCurrElement.getEntryKind()) {
- case IBuildpathEntry.BPE_CONTAINER:
- try {
- name= ScriptElementLabels.getDefault().getContainerEntryLabel(fCurrElement.getPath(), fCurrElement.getScriptProject());
- } catch (ModelException e) {
- }
- desc= NewWizardMessages.AccessRulesDialog_container_description;
- break;
- case IBuildpathEntry.BPE_PROJECT:
- desc= NewWizardMessages.AccessRulesDialog_project_description;
- break;
- default:
- desc= NewWizardMessages.AccessRulesDialog_description;
+ case IBuildpathEntry.BPE_CONTAINER:
+ try {
+ name = ScriptElementLabels.getDefault().getContainerEntryLabel(fCurrElement.getPath(),
+ fCurrElement.getScriptProject());
+ } catch (ModelException e) {
+ }
+ desc = NewWizardMessages.AccessRulesDialog_container_description;
+ break;
+ case IBuildpathEntry.BPE_PROJECT:
+ desc = NewWizardMessages.AccessRulesDialog_project_description;
+ break;
+ default:
+ desc = NewWizardMessages.AccessRulesDialog_description;
}
return Messages.format(desc, name);
}
-
protected void doCustomButtonPressed(ListDialogField field, int index) {
if (index == IDX_ADD) {
addEntry(field);
@@ -267,7 +261,7 @@
}
protected void doSelectionChanged(ListDialogField field) {
- List selected= field.getSelectedElements();
+ List selected = field.getSelectedElements();
field.enableButton(IDX_EDIT, canEdit(selected));
}
@@ -277,26 +271,24 @@
private void editEntry(ListDialogField field) {
- List selElements= field.getSelectedElements();
+ List selElements = field.getSelectedElements();
if (selElements.size() != 1) {
return;
}
- IAccessRule rule= (IAccessRule) selElements.get(0);
- AccessRuleEntryDialog dialog= new AccessRuleEntryDialog(getShell(), rule, fCurrElement);
+ IAccessRule rule = (IAccessRule) selElements.get(0);
+ AccessRuleEntryDialog dialog = new AccessRuleEntryDialog(getShell(), rule, fCurrElement);
if (dialog.open() == Window.OK) {
field.replaceElement(rule, dialog.getRule());
}
}
private void addEntry(ListDialogField field) {
- AccessRuleEntryDialog dialog= new AccessRuleEntryDialog(getShell(), null, fCurrElement);
+ AccessRuleEntryDialog dialog = new AccessRuleEntryDialog(getShell(), null, fCurrElement);
if (dialog.open() == Window.OK) {
field.addElement(dialog.getRule());
}
}
-
-
// -------- TypeRestrictionAdapter --------
private class TypeRestrictionAdapter implements IListAdapter, IDialogFieldListener {
@@ -329,7 +321,7 @@
}
public IAccessRule[] getAccessRules() {
- List elements= fAccessRulesList.getElements();
+ List elements = fAccessRulesList.getElements();
return (IAccessRule[]) elements.toArray(new IAccessRule[elements.size()]);
}
@@ -340,20 +332,23 @@
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
- if(DLTKCore.DEBUG) {
+ if (DLTKCore.DEBUG) {
System.err.println("TODO: AccessRulesDialog add help context"); //$NON-NLS-1$
}
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IDLTKHelpContextIds.ACCESS_RULES_DIALOG);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
+ // IDLTKHelpContextIds.ACCESS_RULES_DIALOG);
}
-
public void performPageSwitch(IWorkbenchPreferenceContainer pageContainer) {
- //HashMap data= new HashMap();
- if(DLTKCore.DEBUG) {
+ // HashMap data= new HashMap();
+ if (DLTKCore.DEBUG) {
System.err.println("TODO:AccessRulesDialog:"); //$NON-NLS-1$
}
- //data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_KEY, DLTKCore.COMPILER_PB_FORBIDDEN_REFERENCE);
- //data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_QUALIFIER, DLTKCore.PLUGIN_ID);
- //pageContainer.openPage(ProblemSeveritiesPreferencePage.PROP_ID, data);
+ // data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_KEY,
+ // DLTKCore.COMPILER_PB_FORBIDDEN_REFERENCE);
+ // data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_QUALIFIER,
+ // DLTKCore.PLUGIN_ID);
+ // pageContainer.openPage(ProblemSeveritiesPreferencePage.PROP_ID,
+ // data);
}
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ScriptEditorHoverConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ScriptEditorHoverConfigurationBlock.java
index efeab47..e53d1f5 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ScriptEditorHoverConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/preferences/ScriptEditorHoverConfigurationBlock.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -58,8 +58,7 @@
/**
* Configures DLTK Editor hover preferences.
*/
-public class ScriptEditorHoverConfigurationBlock
- implements IPreferenceConfigurationBlock {
+public class ScriptEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock {
private static final String DELIMITER = PreferencesMessages.DLTKEditorHoverConfigurationBlock_delimiter;
@@ -80,8 +79,7 @@
}
}
- private class ScriptEditorTextHoverDescriptorLabelProvider
- implements ITableLabelProvider {
+ private class ScriptEditorTextHoverDescriptorLabelProvider implements ITableLabelProvider {
@Override
public Image getColumnImage(Object element, int columnIndex) {
@@ -95,8 +93,7 @@
return ((EditorTextHoverDescriptor) element).getLabel();
case MODIFIER_PROP:
- TableItem item = (TableItem) fHoverTableViewer
- .testFindItem(element);
+ TableItem item = (TableItem) fHoverTableViewer.testFindItem(element);
int index = fHoverTable.indexOf(item);
return fHoverConfigs[index].fModifierString;
@@ -125,12 +122,10 @@
}
}
- private class ScriptEditorTextHoverDescriptorContentProvider
- implements IStructuredContentProvider {
+ private class ScriptEditorTextHoverDescriptorContentProvider implements IStructuredContentProvider {
@Override
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Do nothing since the viewer listens to resource deltas
}
@@ -163,20 +158,17 @@
@Override
public void widgetDefaultSelected(SelectionEvent e) {
Button button = (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button),
- button.getSelection());
+ fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
@Override
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button),
- button.getSelection());
+ fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
}
};
- public ScriptEditorHoverConfigurationBlock(
- PreferencePage mainPreferencePage, OverlayPreferenceStore store,
+ public ScriptEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store,
String nature) {
Assert.isNotNull(mainPreferencePage);
Assert.isNotNull(store);
@@ -194,15 +186,12 @@
// OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
// PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
- OverlayPreferenceStore.STRING,
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
- OverlayPreferenceStore.STRING,
+ overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING,
PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
- .size()];
+ OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
overlayKeys.toArray(keys);
return keys;
}
@@ -210,8 +199,7 @@
/**
* Creates page for hover preferences.
*
- * @param parent
- * the parent composite
+ * @param parent the parent composite
* @return the control for the preference page
*/
@Override
@@ -223,36 +211,32 @@
hoverComposite.setLayout(layout);
String rollOverLabel = PreferencesMessages.DLTKEditorHoverConfigurationBlock_annotationRollover;
- addCheckBox(hoverComposite, rollOverLabel,
- PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0);
+ addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0);
GridData gd;
addFiller(hoverComposite);
Label label = new Label(hoverComposite, SWT.NONE);
- label.setText(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_hoverPreferences);
+ label.setText(PreferencesMessages.DLTKEditorHoverConfigurationBlock_hoverPreferences);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalAlignment = GridData.BEGINNING;
gd.horizontalSpan = 2;
label.setLayoutData(gd);
- TableLayoutComposite layouter = new TableLayoutComposite(hoverComposite,
- SWT.NONE);
+ TableLayoutComposite layouter = new TableLayoutComposite(hoverComposite, SWT.NONE);
addColumnLayoutData(layouter);
// Hover table
- fHoverTable = new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
+ fHoverTable = new Table(layouter,
+ SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
fHoverTable.setHeaderVisible(true);
fHoverTable.setLinesVisible(true);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = SWTUtil.getTableHeightHint(fHoverTable, 10);
gd.horizontalSpan = 2;
- gd.widthHint = new PixelConverter(parent)
- .convertWidthInCharsToPixels(30);
+ gd.widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(30);
layouter.setLayoutData(gd);
fHoverTable.addSelectionListener(new SelectionListener() {
@@ -270,49 +254,41 @@
fHoverTable.setLayout(tableLayout);
fNameColumn = new TableColumn(fHoverTable, SWT.NONE);
- fNameColumn.setText(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_nameColumnTitle);
+ fNameColumn.setText(PreferencesMessages.DLTKEditorHoverConfigurationBlock_nameColumnTitle);
fNameColumn.setResizable(true);
fModifierColumn = new TableColumn(fHoverTable, SWT.NONE);
- fModifierColumn.setText(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierColumnTitle);
+ fModifierColumn.setText(PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierColumnTitle);
fModifierColumn.setResizable(true);
fHoverTableViewer = new CheckboxTableViewer(fHoverTable);
fHoverTableViewer.setUseHashlookup(true);
- fHoverTableViewer.setContentProvider(
- new ScriptEditorTextHoverDescriptorContentProvider());
- fHoverTableViewer.setLabelProvider(
- new ScriptEditorTextHoverDescriptorLabelProvider());
+ fHoverTableViewer.setContentProvider(new ScriptEditorTextHoverDescriptorContentProvider());
+ fHoverTableViewer.setLabelProvider(new ScriptEditorTextHoverDescriptorLabelProvider());
- ((CheckboxTableViewer) fHoverTableViewer)
- .addCheckStateListener(event -> {
- String id = ((EditorTextHoverDescriptor) event.getElement())
- .getId();
- if (id == null)
- return;
- EditorTextHoverDescriptor[] descriptors = getContributedHovers();
- HoverConfig hoverConfig = null;
- int i = 0, length = fHoverConfigs.length;
- while (i < length) {
- if (id.equals(descriptors[i].getId())) {
- hoverConfig = fHoverConfigs[i];
- hoverConfig.fIsEnabled = event.getChecked();
- fModifierEditor.setEnabled(event.getChecked());
- fHoverTableViewer.setSelection(
- new StructuredSelection(descriptors[i]));
- }
- i++;
- }
- handleHoverListSelection();
- updateStatus(hoverConfig);
- });
+ ((CheckboxTableViewer) fHoverTableViewer).addCheckStateListener(event -> {
+ String id = ((EditorTextHoverDescriptor) event.getElement()).getId();
+ if (id == null)
+ return;
+ EditorTextHoverDescriptor[] descriptors = getContributedHovers();
+ HoverConfig hoverConfig = null;
+ int i = 0, length = fHoverConfigs.length;
+ while (i < length) {
+ if (id.equals(descriptors[i].getId())) {
+ hoverConfig = fHoverConfigs[i];
+ hoverConfig.fIsEnabled = event.getChecked();
+ fModifierEditor.setEnabled(event.getChecked());
+ fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
+ }
+ i++;
+ }
+ handleHoverListSelection();
+ updateStatus(hoverConfig);
+ });
// Text field for modifier string
label = new Label(hoverComposite, SWT.LEFT);
- label.setText(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_keyModifier);
+ label.setText(PreferencesMessages.DLTKEditorHoverConfigurationBlock_keyModifier);
fModifierEditor = new Text(hoverComposite, SWT.BORDER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
fModifierEditor.setLayoutData(gd);
@@ -322,14 +298,12 @@
@Override
public void keyPressed(KeyEvent e) {
- isModifierCandidate = e.keyCode > 0 && e.character == 0
- && e.stateMask == 0;
+ isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
}
@Override
public void keyReleased(KeyEvent e) {
- if (isModifierCandidate && e.stateMask > 0
- && e.stateMask == e.stateMask && e.character == 0) {
+ if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {
// && e.time - time < 1000)
String text = fModifierEditor.getText();
Point selection = fModifierEditor.getSelection();
@@ -337,34 +311,29 @@
while (i > -1 && Character.isWhitespace(text.charAt(i))) {
i--;
}
- boolean needsPrefixDelimiter = i > -1 && !String
- .valueOf(text.charAt(i)).equals(DELIMITER);
+ boolean needsPrefixDelimiter = i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
i = selection.y;
- while (i < text.length()
- && Character.isWhitespace(text.charAt(i))) {
+ while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
i++;
}
- boolean needsPostfixDelimiter = i < text.length() && !String
- .valueOf(text.charAt(i)).equals(DELIMITER);
+ boolean needsPostfixDelimiter = i < text.length()
+ && !String.valueOf(text.charAt(i)).equals(DELIMITER);
String insertString;
if (needsPrefixDelimiter && needsPostfixDelimiter)
insertString = Messages.format(
PreferencesMessages.DLTKEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter,
- new String[] { Action
- .findModifierString(e.stateMask) });
+ Action.findModifierString(e.stateMask));
else if (needsPrefixDelimiter)
insertString = Messages.format(
PreferencesMessages.DLTKEditorHoverConfigurationBlock_insertDelimiterAndModifier,
- new String[] { Action
- .findModifierString(e.stateMask) });
+ Action.findModifierString(e.stateMask));
else if (needsPostfixDelimiter)
insertString = Messages.format(
PreferencesMessages.DLTKEditorHoverConfigurationBlock_insertModifierAndDelimiter,
- new String[] { Action
- .findModifierString(e.stateMask) });
+ Action.findModifierString(e.stateMask));
else
insertString = Action.findModifierString(e.stateMask);
@@ -378,13 +347,11 @@
// Description
Label descriptionLabel = new Label(hoverComposite, SWT.LEFT);
- descriptionLabel.setText(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_description);
+ descriptionLabel.setText(PreferencesMessages.DLTKEditorHoverConfigurationBlock_description);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
descriptionLabel.setLayoutData(gd);
- fDescription = new Text(hoverComposite,
- SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
+ fDescription = new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
fDescription.setLayoutData(gd);
@@ -401,8 +368,7 @@
}
private EditorTextHoverDescriptor[] getContributedHovers() {
- return DLTKUIPlugin.getDefault().getEditorTextHoverDescriptors(fStore,
- fNature);
+ return DLTKUIPlugin.getDefault().getEditorTextHoverDescriptors(fStore, fNature);
}
@Override
@@ -410,9 +376,8 @@
EditorTextHoverDescriptor[] hoverDescs = getContributedHovers();
fHoverConfigs = new HoverConfig[hoverDescs.length];
for (int i = 0; i < hoverDescs.length; i++)
- fHoverConfigs[i] = new HoverConfig(
- hoverDescs[i].getModifierString(),
- hoverDescs[i].getStateMask(), hoverDescs[i].isEnabled());
+ fHoverConfigs[i] = new HoverConfig(hoverDescs[i].getModifierString(), hoverDescs[i].getStateMask(),
+ hoverDescs[i].isEnabled());
fHoverTableViewer.setInput(hoverDescs);
@@ -454,10 +419,8 @@
maskBuf.append(fHoverConfigs[i].fStateMask);
maskBuf.append(EditorTextHoverDescriptor.VALUE_SEPARATOR);
}
- fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS,
- buf.toString());
- fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS,
- maskBuf.toString());
+ fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, buf.toString());
+ fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, maskBuf.toString());
DLTKUIPlugin.getDefault().resetEditorTextHoverDescriptors(fNature);
}
@@ -471,11 +434,9 @@
private void restoreFromPreferences() {
- String compiledTextHoverModifiers = fStore
- .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
+ String compiledTextHoverModifiers = fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
- StringTokenizer tokenizer = new StringTokenizer(
- compiledTextHoverModifiers,
+ StringTokenizer tokenizer = new StringTokenizer(compiledTextHoverModifiers,
EditorTextHoverDescriptor.VALUE_SEPARATOR);
HashMap idToModifier = new HashMap(tokenizer.countTokens() / 2);
@@ -485,12 +446,10 @@
idToModifier.put(id, tokenizer.nextToken());
}
- String compiledTextHoverModifierMasks = DLTKUIPlugin.getDefault()
- .getPreferenceStore().getString(
- PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
+ String compiledTextHoverModifierMasks = DLTKUIPlugin.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
- tokenizer = new StringTokenizer(compiledTextHoverModifierMasks,
- EditorTextHoverDescriptor.VALUE_SEPARATOR);
+ tokenizer = new StringTokenizer(compiledTextHoverModifierMasks, EditorTextHoverDescriptor.VALUE_SEPARATOR);
HashMap idToModifierMask = new HashMap(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
@@ -500,14 +459,12 @@
}
for (int i = 0; i < fHoverConfigs.length; i++) {
- String modifierString = (String) idToModifier
- .get(getContributedHovers()[i].getId());
+ String modifierString = (String) idToModifier.get(getContributedHovers()[i].getId());
boolean enabled = true;
if (modifierString == null)
modifierString = EditorTextHoverDescriptor.DISABLED_TAG;
- if (modifierString
- .startsWith(EditorTextHoverDescriptor.DISABLED_TAG)) {
+ if (modifierString.startsWith(EditorTextHoverDescriptor.DISABLED_TAG)) {
enabled = false;
modifierString = modifierString.substring(1);
}
@@ -517,14 +474,12 @@
fHoverConfigs[i].fModifierString = modifierString;
fHoverConfigs[i].fIsEnabled = enabled;
- fHoverConfigs[i].fStateMask = EditorTextHoverDescriptor
- .computeStateMask(modifierString);
+ fHoverConfigs[i].fStateMask = EditorTextHoverDescriptor.computeStateMask(modifierString);
if (fHoverConfigs[i].fStateMask == -1) {
try {
fHoverConfigs[i].fStateMask = Integer
- .parseInt((String) idToModifierMask
- .get(getContributedHovers()[i].getId()));
+ .parseInt((String) idToModifierMask.get(getContributedHovers()[i].getId()));
} catch (NumberFormatException ex) {
fHoverConfigs[i].fStateMask = -1;
}
@@ -539,8 +494,7 @@
String modifiers = fModifierEditor.getText();
fHoverConfigs[i].fModifierString = modifiers;
- fHoverConfigs[i].fStateMask = EditorTextHoverDescriptor
- .computeStateMask(modifiers);
+ fHoverConfigs[i].fStateMask = EditorTextHoverDescriptor.computeStateMask(modifiers);
// update table
fHoverTableViewer.refresh(getContributedHovers()[i]);
@@ -573,11 +527,10 @@
}
private void updateStatus(HoverConfig hoverConfig) {
- if (hoverConfig != null && hoverConfig.fIsEnabled
- && hoverConfig.fStateMask == -1)
- fStatus = new StatusInfo(IStatus.ERROR, Messages.format(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierIsNotValid,
- hoverConfig.fModifierString));
+ if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1)
+ fStatus = new StatusInfo(IStatus.ERROR,
+ Messages.format(PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierIsNotValid,
+ hoverConfig.fModifierString));
else
fStatus = new StatusInfo();
@@ -586,18 +539,16 @@
while (fStatus.isOK() && i < fHoverConfigs.length) {
if (fHoverConfigs[i].fIsEnabled) {
String label = getContributedHovers()[i].getLabel();
- Integer stateMask = Integer
- .valueOf(fHoverConfigs[i].fStateMask);
+ Integer stateMask = Integer.valueOf(fHoverConfigs[i].fStateMask);
if (fHoverConfigs[i].fStateMask == -1)
- fStatus = new StatusInfo(IStatus.ERROR, Messages.format(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierIsNotValidForHover,
- new String[] { fHoverConfigs[i].fModifierString,
- label }));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ Messages.format(
+ PreferencesMessages.DLTKEditorHoverConfigurationBlock_modifierIsNotValidForHover,
+ fHoverConfigs[i].fModifierString, label));
else if (stateMasks.containsKey(stateMask))
- fStatus = new StatusInfo(IStatus.ERROR, Messages.format(
- PreferencesMessages.DLTKEditorHoverConfigurationBlock_duplicateModifier,
- new String[] { label,
- (String) stateMasks.get(stateMask) }));
+ fStatus = new StatusInfo(IStatus.ERROR,
+ Messages.format(PreferencesMessages.DLTKEditorHoverConfigurationBlock_duplicateModifier,
+ label, stateMasks.get(stateMask)));
else
stateMasks.put(stateMask, label);
}
@@ -608,8 +559,7 @@
StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
}
- private Button addCheckBox(Composite parent, String label, String key,
- int indentation) {
+ private Button addCheckBox(Composite parent, String label, String key, int indentation) {
Button checkBox = new Button(parent, SWT.CHECK);
checkBox.setText(label);
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ContentAssistProcessor.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ContentAssistProcessor.java
index 0153881..6252472 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ContentAssistProcessor.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/text/completion/ContentAssistProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation 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
@@ -81,16 +81,14 @@
* </ul>
* </p>
*
- *
*/
-public abstract class ContentAssistProcessor
- implements IContentAssistProcessor {
+public abstract class ContentAssistProcessor implements IContentAssistProcessor {
private static final boolean DEBUG = "true".equalsIgnoreCase(Platform //$NON-NLS-1$
.getDebugOption("org.eclipse.dltk.ui/debug/ResultCollector")); //$NON-NLS-1$
/**
- * Dialog settings key for the "all categories are disabled" warning dialog.
- * See {@link OptionalMessageDialog}.
+ * Dialog settings key for the "all categories are disabled" warning dialog. See
+ * {@link OptionalMessageDialog}.
*
*/
private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY = "EmptyDefaultAssistCategory"; //$NON-NLS-1$
@@ -103,8 +101,8 @@
private char[] fCompletionAutoActivationCharacters;
- private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR = (
- d1, d2) -> d1.getSortOrder() - d2.getSortOrder();
+ private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR = (d1, d2) -> d1.getSortOrder()
+ - d2.getSortOrder();
/* cycling stuff */
private int fRepetition = -1;
@@ -117,8 +115,7 @@
private String fErrorMessage;
- class CompletionListener
- implements ICompletionListener, ICompletionListenerExtension {
+ class CompletionListener implements ICompletionListener, ICompletionListenerExtension {
@Override
public void assistSessionStarted(ContentAssistEvent event) {
@@ -158,8 +155,7 @@
extension.setShowEmptyList(true);
if (extension instanceof IContentAssistantExtension3) {
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
- ((ContentAssistant) ext3)
- .setRepeatedInvocationTrigger(binding);
+ ((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
}
}
}
@@ -193,15 +189,13 @@
extension.setStatusLineVisible(false);
if (extension instanceof IContentAssistantExtension3) {
IContentAssistantExtension3 ext3 = (IContentAssistantExtension3) extension;
- ((ContentAssistant) ext3).setRepeatedInvocationTrigger(
- KeySequence.getInstance());
+ ((ContentAssistant) ext3).setRepeatedInvocationTrigger(KeySequence.getInstance());
}
}
}
@Override
- public void selectionChanged(ICompletionProposal proposal,
- boolean smartToggle) {
+ public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
}
@Override
@@ -211,62 +205,48 @@
}
- public ContentAssistProcessor(ContentAssistant assistant,
- String partition) {
+ public ContentAssistProcessor(ContentAssistant assistant, String partition) {
Assert.isNotNull(partition);
Assert.isNotNull(assistant);
fPartition = partition;
- fCategories = CompletionProposalComputerRegistry.getDefault()
- .getProposalCategories();
+ fCategories = CompletionProposalComputerRegistry.getDefault().getProposalCategories();
fAssistant = assistant;
fAssistant.addCompletionListener(new CompletionListener());
}
@Override
- public final ICompletionProposal[] computeCompletionProposals(
- ITextViewer viewer, int offset) {
+ public final ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
final long startTime = System.currentTimeMillis();
clearState();
IProgressMonitor monitor = createProgressMonitor();
- monitor.beginTask(
- ScriptTextMessages.ContentAssistProcessor_computing_proposals,
- fCategories.size() + 1);
+ monitor.beginTask(ScriptTextMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);
ContentAssistInvocationContext context = createContext(viewer, offset);
final long setupTime = System.currentTimeMillis();
- monitor.subTask(
- ScriptTextMessages.ContentAssistProcessor_collecting_proposals);
- final List<ICompletionProposal> proposals = collectProposals(viewer,
- offset, monitor, context);
+ monitor.subTask(ScriptTextMessages.ContentAssistProcessor_collecting_proposals);
+ final List<ICompletionProposal> proposals = collectProposals(viewer, offset, monitor, context);
final long collectTime = System.currentTimeMillis();
- monitor.subTask(
- ScriptTextMessages.ContentAssistProcessor_sorting_proposals);
+ monitor.subTask(ScriptTextMessages.ContentAssistProcessor_sorting_proposals);
- final List<ICompletionProposal> filtered = filterAndSortProposals(
- proposals, monitor, context);
+ final List<ICompletionProposal> filtered = filterAndSortProposals(proposals, monitor, context);
fNumberOfComputedResults = filtered.size();
final long filterTime = System.currentTimeMillis();
- ICompletionProposal[] result = filtered
- .toArray(new ICompletionProposal[filtered.size()]);
+ ICompletionProposal[] result = filtered.toArray(new ICompletionProposal[filtered.size()]);
monitor.done();
if (DEBUG) {
- System.err.println(
- "Code Assist stats of " + result.length + " proposals:"); //$NON-NLS-1$ //$NON-NLS-2$
- System.err.println(
- "Code Assist (setup):\t" + (setupTime - startTime)); //$NON-NLS-1$
- System.err.println(
- "Code Assist (collect):\t" + (collectTime - setupTime)); //$NON-NLS-1$
- System.err.println(
- "Code Assist (sort):\t" + (filterTime - collectTime)); //$NON-NLS-1$
+ System.err.println("Code Assist stats of " + result.length + " proposals:"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.err.println("Code Assist (setup):\t" + (setupTime - startTime)); //$NON-NLS-1$
+ System.err.println("Code Assist (collect):\t" + (collectTime - setupTime)); //$NON-NLS-1$
+ System.err.println("Code Assist (sort):\t" + (filterTime - collectTime)); //$NON-NLS-1$
}
return result;
@@ -277,15 +257,14 @@
fNumberOfComputedResults = 0;
}
- private List<ICompletionProposal> collectProposals(ITextViewer viewer,
- int offset, IProgressMonitor monitor,
+ private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor,
ContentAssistInvocationContext context) {
List<ICompletionProposal> proposals = new ArrayList<>();
Set<ICompletionProposal> proposalSet = new HashSet<>();
List<CompletionProposalCategory> providers = getCategories();
for (CompletionProposalCategory cat : providers) {
- List<ICompletionProposal> computed = cat.computeCompletionProposals(
- context, fPartition, new SubProgressMonitor(monitor, 1));
+ List<ICompletionProposal> computed = cat.computeCompletionProposals(context, fPartition,
+ new SubProgressMonitor(monitor, 1));
proposalSet.addAll(computed);
if (fErrorMessage == null) {
fErrorMessage = cat.getErrorMessage();
@@ -299,60 +278,48 @@
* Filters and sorts the proposals. The passed list may be modified and
* returned, or a new list may be created and returned.
*
- * @param proposals
- * the list of collected proposals (element type:
- * {@link ICompletionProposal})
- * @param monitor
- * a progress monitor
- * @param context
- * TODO
- * @return the list of filtered and sorted proposals, ready for display
- * (element type: {@link ICompletionProposal})
+ * @param proposals the list of collected proposals (element type:
+ * {@link ICompletionProposal})
+ * @param monitor a progress monitor
+ * @param context TODO
+ * @return the list of filtered and sorted proposals, ready for display (element
+ * type: {@link ICompletionProposal})
*/
- protected List<ICompletionProposal> filterAndSortProposals(
- List<ICompletionProposal> proposals, IProgressMonitor monitor,
- ContentAssistInvocationContext context) {
+ protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals,
+ IProgressMonitor monitor, ContentAssistInvocationContext context) {
return proposals;
}
@Override
- public IContextInformation[] computeContextInformation(ITextViewer viewer,
- int offset) {
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
clearState();
IProgressMonitor monitor = createProgressMonitor();
- monitor.beginTask(
- ScriptTextMessages.ContentAssistProcessor_computing_contexts,
- fCategories.size() + 1);
+ monitor.beginTask(ScriptTextMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
- monitor.subTask(
- ScriptTextMessages.ContentAssistProcessor_collecting_contexts);
- final List<IContextInformation> proposals = collectContextInformation(
- viewer, offset, monitor);
+ monitor.subTask(ScriptTextMessages.ContentAssistProcessor_collecting_contexts);
+ final List<IContextInformation> proposals = collectContextInformation(viewer, offset, monitor);
- monitor.subTask(
- ScriptTextMessages.ContentAssistProcessor_sorting_contexts);
- List<IContextInformation> filtered = filterAndSortContextInformation(
- proposals, monitor);
+ monitor.subTask(ScriptTextMessages.ContentAssistProcessor_sorting_contexts);
+ List<IContextInformation> filtered = filterAndSortContextInformation(proposals, monitor);
fNumberOfComputedResults = filtered.size();
- IContextInformation[] result = filtered
- .toArray(new IContextInformation[filtered.size()]);
+ IContextInformation[] result = filtered.toArray(new IContextInformation[filtered.size()]);
monitor.done();
return result;
}
- private List<IContextInformation> collectContextInformation(
- ITextViewer viewer, int offset, IProgressMonitor monitor) {
+ private List<IContextInformation> collectContextInformation(ITextViewer viewer, int offset,
+ IProgressMonitor monitor) {
List<IContextInformation> proposals = new ArrayList<>();
ContentAssistInvocationContext context = createContext(viewer, offset);
setContextInformationMode(context);
List<CompletionProposalCategory> providers = getCategories();
for (CompletionProposalCategory cat : providers) {
- List<IContextInformation> computed = cat.computeContextInformation(
- context, fPartition, new SubProgressMonitor(monitor, 1));
+ List<IContextInformation> computed = cat.computeContextInformation(context, fPartition,
+ new SubProgressMonitor(monitor, 1));
proposals.addAll(computed);
if (fErrorMessage == null) {
fErrorMessage = cat.getErrorMessage();
@@ -366,16 +333,14 @@
* Filters and sorts the context information objects. The passed list may be
* modified and returned, or a new list may be created and returned.
*
- * @param contexts
- * the list of collected proposals (element type:
- * {@link IContextInformation})
- * @param monitor
- * a progress monitor
- * @return the list of filtered and sorted proposals, ready for display
- * (element type: {@link IContextInformation})
+ * @param contexts the list of collected proposals (element type:
+ * {@link IContextInformation})
+ * @param monitor a progress monitor
+ * @return the list of filtered and sorted proposals, ready for display (element
+ * type: {@link IContextInformation})
*/
- protected List<IContextInformation> filterAndSortContextInformation(
- List<IContextInformation> contexts, IProgressMonitor monitor) {
+ protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts,
+ IProgressMonitor monitor) {
return contexts;
}
@@ -383,11 +348,9 @@
* Sets this processor's set of characters triggering the activation of the
* completion proposal computation.
*
- * @param activationSet
- * the activation set
+ * @param activationSet the activation set
*/
- public final void setCompletionProposalAutoActivationCharacters(
- char[] activationSet) {
+ public final void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
fCompletionAutoActivationCharacters = activationSet;
}
@@ -427,22 +390,18 @@
return new NullProgressMonitor();
}
- protected void setContextInformationMode(
- ContentAssistInvocationContext context) {
+ protected void setContextInformationMode(ContentAssistInvocationContext context) {
// empty
}
/**
* Creates the context that is passed to the completion proposal computers.
*
- * @param viewer
- * the viewer that content assist is invoked on
- * @param offset
- * the content assist offset
+ * @param viewer the viewer that content assist is invoked on
+ * @param offset the content assist offset
* @return the context to be passed to the computers
*/
- protected ContentAssistInvocationContext createContext(ITextViewer viewer,
- int offset) {
+ protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset) {
return new ContentAssistInvocationContext(viewer, offset);
}
@@ -464,8 +423,7 @@
private List<List<CompletionProposalCategory>> getCategoryIteration() {
List<List<CompletionProposalCategory>> sequence = new ArrayList<>();
sequence.add(getDefaultCategories());
- for (Iterator<CompletionProposalCategory> it = getSeparateCategories()
- .iterator(); it.hasNext();) {
+ for (Iterator<CompletionProposalCategory> it = getSeparateCategories().iterator(); it.hasNext();) {
CompletionProposalCategory cat = it.next();
sequence.add(Collections.singletonList(cat));
}
@@ -476,8 +434,7 @@
// default mix - enable all included computers
List<CompletionProposalCategory> included = getDefaultCategoriesUnchecked();
- if ((IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition))
- && included.isEmpty() && !fCategories.isEmpty())
+ if ((IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition)) && included.isEmpty() && !fCategories.isEmpty())
if (informUserAboutEmptyDefaultCategory())
// preferences were restored - recompute the default categories
included = getDefaultCategoriesUnchecked();
@@ -495,28 +452,23 @@
}
/**
- * Informs the user about the fact that there are no enabled categories in
- * the default content assist set and shows a link to the preferences.
+ * Informs the user about the fact that there are no enabled categories in the
+ * default content assist set and shows a link to the preferences.
*/
private boolean informUserAboutEmptyDefaultCategory() {
- if (OptionalMessageDialog
- .isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
+ if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
final Shell shell = DLTKUIPlugin.getActiveWorkbenchShell();
String title = ScriptTextMessages.ContentAssistProcessor_all_disabled_title;
String message = ScriptTextMessages.ContentAssistProcessor_all_disabled_message;
// see PreferencePage#createControl for the 'defaults' label
- final String restoreButtonLabel = JFaceResources
- .getString("defaults"); //$NON-NLS-1$
+ final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
final String linkMessage = Messages.format(
ScriptTextMessages.ContentAssistProcessor_all_disabled_preference_link,
LegacyActionTools.removeMnemonics(restoreButtonLabel));
final int restoreId = IDialogConstants.CLIENT_ID + 10;
- final OptionalMessageDialog dialog = new OptionalMessageDialog(
- PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title,
- null /* default image */, message, MessageDialog.WARNING,
- new String[] { restoreButtonLabel,
- IDialogConstants.CLOSE_LABEL },
- 1) {
+ final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell,
+ title, null /* default image */, message, MessageDialog.WARNING,
+ new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
@Override
protected Control createCustomArea(Composite composite) {
// wrap link and checkbox in one composite without space
@@ -529,12 +481,9 @@
Composite linkComposite = new Composite(parent, SWT.NONE);
layout = new GridLayout();
- layout.marginHeight = convertVerticalDLUsToPixels(
- IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(
- IDialogConstants.HORIZONTAL_MARGIN);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(
- IDialogConstants.HORIZONTAL_SPACING);
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
linkComposite.setLayout(layout);
Link link = new Link(linkComposite, SWT.NONE);
@@ -548,8 +497,7 @@
null, null).open();
}
});
- GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING,
- true, false);
+ GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gridData.widthHint = this.getMinimumMessageWidth();
link.setLayoutData(gridData);
@@ -562,27 +510,20 @@
@Override
protected void createButtonsForButtonBar(Composite parent) {
Button[] buttons = new Button[2];
- buttons[0] = createButton(parent, restoreId,
- restoreButtonLabel, false);
- buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID,
- IDialogConstants.CLOSE_LABEL, true);
+ buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
+ buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
setButtons(buttons);
}
};
if (restoreId == dialog.open()) {
/*
- * FIXME Restore default settings in DLTKUIPlugin preferences,
- * since at the moment this is the only IPreferenceStore these
- * preferences are read from.
+ * FIXME Restore default settings in DLTKUIPlugin preferences, since at the
+ * moment this is the only IPreferenceStore these preferences are read from.
*/
- IPreferenceStore store = DLTKUIPlugin.getDefault()
- .getPreferenceStore();
- store.setToDefault(
- PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
- store.setToDefault(
- PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry
- .getDefault();
+ IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
+ store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+ store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+ CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
registry.reload();
return true;
}
@@ -595,8 +536,7 @@
private List<CompletionProposalCategory> getSeparateCategories() {
ArrayList<CompletionProposalCategory> sorted = new ArrayList<>();
for (CompletionProposalCategory category : fCategories) {
- if (category.isSeparateCommand()
- && category.hasComputers(fPartition))
+ if (category.isSeparateCommand() && category.hasComputers(fPartition))
sorted.add(category);
}
Collections.sort(sorted, ORDER_COMPARATOR);
@@ -604,16 +544,12 @@
}
private String createEmptyMessage() {
- return Messages.format(
- ScriptTextMessages.ContentAssistProcessor_empty_message,
- new String[] { getCategoryLabel(fRepetition) });
+ return Messages.format(ScriptTextMessages.ContentAssistProcessor_empty_message, getCategoryLabel(fRepetition));
}
private String createIterationMessage() {
- return Messages.format(
- ScriptTextMessages.ContentAssistProcessor_toggle_affordance_update_message,
- new String[] { getCategoryLabel(fRepetition), fIterationGesture,
- getCategoryLabel(fRepetition + 1) });
+ return Messages.format(ScriptTextMessages.ContentAssistProcessor_toggle_affordance_update_message,
+ getCategoryLabel(fRepetition), fIterationGesture, getCategoryLabel(fRepetition + 1));
}
private String getCategoryLabel(int repetition) {
@@ -629,17 +565,16 @@
private String getIterationGesture() {
TriggerSequence binding = getIterationBinding();
- return binding != null ? Messages.format(
- ScriptTextMessages.ContentAssistProcessor_toggle_affordance_press_gesture,
- new Object[] { binding.format() })
+ return binding != null
+ ? Messages.format(ScriptTextMessages.ContentAssistProcessor_toggle_affordance_press_gesture,
+ new Object[] { binding.format() })
: ScriptTextMessages.ContentAssistProcessor_toggle_affordance_click_gesture;
}
private KeySequence getIterationBinding() {
- final IBindingService bindingSvc = PlatformUI.getWorkbench()
- .getAdapter(IBindingService.class);
- TriggerSequence binding = bindingSvc.getBestActiveBindingFor(
- ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ final IBindingService bindingSvc = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ TriggerSequence binding = bindingSvc
+ .getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
if (binding instanceof KeySequence)
return (KeySequence) binding;
return null;
diff --git a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/NewNameQueries.java b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/NewNameQueries.java
index 8316edb..08d4b9f 100644
--- a/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/NewNameQueries.java
+++ b/core/plugins/org.eclipse.dltk.ui/ui refactoring/org/eclipse/dltk/internal/ui/refactoring/reorg/NewNameQueries.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation 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
@@ -38,26 +38,25 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-
public class NewNameQueries implements INewNameQueries {
- private static final String INVALID_NAME_NO_MESSAGE= "";//$NON-NLS-1$
+ private static final String INVALID_NAME_NO_MESSAGE = "";//$NON-NLS-1$
private final Wizard fWizard;
private final Shell fShell;
public NewNameQueries() {
- fShell= null;
- fWizard= null;
+ fShell = null;
+ fWizard = null;
}
public NewNameQueries(Wizard wizard) {
- fWizard= wizard;
- fShell= null;
+ fWizard = wizard;
+ fShell = null;
}
public NewNameQueries(Shell shell) {
fShell = shell;
- fWizard= null;
+ fWizard = null;
}
private Shell getShell() {
@@ -75,56 +74,47 @@
if (DLTKCore.DEBUG) {
System.err.println("TODO:add removeScriptLikeExtensions code here..."); //$NON-NLS-1$
}
- String[] keys= {/*DLTKCore.removeScriptLikeExtension(*/cu.getElementName()/*)*/};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
+ String message = Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, cu.getElementName());
return createStaticQuery(createSourceModuleNameValidator(cu), message, initialSuggestedName, getShell());
}
-
@Override
public INewNameQuery createNewResourceNameQuery(IResource res, String initialSuggestedName) {
- String[] keys= {res.getName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
+ String message = Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, res.getName());
return createStaticQuery(createResourceNameValidator(res), message, initialSuggestedName, getShell());
}
-
@Override
public INewNameQuery createNewPackageNameQuery(IScriptFolder pack, String initialSuggestedName) {
- String[] keys= {pack.getElementName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
+ String message = Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, pack.getElementName());
return createStaticQuery(createPackageNameValidator(pack), message, initialSuggestedName, getShell());
}
@Override
public INewNameQuery createNewProjectFragmentNameQuery(IProjectFragment root, String initialSuggestedName) {
- String[] keys= {root.getElementName()};
- String message= Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, keys);
+ String message = Messages.format(ReorgMessages.ReorgQueries_enterNewNameQuestion, root.getElementName());
return createStaticQuery(createProjectFragmentNameValidator(root), message, initialSuggestedName, getShell());
}
-
@Override
- public INewNameQuery createNullQuery(){
+ public INewNameQuery createNullQuery() {
return createStaticQuery(null);
}
-
@Override
- public INewNameQuery createStaticQuery(final String newName){
+ public INewNameQuery createStaticQuery(final String newName) {
return () -> newName;
}
- private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){
+ private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message,
+ final String initial, final Shell shell) {
return () -> {
- InputDialog dialog = new InputDialog(shell,
- ReorgMessages.ReorgQueries_nameConflictMessage, message,
+ InputDialog dialog = new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message,
initial, validator) {
/*
* (non-Javadoc)
*
- * @see
- * org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.
+ * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.
* eclipse.swt.widgets.Composite)
*/
@Override
@@ -140,7 +130,7 @@
};
}
- private static IInputValidator createResourceNameValidator(final IResource res){
+ private static IInputValidator createResourceNameValidator(final IResource res) {
IInputValidator validator = newText -> {
if (newText == null || "".equals(newText) //$NON-NLS-1$
|| res.getParent() == null)
@@ -149,8 +139,7 @@
return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
if (!res.getParent().getFullPath().isValidSegment(newText))
return ReorgMessages.ReorgQueries_invalidNameMessage;
- IStatus status = res.getParent().getWorkspace()
- .validateName(newText, res.getType());
+ IStatus status = res.getParent().getWorkspace().validateName(newText, res.getType());
if (status.getSeverity() == IStatus.ERROR)
return status.getMessage();
@@ -169,11 +158,10 @@
String newCuName = ScriptModelUtil.getRenamedCUName(cu, newText);
IDLTKLanguageToolkit toolkit = null;
toolkit = DLTKLanguageManager.getLanguageToolkit(cu);
- IStatus status = new Status(IStatus.ERROR, DLTKUIPlugin.PLUGIN_ID,
- 0, ReorgMessages.NewNameQueries_mustBeAScriptProject, null);
+ IStatus status = new Status(IStatus.ERROR, DLTKUIPlugin.PLUGIN_ID, 0,
+ ReorgMessages.NewNameQueries_mustBeAScriptProject, null);
if (toolkit != null) {
- if (DLTKContentTypeManager
- .isValidFileNameForContentType(toolkit, newCuName)) {
+ if (DLTKContentTypeManager.isValidFileNameForContentType(toolkit, newCuName)) {
status = IModelStatus.VERIFIED_OK;
} else {
status = new Status(IStatus.ERROR, DLTKUIPlugin.PLUGIN_ID,
@@ -185,8 +173,7 @@
RefactoringStatus refStatus;
refStatus = Checks.checkSourceModuleNewName(cu, newText);
if (refStatus.hasFatalError())
- return refStatus
- .getMessageMatchingSeverity(RefactoringStatus.FATAL);
+ return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL);
if (cu.getElementName().equalsIgnoreCase(newCuName))
return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;
@@ -196,10 +183,10 @@
return validator;
}
-
private static IInputValidator createProjectFragmentNameValidator(final IProjectFragment root) {
return new IInputValidator() {
- IInputValidator resourceNameValidator= createResourceNameValidator(root.getResource());
+ IInputValidator resourceNameValidator = createResourceNameValidator(root.getResource());
+
@Override
public String isValid(String newText) {
return resourceNameValidator.isValid(newText);
@@ -219,8 +206,7 @@
// try {
if (parent instanceof IProjectFragment) {
if (DLTKCore.DEBUG) {
- System.err.println(
- "TODO:NewNamequeries add isPackageNameOkInRoot check..."); //$NON-NLS-1$
+ System.err.println("TODO:NewNamequeries add isPackageNameOkInRoot check..."); //$NON-NLS-1$
}
// if (! RenamePackageProcessor.isPackageNameOkInRoot(newText, (IProjectFragment)parent))
// return ReorgMessages.ReorgQueries_packagewithThatNameexistsMassage;